mirror of
https://github.com/ConjureETS/DeathBook.git
synced 2026-03-25 13:00:59 +00:00
- Removed some debug logs
This commit is contained in:
parent
bbf3de222f
commit
ca79ca8381
@ -27,6 +27,12 @@ namespace DeathBook.Model
|
|||||||
{
|
{
|
||||||
List<Person> people = new List<Person>(numPeople);
|
List<Person> people = new List<Person>(numPeople);
|
||||||
|
|
||||||
|
/* Sphere uniform distribution using the spiral method with the golden angle
|
||||||
|
* ~2.39996323 rad, the golden angle (the most irrational angle)
|
||||||
|
* is used here to make sure that the sin and cos functions
|
||||||
|
* dont end up drawing clusters of points and the spirals are way
|
||||||
|
* less visible.
|
||||||
|
*/
|
||||||
float dlong = Mathf.PI * (3 - Mathf.Sqrt(5)); //~2.39996323
|
float dlong = Mathf.PI * (3 - Mathf.Sqrt(5)); //~2.39996323
|
||||||
|
|
||||||
float dz = (2f / numPeople) * radius;
|
float dz = (2f / numPeople) * radius;
|
||||||
|
|||||||
@ -21,7 +21,6 @@ public class PersonTest : MonoBehaviour
|
|||||||
|
|
||||||
void OnMouseOver()
|
void OnMouseOver()
|
||||||
{
|
{
|
||||||
Debug.Log("abc");
|
|
||||||
if (!_highlighted)
|
if (!_highlighted)
|
||||||
{
|
{
|
||||||
_highlighted = true;
|
_highlighted = true;
|
||||||
|
|||||||
@ -1,94 +1,88 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using DeathBook.Model;
|
using DeathBook.Model;
|
||||||
|
|
||||||
public class SphereSR : MonoBehaviour
|
public class SphereSR : MonoBehaviour
|
||||||
{
|
{
|
||||||
public FriendshipLink LinkObj;
|
public FriendshipLink LinkObj;
|
||||||
public PersonTest PersonObj;
|
public PersonTest PersonObj;
|
||||||
public int NumPeople = 50;
|
public int NumPeople = 50;
|
||||||
public int AvgNumFriends = 20;
|
public int AvgNumFriends = 20;
|
||||||
public float FriendshipLikeliness = 0.4f;
|
public float FriendshipLikeliness = 0.4f;
|
||||||
public float SphereRadius = 1f;
|
public float SphereRadius = 1f;
|
||||||
public float rotationSpeed = 0.7f;
|
public float rotationSpeed = 0.7f;
|
||||||
|
|
||||||
public float torqueForce = 50f;
|
public float torqueForce = 50f;
|
||||||
private bool dragging = false;
|
private bool dragging = false;
|
||||||
private Vector3 delta = new Vector3();
|
private Vector3 delta = new Vector3();
|
||||||
private Rigidbody rb;
|
private Rigidbody rb;
|
||||||
|
|
||||||
private PersonTest[] peopleNodes;
|
private PersonTest[] peopleNodes;
|
||||||
//TODO private Friendship[] friendships;
|
//TODO private Friendship[] friendships;
|
||||||
private GameObject[] nodes;
|
private GameObject[] nodes;
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
LevelGenerator lGen = new LevelGenerator();
|
LevelGenerator lGen = new LevelGenerator();
|
||||||
Level lvl = lGen.GenerateLevel(NumPeople, AvgNumFriends, FriendshipLikeliness, SphereRadius);
|
Level lvl = lGen.GenerateLevel(NumPeople, AvgNumFriends, FriendshipLikeliness, SphereRadius);
|
||||||
|
|
||||||
InstantiateNodes(lvl);
|
InstantiateNodes(lvl);
|
||||||
AssignLinks(lvl);
|
AssignLinks(lvl);
|
||||||
rb = GetComponent<Rigidbody>();
|
rb = GetComponent<Rigidbody>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
Vector3 screenMousePos = Input.mousePosition;
|
Vector3 screenMousePos = Input.mousePosition;
|
||||||
|
|
||||||
screenMousePos.z = transform.position.z - Camera.main.transform.position.z;
|
screenMousePos.z = transform.position.z - Camera.main.transform.position.z;
|
||||||
|
|
||||||
Vector3 worldMousePos = Camera.main.ScreenToWorldPoint(screenMousePos);
|
Vector3 worldMousePos = Camera.main.ScreenToWorldPoint(screenMousePos);
|
||||||
|
|
||||||
// If the world position of the mouse is greater than the radius of the sphere, we are outside
|
// If the world position of the mouse is greater than the radius of the sphere, we are outside
|
||||||
if (Mathf.Sqrt(worldMousePos.x * worldMousePos.x + worldMousePos.y * worldMousePos.y) > SphereRadius + 1f)
|
if (Mathf.Sqrt(worldMousePos.x * worldMousePos.x + worldMousePos.y * worldMousePos.y) > SphereRadius + 1f)
|
||||||
{
|
{
|
||||||
transform.Rotate(Vector3.one * Time.deltaTime * rotationSpeed);
|
transform.Rotate(Vector3.one * Time.deltaTime * rotationSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
//when right btn clicked, call the chnge rotation
|
//when right btn clicked, call the chnge rotation
|
||||||
if (Input.GetMouseButtonDown(1))
|
if (Input.GetMouseButtonDown(1))
|
||||||
{
|
{
|
||||||
dragging = true;
|
dragging = true;
|
||||||
}
|
}
|
||||||
else if (Input.GetMouseButtonUp(1))
|
else if (Input.GetMouseButtonUp(1))
|
||||||
{
|
{
|
||||||
dragging = false;
|
dragging = false;
|
||||||
delta = new Vector3();
|
delta = new Vector3();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dragging)
|
if (dragging)
|
||||||
{
|
{
|
||||||
MoveSphere();
|
MoveSphere();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveSphere()
|
void MoveSphere()
|
||||||
{
|
{
|
||||||
float deltaX = Input.GetAxis("Mouse X");
|
float deltaX = Input.GetAxis("Mouse X");
|
||||||
float deltaY = Input.GetAxis("Mouse Y");
|
float deltaY = Input.GetAxis("Mouse Y");
|
||||||
if (deltaX == 0 && deltaY == 0)
|
if (deltaX == 0 && deltaY == 0)
|
||||||
{
|
{
|
||||||
delta = new Vector3();
|
delta = new Vector3();
|
||||||
rb.angularVelocity *= 0.8f;
|
rb.angularVelocity *= 0.8f;
|
||||||
}
|
}
|
||||||
delta += new Vector3(deltaX, deltaY, 0);
|
delta += new Vector3(deltaX, deltaY, 0);
|
||||||
//rigidbody.AddTorque();
|
//rigidbody.AddTorque();
|
||||||
rb.AddTorque(Vector3.down * delta.x * torqueForce * Time.deltaTime, ForceMode.Impulse);
|
rb.AddTorque(Vector3.down * delta.x * torqueForce * Time.deltaTime, ForceMode.Impulse);
|
||||||
rb.AddTorque(Vector3.right * delta.y * torqueForce * Time.deltaTime, ForceMode.Impulse);
|
rb.AddTorque(Vector3.right * delta.y * torqueForce * Time.deltaTime, ForceMode.Impulse);
|
||||||
Debug.Log(delta.x + ", " + delta.y);
|
Debug.Log(delta.x + ", " + delta.y);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InstantiateNodes(Level lvl)
|
private void InstantiateNodes(Level lvl)
|
||||||
{
|
{
|
||||||
/* Sphere uniform distribution using the spiral method with the golden angle
|
|
||||||
* ~2.39996323 rad, the golden angle (the most irrational angle)
|
|
||||||
* is used here to make sure that the sin and cos functions
|
|
||||||
* dont end up drawing clusters of points and the spirals are way
|
|
||||||
* less visible.
|
|
||||||
*/
|
|
||||||
peopleNodes = new PersonTest[lvl.people.Count];
|
peopleNodes = new PersonTest[lvl.people.Count];
|
||||||
|
|
||||||
int ctr = 0;
|
int ctr = 0;
|
||||||
@ -100,10 +94,10 @@ public class SphereSR : MonoBehaviour
|
|||||||
pInst.transform.parent = this.transform;
|
pInst.transform.parent = this.transform;
|
||||||
|
|
||||||
peopleNodes[ctr++] = pInst;
|
peopleNodes[ctr++] = pInst;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AssignLinks(Level lvl)
|
private void AssignLinks(Level lvl)
|
||||||
{
|
{
|
||||||
foreach (Friendship f in lvl.friendships)
|
foreach (Friendship f in lvl.friendships)
|
||||||
{
|
{
|
||||||
@ -111,10 +105,10 @@ public class SphereSR : MonoBehaviour
|
|||||||
int id1 = f.friend1.id;
|
int id1 = f.friend1.id;
|
||||||
int id2 = f.friend2.id;
|
int id2 = f.friend2.id;
|
||||||
link.AttachToObjects(peopleNodes[id1].gameObject, peopleNodes[id2].gameObject);
|
link.AttachToObjects(peopleNodes[id1].gameObject, peopleNodes[id2].gameObject);
|
||||||
|
|
||||||
// Temporary stuff, for testing
|
// Temporary stuff, for testing
|
||||||
peopleNodes[id1].AddLink(link);
|
peopleNodes[id1].AddLink(link);
|
||||||
peopleNodes[id2].AddLink(link);
|
peopleNodes[id2].AddLink(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user