126 lines
3.4 KiB
C#
126 lines
3.4 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using GCGame.Table;
|
|
using System;
|
|
|
|
public class CombatTipsItem
|
|
{
|
|
public Tab_LevelCombatTipItem _ItemTab;
|
|
public int _CombatValA;
|
|
public int _CombatValB;
|
|
public int _CombatCur;
|
|
public List<int> _CombatCulTypes = new List<int>();
|
|
}
|
|
|
|
public class LevelCombatCombatPanel : UIControllerBase<LevelCombatCombatPanel>
|
|
{
|
|
|
|
private void Start()
|
|
{
|
|
SetInstance(this);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
SetInstance(null);
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
InitCombatInfo();
|
|
ShowCombatInfo();
|
|
}
|
|
|
|
#region
|
|
|
|
public UIContainerBase _TipsContainer;
|
|
|
|
private List<CombatTipsItem> _CombatItems;
|
|
private List<CombatTipsItem> _ShowItems;
|
|
|
|
private void InitCombatInfo()
|
|
{
|
|
if (_CombatItems != null)
|
|
return;
|
|
|
|
_CombatItems = new List<CombatTipsItem>();
|
|
var levelCombatItemTabs = TableManager.GetLevelCombatTipItem().Values;
|
|
foreach (var itemTab in levelCombatItemTabs)
|
|
{
|
|
if (itemTab.Class == 1)
|
|
{
|
|
CombatTipsItem tipsItem = new CombatTipsItem();
|
|
tipsItem._ItemTab = itemTab;
|
|
string[] split = tipsItem._ItemTab.ShowParam.Split(';');
|
|
for (int i = 0; i < split.Length; ++i)
|
|
{
|
|
if (!string.IsNullOrEmpty(split[i]))
|
|
{
|
|
tipsItem._CombatCulTypes.Add(int.Parse(split[i]));
|
|
}
|
|
}
|
|
_CombatItems.Add(tipsItem);
|
|
}
|
|
}
|
|
|
|
_CombatItems.Sort((itemA, itemB) =>
|
|
{
|
|
if (itemA._ItemTab.Sort > itemB._ItemTab.Sort)
|
|
return 1;
|
|
if (itemA._ItemTab.Sort < itemB._ItemTab.Sort)
|
|
return -1;
|
|
return 0;
|
|
});
|
|
}
|
|
|
|
private void ShowCombatInfo()
|
|
{
|
|
int level = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level;
|
|
|
|
_ShowItems = new List<CombatTipsItem>();
|
|
var combatTab = TableManager.GetCombatTipByID(level, 0);
|
|
for (int i = 0; i < _CombatItems.Count; ++i)
|
|
{
|
|
if (i < combatTab.getTipValueACount())
|
|
{
|
|
_CombatItems[i]._CombatValA = combatTab.GetTipValueAbyIndex(i);
|
|
_CombatItems[i]._CombatValB = combatTab.GetTipValueBbyIndex(i);
|
|
_CombatItems[i]._CombatCur = _CombatItems[i]._CombatValA - 1;
|
|
}
|
|
|
|
if (_CombatItems[i]._CombatValA > 0)
|
|
{
|
|
_ShowItems.Add(_CombatItems[i]);
|
|
}
|
|
}
|
|
|
|
//_TipsContainer.InitContentItem(_ShowItems);
|
|
|
|
CG_COMBATVALUE_ASK packet = (CG_COMBATVALUE_ASK)PacketDistributed.CreatePacket(MessageID.PACKET_CG_COMBATVALUE_ASK);
|
|
packet.ShowPowerRemind = 0;
|
|
packet.SendPacket();
|
|
}
|
|
|
|
public void UpdateCurCombat(GC_COMBATVALUE_RET packet)
|
|
{
|
|
for (int i = 0; i < _ShowItems.Count; ++i)
|
|
{
|
|
_ShowItems[i]._CombatCur = 0;
|
|
for (int j = 0; j < packet.combatValueListCount; ++j)
|
|
{
|
|
var combatInfo = packet.GetCombatValueList(j);
|
|
if (_ShowItems[i]._CombatCulTypes.Contains(combatInfo.CombatType))
|
|
{
|
|
_ShowItems[i]._CombatCur += combatInfo.CombatValue;
|
|
}
|
|
}
|
|
}
|
|
|
|
_TipsContainer.InitContentItem(_ShowItems);
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|