397 lines
14 KiB
C#
397 lines
14 KiB
C#
|
using System.Collections.Generic;
|
|||
|
using GCGame.Table;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using Games.Events;
|
|||
|
using Games.Item;
|
|||
|
|
|||
|
public class MagicClearResult : MonoBehaviour
|
|||
|
{
|
|||
|
public Image MagicQuility;
|
|||
|
public Image MagicIcon;
|
|||
|
public Text MagicName;
|
|||
|
public Image PayIcon;
|
|||
|
public Text PayName;
|
|||
|
public Text PayNum;
|
|||
|
public Text PayMoneyNum;
|
|||
|
public Text PayMoneyHas;
|
|||
|
public Image MoneyTypeHas;
|
|||
|
public Image MoneyTypeNeed;
|
|||
|
public Text ScoreOld;
|
|||
|
public Text ScoreNew;
|
|||
|
public GameObject ScoreOldObj;
|
|||
|
public GameObject ScoreNewObj;
|
|||
|
public Button PayGetBtn;
|
|||
|
public Button ReplaceBtn;
|
|||
|
public Toggle m_PayGold;
|
|||
|
|
|||
|
public Transform UpIma;//向上的箭头
|
|||
|
public Transform DownIma;//向下的箭头
|
|||
|
|
|||
|
public GameObject OldAttrObj;
|
|||
|
public GameObject NewAttrObj;
|
|||
|
|
|||
|
public GameObject PayMoneyObj;
|
|||
|
|
|||
|
GameItem m_CurrentSelect = null;
|
|||
|
|
|||
|
List<GameObject> ObjLists = new List<GameObject>();
|
|||
|
|
|||
|
void Awake()
|
|||
|
{
|
|||
|
Hashtable calbackMoveparam1 = new Hashtable();
|
|||
|
calbackMoveparam1["name"] = "MagicClearResult";
|
|||
|
MessageEventCallBack fun1 = UpdateNewAttrInfo;
|
|||
|
calbackMoveparam1.Add("callFun", fun1);
|
|||
|
Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.MagicClearResult, calbackMoveparam1);
|
|||
|
|
|||
|
Hashtable calbackMoveparam = new Hashtable();
|
|||
|
calbackMoveparam["name"] = "MagicClearResultItemUpdate";
|
|||
|
MessageEventCallBack fun = ItemUpdate;
|
|||
|
calbackMoveparam.Add("callFun", fun);
|
|||
|
Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.MagicItemUpdate, calbackMoveparam);
|
|||
|
|
|||
|
Hashtable calbackMoveparam4 = new Hashtable();
|
|||
|
calbackMoveparam4["name"] = "MagicClearResultMoneyUpdate";
|
|||
|
MessageEventCallBack fun3 = PayFresh;
|
|||
|
calbackMoveparam4.Add("callFun", fun3);
|
|||
|
EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.FRESHSAMEUSETIP, calbackMoveparam4);
|
|||
|
}
|
|||
|
|
|||
|
void Start()
|
|||
|
{
|
|||
|
m_PayGold.isOn = false;
|
|||
|
//PayMoneyObj.SetActive(m_PayGold.isOn);
|
|||
|
}
|
|||
|
|
|||
|
void OnDestroy()
|
|||
|
{
|
|||
|
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.MagicClearResult, "MagicClearResult");
|
|||
|
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.MagicItemUpdate, "MagicClearResultItemUpdate");
|
|||
|
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.FRESHSAMEUSETIP, "MagicClearResultMoneyUpdate");
|
|||
|
}
|
|||
|
|
|||
|
public void PayFresh(Hashtable addparam, Hashtable sendparam)
|
|||
|
{
|
|||
|
long MoneyHas = GameManager.gameManager.PlayerDataPool.Money.GetMoney_YuanBao();
|
|||
|
PayMoneyHas.text = MoneyHas.ToString();
|
|||
|
}
|
|||
|
|
|||
|
public void ItemUpdate(Hashtable addParam, Hashtable sendParam)
|
|||
|
{
|
|||
|
if (m_CurrentSelect == null)
|
|||
|
return;
|
|||
|
ShowXilianInfo();
|
|||
|
}
|
|||
|
|
|||
|
public void UpdateNewAttrInfo(Hashtable addParam,Hashtable sendParam)
|
|||
|
{
|
|||
|
if (sendParam.ContainsKey("GameItemID") == false)
|
|||
|
return;
|
|||
|
GameItem gameItem = GameManager.gameManager.PlayerDataPool.BackPack.GetItemByGuid((ulong)sendParam["GameItemID"]);
|
|||
|
if (gameItem == null)
|
|||
|
{
|
|||
|
GameItemContainer Container = GameManager.gameManager.PlayerDataPool.GetItemContainer(GameItemContainer.Type.TYPE_MAGICPACK);
|
|||
|
if (Container != null)
|
|||
|
{
|
|||
|
gameItem = Container.GetItemByGuid((ulong)sendParam["GameItemID"]);
|
|||
|
}
|
|||
|
}
|
|||
|
if(gameItem==null)
|
|||
|
return;
|
|||
|
m_CurrentSelect = gameItem;
|
|||
|
ShowXilianInfo();
|
|||
|
}
|
|||
|
|
|||
|
public void ShowXilianInfo()
|
|||
|
{
|
|||
|
if (m_CurrentSelect == null)
|
|||
|
return;
|
|||
|
Tab_CommonItem item = TableManager.GetCommonItemByID(m_CurrentSelect.DataID, 0);
|
|||
|
if (item == null)
|
|||
|
return;
|
|||
|
MagicName.text = item.Name;
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(MagicQuility, GCGame.Utils.GetItemQualityFrame(item.Quality, false));
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(MagicIcon, item.Icon);
|
|||
|
if (item.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, item.QualityEffect, MagicIcon.transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, item.QualityEffect, MagicIcon.transform);
|
|||
|
}
|
|||
|
|
|||
|
var magicCosts = TableManager.GetMagicWeaponRandCost().Values;
|
|||
|
foreach (var value in magicCosts)
|
|||
|
{
|
|||
|
if (item.MinLevelRequire > value.LevelMin && item.Quality == value.Color)
|
|||
|
{
|
|||
|
ConsumPay(value.ItemId, value.Num);
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
UpdateXilianAttr();
|
|||
|
}
|
|||
|
|
|||
|
public void UpdateXilianAttr()
|
|||
|
{
|
|||
|
if (m_CurrentSelect == null || m_CurrentSelect.IsValid() == false)
|
|||
|
return;
|
|||
|
for(int i=0;i< ObjLists.Count;i++)
|
|||
|
{
|
|||
|
if(ObjLists[i]!=null)
|
|||
|
{
|
|||
|
ObjLists[i].SetActive(false);
|
|||
|
ObjLists[i].transform.parent = null;
|
|||
|
GameObject.Destroy(ObjLists[i]);
|
|||
|
}
|
|||
|
}
|
|||
|
ObjLists.Clear();
|
|||
|
for (int i=0;i<m_CurrentSelect.ExAttrs.Count;i++)
|
|||
|
{
|
|||
|
CloneAttrObj(m_CurrentSelect.ExAttrs[i], OldAttrObj);
|
|||
|
}
|
|||
|
|
|||
|
ReplaceBtn.interactable = (m_CurrentSelect.ExAttrsNew.Count > 0);
|
|||
|
for (int i = 0; i < m_CurrentSelect.ExAttrsNew.Count; i++)
|
|||
|
{
|
|||
|
CloneAttrObj(m_CurrentSelect.ExAttrsNew[i], NewAttrObj);
|
|||
|
}
|
|||
|
SetOldScore();
|
|||
|
SetNewScore();
|
|||
|
}
|
|||
|
|
|||
|
public void SetOldScore()
|
|||
|
{
|
|||
|
var scoreTabs = TableManager.GetEquipScore().Values;
|
|||
|
float score = 0;
|
|||
|
if(m_CurrentSelect==null || m_CurrentSelect.ExAttrs.Count<=0)
|
|||
|
{
|
|||
|
ScoreOldObj.SetActive(false);
|
|||
|
return;
|
|||
|
}
|
|||
|
ScoreOldObj.SetActive(true);
|
|||
|
foreach (var value in scoreTabs)
|
|||
|
{
|
|||
|
for(int i=0;i<m_CurrentSelect.ExAttrs.Count;i++)
|
|||
|
{
|
|||
|
if(m_CurrentSelect.ExAttrs[i].mPropID == value.PropID && m_CurrentSelect.ExAttrs[i].PropSubID == value.PropSubID)
|
|||
|
{
|
|||
|
score += (m_CurrentSelect.ExAttrs[i].XilianValue * value.PropScore);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
int scoreInt = (int)score;
|
|||
|
ScoreOld.text = scoreInt.ToString();
|
|||
|
}
|
|||
|
|
|||
|
public void SetNewScore()
|
|||
|
{
|
|||
|
var scoreTabs = TableManager.GetEquipScore().Values;
|
|||
|
float score = 0;
|
|||
|
if (m_CurrentSelect == null || m_CurrentSelect.ExAttrsNew.Count <= 0)
|
|||
|
{
|
|||
|
ScoreNewObj.SetActive(false);
|
|||
|
return;
|
|||
|
}
|
|||
|
ScoreNewObj.SetActive(true);
|
|||
|
foreach (var value in scoreTabs)
|
|||
|
{
|
|||
|
for (int i = 0; i < m_CurrentSelect.ExAttrsNew.Count; i++)
|
|||
|
{
|
|||
|
if (m_CurrentSelect.ExAttrsNew[i].mPropID == value.PropID && m_CurrentSelect.ExAttrsNew[i].PropSubID == value.PropSubID)
|
|||
|
{
|
|||
|
score += (m_CurrentSelect.ExAttrsNew[i].XilianValue * value.PropScore);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
int scoreInt = (int)score;
|
|||
|
ScoreNew.text = scoreInt.ToString();
|
|||
|
|
|||
|
UpIma.gameObject.SetActive(false);
|
|||
|
DownIma.gameObject.SetActive(false);
|
|||
|
if (int.Parse(ScoreOld.text) < int.Parse(ScoreNew.text))
|
|||
|
{
|
|||
|
UpIma.gameObject.SetActive(true);
|
|||
|
DownIma.gameObject.SetActive(false);
|
|||
|
if (gameObject.activeInHierarchy)
|
|||
|
{
|
|||
|
//Debug.LogError("正在显示法宝洗炼界面");
|
|||
|
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{40318}"), null,
|
|||
|
() =>
|
|||
|
{
|
|||
|
Click_Replace();
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
UpIma.gameObject.SetActive(false);
|
|||
|
DownIma.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void CloneAttrObj(EquipXilianAttr exAttr,GameObject cloneObj)
|
|||
|
{
|
|||
|
if (exAttr == null || cloneObj == null)
|
|||
|
return;
|
|||
|
GameObject attrObj = GameObject.Instantiate(cloneObj);
|
|||
|
if (attrObj == null)
|
|||
|
return;
|
|||
|
attrObj.SetActive(true);
|
|||
|
attrObj.transform.SetParent(cloneObj.transform.parent);
|
|||
|
attrObj.transform.localPosition = cloneObj.transform.localPosition;
|
|||
|
attrObj.transform.localScale = cloneObj.transform.localScale;
|
|||
|
Text _AttrValue = attrObj.GetComponentInChildren<Text>();
|
|||
|
if (_AttrValue == null || m_CurrentSelect == null || exAttr.XilianValue<=0)
|
|||
|
{
|
|||
|
GameObject.Destroy(attrObj);
|
|||
|
return;
|
|||
|
}
|
|||
|
string attrStr = PropID.GetAttrValue((PropID.PropertyID)exAttr.mPropID, exAttr.PropSubID, exAttr.XilianValue);
|
|||
|
_AttrValue.text = m_CurrentSelect.GetEquipColorStr() + attrStr + "</color>";
|
|||
|
ObjLists.Add(attrObj);
|
|||
|
}
|
|||
|
|
|||
|
public void ConsumPay(int PayItemId,int PayNeedNum)
|
|||
|
{
|
|||
|
Tab_CommonItem Payitem = TableManager.GetCommonItemByID(PayItemId, 0);
|
|||
|
if (Payitem == null)
|
|||
|
return;
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(PayIcon, Payitem.Icon);
|
|||
|
if (Payitem.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, Payitem.QualityEffect, PayIcon.transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, Payitem.QualityEffect, PayIcon.transform);
|
|||
|
}
|
|||
|
|
|||
|
PayName.text = Payitem.Name;
|
|||
|
int hasNum = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(PayItemId);
|
|||
|
if(hasNum < PayNeedNum)
|
|||
|
{
|
|||
|
PayNum.text = string.Format("{2}{0}</color>/{1}",hasNum,PayNeedNum, StrDictionary.GetClientDictionaryString("#{5526}"));
|
|||
|
PayGetBtn.gameObject.SetActive(true);
|
|||
|
PayGetBtn.onClick.RemoveAllListeners();
|
|||
|
PayGetBtn.onClick.AddListener(delegate ()
|
|||
|
{
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(PayItemId, ItemTooltipsLogic.ShowType.GetPath, transform.position);
|
|||
|
});
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
PayNum.text = string.Format("{0}/{1}", hasNum, PayNeedNum);
|
|||
|
PayGetBtn.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
long MoneyHas = GameManager.gameManager.PlayerDataPool.Money.GetMoney_YuanBao();
|
|||
|
PayMoneyHas.text = MoneyHas.ToString();
|
|||
|
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(MoneyTypeHas, UICurrencyItem.GetCurrencySprite(MONEYTYPE.MONEYTYPE_YUANBAO));
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(MoneyTypeNeed, UICurrencyItem.GetCurrencySprite(MONEYTYPE.MONEYTYPE_YUANBAO));
|
|||
|
foreach (var shop in TableManager.GetYuanBaoShop().Values)
|
|||
|
{
|
|||
|
if (shop.MoneyType == 1 && shop.ItemID == PayItemId)
|
|||
|
{
|
|||
|
PayMoneyNum.text = (shop.PriceForever* PayNeedNum).ToString();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
public void BuyFast()
|
|||
|
{
|
|||
|
JudgeMoneyLogic.ShowSwitchMoneyPanel(MONEYTYPE.MONEYTYPE_YUANBAO, true);
|
|||
|
}
|
|||
|
public void Click_GetPayItem()
|
|||
|
{
|
|||
|
if (m_CurrentSelect == null)
|
|||
|
return;
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(m_CurrentSelect, ItemTooltipsLogic.ShowType.GetPath, transform.position);
|
|||
|
}
|
|||
|
|
|||
|
public void Click_Replace()
|
|||
|
{
|
|||
|
if (m_CurrentSelect == null || m_CurrentSelect.IsValid() == false)
|
|||
|
return;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
CG_HANDLE_MAGIC_WEAPON send = (CG_HANDLE_MAGIC_WEAPON)PacketDistributed.CreatePacket(MessageID.PACKET_CG_HANDLE_MAGIC_WEAPON);
|
|||
|
send.SetGuid(m_CurrentSelect.Guid);
|
|||
|
send.SetHandletype((int)CG_HANDLE_MAGIC_WEAPON.EMagicWeaponHandleType.EReplace);
|
|||
|
|
|||
|
GameItem gameItem = GameManager.gameManager.PlayerDataPool.BackPack.GetItemByGuid(m_CurrentSelect.Guid);
|
|||
|
if (gameItem != null)
|
|||
|
{
|
|||
|
send.SetPackType((int)GameItemContainer.Type.TYPE_BACKPACK);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
GameItemContainer Container = GameManager.gameManager.PlayerDataPool.GetItemContainer(GameItemContainer.Type.TYPE_MAGICPACK);
|
|||
|
if (Container != null)
|
|||
|
{
|
|||
|
gameItem = Container.GetItemByGuid(m_CurrentSelect.Guid);
|
|||
|
if (gameItem != null)
|
|||
|
{
|
|||
|
send.SetPackType((int)GameItemContainer.Type.TYPE_MAGICPACK);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
send.SendPacket();
|
|||
|
}
|
|||
|
|
|||
|
public void Click_Clear()
|
|||
|
{
|
|||
|
if (m_CurrentSelect == null || m_CurrentSelect.IsValid() == false)
|
|||
|
return;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
CG_HANDLE_MAGIC_WEAPON send = (CG_HANDLE_MAGIC_WEAPON)PacketDistributed.CreatePacket(MessageID.PACKET_CG_HANDLE_MAGIC_WEAPON);
|
|||
|
send.SetGuid(m_CurrentSelect.Guid);
|
|||
|
if(m_PayGold.isOn==false)
|
|||
|
send.SetHandletype((int)CG_HANDLE_MAGIC_WEAPON.EMagicWeaponHandleType.ERefine);
|
|||
|
else
|
|||
|
send.SetHandletype((int)CG_HANDLE_MAGIC_WEAPON.EMagicWeaponHandleType.ERefinCostItemAndMoney);
|
|||
|
|
|||
|
GameItem gameItem = GameManager.gameManager.PlayerDataPool.BackPack.GetItemByGuid(m_CurrentSelect.Guid);
|
|||
|
if (gameItem != null)
|
|||
|
{
|
|||
|
send.SetPackType((int)GameItemContainer.Type.TYPE_BACKPACK);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
GameItemContainer Container = GameManager.gameManager.PlayerDataPool.GetItemContainer(GameItemContainer.Type.TYPE_MAGICPACK);
|
|||
|
if (Container != null)
|
|||
|
{
|
|||
|
gameItem = Container.GetItemByGuid(m_CurrentSelect.Guid);
|
|||
|
if (gameItem != null)
|
|||
|
{
|
|||
|
send.SetPackType((int)GameItemContainer.Type.TYPE_MAGICPACK);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
send.SendPacket();
|
|||
|
}
|
|||
|
|
|||
|
public void Click_Close()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.MagicClearWndPath);
|
|||
|
}
|
|||
|
|
|||
|
public void Toggle_Click()
|
|||
|
{
|
|||
|
PayMoneyObj.SetActive(m_PayGold.isOn);
|
|||
|
}
|
|||
|
}
|