mirror of
https://github.com/ConjureETS/DeathBook.git
synced 2026-03-24 04:20:58 +00:00
Merge branch 'master' of https://github.com/ConjureETS/DeathBook
Conflicts: Assets/Scenes/Creator.unity Signed-off-by: RosimInc <rosim_inc@hotmail.com>
This commit is contained in:
commit
43451b9be4
@ -1,7 +1,7 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 0fe2d64981912a545a084438d8089f68
|
guid: bd865f25edf545140a9ed3797bb1b4cb
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
timeCreated: 1439307965
|
timeCreated: 1439489157
|
||||||
licenseType: Free
|
licenseType: Free
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
userData:
|
userData:
|
||||||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
@ -6,7 +6,7 @@ Material:
|
|||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_PrefabParentObject: {fileID: 0}
|
m_PrefabParentObject: {fileID: 0}
|
||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_Name: laserPic
|
m_Name: LinkBeam
|
||||||
m_Shader: {fileID: 200, guid: 0000000000000000f000000000000000, type: 0}
|
m_Shader: {fileID: 200, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
m_ShaderKeywords:
|
m_ShaderKeywords:
|
||||||
m_LightmapFlags: 5
|
m_LightmapFlags: 5
|
||||||
109
Assets/Prefabs/NetworkingSphere.prefab
Normal file
109
Assets/Prefabs/NetworkingSphere.prefab
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &182606
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
serializedVersion: 4
|
||||||
|
m_Component:
|
||||||
|
- 4: {fileID: 433422}
|
||||||
|
- 33: {fileID: 3303090}
|
||||||
|
- 23: {fileID: 2322642}
|
||||||
|
- 114: {fileID: 11432906}
|
||||||
|
- 54: {fileID: 5423250}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: NetworkingSphere
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &433422
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
m_GameObject: {fileID: 182606}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 5.96046448e-08, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 0
|
||||||
|
--- !u!23 &2322642
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
m_GameObject: {fileID: 182606}
|
||||||
|
m_Enabled: 0
|
||||||
|
m_CastShadows: 1
|
||||||
|
m_ReceiveShadows: 1
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_SubsetIndices:
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_UseLightProbes: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_PreserveUVs: 1
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_AutoUVMaxDistance: .5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
--- !u!33 &3303090
|
||||||
|
MeshFilter:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
m_GameObject: {fileID: 182606}
|
||||||
|
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
--- !u!54 &5423250
|
||||||
|
Rigidbody:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
m_GameObject: {fileID: 182606}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Mass: 1
|
||||||
|
m_Drag: 0
|
||||||
|
m_AngularDrag: .800000012
|
||||||
|
m_UseGravity: 0
|
||||||
|
m_IsKinematic: 0
|
||||||
|
m_Interpolate: 0
|
||||||
|
m_Constraints: 0
|
||||||
|
m_CollisionDetection: 0
|
||||||
|
--- !u!114 &11432906
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_PrefabParentObject: {fileID: 0}
|
||||||
|
m_PrefabInternal: {fileID: 100100000}
|
||||||
|
m_GameObject: {fileID: 182606}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: d0907c1567bad554c8b995de3459e517, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
LinkObj: {fileID: 11495142, guid: fab430cecad80ad4391987a06b550cb7, type: 2}
|
||||||
|
PersonObj: {fileID: 11406500, guid: d4b0e683ea5ec974987ea1f6741b333c, type: 2}
|
||||||
|
NumPeople: 100
|
||||||
|
AvgNumFriends: 10
|
||||||
|
FriendshipLikeliness: .300000012
|
||||||
|
SphereRadius: 7
|
||||||
|
rotationSpeed: .699999988
|
||||||
|
torqueForce: 1
|
||||||
|
--- !u!1001 &100100000
|
||||||
|
Prefab:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Modification:
|
||||||
|
m_TransformParent: {fileID: 0}
|
||||||
|
m_Modifications: []
|
||||||
|
m_RemovedComponents: []
|
||||||
|
m_ParentPrefab: {fileID: 0}
|
||||||
|
m_RootGameObject: {fileID: 182606}
|
||||||
|
m_IsPrefabParent: 1
|
||||||
8
Assets/Prefabs/NetworkingSphere.prefab.meta
Normal file
8
Assets/Prefabs/NetworkingSphere.prefab.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 136ea38d5deb4c9418beb879167d9b03
|
||||||
|
timeCreated: 1439489411
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -197,7 +197,7 @@ MeshRenderer:
|
|||||||
m_PrefabParentObject: {fileID: 0}
|
m_PrefabParentObject: {fileID: 0}
|
||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 736567784}
|
m_GameObject: {fileID: 736567784}
|
||||||
m_Enabled: 0
|
m_Enabled: 1
|
||||||
m_CastShadows: 1
|
m_CastShadows: 1
|
||||||
m_ReceiveShadows: 1
|
m_ReceiveShadows: 1
|
||||||
m_Materials:
|
m_Materials:
|
||||||
@ -258,10 +258,10 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
LinkObj: {fileID: 11495142, guid: fab430cecad80ad4391987a06b550cb7, type: 2}
|
LinkObj: {fileID: 11495142, guid: fab430cecad80ad4391987a06b550cb7, type: 2}
|
||||||
PersonObj: {fileID: 11406500, guid: 646dd6566f9e1374caa3af8ad37c43d3, type: 2}
|
PersonObj: {fileID: 11406500, guid: d4b0e683ea5ec974987ea1f6741b333c, type: 2}
|
||||||
NumPeople: 200
|
NumPeople: 100
|
||||||
AvgNumFriends: 10
|
AvgNumFriends: 10
|
||||||
FriendshipLikeliness: 1
|
FriendshipLikeliness: .300000012
|
||||||
SphereRadius: 7
|
SphereRadius: 7
|
||||||
rotationSpeed: .699999988
|
rotationSpeed: .699999988
|
||||||
torqueForce: .100000001
|
torqueForce: .100000001
|
||||||
|
|||||||
@ -293,100 +293,6 @@ CanvasRenderer:
|
|||||||
m_PrefabParentObject: {fileID: 0}
|
m_PrefabParentObject: {fileID: 0}
|
||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 534364716}
|
m_GameObject: {fileID: 534364716}
|
||||||
--- !u!1 &736567784
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_PrefabParentObject: {fileID: 0}
|
|
||||||
m_PrefabInternal: {fileID: 0}
|
|
||||||
serializedVersion: 4
|
|
||||||
m_Component:
|
|
||||||
- 4: {fileID: 736567788}
|
|
||||||
- 33: {fileID: 736567787}
|
|
||||||
- 23: {fileID: 736567785}
|
|
||||||
- 114: {fileID: 736567789}
|
|
||||||
- 54: {fileID: 736567786}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Center
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!23 &736567785
|
|
||||||
MeshRenderer:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_PrefabParentObject: {fileID: 0}
|
|
||||||
m_PrefabInternal: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 736567784}
|
|
||||||
m_Enabled: 0
|
|
||||||
m_CastShadows: 1
|
|
||||||
m_ReceiveShadows: 1
|
|
||||||
m_Materials:
|
|
||||||
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
|
|
||||||
m_SubsetIndices:
|
|
||||||
m_StaticBatchRoot: {fileID: 0}
|
|
||||||
m_UseLightProbes: 1
|
|
||||||
m_ReflectionProbeUsage: 1
|
|
||||||
m_ProbeAnchor: {fileID: 0}
|
|
||||||
m_ScaleInLightmap: 1
|
|
||||||
m_PreserveUVs: 1
|
|
||||||
m_ImportantGI: 0
|
|
||||||
m_AutoUVMaxDistance: .5
|
|
||||||
m_AutoUVMaxAngle: 89
|
|
||||||
m_LightmapParameters: {fileID: 0}
|
|
||||||
m_SortingLayerID: 0
|
|
||||||
m_SortingOrder: 0
|
|
||||||
--- !u!54 &736567786
|
|
||||||
Rigidbody:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_PrefabParentObject: {fileID: 0}
|
|
||||||
m_PrefabInternal: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 736567784}
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Mass: 1
|
|
||||||
m_Drag: 0
|
|
||||||
m_AngularDrag: .800000012
|
|
||||||
m_UseGravity: 0
|
|
||||||
m_IsKinematic: 0
|
|
||||||
m_Interpolate: 0
|
|
||||||
m_Constraints: 0
|
|
||||||
m_CollisionDetection: 0
|
|
||||||
--- !u!33 &736567787
|
|
||||||
MeshFilter:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_PrefabParentObject: {fileID: 0}
|
|
||||||
m_PrefabInternal: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 736567784}
|
|
||||||
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
--- !u!4 &736567788
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_PrefabParentObject: {fileID: 0}
|
|
||||||
m_PrefabInternal: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 736567784}
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 5.96046448e-08, y: 0, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_RootOrder: 2
|
|
||||||
--- !u!114 &736567789
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_PrefabParentObject: {fileID: 0}
|
|
||||||
m_PrefabInternal: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 736567784}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: d0907c1567bad554c8b995de3459e517, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
Link: {fileID: 11495142, guid: fab430cecad80ad4391987a06b550cb7, type: 2}
|
|
||||||
Person: {fileID: 11406500, guid: 646dd6566f9e1374caa3af8ad37c43d3, type: 2}
|
|
||||||
PointsAmount: 400
|
|
||||||
SphereRadius: 7
|
|
||||||
rotationSpeed: .699999988
|
|
||||||
torqueForce: 50
|
|
||||||
--- !u!1 &1057734534
|
--- !u!1 &1057734534
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -611,3 +517,45 @@ Transform:
|
|||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 4
|
m_RootOrder: 4
|
||||||
|
--- !u!1001 &2065124246
|
||||||
|
Prefab:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Modification:
|
||||||
|
m_TransformParent: {fileID: 0}
|
||||||
|
m_Modifications:
|
||||||
|
- target: {fileID: 433422, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
|
||||||
|
propertyPath: m_LocalPosition.x
|
||||||
|
value: 5.96046448e-08
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 433422, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
|
||||||
|
propertyPath: m_LocalPosition.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 433422, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
|
||||||
|
propertyPath: m_LocalPosition.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 433422, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
|
||||||
|
propertyPath: m_LocalRotation.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 433422, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
|
||||||
|
propertyPath: m_LocalRotation.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 433422, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
|
||||||
|
propertyPath: m_LocalRotation.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 433422, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
|
||||||
|
propertyPath: m_LocalRotation.w
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 433422, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
|
||||||
|
propertyPath: m_RootOrder
|
||||||
|
value: 2
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
m_RemovedComponents: []
|
||||||
|
m_ParentPrefab: {fileID: 100100000, guid: 136ea38d5deb4c9418beb879167d9b03, type: 2}
|
||||||
|
m_IsPrefabParent: 0
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
114
Assets/Scripts/NetworkingSphere.cs
Normal file
114
Assets/Scripts/NetworkingSphere.cs
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using DeathBook.Model;
|
||||||
|
|
||||||
|
public class NetworkingSphere : MonoBehaviour
|
||||||
|
{
|
||||||
|
public FriendshipLink LinkObj;
|
||||||
|
public PersonTest PersonObj;
|
||||||
|
public int NumPeople = 50;
|
||||||
|
public int AvgNumFriends = 20;
|
||||||
|
public float FriendshipLikeliness = 0.4f;
|
||||||
|
public float SphereRadius = 1f;
|
||||||
|
public float rotationSpeed = 0.7f;
|
||||||
|
|
||||||
|
public float torqueForce = 50f;
|
||||||
|
private bool dragging = false;
|
||||||
|
private Vector3 delta = new Vector3();
|
||||||
|
private Rigidbody rb;
|
||||||
|
|
||||||
|
private PersonTest[] peopleNodes;
|
||||||
|
//TODO private Friendship[] friendships;
|
||||||
|
private GameObject[] nodes;
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
LevelGenerator lGen = new LevelGenerator();
|
||||||
|
Level lvl = lGen.GenerateLevel(NumPeople, AvgNumFriends, FriendshipLikeliness, SphereRadius);
|
||||||
|
|
||||||
|
InstantiateNodes(lvl);
|
||||||
|
AssignLinks(lvl);
|
||||||
|
rb = GetComponent<Rigidbody>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
Vector3 screenMousePos = Input.mousePosition;
|
||||||
|
|
||||||
|
screenMousePos.z = transform.position.z - Camera.main.transform.position.z;
|
||||||
|
|
||||||
|
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 (Mathf.Sqrt(worldMousePos.x * worldMousePos.x + worldMousePos.y * worldMousePos.y) > SphereRadius + 1f)
|
||||||
|
{
|
||||||
|
transform.Rotate(Vector3.one * Time.deltaTime * rotationSpeed);
|
||||||
|
}
|
||||||
|
|
||||||
|
//when right btn clicked, call the chnge rotation
|
||||||
|
if (Input.GetMouseButtonDown(1))
|
||||||
|
{
|
||||||
|
dragging = true;
|
||||||
|
}
|
||||||
|
else if (Input.GetMouseButtonUp(1))
|
||||||
|
{
|
||||||
|
dragging = false;
|
||||||
|
delta = new Vector3();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dragging)
|
||||||
|
{
|
||||||
|
MoveSphere();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MoveSphere()
|
||||||
|
{
|
||||||
|
float deltaX = Input.GetAxis("Mouse X");
|
||||||
|
float deltaY = Input.GetAxis("Mouse Y");
|
||||||
|
if (deltaX == 0 && deltaY == 0)
|
||||||
|
{
|
||||||
|
delta = new Vector3();
|
||||||
|
rb.angularVelocity *= 0.8f;
|
||||||
|
}
|
||||||
|
delta += new Vector3(deltaX, deltaY, 0);
|
||||||
|
//rigidbody.AddTorque();
|
||||||
|
rb.AddTorque(Vector3.down * delta.x * torqueForce * Time.deltaTime, ForceMode.Impulse);
|
||||||
|
rb.AddTorque(Vector3.right * delta.y * torqueForce * Time.deltaTime, ForceMode.Impulse);
|
||||||
|
Debug.Log(delta.x + ", " + delta.y);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InstantiateNodes(Level lvl)
|
||||||
|
{
|
||||||
|
peopleNodes = new PersonTest[lvl.people.Count];
|
||||||
|
|
||||||
|
int ctr = 0;
|
||||||
|
foreach (Person p in lvl.people)
|
||||||
|
{
|
||||||
|
|
||||||
|
PersonTest pInst = Instantiate(PersonObj, p.initialPosition, Quaternion.identity) as PersonTest;
|
||||||
|
|
||||||
|
pInst.transform.parent = this.transform;
|
||||||
|
|
||||||
|
peopleNodes[ctr++] = pInst;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AssignLinks(Level lvl)
|
||||||
|
{
|
||||||
|
foreach (Friendship f in lvl.friendships)
|
||||||
|
{
|
||||||
|
FriendshipLink link = Instantiate(LinkObj) as FriendshipLink;
|
||||||
|
int id1 = f.friend1.id;
|
||||||
|
int id2 = f.friend2.id;
|
||||||
|
link.AttachToObjects(peopleNodes[id1].gameObject, peopleNodes[id2].gameObject);
|
||||||
|
|
||||||
|
// Temporary stuff, for testing
|
||||||
|
peopleNodes[id1].AddLink(link);
|
||||||
|
peopleNodes[id2].AddLink(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,146 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
public class Center : MonoBehaviour
|
|
||||||
{
|
|
||||||
|
|
||||||
//public float fov = Camera.main.fieldOfView;
|
|
||||||
public Vector3 nextPosition;
|
|
||||||
public float moveSpeed = 0;
|
|
||||||
|
|
||||||
public FriendshipLink Link;
|
|
||||||
public PersonTest Person;
|
|
||||||
public int PointsAmount = 50;
|
|
||||||
public float SphereRadius = 1f;
|
|
||||||
public float rotationSpeed = 0.7f;
|
|
||||||
|
|
||||||
public float torqueForce = 50f;
|
|
||||||
private bool dragging = false;
|
|
||||||
private Vector3 delta = new Vector3();
|
|
||||||
private Rigidbody rb;
|
|
||||||
private PersonTest[] people;
|
|
||||||
|
|
||||||
|
|
||||||
private GameObject[] nodes;
|
|
||||||
|
|
||||||
void Awake()
|
|
||||||
{
|
|
||||||
InstantiateNodes();
|
|
||||||
AssignLinks();
|
|
||||||
rb = GetComponent<Rigidbody>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
Vector3 screenMousePos = Input.mousePosition;
|
|
||||||
|
|
||||||
screenMousePos.z = transform.position.z - Camera.main.transform.position.z;
|
|
||||||
|
|
||||||
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 (Mathf.Sqrt(worldMousePos.x * worldMousePos.x + worldMousePos.y * worldMousePos.y) > SphereRadius + 1f)
|
|
||||||
{
|
|
||||||
transform.Rotate(Vector3.one * Time.deltaTime * rotationSpeed);
|
|
||||||
}
|
|
||||||
|
|
||||||
//when right btn clicked, call the chnge rotation
|
|
||||||
if (Input.GetMouseButtonDown(1))
|
|
||||||
{
|
|
||||||
dragging = true;
|
|
||||||
}
|
|
||||||
else if (Input.GetMouseButtonUp(1))
|
|
||||||
{
|
|
||||||
dragging = false;
|
|
||||||
delta = new Vector3();
|
|
||||||
}
|
|
||||||
|
|
||||||
//camera zoom
|
|
||||||
if (Input.GetAxis("Mouse ScrollWheel") != 0)
|
|
||||||
{
|
|
||||||
Debug.Log("Pressed middle click.");
|
|
||||||
//Camera.main.transform.position.z += (moveSpeed * Time.deltaTime);
|
|
||||||
//transform.position = Vector3.Lerp(transform.position, nextPosition, Time.deltaTime * moveSpeed);
|
|
||||||
//Camera.main.fieldOfView += Input.GetAxis("Mouse ScrollWheel") * 10f;
|
|
||||||
//Camera.main.transform
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FixedUpdate()
|
|
||||||
{
|
|
||||||
if (dragging)
|
|
||||||
{
|
|
||||||
MoveSphere();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MoveSphere()
|
|
||||||
{
|
|
||||||
float deltaX = Input.GetAxis("Mouse X");
|
|
||||||
float deltaY = Input.GetAxis("Mouse Y");
|
|
||||||
if (deltaX == 0 && deltaY == 0)
|
|
||||||
{
|
|
||||||
delta = new Vector3();
|
|
||||||
rb.angularVelocity *= 0.8f;
|
|
||||||
}
|
|
||||||
delta += new Vector3(deltaX, deltaY, 0);
|
|
||||||
rb.AddTorque(Vector3.down * delta.x * torqueForce * Time.fixedDeltaTime, ForceMode.Impulse);
|
|
||||||
rb.AddTorque(Vector3.right * delta.y * torqueForce * Time.fixedDeltaTime, ForceMode.Impulse);
|
|
||||||
Debug.Log(delta.x + ", " + delta.y);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void InstantiateNodes()
|
|
||||||
{
|
|
||||||
/* 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.
|
|
||||||
*/
|
|
||||||
people = new PersonTest[PointsAmount];
|
|
||||||
|
|
||||||
float goldenAngle = Mathf.PI * (3 - Mathf.Sqrt(5));
|
|
||||||
|
|
||||||
float zDistance = (2f / PointsAmount) * SphereRadius;
|
|
||||||
float longitude = 0f;
|
|
||||||
float z = SphereRadius;
|
|
||||||
|
|
||||||
for (int i = 0; i < PointsAmount; i++)
|
|
||||||
{
|
|
||||||
float r = Mathf.Sqrt(SphereRadius * SphereRadius - z * z);
|
|
||||||
|
|
||||||
float x = Mathf.Sin(longitude) * r;
|
|
||||||
float y = Mathf.Cos(longitude) * r;
|
|
||||||
|
|
||||||
PersonTest simon = Instantiate(Person, new Vector3(x, y, z), Quaternion.identity) as PersonTest;
|
|
||||||
|
|
||||||
simon.transform.parent = this.transform;
|
|
||||||
|
|
||||||
people[i] = simon;
|
|
||||||
|
|
||||||
z -= zDistance;
|
|
||||||
longitude += goldenAngle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AssignLinks()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < people.Length / 4; i++)
|
|
||||||
{
|
|
||||||
FriendshipLink link = Instantiate(Link) as FriendshipLink;
|
|
||||||
|
|
||||||
int destinationIndex = Random.Range(people.Length / 2, people.Length - 1);
|
|
||||||
|
|
||||||
link.AttachToObjects(people[i].gameObject, people[destinationIndex].gameObject);
|
|
||||||
|
|
||||||
// Temporary stuff, for testing
|
|
||||||
people[i].AddLink(link);
|
|
||||||
people[destinationIndex].AddLink(link);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -21,7 +21,6 @@ public class PersonTest : MonoBehaviour
|
|||||||
|
|
||||||
void OnMouseOver()
|
void OnMouseOver()
|
||||||
{
|
{
|
||||||
Debug.Log("abc");
|
|
||||||
if (!_highlighted)
|
if (!_highlighted)
|
||||||
{
|
{
|
||||||
_highlighted = true;
|
_highlighted = true;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 646dd6566f9e1374caa3af8ad37c43d3
|
guid: d4b0e683ea5ec974987ea1f6741b333c
|
||||||
timeCreated: 1439361747
|
timeCreated: 1439489111
|
||||||
licenseType: Free
|
licenseType: Free
|
||||||
NativeFormatImporter:
|
NativeFormatImporter:
|
||||||
userData:
|
userData:
|
||||||
|
|||||||
@ -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