- Added the recent posts

This commit is contained in:
Patrice Vignola 2015-08-16 23:38:23 -04:00
parent 21096cf405
commit 8ef54b27c0
9 changed files with 2488 additions and 1322 deletions

2299
Assets/Prefabs/Canvas.prefab Normal file

File diff suppressed because it is too large Load Diff

View 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

View File

@ -1,13 +1,41 @@
using System.Collections.Generic;
using DeathBook.Util;
using System.Collections.Generic;
using UnityEngine;
namespace DeathBook.Model
{
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*/)
{
//and here...
return null;
if (LevelManager.Instance.GameLevel.NumDead == LevelManager.Instance.GameLevel.People.Count)
{
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*/)

View File

@ -4,6 +4,12 @@ namespace DeathBook.Model
{
public class Status : Post
{
//TODO
private string _text;
public string Text
{
get { return _text; }
set { _text = value; }
}
}
}

View 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;
}
}
}

View 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: