mirror of
https://github.com/ConjureETS/DeathBook.git
synced 2026-03-24 12:30:59 +00:00
Conflicts: Assets/Prefabs/PersonNode.prefab Assets/Scenes/Gameplay.unity Assets/Scripts/Models/Person.cs Assets/Scripts/NetworkingSphere.cs Known issues: Picture F_30 is rotated When clicking two people fast, one of them is killed in a crooked fashion Signed-off-by: RosimInc <rosim_inc@hotmail.com>
100 lines
2.5 KiB
C#
100 lines
2.5 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using UnityEngine.UI;
|
|
using DeathBook.Model;
|
|
using DeathBook.Util;
|
|
|
|
public class PersonDetailsPanel : MonoBehaviour, IObserver
|
|
{
|
|
public Image ProfilePicture;
|
|
public Text Name;
|
|
public GameObject FriendsPanel;
|
|
public Button KillButton;
|
|
public Button WatchButton;
|
|
public Button XButton;
|
|
public GameObject Container;
|
|
|
|
public Image UIFriendPicture;
|
|
|
|
private PersonNode _node;
|
|
private Person _model;
|
|
|
|
void Awake()
|
|
{
|
|
Container.SetActive(false);
|
|
}
|
|
|
|
public void SetNode(PersonNode node)
|
|
{
|
|
if (_model != null)
|
|
{
|
|
_model.UnSubscribe(this);
|
|
}
|
|
|
|
_node = node;
|
|
_model = node.Model;
|
|
|
|
_model.Subscribe(this);
|
|
|
|
Container.SetActive(true);
|
|
|
|
UpdateInfo();
|
|
}
|
|
|
|
public void Notify()
|
|
{
|
|
UpdateInfo();
|
|
}
|
|
|
|
private void UpdateInfo()
|
|
{
|
|
Name.text = _model.Name;
|
|
|
|
foreach (Transform picture in FriendsPanel.transform)
|
|
{
|
|
Destroy(picture.gameObject);
|
|
}
|
|
|
|
ProfilePicture.sprite = _model.Picture;
|
|
|
|
RectTransform panelTrans = FriendsPanel.GetComponent<RectTransform>();
|
|
|
|
panelTrans.anchorMin = new Vector2(0f, -0.3125f * _model.FriendList.Count);
|
|
panelTrans.anchorMax = new Vector2(1f, 1f);
|
|
panelTrans.offsetMin = Vector2.zero;
|
|
panelTrans.offsetMax = Vector2.zero;
|
|
|
|
float height = 1f / _model.FriendList.Count;
|
|
|
|
for (int i = 0; i < _model.FriendList.Count; i++)
|
|
{
|
|
Person friend = _model.FriendList[i].Friend;
|
|
|
|
Image friendPicture = Instantiate(UIFriendPicture) as Image;
|
|
|
|
friendPicture.sprite = friend.Picture;
|
|
|
|
friendPicture.transform.SetParent(FriendsPanel.transform);
|
|
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)
|
|
{
|
|
Debug.Log(friendPicture.rectTransform.position);
|
|
}
|
|
else if (i == 0)
|
|
{
|
|
Debug.Log(friendPicture.rectTransform.position);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
Container.SetActive(false);
|
|
_node.Select(false);
|
|
}
|
|
}
|