210 lines
6.2 KiB
C#
210 lines
6.2 KiB
C#
using Games.LogicObj;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
using GCGame;
|
|
using Module.Log;
|
|
using Games.GlobeDefine;
|
|
using System.Collections.Generic;
|
|
using System;
|
|
using GCGame.Table;
|
|
|
|
public class GuildWarResultInfo : MonoBehaviour {
|
|
|
|
public GameObject MatchLevelObj;
|
|
public GameObject MatchInfoObj;
|
|
|
|
Dictionary<int, string> MatchLevel = new Dictionary<int, string>()
|
|
{
|
|
{0,"#{35101}" },
|
|
{1,"#{35102}" },
|
|
{2,"#{35103}" },
|
|
{3,"#{35104}" },
|
|
{4,"#{35105}" },
|
|
{5,"#{35106}" },
|
|
{6,"#{35107}" },
|
|
{7,"#{35108}" },
|
|
{8,"#{35109}" },
|
|
{9,"#{35110}" },
|
|
};
|
|
|
|
Dictionary<int, string> MatchSC = new Dictionary<int, string>()
|
|
{
|
|
{0,"#{35111}" },
|
|
{1,"#{35112}" },
|
|
{2,"#{35113}" },
|
|
};
|
|
|
|
void Awake()
|
|
{
|
|
Hashtable add = new Hashtable();
|
|
add["name"] = "GuildMatchResult";
|
|
Games.Events.MessageEventCallBack call = ResultInfo;
|
|
add["callFun"] = call;
|
|
Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.GuildWarResultInfo, add);
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
for(int i=0;i<10;i++)
|
|
{
|
|
CloneMatchLevelObj(i);
|
|
}
|
|
|
|
}
|
|
|
|
void OnDestroy()
|
|
{
|
|
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.GuildWarResultInfo, "GuildMatchResult");
|
|
}
|
|
|
|
public void Click_Close()
|
|
{
|
|
UIManager.CloseUI(UIInfo.GuildWarResultInfo);
|
|
}
|
|
|
|
public void ResultInfo(Hashtable add,Hashtable send)
|
|
{
|
|
if (send.ContainsKey("data") == false)
|
|
return;
|
|
GC_UNION_MATCH_FIGHT_LIST packet = (GC_UNION_MATCH_FIGHT_LIST)send["data"];
|
|
if (packet == null)
|
|
return;
|
|
for (int i = 0; i < matchinfoObjs.Count; i++)
|
|
{
|
|
GameObject obj = matchinfoObjs[i];
|
|
obj.SetActive(false);
|
|
GameObject.Destroy(obj);
|
|
}
|
|
matchinfoObjs.Clear();
|
|
for (int i=0;i<packet.infoCount;i++)
|
|
{
|
|
UnionMatchFightListInfo info = packet.GetInfo(i);
|
|
string levelName = StrDictionary.GetClientDictionaryString(MatchSC[i / 4]);
|
|
CloneMatchInfoObj(levelName, info, (i % 2) == 0);
|
|
}
|
|
}
|
|
|
|
GameObject OldSelectObj = null;
|
|
void CloneMatchLevelObj(int index)
|
|
{
|
|
if (MatchLevelObj == null)
|
|
return;
|
|
GameObject newObj = GameObject.Instantiate(MatchLevelObj);
|
|
if (newObj == null)
|
|
return;
|
|
newObj.SetActive(true);
|
|
newObj.transform.SetParent(MatchLevelObj.transform.parent);
|
|
newObj.transform.localPosition = MatchLevelObj.transform.localPosition;
|
|
newObj.transform.localScale = MatchLevelObj.transform.localScale;
|
|
|
|
Transform selectTran = newObj.transform.Find("Button/select");
|
|
Text Name = newObj.GetComponentInChildren<Text>();
|
|
Text HL_Name = selectTran.GetComponentInChildren<Text>();
|
|
Button btn = newObj.GetComponentInChildren<Button>();
|
|
if(Name!=null)
|
|
{
|
|
Name.text = StrDictionary.GetClientDictionaryString( MatchLevel[index]);
|
|
if(HL_Name != null)
|
|
{
|
|
HL_Name.text = Name.text;
|
|
}
|
|
}
|
|
if(selectTran!=null)
|
|
{
|
|
selectTran.gameObject.SetActive(false);
|
|
}
|
|
if(btn!=null)
|
|
{
|
|
btn.onClick.AddListener(delegate ()
|
|
{
|
|
Singleton<ObjManager>.Instance.MainPlayer.GuildWarUnionInfoReq(CG_GUILD_UNION_MATCH_REQ.UNION_MATCH_REQ.FIGHT_INFO, index);
|
|
if(OldSelectObj!=null)
|
|
{
|
|
OnSelect(index, selectTran.gameObject);
|
|
}
|
|
});
|
|
}
|
|
|
|
if(index==0)
|
|
{
|
|
OnSelect(index, selectTran.gameObject);
|
|
}
|
|
}
|
|
|
|
public void OnSelect(int index,GameObject selectObj)
|
|
{
|
|
for (int i = 0; i < matchinfoObjs.Count; i++)
|
|
{
|
|
GameObject obj = matchinfoObjs[i];
|
|
obj.SetActive(false);
|
|
GameObject.Destroy(obj);
|
|
}
|
|
matchinfoObjs.Clear();
|
|
|
|
Singleton<ObjManager>.Instance.MainPlayer.GuildWarUnionInfoReq(CG_GUILD_UNION_MATCH_REQ.UNION_MATCH_REQ.FIGHT_INFO, index);
|
|
if (OldSelectObj != null)
|
|
{
|
|
OldSelectObj.SetActive(false);
|
|
}
|
|
OldSelectObj = selectObj;
|
|
if (OldSelectObj != null)
|
|
OldSelectObj.SetActive(true);
|
|
}
|
|
|
|
List<GameObject> matchinfoObjs = new List<GameObject>();
|
|
void CloneMatchInfoObj(string saici, UnionMatchFightListInfo info, bool isEvent)
|
|
{
|
|
if (MatchInfoObj == null)
|
|
return;
|
|
GameObject newObj = GameObject.Instantiate(MatchInfoObj);
|
|
if (newObj == null)
|
|
return;
|
|
newObj.SetActive(true);
|
|
newObj.transform.SetParent(MatchInfoObj.transform.parent);
|
|
newObj.transform.localPosition = MatchInfoObj.transform.localPosition;
|
|
newObj.transform.localScale = MatchInfoObj.transform.localScale;
|
|
matchinfoObjs.Add(newObj);
|
|
|
|
Transform back1 = newObj.transform.Find("back1");
|
|
Transform back2 = newObj.transform.Find("back2");
|
|
if (back1 != null)
|
|
{
|
|
back1.gameObject.SetActive(isEvent);
|
|
}
|
|
if (back2 != null)
|
|
{
|
|
back2.gameObject.SetActive(isEvent == false);
|
|
}
|
|
|
|
Text[] texts = newObj.GetComponentsInChildren<Text>();
|
|
for(int i=0;i<texts.Length;i++)
|
|
{
|
|
if(texts[i].gameObject.name == "saici")
|
|
{
|
|
texts[i].text = saici;
|
|
}
|
|
if (texts[i].gameObject.name == "VS")
|
|
{
|
|
texts[i].text = string.Format("{0} VS {1}", info.GuildName1, info.GuildName2);
|
|
}
|
|
if (texts[i].gameObject.name == "winer")
|
|
{
|
|
if(info.WinnerIndex == -1)
|
|
{
|
|
texts[i].text = StrDictionary.GetClientDictionaryString("#{35114}");
|
|
}
|
|
if(info.WinnerIndex == 0)
|
|
{
|
|
texts[i].text = info.GuildName1;
|
|
}
|
|
if (info.WinnerIndex == 1)
|
|
{
|
|
texts[i].text = info.GuildName2;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|