171 lines
5.9 KiB
C#
171 lines
5.9 KiB
C#
|
using System.Collections.Generic;
|
|||
|
using Games.LogicObj;
|
|||
|
using GCGame;
|
|||
|
using GCGame.Table;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using Games.Fellow;
|
|||
|
using Games.Events;
|
|||
|
|
|||
|
public class PetClearWnd : MonoBehaviour
|
|||
|
{
|
|||
|
public Image headQuility;
|
|||
|
public Image headIcon;
|
|||
|
public Image payQuility;
|
|||
|
public Image payIcon;
|
|||
|
public Text payName;
|
|||
|
public Text payNum;
|
|||
|
public GameObject GetItemBtn;
|
|||
|
|
|||
|
public void Awake()
|
|||
|
{
|
|||
|
Hashtable add1 = new Hashtable();
|
|||
|
add1["name"] = "PetClearWnd_AddNewData";
|
|||
|
Games.Events.MessageEventCallBack call1 = AddNewData;
|
|||
|
add1["callFun"] = call1;
|
|||
|
Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.UpdatePetClearData, add1);
|
|||
|
|
|||
|
Hashtable calbackMoveparam3 = new Hashtable();
|
|||
|
calbackMoveparam3["name"] = "PetClearPayFresh";
|
|||
|
MessageEventCallBack fun3 = PayFresh;
|
|||
|
calbackMoveparam3.Add("callFun", fun3);
|
|||
|
EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.FRESHSAMEUSETIP, calbackMoveparam3);
|
|||
|
}
|
|||
|
|
|||
|
public void PayFresh(Hashtable addparam, Hashtable sendparam)
|
|||
|
{
|
|||
|
OnSelectPet();
|
|||
|
}
|
|||
|
|
|||
|
public void AddNewData(Hashtable addparam, Hashtable sendparam)
|
|||
|
{
|
|||
|
OnSelectPet();
|
|||
|
}
|
|||
|
|
|||
|
private void OnEnable()
|
|||
|
{
|
|||
|
OnSelectPet();
|
|||
|
}
|
|||
|
|
|||
|
public void OnDestroy()
|
|||
|
{
|
|||
|
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.UpdatePetClearData, "PetClearWnd_AddNewData");
|
|||
|
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.FRESHSAMEUSETIP, "PetClearPayFresh");
|
|||
|
}
|
|||
|
|
|||
|
public void ClearInfo(bool state)
|
|||
|
{
|
|||
|
headIcon.gameObject.SetActive(state);
|
|||
|
payIcon.gameObject.SetActive(state);
|
|||
|
payQuility.gameObject.SetActive(state);
|
|||
|
payName.gameObject.SetActive(state);
|
|||
|
payNum.gameObject.SetActive(state);
|
|||
|
}
|
|||
|
|
|||
|
public void ShowPay(int costID,int costNum)
|
|||
|
{
|
|||
|
payIcon.gameObject.SetActive(true);
|
|||
|
payName.gameObject.SetActive(true);
|
|||
|
payNum.gameObject.SetActive(true);
|
|||
|
payQuility.gameObject.SetActive(true);
|
|||
|
Tab_CommonItem item = TableManager.GetCommonItemByID(costID, 0);
|
|||
|
if (item != null)
|
|||
|
{
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(payQuility, Utils.GetItemQualityFrame(item.Quality));
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(payIcon, item.Icon);
|
|||
|
if (item.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, item.QualityEffect, payIcon.transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, item.QualityEffect, payIcon.transform);
|
|||
|
}
|
|||
|
}
|
|||
|
payName.text = item.Name; //<color=#0000ff>
|
|||
|
int hasCount = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(costID);
|
|||
|
if (hasCount < costNum)
|
|||
|
{
|
|||
|
payNum.text = string.Format("<color=#ff0000ff>{0}</color>/{1}", hasCount, costNum);
|
|||
|
GetItemBtn.SetActive(true);
|
|||
|
Button btn = GetItemBtn.GetComponent<Button>();
|
|||
|
if (btn != null)
|
|||
|
{
|
|||
|
btn.onClick.RemoveAllListeners();
|
|||
|
btn.onClick.AddListener(delegate ()
|
|||
|
{
|
|||
|
ItemGetPathPopRoot.Show(costID, btn.transform.position);
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
payNum.text = string.Format("<color=#00ff00ff>{0}</color>/{1}", hasCount, costNum);
|
|||
|
GetItemBtn.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void OnSelectPet(bool showPay = false)
|
|||
|
{
|
|||
|
ClearInfo(false);
|
|||
|
|
|||
|
if (GameManager.gameManager.PlayerDataPool.FellowContainer == null)
|
|||
|
return;
|
|||
|
Fellow pet = GameManager.gameManager.PlayerDataPool.FellowContainer.GetFellowByGuid(PetMainWnd.CurrentSelectFellowId);
|
|||
|
if (pet == null || pet.Guid == Games.GlobeDefine.GlobeVar.INVALID_GUID)
|
|||
|
{
|
|||
|
if(showPay)
|
|||
|
{
|
|||
|
var growths = TableManager.GetInitFellowGrowth().Values;
|
|||
|
foreach (var item in growths)
|
|||
|
{
|
|||
|
ShowPay(item.CostItemId, item.CostItemNum);
|
|||
|
}
|
|||
|
}
|
|||
|
return;
|
|||
|
}
|
|||
|
headIcon.gameObject.SetActive(true);
|
|||
|
Tab_FellowBase fellowBase = TableManager.GetFellowBaseByID(pet.DataId, 0);
|
|||
|
if(fellowBase!=null)
|
|||
|
{
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(headIcon,fellowBase.Icon);
|
|||
|
}
|
|||
|
int quility = (int)Utils.GetQualityIndex(pet.Quality);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(headQuility, Utils.GetItemQualityFrame(quility));
|
|||
|
Tab_InitFellowGrowth growth = TableManager.GetInitFellowGrowthByID(pet.DataId, 0);
|
|||
|
if(growth!=null)
|
|||
|
{
|
|||
|
ShowPay(growth.CostItemId, growth.CostItemNum);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void OnClick_OpenClearWnd()
|
|||
|
{
|
|||
|
Fellow pet = GameManager.gameManager.PlayerDataPool.FellowContainer.GetFellowByGuid(PetMainWnd.CurrentSelectFellowId);
|
|||
|
if (pet == null || false == pet.IsValid())
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{20153}"));
|
|||
|
return;
|
|||
|
}
|
|||
|
UIManager.ShowUI(UIInfo.PetsClearWndPath, OnOpenSuccess, 0);
|
|||
|
}
|
|||
|
|
|||
|
public void OnClick_OpenAutoClearWnd()
|
|||
|
{
|
|||
|
Fellow pet = GameManager.gameManager.PlayerDataPool.FellowContainer.GetFellowByGuid(PetMainWnd.CurrentSelectFellowId);
|
|||
|
if (pet == null || false == pet.IsValid())
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{20153}"));
|
|||
|
return;
|
|||
|
}
|
|||
|
UIManager.ShowUI(UIInfo.PetsClearWndPath,OnOpenSuccess,1);
|
|||
|
}
|
|||
|
|
|||
|
public void OnOpenSuccess(bool success, object param)
|
|||
|
{
|
|||
|
Hashtable send = new Hashtable();
|
|||
|
send["operator"] = param;
|
|||
|
Games.Events.EventDispatcher.Instance.SendMessage(Games.Events.EventId.OpenPetClearWndSuccess, send);
|
|||
|
}
|
|||
|
}
|