diff --git a/Assets/Scripts/Models/Friendship.cs b/Assets/Scripts/Models/Friendship.cs index 3cea223..caba40d 100644 --- a/Assets/Scripts/Models/Friendship.cs +++ b/Assets/Scripts/Models/Friendship.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; namespace DeathBook.Model { diff --git a/Assets/Scripts/Models/Level.cs b/Assets/Scripts/Models/Level.cs index f3c825e..d07b8ed 100644 --- a/Assets/Scripts/Models/Level.cs +++ b/Assets/Scripts/Models/Level.cs @@ -1,12 +1,16 @@ using UnityEngine; -using System.Collections; +using System.Collections.Generic; namespace DeathBook.Model { public class Level { - private int points; - private Person[] peeps; + private int score; + + private List peeps; + private List friendships; + + //private Generator gen; private int gameTime; private int globalAwareness; diff --git a/Assets/Scripts/Models/LevelGenerator.cs b/Assets/Scripts/Models/LevelGenerator.cs index 651cd97..cdd84f0 100644 --- a/Assets/Scripts/Models/LevelGenerator.cs +++ b/Assets/Scripts/Models/LevelGenerator.cs @@ -1,12 +1,76 @@ -using System.Collections.Generic; +using UnityEngine; +using System.Collections.Generic; namespace DeathBook.Model { public class LevelGenerator { - public Level generateLevel(/*put stuff here*/) + private int numFriends; + private int avgConnections; + private float radius; + + public Level GenerateLevel() { //and here... + + + List people = CreatePeople(); + List friendships = CreateFriendships(people); + + return null; + } + + private List CreatePeople() + { + List people = new List(numFriends); + + float dlong = Mathf.PI * (3 - Mathf.Sqrt(5)); //~2.39996323 + + float dz = (2f / numFriends) * radius; + float longitude = 0f; + float z = radius - dz / 2; + float r, x, y; + Person p; + + for (int i = 0; i < numFriends; i++) + { + r = Mathf.Sqrt(radius * radius - z * z); + + x = Mathf.Cos(longitude) * r; + y = Mathf.Sin(longitude) * r; + + p = new Person(x,y,z); + people.Add(p); + + z -= dz; + + longitude += dlong; + } + + return people; + } + + private List CreateFriendships(List people) + { + List friendships = new List(); + + float rSq = radius * radius; + + for (int i = 0, count = people.Count; i < count; i++) + { + for (int j = i+1; j < count; j++) + { + // Nombre d'amis présents + + // + + } + } + + + + + //TODO return null; } } diff --git a/Assets/Scripts/Models/Person.cs b/Assets/Scripts/Models/Person.cs index e43288d..7b0823f 100644 --- a/Assets/Scripts/Models/Person.cs +++ b/Assets/Scripts/Models/Person.cs @@ -1,13 +1,13 @@ using UnityEngine; -using System.Collections; +using System.Collections.Generic; namespace DeathBook.Model { public class Person { private string name; - private Friendship[] friendList; - private int friendCount; //lazy + private List friendList = new List(); + public Vector3 initialPosition; private int timeBetweenPosts; // f = 1/T; private int connectionTime; private int disconnectionTime; @@ -19,6 +19,10 @@ namespace DeathBook.Model //private Node node; + public Person(float x, float y, float z) + { + initialPosition = new Vector3(x, y, z); + } private bool isConnected(int time) {