225 lines
6.4 KiB
C#
225 lines
6.4 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using Games.Item;
|
|||
|
using System.Collections.Generic;
|
|||
|
using GCGame.Table;
|
|||
|
|
|||
|
public class EquipEnhanceQianghua : UIControllerBase<EquipEnhanceQianghua>
|
|||
|
{
|
|||
|
// 是否有新的套装被强化
|
|||
|
private static bool hasNewSuitLevel = false;
|
|||
|
public static bool HasNewSuitLevel
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return hasNewSuitLevel;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
hasNewSuitLevel = value;
|
|||
|
if (EquipEnhanceQianghua.Instance() != null)
|
|||
|
{
|
|||
|
EquipEnhanceQianghua.Instance().effectEnhanceSuit.gameObject.SetActive(value);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public GameObject effectEnhanceSuit;
|
|||
|
|
|||
|
void OnEnable ()
|
|||
|
{
|
|||
|
ShowQianghuaPage();
|
|||
|
SetInstance(this);
|
|||
|
|
|||
|
ShowSuitLevel();
|
|||
|
}
|
|||
|
|
|||
|
void OnDisable()
|
|||
|
{
|
|||
|
SetInstance(null);
|
|||
|
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.FRESHSAMEUSETIP, "QianghuaMoneyUpdate");
|
|||
|
}
|
|||
|
|
|||
|
public void UpdateEquip()
|
|||
|
{
|
|||
|
if (!_EquipEnhanceRoot.RefreshItems())
|
|||
|
{
|
|||
|
_EquipEnhanceRoot.InitAllEquipList();
|
|||
|
|
|||
|
Hashtable hash = new Hashtable();
|
|||
|
hash.Add("QianghuaTips", true);
|
|||
|
|
|||
|
_EquipEnhanceRoot._EquipContainer.InitSelectContent(_EquipEnhanceRoot._AllEquipList, new GameItem[1] { _GameItem }, OnSelectEquipQianghua1, null, hash);
|
|||
|
}
|
|||
|
|
|||
|
OnSelectEquipQianghua1(_GameItem);
|
|||
|
ShowSuitLevel();
|
|||
|
}
|
|||
|
|
|||
|
public void ShowSuitLevel()
|
|||
|
{
|
|||
|
var tabCurLevel = TableManager.GetEquipEnchanceSuitByID(GameManager.gameManager.PlayerDataPool.EquipSuitID, 0);
|
|||
|
if (tabCurLevel != null)
|
|||
|
{
|
|||
|
_CurrSuitLevel.text = tabCurLevel.EnchanceLevel.ToString();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_CurrSuitLevel.text = "0";
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public EquipEnhanceRoot _EquipEnhanceRoot;
|
|||
|
|
|||
|
#region pages
|
|||
|
|
|||
|
public void ShowQianghuaPage()
|
|||
|
{
|
|||
|
_EquipEnhanceRoot._EquipContainer.gameObject.SetActive(true);
|
|||
|
_EquipEnhanceRoot._EquipContainer._IsMultiSelect = false;
|
|||
|
_EquipEnhanceRoot.InitAllEquipList();
|
|||
|
//if (_EquipEnhanceRoot._AllEquipList.Count == 0)
|
|||
|
//{
|
|||
|
// _EquipEnhanceRoot._EquipContainer.InitSelectContent(_EquipEnhanceRoot._AllEquipList, null);
|
|||
|
// OnSelectEquipQianghua1(null);
|
|||
|
// return;
|
|||
|
//}
|
|||
|
|
|||
|
var lastSelects = _EquipEnhanceRoot._EquipContainer.GetSelecteds<GameItem>();
|
|||
|
|
|||
|
// 装备强化列表只显示已装备物品
|
|||
|
List<GameItem> equipedItem = new List<GameItem>();
|
|||
|
foreach(var item in GameManager.gameManager.PlayerDataPool.EquipPack.GetList())
|
|||
|
{
|
|||
|
if (item.IsValid())
|
|||
|
{
|
|||
|
equipedItem.Add(item);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
var defaultSelect = new List<GameItem>();
|
|||
|
if (EquipEnhanceRoot._DefaultSelectedItem != null
|
|||
|
&& EquipEnhanceRoot._DefaultSelectedPage == 1)
|
|||
|
{
|
|||
|
defaultSelect.Add(EquipEnhanceRoot._DefaultSelectedItem);
|
|||
|
EquipEnhanceRoot._DefaultSelectedPage = -1;
|
|||
|
EquipEnhanceRoot._DefaultSelectedItem = null;
|
|||
|
}
|
|||
|
else if(lastSelects.Count > 0)
|
|||
|
{
|
|||
|
for(int i = 0; i < lastSelects.Count; ++i)
|
|||
|
{
|
|||
|
if(equipedItem.Count > 0 && equipedItem.Contains(lastSelects[i]))
|
|||
|
{
|
|||
|
defaultSelect.Add(lastSelects[i]);
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (defaultSelect.Count == 0 && _EquipEnhanceRoot._AllEquipList.Count > 0)
|
|||
|
{
|
|||
|
defaultSelect.Add(_EquipEnhanceRoot._AllEquipList[0]);
|
|||
|
}
|
|||
|
|
|||
|
Hashtable hash = new Hashtable();
|
|||
|
hash.Add("QianghuaTips", true);
|
|||
|
|
|||
|
if (defaultSelect.Count > 0)
|
|||
|
{
|
|||
|
_EquipEnhanceRoot._EquipContainer.InitSelectContent(equipedItem, defaultSelect, OnSelectEquipQianghua1, null, hash);
|
|||
|
OnSelectEquipQianghua1(defaultSelect[0]);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_EquipEnhanceRoot._EquipContainer.InitSelectContent(equipedItem, null, OnSelectEquipQianghua1, null, hash);
|
|||
|
OnSelectEquipQianghua1(null);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region qianghua
|
|||
|
|
|||
|
public CommonItemEquipItem _EquipItem;
|
|||
|
public Text _StrengthLevel;
|
|||
|
public EquipStarProcess _EquipPerfect;
|
|||
|
public Text _StrengthAttr;
|
|||
|
public Text _CurrSuitLevel;
|
|||
|
|
|||
|
private GameItem _GameItem;
|
|||
|
|
|||
|
// 装备强化
|
|||
|
private void OnSelectEquipQianghua1(object selectObj)
|
|||
|
{
|
|||
|
GameItem equipItem = selectObj as GameItem;
|
|||
|
if (equipItem == null)
|
|||
|
{
|
|||
|
_GameItem = null;
|
|||
|
_EquipItem.InitItem(null);
|
|||
|
_StrengthLevel.text = "";
|
|||
|
_StrengthAttr.text = "";
|
|||
|
_EquipPerfect.Value = 0;
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
_GameItem = equipItem;
|
|||
|
_EquipItem.InitItem(_GameItem);
|
|||
|
_StrengthLevel.text = "+" + _GameItem.StrengthLevel;
|
|||
|
_EquipPerfect.Value = _GameItem.GetStrengthPerfect();
|
|||
|
|
|||
|
if (_GameItem.StrengthLevel == 0)
|
|||
|
{
|
|||
|
_StrengthAttr.text = "0%";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Vector3 enhanceTotal = Vector3.zero;
|
|||
|
for (int i = 1; i < _GameItem.StrengthLevel + 1; ++i)
|
|||
|
{
|
|||
|
var enhanceRate = _GameItem.GetEquipStarRate(i);
|
|||
|
enhanceTotal += enhanceRate;
|
|||
|
}
|
|||
|
|
|||
|
_StrengthAttr.text = StrDictionary.GetClientDictionaryString("#{5304}", enhanceTotal.x, enhanceTotal.y, enhanceTotal.z);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void OnQianghua()
|
|||
|
{
|
|||
|
if (_GameItem == null)
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{5383}"));
|
|||
|
return;
|
|||
|
}
|
|||
|
EquipQianghuaRoot.Show(_GameItem, false);
|
|||
|
}
|
|||
|
|
|||
|
public void OnQianghuaAuto()
|
|||
|
{
|
|||
|
if (_GameItem == null)
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{5383}"));
|
|||
|
return;
|
|||
|
}
|
|||
|
EquipQianghuaRoot.Show(_GameItem, true);
|
|||
|
}
|
|||
|
|
|||
|
public void OnShowSuitTips()
|
|||
|
{
|
|||
|
HasNewSuitLevel = false;
|
|||
|
int enhanceLevel = 0;
|
|||
|
var tab = TableManager.GetEquipEnchanceSuitByID(GameManager.gameManager.PlayerDataPool.EquipSuitID, 0);
|
|||
|
if (tab != null)
|
|||
|
{
|
|||
|
enhanceLevel = tab.EnchanceLevel;
|
|||
|
}
|
|||
|
|
|||
|
EquipQianghuaSuitTips.Show(enhanceLevel, GameManager.gameManager.PlayerDataPool.NextSuitEquipCnt);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|