mirror of
https://github.com/ConjureETS/DeathBook.git
synced 2026-03-24 04:20:58 +00:00
- Added the recent posts
This commit is contained in:
parent
21096cf405
commit
8ef54b27c0
2299
Assets/Prefabs/Canvas.prefab
Normal file
2299
Assets/Prefabs/Canvas.prefab
Normal file
File diff suppressed because it is too large
Load Diff
8
Assets/Prefabs/Canvas.prefab.meta
Normal file
8
Assets/Prefabs/Canvas.prefab.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5c94559626c169f47a446ce0517b8aec
|
||||||
|
timeCreated: 1439782683
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,41 @@
|
|||||||
using System.Collections.Generic;
|
using DeathBook.Util;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DeathBook.Model
|
namespace DeathBook.Model
|
||||||
{
|
{
|
||||||
public class PostGenerator
|
public class PostGenerator
|
||||||
{
|
{
|
||||||
|
private string[] _posts;
|
||||||
|
|
||||||
|
public PostGenerator()
|
||||||
|
{
|
||||||
|
TextAsset postsFile = Resources.Load("TextFiles/FacebookPosts") as TextAsset;
|
||||||
|
|
||||||
|
_posts = postsFile.text.Split('\n');
|
||||||
|
}
|
||||||
|
|
||||||
public Status generateStatus(/*put stuff here*/)
|
public Status generateStatus(/*put stuff here*/)
|
||||||
{
|
{
|
||||||
//and here...
|
if (LevelManager.Instance.GameLevel.NumDead == LevelManager.Instance.GameLevel.People.Count)
|
||||||
return null;
|
{
|
||||||
|
return new Status() { Text = "" };
|
||||||
|
}
|
||||||
|
|
||||||
|
Person person = null;
|
||||||
|
|
||||||
|
// May be a bottleneck if unlucky, needs to be tested
|
||||||
|
do
|
||||||
|
{
|
||||||
|
person = LevelManager.Instance.GameLevel.People[UnityEngine.Random.Range(0, LevelManager.Instance.GameLevel.People.Count)];
|
||||||
|
} while (!person.Alive);
|
||||||
|
|
||||||
|
Status status = new Status()
|
||||||
|
{
|
||||||
|
Text = "<b>" + person.Name + "</b>" + ": " + _posts[UnityEngine.Random.Range(0, _posts.Length)]
|
||||||
|
};
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Headline generateHeadline(/*put stuff here*/)
|
public Headline generateHeadline(/*put stuff here*/)
|
||||||
|
|||||||
@ -4,6 +4,12 @@ namespace DeathBook.Model
|
|||||||
{
|
{
|
||||||
public class Status : Post
|
public class Status : Post
|
||||||
{
|
{
|
||||||
//TODO
|
private string _text;
|
||||||
|
|
||||||
|
public string Text
|
||||||
|
{
|
||||||
|
get { return _text; }
|
||||||
|
set { _text = value; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
32
Assets/Scripts/RecentPostsPanel.cs
Normal file
32
Assets/Scripts/RecentPostsPanel.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using DeathBook.Model;
|
||||||
|
|
||||||
|
public class RecentPostsPanel : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Text Content;
|
||||||
|
|
||||||
|
PostGenerator _postGenerator;
|
||||||
|
|
||||||
|
private float _elapsedTime = 0f;
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
_postGenerator = new PostGenerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update ()
|
||||||
|
{
|
||||||
|
_elapsedTime += Time.deltaTime;
|
||||||
|
|
||||||
|
if (_elapsedTime >= 15f)
|
||||||
|
{
|
||||||
|
Status status = _postGenerator.generateStatus();
|
||||||
|
|
||||||
|
Content.text = status.Text;
|
||||||
|
|
||||||
|
_elapsedTime = 0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/Scripts/RecentPostsPanel.cs.meta
Normal file
12
Assets/Scripts/RecentPostsPanel.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 328bab13d05c81f4fac709e8ea0a741e
|
||||||
|
timeCreated: 1439780538
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
x
Reference in New Issue
Block a user