mirror of
https://github.com/ConjureETS/DeathBook.git
synced 2026-03-24 04:20:58 +00:00
Started implementing the person model
Signed-off-by: RosimInc <rosim_inc@hotmail.com>
This commit is contained in:
parent
43451b9be4
commit
768e1b2673
@ -10,6 +10,9 @@ namespace DeathBook.Model
|
|||||||
private float probability;
|
private float probability;
|
||||||
private float radius;
|
private float radius;
|
||||||
|
|
||||||
|
private const float minConnTime = 3;
|
||||||
|
private const float maxConnTime = 20;
|
||||||
|
|
||||||
public Level GenerateLevel(int numPeople, int avgFriends, float probability, float radius)
|
public Level GenerateLevel(int numPeople, int avgFriends, float probability, float radius)
|
||||||
{
|
{
|
||||||
this.numPeople = numPeople;
|
this.numPeople = numPeople;
|
||||||
@ -48,7 +51,8 @@ namespace DeathBook.Model
|
|||||||
x = Mathf.Cos(longitude) * r;
|
x = Mathf.Cos(longitude) * r;
|
||||||
y = Mathf.Sin(longitude) * r;
|
y = Mathf.Sin(longitude) * r;
|
||||||
|
|
||||||
p = new Person(i, x, y, z);
|
p = CreatePerson(i, x, y, z);
|
||||||
|
|
||||||
people.Add(p);
|
people.Add(p);
|
||||||
|
|
||||||
z -= dz;
|
z -= dz;
|
||||||
@ -123,6 +127,17 @@ namespace DeathBook.Model
|
|||||||
p2.AddFriendship(f);
|
p2.AddFriendship(f);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Person CreatePerson(int id, float x, float y, float z)
|
||||||
|
{
|
||||||
|
Vector3 pos = new Vector3(x, y, z);
|
||||||
|
//Vector2 times =
|
||||||
|
|
||||||
|
//Person p = new Person(id, pos,);
|
||||||
|
Person p = new Person(id);
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class DistanceNode
|
internal class DistanceNode
|
||||||
|
|||||||
@ -9,22 +9,21 @@ namespace DeathBook.Model
|
|||||||
private string name;
|
private string name;
|
||||||
private List<Friendship> friendList = new List<Friendship>();
|
private List<Friendship> friendList = new List<Friendship>();
|
||||||
public Vector3 initialPosition;
|
public Vector3 initialPosition;
|
||||||
|
public float connectionTime;
|
||||||
|
public float disconnectionTime;
|
||||||
|
public float awarenessLevel;
|
||||||
|
public bool alive;
|
||||||
|
public bool connected;
|
||||||
|
|
||||||
public int numFriends;
|
public int numFriends;
|
||||||
private int timeBetweenPosts; // f = 1/T;
|
public int timeBetweenPosts; // f = 1/T;
|
||||||
private int connectionTime;
|
public float importance; // Size of the quad
|
||||||
private int disconnectionTime;
|
|
||||||
private int awarenessLevel;
|
|
||||||
private bool alive;
|
|
||||||
|
|
||||||
private int happiness;
|
private int happiness;
|
||||||
private bool connected;
|
|
||||||
|
|
||||||
//private Node node;
|
public Person(int id)
|
||||||
|
|
||||||
public Person(int id, float x, float y, float z)
|
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
initialPosition = new Vector3(x, y, z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddFriendship(Friendship f)
|
public void AddFriendship(Friendship f)
|
||||||
|
|||||||
32
Assets/Scripts/Models/Utils.cs
Normal file
32
Assets/Scripts/Models/Utils.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace DeathBook.Model
|
||||||
|
{
|
||||||
|
public class Utils
|
||||||
|
{
|
||||||
|
public static void Test()
|
||||||
|
{
|
||||||
|
float mean = 50;
|
||||||
|
float range = 50;
|
||||||
|
int numSteps = 2;
|
||||||
|
|
||||||
|
int numTries = 100;
|
||||||
|
|
||||||
|
for (int i = 0; i < numTries; i++)
|
||||||
|
{
|
||||||
|
Debug.Log(GetRandomValue(mean, range, numSteps));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float GetRandomValue(float mean, float range, int numSteps)
|
||||||
|
{
|
||||||
|
float sum = 0;
|
||||||
|
for (int i = 0; i < numSteps; i++)
|
||||||
|
{
|
||||||
|
sum += Random.value;
|
||||||
|
}
|
||||||
|
return (sum / numSteps * 2 - 1) * range + mean;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/Scripts/Models/Utils.cs.meta
Normal file
12
Assets/Scripts/Models/Utils.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 710c7285af897124a8e7e5c5ecf05109
|
||||||
|
timeCreated: 1439506723
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
16
Assets/Tests/SRTest.cs
Normal file
16
Assets/Tests/SRTest.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
using DeathBook.Model;
|
||||||
|
|
||||||
|
public class SRTest : MonoBehaviour {
|
||||||
|
|
||||||
|
// Use this for initialization
|
||||||
|
void Start () {
|
||||||
|
Utils.Test();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update () {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/Tests/SRTest.cs.meta
Normal file
12
Assets/Tests/SRTest.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 43fe8f02e31afb5499ff01247a389c14
|
||||||
|
timeCreated: 1439506745
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
x
Reference in New Issue
Block a user