You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.9 KiB
59 lines
1.9 KiB
4 years ago
|
using AX.MessageSystem;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class OwnerPanel : MonoBehaviour {
|
||
|
public long UserId;
|
||
|
private List<GameObject> powers;
|
||
|
public GameObject itemPre;
|
||
|
// Use this for initialization
|
||
|
void Start () {
|
||
|
|
||
|
}
|
||
|
void OnDestroy()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
public static event Func<long, List<GameObject>, List<GameObject>> GetOnesPower;
|
||
|
// Update is called once per frame
|
||
|
void Update () {
|
||
|
|
||
|
}
|
||
|
public void GetOwnersPower(UserData owner)
|
||
|
{
|
||
|
UserId = owner.UserInfo.Id;
|
||
|
powers = new List<GameObject>();
|
||
|
if(GetOnesPower != null)
|
||
|
{
|
||
|
powers = GetOnesPower(owner.UserInfo.Id, powers);
|
||
|
}
|
||
|
itemPre = Resources.Load("HandOver/OwnerPowerItem") as GameObject;
|
||
|
foreach(GameObject power in powers)
|
||
|
{
|
||
|
GameObject item = Instantiate(itemPre, transform);
|
||
|
CloneGameObjInfo info = power.GetComponent<CloneGameObjInfo>();
|
||
|
item.name = "OwnerPowerItem-" + info.gameObjID.ToString();
|
||
|
item.transform.Find("Text").GetComponent<Text>().text = info.FullName;
|
||
|
}
|
||
|
gameObject.SetActive(false);
|
||
|
}
|
||
|
private void AddPower(IMessage obj)
|
||
|
{
|
||
|
var pair = (HandOverPair)obj.Data;
|
||
|
if (pair.acceptedID == this.UserId)
|
||
|
{
|
||
|
foreach(long powerID in pair.powers)
|
||
|
{
|
||
|
GameObject item = Instantiate(itemPre, transform);
|
||
|
item.name = "OwnerPowerItem-" + powerID.ToString();
|
||
|
CloneGameObjInfo info = EntitiesManager.Instance.GetEntityByID(powerID).GetComponent<CloneGameObjInfo>();
|
||
|
item.transform.Find("Text").GetComponent<Text>().text = CloneObjTypeName.Instance.GetCloneNameByType(info.gameObjType) + " x 1";
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|