Conflicts:
	Assets/Prefabs/NetworkingSphere.prefab
	Assets/Scenes/Gameplay.unity
	Assets/Scripts/Models/Person.cs
	Assets/Scripts/NetworkingSphere.cs

Signed-off-by: RosimInc <rosim_inc@hotmail.com>
This commit is contained in:
RosimInc 2015-08-16 01:01:03 -04:00
commit bcbf97fa44
10 changed files with 990 additions and 853 deletions

View File

@ -395,7 +395,19 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 11443318} m_TargetGraphic: {fileID: 11443318}
m_OnClick: m_OnClick:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls:
- m_Target: {fileID: 11476684}
m_MethodName: KillNode
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0, m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null Culture=neutral, PublicKeyToken=null
--- !u!114 &11411578 --- !u!114 &11411578
@ -457,8 +469,8 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 11431992} m_TargetGraphic: {fileID: 11431992}
m_HandleRect: {fileID: 22417254} m_HandleRect: {fileID: 22417254}
m_Direction: 2 m_Direction: 2
m_Value: 1 m_Value: .999378026
m_Size: .427392095 m_Size: .427392036
m_NumberOfSteps: 0 m_NumberOfSteps: 0
m_OnValueChanged: m_OnValueChanged:
m_PersistentCalls: m_PersistentCalls:
@ -645,7 +657,7 @@ MonoBehaviour:
WatchButton: {fileID: 11491412} WatchButton: {fileID: 11491412}
XButton: {fileID: 11494666} XButton: {fileID: 11494666}
Container: {fileID: 147852} Container: {fileID: 147852}
UIFriendPicture: {fileID: 11467422, guid: 16a1d168f1ef75b4690435675a9e69b0, type: 2} FriendPicture: {fileID: 11469406, guid: 16a1d168f1ef75b4690435675a9e69b0, type: 2}
--- !u!114 &11478962 --- !u!114 &11478962
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@ -1093,7 +1105,7 @@ RectTransform:
m_RootOrder: 0 m_RootOrder: 0
m_AnchorMin: {x: .5, y: 1} m_AnchorMin: {x: .5, y: 1}
m_AnchorMax: {x: .5, y: 1} m_AnchorMax: {x: .5, y: 1}
m_AnchoredPosition: {x: 0, y: -65.9999924} m_AnchoredPosition: {x: 0, y: -65.95298}
m_SizeDelta: {x: 90, y: 132} m_SizeDelta: {x: 90, y: 132}
m_Pivot: {x: .5, y: .5} m_Pivot: {x: .5, y: .5}
--- !u!224 &22462244 --- !u!224 &22462244

View File

@ -62,7 +62,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 193868} m_GameObject: {fileID: 193868}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: -544.163269, y: -235.973114, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 496448} - {fileID: 496448}
@ -75,7 +75,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 136744} m_GameObject: {fileID: 136744}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: -.00100000005}
m_LocalScale: {x: .800000012, y: .800000012, z: 1} m_LocalScale: {x: .800000012, y: .800000012, z: 1}
m_Children: m_Children:
- {fileID: 498100} - {fileID: 498100}

View File

@ -10,6 +10,8 @@ GameObject:
- 224: {fileID: 22403202} - 224: {fileID: 22403202}
- 222: {fileID: 22221002} - 222: {fileID: 22221002}
- 114: {fileID: 11467422} - 114: {fileID: 11467422}
- 114: {fileID: 11469406}
- 114: {fileID: 11492734}
m_Layer: 5 m_Layer: 5
m_Name: UIFriendPicture m_Name: UIFriendPicture
m_TagString: Untagged m_TagString: Untagged
@ -38,6 +40,47 @@ MonoBehaviour:
m_FillAmount: 1 m_FillAmount: 1
m_FillClockwise: 1 m_FillClockwise: 1
m_FillOrigin: 0 m_FillOrigin: 0
--- !u!114 &11469406
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 115844}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 343d57f2bac42ae48ba9722c53e5526f, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &11492734
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 115844}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -1862395651, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
delegates:
- eventID: 4
callback:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 11469406}
m_MethodName: OnClick
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_TypeName: UnityEngine.EventSystems.EventTrigger+TriggerEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
--- !u!222 &22221002 --- !u!222 &22221002
CanvasRenderer: CanvasRenderer:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1

File diff suppressed because it is too large Load Diff

View File

@ -48,6 +48,8 @@ namespace DeathBook.Model
private Sprite picture; private Sprite picture;
public Sprite Picture { get { return picture; } } public Sprite Picture { get { return picture; } }
private Action onSelected;
public Action OnSelected {get {return onSelected;} set { onSelected = value; } }
public Person(int id, string fName, string lName, Vector3 pos, int conn, int disconn, float freq, Sprite pic) public Person(int id, string fName, string lName, Vector3 pos, int conn, int disconn, float freq, Sprite pic)
{ {
@ -126,5 +128,13 @@ namespace DeathBook.Model
foreach (Friendship f in deadFriendsList) foreach (Friendship f in deadFriendsList)
f.Update(deltaTime); f.Update(deltaTime);
} }
public void SelectNode()
{
if (OnSelected != null)
{
OnSelected();
}
}
} }
} }

View File

@ -40,6 +40,9 @@ public class NetworkingSphere : MonoBehaviour
private PersonNode _selectedNode; private PersonNode _selectedNode;
// Used to disable the physics when the user has clicked on a node
private bool _isRotatingTowardsNode = false;
void Awake() void Awake()
{ {
manager = LevelManager.Instance; manager = LevelManager.Instance;
@ -87,7 +90,7 @@ public class NetworkingSphere : MonoBehaviour
delta = new Vector3(); delta = new Vector3();
} }
if (dragging) if (dragging && !_isRotatingTowardsNode)
{ {
MoveSphere(); MoveSphere();
} }
@ -140,17 +143,20 @@ public class NetworkingSphere : MonoBehaviour
private void OnNodeClicked(PersonNode node) private void OnNodeClicked(PersonNode node)
{ {
if (node == _selectedNode) return;
if (_selectedNode != null) if (_selectedNode != null)
{ {
_selectedNode.Select(false); _selectedNode.Select(false);
} }
node.Kill();
DetailsPanel.SetNode(node); DetailsPanel.SetNode(node);
node.Select(true); node.Select(true);
_selectedNode = node; _selectedNode = node;
// Testing to see how it looks and feels like
FocusOnNode(node);
} }
private void AssignLinks(Level lvl) private void AssignLinks(Level lvl)
@ -168,4 +174,65 @@ public class NetworkingSphere : MonoBehaviour
peopleNodes[id2].AddLink(link); peopleNodes[id2].AddLink(link);
} }
} }
public void FocusOnNode(PersonNode node)
{
StopCoroutine("RotateTowardsNodeCoroutine");
StartCoroutine("RotateTowardsNodeCoroutine", node);
/*
Debug.Log(node.transform.eulerAngles);
float xangle = (Mathf.Atan2(finalPos.z, finalPos.y) - Mathf.Atan2(initialPos.z, initialPos.y)) * Mathf.Rad2Deg;
Debug.Log(node.transform.position);
transform.Rotate(new Vector3(90, 0, 0));
//transform.rotation = transform.rotation * Quaternion.AngleAxis(xangle, Vector3.right);
Debug.Log(xangle);
float yAngle = (Mathf.Atan2(finalPos.x, finalPos.z) - Mathf.Atan2(node.transform.position.x, node.transform.position.z)) * Mathf.Rad2Deg;
Debug.Log(yAngle);
//transform.Rotate(new Vector3(xangle, yAngle, 0));
//float zAngle = (Mathf.Atan2(finalPos.y, finalPos.x) - Mathf.Atan2(initialPos.y, initialPos.x)) * Mathf.Rad2Deg;
//transform.rotation = transform.rotation * Quaternion.AngleAxis(xangle, Vector3.right) * Quaternion.AngleAxis(yAngle, Vector3.up) * Quaternion.AngleAxis(zAngle, Vector3.forward);
*/
}
private IEnumerator RotateTowardsNodeCoroutine(PersonNode node)
{
_isRotatingTowardsNode = true;
rb.angularVelocity = Vector3.zero;
//Vector3 finalPos = new Vector3(0f, 0f, -SphereRadius);
Quaternion initialRot = transform.localRotation;
transform.localRotation = Quaternion.identity; // Temporary hack for the game jam
Vector3 nodePos = node.transform.position;
Vector3 longDir = nodePos;
longDir.y = 0;
float xAngle = Mathf.Asin(nodePos.normalized.y) * Mathf.Rad2Deg; // Latitude
float yAngle = Vector3.Angle(-Vector3.forward, longDir) * (longDir.x < 0 ? -1 : 1); // Longitude
Quaternion finalRot = Quaternion.AngleAxis(-xAngle, Vector3.right) * Quaternion.AngleAxis(yAngle, Vector3.up);
float ratio = 0f;
while (ratio < 1f)
{
ratio += Time.deltaTime / 1.5f;
transform.localRotation = Quaternion.Lerp(initialRot, finalRot, Mathf.SmoothStep(0f, 1f, ratio));
yield return null;
}
_isRotatingTowardsNode = false;
}
} }

View File

@ -14,7 +14,7 @@ public class PersonDetailsPanel : MonoBehaviour, IObserver
public Button XButton; public Button XButton;
public GameObject Container; public GameObject Container;
public Image UIFriendPicture; public UIFriendPicture FriendPicture;
private PersonNode _node; private PersonNode _node;
private Person _model; private Person _model;
@ -50,6 +50,9 @@ public class PersonDetailsPanel : MonoBehaviour, IObserver
{ {
Name.text = _model.Name; Name.text = _model.Name;
KillButton.gameObject.SetActive(_model.Alive);
WatchButton.gameObject.SetActive(_model.Alive);
foreach (Transform picture in FriendsPanel.transform) foreach (Transform picture in FriendsPanel.transform)
{ {
Destroy(picture.gameObject); Destroy(picture.gameObject);
@ -70,24 +73,19 @@ public class PersonDetailsPanel : MonoBehaviour, IObserver
{ {
Person friend = _model.FriendList[i].Friend; Person friend = _model.FriendList[i].Friend;
Image friendPicture = Instantiate(UIFriendPicture) as Image; UIFriendPicture friendPicture = Instantiate(FriendPicture) as UIFriendPicture;
friendPicture.sprite = friend.Picture; friendPicture.Model = friend;
friendPicture.transform.SetParent(FriendsPanel.transform); Image picture = friendPicture.Picture;
friendPicture.rectTransform.anchorMin = new Vector2(0.022f, 1f - (height - 0.01f) * (i + 1) - i * 0.01f);
friendPicture.rectTransform.anchorMax = new Vector2(0.26f, (1f - height * i));
friendPicture.rectTransform.offsetMin = Vector2.zero;
friendPicture.rectTransform.offsetMax = Vector2.zero;
if (i == _model.FriendList.Count - 1) picture.sprite = friend.Picture;
{
Debug.Log(friendPicture.rectTransform.position); picture.transform.SetParent(FriendsPanel.transform);
} picture.rectTransform.anchorMin = new Vector2(0.022f, 1f - (height - 0.01f) * (i + 1) - i * 0.01f);
else if (i == 0) picture.rectTransform.anchorMax = new Vector2(0.26f, (1f - height * i));
{ picture.rectTransform.offsetMin = Vector2.zero;
Debug.Log(friendPicture.rectTransform.position); picture.rectTransform.offsetMax = Vector2.zero;
}
} }
} }
@ -96,4 +94,9 @@ public class PersonDetailsPanel : MonoBehaviour, IObserver
Container.SetActive(false); Container.SetActive(false);
_node.Select(false); _node.Select(false);
} }
public void KillNode()
{
_node.Kill();
}
} }

View File

@ -38,6 +38,7 @@ public class PersonNode : MonoBehaviour, IObserver
{ {
_model = value; _model = value;
_model.Subscribe(this); _model.Subscribe(this);
_model.OnSelected += () => { OnClicked(this); };
UpdateInfo(); UpdateInfo();
SetProfilePicture(); SetProfilePicture();
} }

View File

@ -0,0 +1,33 @@
using UnityEngine;
using System.Collections;
using DeathBook.Model;
using UnityEngine.UI;
[RequireComponent(typeof(Image))]
public class UIFriendPicture : MonoBehaviour
{
private Person _model;
public Person Model
{
get { return _model; }
set { _model = value; }
}
private Image _picture;
public Image Picture
{
get { return _picture; }
}
void Awake()
{
_picture = GetComponent<Image>();
}
public void OnClick()
{
_model.SelectNode();
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 343d57f2bac42ae48ba9722c53e5526f
timeCreated: 1439693427
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: