Added connection and disconnection times.

Prevented killing online people.

Signed-off-by: RosimInc <rosim_inc@hotmail.com>
This commit is contained in:
RosimInc 2015-08-15 23:43:45 -04:00
parent 9bd0c1c182
commit 4d41e5948b
8 changed files with 118 additions and 45 deletions

View File

@ -88,12 +88,14 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d0907c1567bad554c8b995de3459e517, type: 3} m_Script: {fileID: 11500000, guid: d0907c1567bad554c8b995de3459e517, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
LinkObj: {fileID: 11495142, guid: fab430cecad80ad4391987a06b550cb7, type: 2} gameObjects:
PersonObj: {fileID: 11417564, guid: 7a5b1db47a2c30e419038df40dffa79a, type: 2} LinkObj: {fileID: 11495142, guid: fab430cecad80ad4391987a06b550cb7, type: 2}
NumPeople: 50 PersonObj: {fileID: 11417564, guid: 7a5b1db47a2c30e419038df40dffa79a, type: 2}
AvgNumFriends: 8 levelOptions:
FriendshipLikeliness: .400000006 NumPeople: 50
SphereRadius: 7 AvgNumFriends: 8
FriendshipLikeliness: .600000024
SphereRadius: 7
rotationSpeed: .699999988 rotationSpeed: .699999988
torqueForce: 1 torqueForce: 1
DetailsPanel: {fileID: 0} DetailsPanel: {fileID: 0}

View File

@ -438,6 +438,10 @@ MonoBehaviour:
type: 2} type: 2}
m_PrefabInternal: {fileID: 1009381200} m_PrefabInternal: {fileID: 1009381200}
m_Script: {fileID: 11500000, guid: 88fb1885d6f8fd6409e3866b7707a12a, type: 3} m_Script: {fileID: 11500000, guid: 88fb1885d6f8fd6409e3866b7707a12a, type: 3}
--- !u!1 &811802576 stripped
GameObject:
m_PrefabParentObject: {fileID: 147852, guid: c993e87661906234fba410e55ed66832, type: 2}
m_PrefabInternal: {fileID: 1009381200}
--- !u!1 &997683484 --- !u!1 &997683484
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -581,7 +585,7 @@ Prefab:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 22417254, guid: c993e87661906234fba410e55ed66832, type: 2} - target: {fileID: 22417254, guid: c993e87661906234fba410e55ed66832, type: 2}
propertyPath: m_AnchorMin.y propertyPath: m_AnchorMin.y
value: .549793065 value: .590630949
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 22417254, guid: c993e87661906234fba410e55ed66832, type: 2} - target: {fileID: 22417254, guid: c993e87661906234fba410e55ed66832, type: 2}
propertyPath: m_AnchorMax.x propertyPath: m_AnchorMax.x
@ -619,6 +623,19 @@ Prefab:
value: value:
objectReference: {fileID: 21300000, guid: 0c813218655d0a1468d7269b69deb9d5, objectReference: {fileID: 21300000, guid: 0c813218655d0a1468d7269b69deb9d5,
type: 3} type: 3}
- target: {fileID: 22458514, guid: c993e87661906234fba410e55ed66832, type: 2}
propertyPath: m_AnchoredPosition.y
value: -65.9512253
objectReference: {fileID: 0}
- target: {fileID: 11476684, guid: c993e87661906234fba410e55ed66832, type: 2}
propertyPath: Container
value:
objectReference: {fileID: 811802576}
- target: {fileID: 11476684, guid: c993e87661906234fba410e55ed66832, type: 2}
propertyPath: UIFriendPicture
value:
objectReference: {fileID: 11467422, guid: 16a1d168f1ef75b4690435675a9e69b0,
type: 2}
m_RemovedComponents: [] m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: c993e87661906234fba410e55ed66832, type: 2} m_ParentPrefab: {fileID: 100100000, guid: c993e87661906234fba410e55ed66832, type: 2}
m_IsPrefabParent: 0 m_IsPrefabParent: 0
@ -1083,16 +1100,16 @@ Prefab:
value: value:
objectReference: {fileID: 724043967} objectReference: {fileID: 724043967}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: FriendshipLikeliness propertyPath: levelOptions.NumPeople
value: .600000024 value: 2
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: NumPeople propertyPath: levelOptions.AvgNumFriends
value: 50 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} - target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: AvgNumFriends propertyPath: levelOptions.FriendshipLikeliness
value: 4 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} m_ParentPrefab: {fileID: 100100000, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}

View File

@ -159,7 +159,6 @@ Camera:
m_OcclusionCulling: 1 m_OcclusionCulling: 1
m_StereoConvergence: 10 m_StereoConvergence: 10
m_StereoSeparation: .0219999999 m_StereoSeparation: .0219999999
m_StereoMirrorMode: 0
--- !u!4 &61719365 --- !u!4 &61719365
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -733,15 +732,15 @@ Prefab:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 22417254, guid: c993e87661906234fba410e55ed66832, type: 2} - target: {fileID: 22417254, guid: c993e87661906234fba410e55ed66832, type: 2}
propertyPath: m_AnchorMin.y propertyPath: m_AnchorMin.y
value: 0 value: .594142556
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 22417254, guid: c993e87661906234fba410e55ed66832, type: 2} - target: {fileID: 22417254, guid: c993e87661906234fba410e55ed66832, type: 2}
propertyPath: m_AnchorMax.x propertyPath: m_AnchorMax.x
value: 0 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 22417254, guid: c993e87661906234fba410e55ed66832, type: 2} - target: {fileID: 22417254, guid: c993e87661906234fba410e55ed66832, type: 2}
propertyPath: m_AnchorMax.y propertyPath: m_AnchorMax.y
value: 0 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: c993e87661906234fba410e55ed66832, type: 2} m_ParentPrefab: {fileID: 100100000, guid: c993e87661906234fba410e55ed66832, type: 2}
@ -923,7 +922,6 @@ MonoBehaviour:
m_SubmitButton: Submit m_SubmitButton: Submit
m_CancelButton: Cancel m_CancelButton: Cancel
m_InputActionsPerSecond: 10 m_InputActionsPerSecond: 10
m_RepeatDelay: .5
m_AllowActivationOnMobileDevice: 0 m_AllowActivationOnMobileDevice: 0
--- !u!114 &1999982086 --- !u!114 &1999982086
MonoBehaviour: MonoBehaviour:
@ -1056,6 +1054,20 @@ Prefab:
propertyPath: DetailsPanel propertyPath: DetailsPanel
value: value:
objectReference: {fileID: 724043967} objectReference: {fileID: 724043967}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: gameObjects.LinkObj
value:
objectReference: {fileID: 11495142, guid: fab430cecad80ad4391987a06b550cb7,
type: 2}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: gameObjects.PersonObj
value:
objectReference: {fileID: 11417564, guid: 7a5b1db47a2c30e419038df40dffa79a,
type: 2}
- target: {fileID: 11432906, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
propertyPath: levelOptions.SphereRadius
value: 7
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2} m_ParentPrefab: {fileID: 100100000, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
m_IsPrefabParent: 0 m_IsPrefabParent: 0

View File

@ -6,7 +6,7 @@ namespace DeathBook.Model
{ {
public class Level : Observable, Updatable public class Level : Observable, Updatable
{ {
private const float TimeScale = 30f; private const float TimeScale = 30*4f;
private int score; private int score;
public int Score { get { return score; } } public int Score { get { return score; } }
@ -17,8 +17,12 @@ namespace DeathBook.Model
public List<FriendshipLink> Friendships { get { return friendships; } } public List<FriendshipLink> Friendships { get { return friendships; } }
//1 = 1 minute //1 = 1 minute
private float gameTime; private float gameTime; // real seconds elapsed since beginning
public int GameTime { get { return (int)(gameTime * TimeScale); } } public int GameTime { get { return (int)(gameTime * TimeScale); } }
//Time of day, between 0 minute to 1440 minutes (a day)
public int DayTime { get { return GameTime % (24*60); } }
private int lastHour = -1;
private float globalAwareness; //on a scale from 0 to 1 private float globalAwareness; //on a scale from 0 to 1
public float GlobalAwareness { get { return globalAwareness; } } public float GlobalAwareness { get { return globalAwareness; } }
@ -32,7 +36,12 @@ namespace DeathBook.Model
public void Update(float deltaTime) public void Update(float deltaTime)
{ {
gameTime += deltaTime; gameTime += deltaTime;
NotifyObservers(); int hour = DayTime / 60;
if (hour != lastHour)
{
lastHour = hour;
NotifyObservers();
}
//TODO Global awareness - start trends //TODO Global awareness - start trends
} }

View File

@ -133,9 +133,20 @@ namespace DeathBook.Model
private Person CreatePerson(int id, float x, float y, float z) private Person CreatePerson(int id, float x, float y, float z)
{ {
Vector3 pos = new Vector3(x, y, z); Vector3 pos = new Vector3(x, y, z);
//Vector2 times = //Value between 3 and 21
float connectionDuration = Utils.GetRandomValue(12, 9, 3);
int connectionTime = Random.Range(0, 24 * 60);
int disconnectionTime = (connectionTime + (int)(connectionDuration * 60)) % (24 * 60);
float freq = Utils.GetRandomValue(0, 1, 3);
Person p = new Person(id, pos); bool isFemale = Random.value <= 0.5;
string fName = "Fifi"; //isFemale ? NameGenerator.GetFemaleName() : NameGenerator.GetMaleName();
string lName = "Brindacier"; //NameGenerator.GetLastName();
Sprite pic = isFemale ? PictureGenerator.GetFemalePicture() : PictureGenerator.GetMalePicture();
Person p = new Person(id, fName, lName, pos, connectionTime, disconnectionTime, freq, pic);
return p; return p;
} }

View File

@ -28,14 +28,13 @@ namespace DeathBook.Model
private int friendCount = 0; private int friendCount = 0;
public int FriendCount { get { return friendCount; } } public int FriendCount { get { return friendCount; } }
private int timeBetweenPosts; // f = 1/T; private float postFrequency; //on a scale from 0 to 1
public int TimeBetweenPosts { get { return timeBetweenPosts; } } public float PostFrequency { get { return postFrequency; } }
private float connectionTime; private int connectionTime;
public float ConnectionTime { get { return connectionTime; } } public int ConnectionTime { get { return connectionTime; } }
private int disconnectionTime;
private float disconnectionTime; public int DisconnectionTime { get { return disconnectionTime; } }
public float DisconnectionTime { get { return disconnectionTime; } }
private float awarenessLevel = 0; //on a scale from 0 to 1 private float awarenessLevel = 0; //on a scale from 0 to 1
public float AwarenessLevel { get { return awarenessLevel; } } public float AwarenessLevel { get { return awarenessLevel; } }
@ -44,23 +43,25 @@ namespace DeathBook.Model
public bool Alive { get { return alive; } } public bool Alive { get { return alive; } }
private bool online = true; private bool online = true;
public bool Online { get { return online; } } public bool Online { get { return online; } set { online = value; NotifyObservers(); } }
private Sprite picture; private Sprite picture;
public Sprite Picture { get { return picture; } } public Sprite Picture { get { return picture; } }
public Person(int id, Vector3 pos) public Person(int id, string fName, string lName, Vector3 pos, int conn, int disconn, float freq, Sprite pic)
{ {
this.id = id; this.id = id;
initialPosition = pos; this.firstName = fName;
this.lastName = lName;
this.initialPosition = pos;
this.connectionTime = conn;
this.disconnectionTime = disconn;
Debug.Log("I am " + id + " and I connect at " + Utils.GetTimeString(connectionTime) + " until " + Utils.GetTimeString(disconnectionTime));
this.postFrequency = freq;
this.picture = pic;
// TODO Use names from db online = IsOnline(0);
firstName = "Mark";
lastName = "Zuckerberg";
// For testing purposes
picture = UnityEngine.Random.Range(0, 2) == 0 ? PictureGenerator.GetFemalePicture() : PictureGenerator.GetMalePicture();
} }
public void AddFriendship(Friendship f) public void AddFriendship(Friendship f)
@ -78,13 +79,18 @@ namespace DeathBook.Model
deadFriendsList.Add(f); deadFriendsList.Add(f);
} }
public void Kill() public bool Kill()
{ {
if (Online)
return false;
Debug.Log("Person " + id + " died!"); Debug.Log("Person " + id + " died!");
alive = false; alive = false;
foreach (Friendship f in friendsList) foreach (Friendship f in friendsList)
f.Friend.NotifyFriendWasKilled(f.Other); f.Friend.NotifyFriendWasKilled(f.Other);
NotifyObservers(); NotifyObservers();
return true;
} }
public void NoticeDeath(Friendship f) public void NoticeDeath(Friendship f)
@ -96,12 +102,22 @@ namespace DeathBook.Model
NotifyObservers(); NotifyObservers();
} }
//Time in hours
private bool IsOnline(int time)
{
if (ConnectionTime < DisconnectionTime)
return (time > ConnectionTime && time < DisconnectionTime);
return !(time < ConnectionTime && time > DisconnectionTime);
}
public void Update(float deltaTime) public void Update(float deltaTime)
{ {
//TODO Update if connected int time = LevelManager.Instance.GameLevel.DayTime;
int time = LevelManager.Instance.GameLevel.GameTime;
bool isOnline = IsOnline(time);
if (isOnline != Online)
Online = isOnline;
//The following actions are only performed if user is online //The following actions are only performed if user is online
if (!Online) if (!Online)

View File

@ -28,5 +28,10 @@ namespace DeathBook.Model
} }
return (sum / numSteps * 2 - 1) * range + mean; return (sum / numSteps * 2 - 1) * range + mean;
} }
public static string GetTimeString(int time)
{
return time / 60 + "h " + time % 60 + "m";
}
} }
} }

View File

@ -51,10 +51,11 @@ public class NetworkingSphere : MonoBehaviour
rb = GetComponent<Rigidbody>(); rb = GetComponent<Rigidbody>();
} }
/*void OnGUI() void OnGUI()
{ {
GUI.Button(new Rect(10, 100, 400, 40), manager.GameLevel.GameTime + ""); int time = manager.GameLevel.DayTime;
}*/ GUI.Button(new Rect(50, 50, 100, 40), Utils.GetTimeString(time));
}
void Update() void Update()
{ {