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 PetClearOperaWnd : MonoBehaviour
{
public GameObject IsReCommend; //是否推荐
public ClearChangeAttrItem[] clearChangeAttrItemsAttr;
public ClearChangeAttrItem[] clearChangeAttrItemsAttrZizhi;
public GameObject PayGameObject;
public Image PayQuility;
public Image PayIcon;
public Text PayName;
public Text PayNum;
public Text speedText;
public GameObject LyInfo;
public Text LyPrice;
public Text LyHas;
public Button StartBtn;
public GameObject StartAutoBtn;
public GameObject StopBtn;
public GameObject SpeedBtn;
public Toggle AutoPay;
public GameObject GetBtnObj;
public GameObject ReplaceBtn;
public GameObject Disable_ReplaceBtn;
public GameObject FindSeeWnd;
public InitAptitudeStart OldStart;
public InitAptitudeStart NewStart;
public UIImgText OldPower;
public UIImgText NewPower;
public GameObject PowerDown;
public GameObject PowerUp;
private int StartState = 0;
public void Awake()
{
Hashtable add = new Hashtable();
add["name"] = "PetClearOperaWnd";
Games.Events.MessageEventCallBack call = OnOpen;
add["callFun"] = call;
Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.OpenPetClearWndSuccess,add);
Hashtable add1 = new Hashtable();
add1["name"] = "PetClearOperaWnd_AddNewData";
Games.Events.MessageEventCallBack call1 = AddNewData;
add1["callFun"] = call1;
Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.UpdatePetClearData, add1);
Hashtable add2 = new Hashtable();
add2["name"] = "ReplaceNewClearData";
Games.Events.MessageEventCallBack call2 = ReplaceNewData;
add2["callFun"] = call2;
Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.ReplaceNewClearData, add2);
Hashtable calbackMoveparam4 = new Hashtable();
calbackMoveparam4["name"] = "PetClearOperaPayFresh";
MessageEventCallBack fun3 = PayFresh;
calbackMoveparam4.Add("callFun", fun3);
EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.FRESHSAMEUSETIP, calbackMoveparam4);
}
public void OnDestroy()
{
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.UpdatePetClearData, "PetClearOperaWnd_AddNewData");
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.OpenPetClearWndSuccess, "PetClearOperaWnd");
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.ReplaceNewClearData, "ReplaceNewClearData");
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.FRESHSAMEUSETIP, "PetClearOperaPayFresh");
}
private bool isAskClearRespond = true;
private bool isAutoClear = false;
private bool isStop = true;
private bool PauseOne = false;
private float speed = 1.0f;
float waitTime = 0.0f;
public void Update()
{
if (isStop)
return;
if (isAutoClear == false)
return;
if (isAskClearRespond == true)
{
waitTime += Time.deltaTime;
if (waitTime >= (1 / speed))
{
AutoStartClear(false);
waitTime = 0.0f;
}
}
}
public void Click_CloseChange()
{
FindSeeWnd.SetActive(false);
}
public void Click_ShowChangeInfo()
{
if (PetMainWnd.CurrentSelectFellowId == Games.GlobeDefine.GlobeVar.INVALID_GUID)
return;
FindSeeWnd.SetActive(true);
}
public void PayFresh(Hashtable addparam, Hashtable sendparam)
{
CostPay();
FreshStartBtn();
}
private void OnEnable()
{
StartBtn.interactable = true;
}
public void ReplaceNewData(Hashtable addparam, Hashtable sendparam)
{
ulong id = (ulong)sendparam["param"];
if (PetMainWnd.CurrentSelectFellowId == id)
{
Fellow pet = GameManager.gameManager.PlayerDataPool.FellowContainer.GetFellowByGuid(PetMainWnd.CurrentSelectFellowId);
if (pet != null)
{
SetDate(pet);
NewAttrChange(pet);
}
}
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{20152}"));
}
public void SetDate(Fellow pet)
{
if (pet == null || pet.IsValid() == false)
{
IsReCommend.SetActive(false);
ReplaceBtn.SetActive(false);
Disable_ReplaceBtn.SetActive(!ReplaceBtn.activeSelf);
if (clearChangeAttrItemsAttrZizhi.Length >= 5)
{
clearChangeAttrItemsAttrZizhi[0].Clear();
clearChangeAttrItemsAttrZizhi[1].Clear();
clearChangeAttrItemsAttrZizhi[2].Clear();
clearChangeAttrItemsAttrZizhi[3].Clear();
clearChangeAttrItemsAttrZizhi[4].Clear();
}
if (clearChangeAttrItemsAttr.Length >= 6)
{
clearChangeAttrItemsAttr[0].Clear();
clearChangeAttrItemsAttr[1].Clear();
clearChangeAttrItemsAttr[2].Clear();
clearChangeAttrItemsAttr[3].Clear();
clearChangeAttrItemsAttr[4].Clear();
clearChangeAttrItemsAttr[5].Clear();
}
OldPower.text = "";
NewPower.text = "";
PowerUp.SetActive(false);
PowerDown.SetActive(false);
OldStart.InitStart(0);
NewStart.InitStart(0);
return;
}
ReplaceBtn.SetActive(pet.newblood != 0 && pet.newattack != 0 && pet.newavoid != 0);
Disable_ReplaceBtn.SetActive(!ReplaceBtn.activeSelf);
if (clearChangeAttrItemsAttrZizhi.Length >= 5)
{
clearChangeAttrItemsAttrZizhi[0].ShowAttr(pet.Boneatitude, pet.newConstituAptitude, false);
clearChangeAttrItemsAttrZizhi[1].ShowAttr(pet.Forceatitude, pet.newMorfiAptitude, false);
clearChangeAttrItemsAttrZizhi[2].ShowAttr(pet.Poweratitude, pet.newStrengthAptitude, false);
clearChangeAttrItemsAttrZizhi[3].ShowAttr(pet.Smartatitude, pet.newIntellengAptitude, false);
clearChangeAttrItemsAttrZizhi[4].ShowAttr(pet.Agileatitude, pet.newAgileAptitude, false);
}
if(clearChangeAttrItemsAttr.Length>=6)
{
clearChangeAttrItemsAttr[0].ShowAttr(pet.blood,pet.newblood,true);
clearChangeAttrItemsAttr[1].ShowAttr(pet.attack, pet.newattack, true);
clearChangeAttrItemsAttr[2].ShowAttr(pet.physical, pet.newphysical, true);
clearChangeAttrItemsAttr[3].ShowAttr(pet.magic, pet.newmagic, true);
clearChangeAttrItemsAttr[4].ShowAttr(pet.hit, pet.newHit, true);
clearChangeAttrItemsAttr[5].ShowAttr(pet.avoid, pet.newavoid, true);
}
OldPower.text = pet.CombatValue.ToString();
NewPower.text = pet.newtotlepower.ToString();
PowerUp.SetActive(pet.newtotlepower > pet.CombatValue && pet.newtotlepower != 0);
PowerDown.SetActive(pet.newtotlepower < pet.CombatValue && pet.newtotlepower != 0);
IsReCommend.SetActive(pet.RecommonState == 1);
OldStart.InitStart(pet.AptitudeTotle);
NewStart.InitStart(pet.NewAptitudeTotle);
}
public void OnSelectPet()
{
Fellow pet = GameManager.gameManager.PlayerDataPool.FellowContainer.GetFellowByGuid(PetMainWnd.CurrentSelectFellowId);
Click_CloseChange();
SetDate(pet);
AutoClear(false);
AutoPay.isOn = false;
CountCost(pet);
CostPay();
NewAttrChange(pet);
if(pet!=null && pet.IsValid())
{
var modelTab = pet.CharModel();
if (modelTab != null)
{
pet.CalculateAptitudeTotle();
}
}
}
public void OnOpen(Hashtable addparam, Hashtable sendparam)
{
if (sendparam.ContainsKey("operator"))
{
int opera = (int)sendparam["operator"];
isAutoClear = (opera == 1);
}
}
int MoneyPay = 0;
int CostItemNum = 0;
int CostItemId = 0;
public bool CostPay()
{
int hasCount = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(CostItemId);
long MoneyHas = GameManager.gameManager.PlayerDataPool.Money.GetMoney_YuanBao();
if (hasCount < CostItemNum && CostItemId > 0)
{
PayNum.text = string.Format("{0}/{1}", hasCount, CostItemNum);
GetBtnObj.SetActive(true);
Button btn = GetBtnObj.GetComponent