Files
JJBB/Assets/Project/Script/GUI/SkillBar/SkillRootLogic.cs

1346 lines
45 KiB
C#
Raw Normal View History

2024-08-23 15:49:34 +08:00
using System;
using System.Collections.Generic;
using System.Runtime.Remoting.Lifetime;
using Games.GlobeDefine;
using Games.LogicObj;
using Games.SkillModle;
using GCGame;
using GCGame.Table;
using Module.Log;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using Games.Item;
public class SkillRootLogic : MonoBehaviour
{
public static int MAX_SKILL_LEARN_LEVEL = 40;
public static bool canDrag = false;
private static SkillRootLogic m_Instance = null;
public static SkillRootLogic Instance()
{
return m_Instance;
}
private void Awake()
{
_PreSkillNotEnough.SetActive(false);
_PreSkillNotEnoughText.text = StrDictionary.GetClientDictionaryString("#{4762}");
}
void OnEnable()
{
m_Instance = this;
ShowTagPage(0);
InitSkillInfos();
UIManager.ShowUI(UIInfo.MoneyInfoPanel);
GUIData.delMoneyChanged += UpdateSkillCost;
UpdateRedTips();
_DragIcon.gameObject.SetActive(false);
}
void OnDisable()
{
m_Instance = null;
UIManager.CloseUI(UIInfo.MoneyInfoPanel);
GUIData.delMoneyChanged -= UpdateSkillCost;
}
public void CloseWindow()
{
SaveSkillPage();
UIManager.CloseUI(UIInfo.SkillInfo);
}
public void OnShowPage(int page)
{
switch (page)
{
case 0:
InitSkillInfos();
break;
case 1:
//InitChangeInfo();
ReqUnLockPageCount();
break;
}
}
private void ReqUnLockPageCount()
{
ReqUnLockSkillCombine req = new ReqUnLockSkillCombine();
req._Flag = 1;
req.SendMsg();
}
public void UpdateSkillLvUpInfo()
{
LogModule.DebugLog("UpdateSkillLvUpInfo");
InitSkillItems();
OnSkillClassPage(_SkillClasses.SelectedSub1);
UpdateSkillCost();
AdjustLvUpBtn();
}
public void UpdateXiuwei()
{
_Xiuwei.text = StrDictionary.GetClientDictionaryString("#{2829}", GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Xiewei.ToString());
//_Xiuwei.text = StrDictionary.GetClientDictionaryString("#{10405}") + GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Xiewei.ToString();
}
public void ShowHelpMessage(int messageID)
{
MessageHelpLogic.ShowHelpMessage(messageID);
}
public void ShowTagPage(int page)
{
if (page > 1)
return;
_TagPanel.ShowPage(page);
}
#region skill icons
public UITagPanel _TagPanel;
public UISubScollMenu _SkillClasses;
public SkillRootPage _SkillInfoPage;
private Dictionary<string, List<SkillRootItem.SkillShowInfo>> _MySkillInfos;
public Dictionary<string, List<SkillRootItem.SkillShowInfo>> MySkillInfos
{
get
{
return _MySkillInfos;
}
}
private SkillRootItem.SkillShowInfo _SelectedSkillShow;
private void InitSkillInfos()
{
InitSkillItems();
_SkillClasses.Clear();
foreach (var skillClass in _MySkillInfos)
{
_SkillClasses.PushMenu(skillClass.Key);
for (int i = 0; i < skillClass.Value.Count; ++i)
{
if (CanSkillItemLvUp(skillClass.Value[i]))
{
continue;
}
}
}
int idx = 0;
if (UserConfigData._CurSkillPage != null)
{
idx = UserConfigData._CurSkillPage.PageIdx;
}
idx = Mathf.Max(0, idx);
InitSkillPage(idx);
_SkillClasses.ShowDefaultFirst();
_SkillInfoPage.SelectItem(_SelectedSkillShow);
}
/// <summary>
/// 整理和包装玩家所有可学的技能信息并在_MySkillInfos分类存储
/// </summary>
///
private void InitSkillItems()
{
// 全部可学技能列表,为未分类
var totleList = new List<SkillRootItem.SkillShowInfo>();
// 分类过后的全部技能列表
_MySkillInfos = new Dictionary<string, List<SkillRootItem.SkillShowInfo>>();
var skillActives = TableManager.GetSkillActive().Values;
var skillCount = 0;
foreach (var skill in skillActives)
{
if (skill.Profession == Singleton<ObjManager>.GetInstance().MainPlayer.Profession)
skillCount++;
}
// 保存玩家已经学的技能
for(int i = 0; i < Singleton<ObjManager>.GetInstance().MainPlayer.OwnSkillInfo.Length; ++i)
{
//if (skillInfo.SkillLevelTable == null)
// continue;
//潜规则,这两个位置默认存放试用技能
if (i == skillCount - 1 || i == skillCount - 2)
continue;
var skillInfo = Singleton<ObjManager>.GetInstance().MainPlayer.OwnSkillInfo[i];
var showInfo = new SkillRootItem.SkillShowInfo();
showInfo.SkillExTab = skillInfo.SkillExTable;
if (showInfo.SkillExTab == null)
continue;
showInfo.SkillBase = skillInfo.SkillBaseTable;
Tab_SkillLevelUp skillnext = TableManager.GetSkillLevelUpByID(skillInfo.SkillExTable.NextSkillId, 0);
showInfo.SkillLevelUp = skillnext;
totleList.Add(showInfo);
}
// 获得所有可学技能列表
var learnList = TableManager.GetSkillLearn().Values;
foreach (var tabAct in learnList)
{
if (tabAct.Profession != GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession)
continue;
// 获取每个技能相关信息
Tab_SkillEx skillEx = TableManager.GetSkillExByID(tabAct.SkillId, 0);
Tab_SkillBase skillBase = TableManager.GetSkillBaseByID(skillEx.BaseId, 0);
var skillInfo = totleList.Find((showInfo) =>
{
if (showInfo.SkillBase.Id == skillEx.BaseId)
{
return true;
}
return false;
});
if (skillInfo != null)
{
skillInfo.SkillLearn = tabAct;
}
else
{
SkillRootItem.SkillShowInfo showInfo = new SkillRootItem.SkillShowInfo();
showInfo.SkillLearn = tabAct;
showInfo.SkillBase = skillBase;
showInfo.SkillLevelUp = TableManager.GetSkillLevelUpByID(skillEx.SkillExID, 0);
totleList.Add(showInfo);
}
}
// 将已学和没学的技能,按照类型存入字典
foreach (var showInfo in totleList)
{
if (showInfo.SkillLearn == null)
continue;
if (_MySkillInfos.ContainsKey(showInfo.SkillLearn.Class))
{
_MySkillInfos[showInfo.SkillLearn.Class].Add(showInfo);
}
else
{
List<SkillRootItem.SkillShowInfo> showList = new List<SkillRootItem.SkillShowInfo>();
showList.Add(showInfo);
_MySkillInfos.Add(showInfo.SkillLearn.Class, showList);
}
}
CanAnySkillLvUp();
}
public void OnSkillClassPage(object paramObj)
{
LogModule.DebugLog("OnSkillClassPage:" + paramObj);
string skillClass = paramObj as string;
if (_MySkillInfos.ContainsKey(skillClass))
{
_SkillInfoPage.InitContainer(_MySkillInfos[skillClass], OnSkillItemClick);
if (_TagPanel.GetShowingPage() != 1)
_SkillInfoPage.SelectItem(_SelectedSkillShow);
}
}
public void OnShowSkillItem(int skillBaseId)
{
string pageName = "";
SkillRootItem.SkillShowInfo selectedItem = null;
foreach (var skillPage in _MySkillInfos)
{
foreach (var skillShowInfo in skillPage.Value)
{
if (skillShowInfo.SkillBase.Id == skillBaseId)
{
pageName = skillPage.Key;
selectedItem = skillShowInfo;
}
}
}
_SkillClasses.ShowMenu(pageName);
//OnSkillClassPage(pageName);
_SkillInfoPage.SelectItem(selectedItem);
}
public void OnSkillItemClick(object skillItem)
{
SkillRootItem.SkillShowInfo skillShowInfo = skillItem as SkillRootItem.SkillShowInfo;
if (skillShowInfo == null)
return;
_SelectedSkillShow = skillShowInfo;
if (_TagPanel.GetShowingPage() == 0)
{
InitSkillInfo(skillShowInfo);
}
else
{
if (skillShowInfo.SkillExTab != null)
{
var ownSkill = GameManager.gameManager.PlayerDataPool.GetOwnSkillInfo(skillShowInfo.SkillBase.Id);
var newskillEx = TableManager.GetSkillExByID(skillShowInfo.SkillExTab.SkillExID + ownSkill.exSkillLevel, 0);
SkillTooltipsLogic.ShowSkillToolTips(newskillEx.SkillExID, new Vector3(114, -35, 0));
}
else
{
SkillTooltipsLogic.ShowSkillToolTips(skillShowInfo.SkillLearn.SkillId, new Vector3(114, -35, 0));
}
}
}
#endregion
#region skill lv UP
public Text _SkillName;
public Text _SkillCurDesc;
public Text _SkillCurLevel;
public Text _SkillNextDesc;
public Text _LeardNeedLv;
public Text _LeardNeedPreSkill;
public Text _Xiuwei;
public GameObject _NextLvPanel;
public Image[] _DamageTypes;
public UICurrencyItem _LvCost1;
public UICurrencyItem _LvOwn1;
public UICurrencyItem _LvCost2;
public UICurrencyItem _LvOwn2;
public GameObject _MoneyCostPanel;
public GameObject _ItemCostPanel;
public CommonItemMaterialSlot _ItemCostSlot;
public GameObject _PreSkillNotEnough;
public Text _PreSkillNotEnoughText;
public GameObject _ResEnough;
public GameObject _ResLack;
public GameObject _ResLackMoney;
public GameObject _ResLackEXP;
public GameObject _LvUpPanel;
public GameObject _LearnPanel;
public GameObject _MaxLvPanel;
public GameObject _LearnItemPanel;
public GameObject _CantLearnPanel;
public Button _BtnLearn;
public Button _BtnLvUp;
public Text _NextXiuwei;
public CommonItemMaterialSlot _LearnItemSlot;
private SkillRootItem.SkillShowInfo _SelectedSkill;
private bool _IsCanLevelUpSkill = true;
private long _ReplaceExpConsume;
private long _ReplaceMoneyConsume;
public void InitSkillInfo(SkillRootItem.SkillShowInfo skillShowInfo)
{
_SelectedSkill = skillShowInfo;
_IsCanLevelUpSkill = true;
_SkillName.text = skillShowInfo.SkillBase.Name;
string[] skillDamageType = skillShowInfo.SkillLearn.SkillType.Split(';');
for (int i = 0; i < _DamageTypes.Length; ++i)
{
_DamageTypes[i].gameObject.SetActive(false);
}
for (int i = 0; i < skillDamageType.Length; ++i)
{
int index = int.Parse(skillDamageType[i]);
_DamageTypes[index].gameObject.SetActive(true);
}
ShowLevelSkillCondition(skillShowInfo);
ShowLevelSkillCost(skillShowInfo);
AdjustLvUpBtn();
_Xiuwei.text = StrDictionary.GetClientDictionaryString("#{2829}", GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Xiewei.ToString());
}
private void ShowLevelSkillCost(SkillRootItem.SkillShowInfo skillShowInfo)
{
OwnSkillData ownSkillData = GameManager.gameManager.PlayerDataPool.GetOwnSkillInfo(skillShowInfo.SkillBase.Id);
if (skillShowInfo.SkillExTab == null)
{
_LvUpPanel.SetActive(false);
_LearnPanel.SetActive(true);
_MaxLvPanel.SetActive(false);
_SkillCurDesc.gameObject.SetActive(false);
_SkillCurLevel.text = "1";
if (skillShowInfo.SkillLevelUp.Level > GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level
|| !skillShowInfo.IsNeedSkillLearned())
{
_LearnItemPanel.SetActive(false);
_CantLearnPanel.SetActive(true);
_BtnLearn.interactable = false;
}
else
{
_LearnItemPanel.SetActive(true);
_CantLearnPanel.SetActive(false);
int needItem = -1;
int needItemCount = -1;
for (int i = 0; i < skillShowInfo.SkillLevelUp.getConsumIdCount(); ++i)
{
if (skillShowInfo.SkillLevelUp.GetConsumTypebyIndex(i) == (int)CONSUM_TYPE.ITEM)
{
needItem = skillShowInfo.SkillLevelUp.GetConsumIdbyIndex(i);
needItemCount = skillShowInfo.SkillLevelUp.GetConsumValbyIndex(i);
}
}
if (needItem > 0)
{
//Tab_CommonItem needItem = TableManager.GetCommonItemByID(skillShowInfo.SkillActive.NeedItem, 0);
var itemCount = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(needItem);
_LearnItemSlot.InitMaterial(needItem, 1);
if (itemCount > 0)
{
_BtnLearn.interactable = true;
}
else
{
_BtnLearn.interactable = false;
}
_ReplaceExpConsume = 0;
_ReplaceMoneyConsume = 0;
}
}
}
else if (skillShowInfo.SkillLevelUp == null || skillShowInfo.SkillLevelUp.IsMaxLevel > 0)
{
_LvUpPanel.SetActive(false);
_LearnPanel.SetActive(false);
_MaxLvPanel.SetActive(true);
_SkillCurDesc.gameObject.SetActive(true);
_SkillCurDesc.text = ownSkillData.BaseExTableFinal.SkillDesc;
_SkillCurLevel.text = ownSkillData.BaseExTableFinal.Level.ToString();
}
else
{
_LvUpPanel.SetActive(true);
_LearnPanel.SetActive(false);
_MaxLvPanel.SetActive(false);
_SkillCurDesc.gameObject.SetActive(true);
_SkillCurDesc.text = ownSkillData.BaseExTableFinal.SkillDesc;
_SkillCurLevel.text = ownSkillData.BaseExTableFinal.Level.ToString();
UpdateSkillCost();
}
}
public void UpdateSkillCost()
{
//if (!_LvCost1.gameObject.activeInHierarchy)
// return;
UpdateRedTips();
if (CONSUM_TYPE.ITEM == (CONSUM_TYPE)_SelectedSkill.SkillLevelUp.GetConsumTypebyIndex(0))
{
_ReplaceMoneyConsume = 0;
_ReplaceExpConsume = 0;
_MoneyCostPanel.SetActive(false);
_ItemCostPanel.SetActive(true);
_ItemCostSlot.InitMaterial(_SelectedSkill.SkillLevelUp.GetConsumIdbyIndex(0), _SelectedSkill.SkillLevelUp.GetConsumValbyIndex(0));
if (_ItemCostSlot.IsMaterialEnough())
{
if (alreadyLearnNeedSkill == true)
{
_PreSkillNotEnough.SetActive(false);
}
else
{
_PreSkillNotEnough.SetActive(true);
}
}
else
{
_PreSkillNotEnough.SetActive(false);
_IsCanLevelUpSkill &= false;
}
}
else
{
_MoneyCostPanel.SetActive(true);
_ItemCostPanel.SetActive(false);
//通过类型和ID返回角色自身已经拥有的数量
long ownValue = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.SkillExp;
if (ownValue > 0)
{
_LvCost1.ShowCurrency(_SelectedSkill.SkillLevelUp.GetConsumTypebyIndex(0), _SelectedSkill.SkillLevelUp.GetConsumIdbyIndex(0), _SelectedSkill.SkillLevelUp.GetConsumValbyIndex(0));
if (ownValue < _SelectedSkill.SkillLevelUp.GetConsumValbyIndex(0))
{
_LvOwn1.SetColor("<color=red>");
}
_LvOwn1.ShowCurrency(_SelectedSkill.SkillLevelUp.GetConsumTypebyIndex(0), _SelectedSkill.SkillLevelUp.GetConsumIdbyIndex(0), ownValue);
}
else
{
_LvCost1.ShowReplaceOwnCurrency(_SelectedSkill.SkillLevelUp.GetConsumTypebyIndex(0), _SelectedSkill.SkillLevelUp.GetConsumIdbyIndex(0), _SelectedSkill.SkillLevelUp.GetConsumValbyIndex(0));
_LvOwn1.ShowReplaceOwnCurrencyCompare(_SelectedSkill.SkillLevelUp.GetConsumTypebyIndex(0), _SelectedSkill.SkillLevelUp.GetConsumIdbyIndex(0), _SelectedSkill.SkillLevelUp.GetConsumValbyIndex(0));
}
long ownValue2 = GameManager.gameManager.PlayerDataPool.GetLongPropty(_SelectedSkill.SkillLevelUp.GetConsumTypebyIndex(1), _SelectedSkill.SkillLevelUp.GetConsumIdbyIndex(1));
if (ownValue2 > 0)
{
_LvCost2.ShowCurrency(_SelectedSkill.SkillLevelUp.GetConsumTypebyIndex(1), _SelectedSkill.SkillLevelUp.GetConsumIdbyIndex(1), _SelectedSkill.SkillLevelUp.GetConsumValbyIndex(1));
if (ownValue2 < _SelectedSkill.SkillLevelUp.GetConsumValbyIndex(1))
{
_LvOwn2.SetColor("<color=red>");
}
_LvOwn2.ShowCurrency(_SelectedSkill.SkillLevelUp.GetConsumTypebyIndex(1), _SelectedSkill.SkillLevelUp.GetConsumIdbyIndex(1), ownValue2);
}
else
{
_LvCost2.ShowReplaceOwnCurrency(_SelectedSkill.SkillLevelUp.GetConsumTypebyIndex(1), _SelectedSkill.SkillLevelUp.GetConsumIdbyIndex(1), _SelectedSkill.SkillLevelUp.GetConsumValbyIndex(1));
_LvOwn2.ShowReplaceOwnCurrencyCompare(_SelectedSkill.SkillLevelUp.GetConsumTypebyIndex(1), _SelectedSkill.SkillLevelUp.GetConsumIdbyIndex(1), _SelectedSkill.SkillLevelUp.GetConsumValbyIndex(1));
}
_ReplaceExpConsume = (ownValue - _SelectedSkill.SkillLevelUp.GetConsumValbyIndex(0));
_ReplaceMoneyConsume = (ownValue2 - _SelectedSkill.SkillLevelUp.GetConsumValbyIndex(1));
bool isExpEnough = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Exp + _ReplaceExpConsume >= 0;
bool isMoneyEnough = GameManager.gameManager.PlayerDataPool.Money.GetMoneyByType(MONEYTYPE.MONEYTYPE_COIN) + _ReplaceMoneyConsume >= 0;
// 替代后不满足
if (!isExpEnough || !isMoneyEnough)
{
_IsCanLevelUpSkill &= false; //是否可以升级技能 默认为true
_ResLack.SetActive(true);
_ResEnough.SetActive(false);
_ResLackMoney.SetActive(false);
_ResLackEXP.SetActive(false);
_PreSkillNotEnough.SetActive(false);
}
else
{
if (!_IsCanLevelUpSkill && alreadyLearnNeedSkill == false)
{
_PreSkillNotEnough.SetActive(true);
_ResLack.SetActive(false);
_ResEnough.SetActive(false);
_ResLackMoney.SetActive(false);
_ResLackEXP.SetActive(false);
}
else
{
_PreSkillNotEnough.SetActive(false);
//两者都消耗
if ((_ReplaceExpConsume < 0 && isExpEnough) && (_ReplaceMoneyConsume < 0 && isMoneyEnough))
{
_ResLack.SetActive(false);
_ResEnough.SetActive(true);
_ResLackMoney.SetActive(false);
_ResLackEXP.SetActive(false);
}
//只消耗银票
else if (_ReplaceMoneyConsume < 0 && isMoneyEnough)
{
_ResLack.SetActive(false);
_ResEnough.SetActive(false);
_ResLackMoney.SetActive(true);
_ResLackEXP.SetActive(false);
}
//只消耗经验
else if (_ReplaceExpConsume < 0 && isExpEnough)
{
_ResLack.SetActive(false);
_ResEnough.SetActive(false);
_ResLackMoney.SetActive(false);
_ResLackEXP.SetActive(true);
}
//不替代就满足
else if (_ReplaceExpConsume >= 0 && _ReplaceMoneyConsume >= 0)
{
_ResLack.SetActive(false);
_ResEnough.SetActive(false);
_ResLackMoney.SetActive(false);
_ResLackEXP.SetActive(false);
}
}
}
}
AdjustLvUpBtn();
}
private bool alreadyLearnNeedSkill = false;
private void ShowLevelSkillCondition(SkillRootItem.SkillShowInfo skillShowInfo)
{
int exLv = 0;
OwnSkillData ownSkill = GameManager.gameManager.PlayerDataPool.GetOwnSkillInfo(skillShowInfo.SkillBase.Id);
if(ownSkill != null)
{
exLv = ownSkill.exSkillLevel;
}
if(skillShowInfo.SkillLevelUp == null)
{
return;
}
var levelUpNextSkill = TableManager.GetSkillExByID(skillShowInfo.SkillLevelUp.Id + exLv, 0);
if (levelUpNextSkill == null)
return;
if (levelUpNextSkill != null)
{
_SkillNextDesc.text = levelUpNextSkill.SkillDesc;
_NextXiuwei.text = StrDictionary.GetClientDictionaryString("#{2829}", Utils.GetColorEnableGreen()+ levelUpNextSkill.CombatValue.ToString() + "</color>");
}
if (skillShowInfo.SkillLevelUp.IsMaxLevel > 0)
{
_NextLvPanel.SetActive(false);
_SkillNextDesc.gameObject.SetActive(false);
}
else
{
_NextLvPanel.SetActive(true);
_SkillNextDesc.gameObject.SetActive(true);
}
if (skillShowInfo.SkillLevelUp.Level > GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level)
{
_LeardNeedLv.text = Utils.GetColorDisableRed() + skillShowInfo.SkillLevelUp.Level.ToString() + "</color>";
_IsCanLevelUpSkill &= false;
}
else
{
_LeardNeedLv.text = Utils.GetColorEnableGreen() + skillShowInfo.SkillLevelUp.Level.ToString() + "</color>";
}
var needSkill = skillShowInfo.GetNeedSkillLvUp();
if (needSkill == null)
{
_LeardNeedPreSkill.gameObject.SetActive(false);
alreadyLearnNeedSkill = true;
}
else
{
_LeardNeedPreSkill.gameObject.SetActive(true);
alreadyLearnNeedSkill = false;
var skillBase = TableManager.GetSkillBaseByID(needSkill.BaseId, 0);
foreach (var skillInfo in Singleton<ObjManager>.GetInstance().MainPlayer.OwnSkillInfo)
{
var skillEx = skillInfo.SkillExTable;
if (skillEx == null)
continue;
if (skillEx.BaseId == needSkill.BaseId && skillEx.Level >= needSkill.Level)
{
alreadyLearnNeedSkill = true;
}
}
string skillName = skillBase.Name + needSkill.Level + StrDictionary.GetClientDictionaryString("#{5120}");
if (!alreadyLearnNeedSkill)
{
_LeardNeedPreSkill.text = Utils.GetColorDisableRed() + skillName + "</color>";
_IsCanLevelUpSkill = false;
}
else
{
_LeardNeedPreSkill.text = Utils.GetColorEnableGreen() + skillName + "</color>";
}
}
}
void OnLvUpClick()
{
string tips = "";
if ((GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.SkillExp != 0 && _ReplaceExpConsume < 0 )
&& (GameManager.gameManager.PlayerDataPool.Money.GetMoney_CoinBind() != 0 && _ReplaceMoneyConsume < 0))
{
tips = StrDictionary.GetClientDictionaryString("#{4744}", -_ReplaceExpConsume, -_ReplaceMoneyConsume);
}
else if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.SkillExp != 0 && _ReplaceExpConsume < 0)
{
tips = StrDictionary.GetClientDictionaryString("#{4745}", -_ReplaceExpConsume);
}
else if (GameManager.gameManager.PlayerDataPool.Money.GetMoney_CoinBind() != 0 && _ReplaceMoneyConsume < 0)
{
tips = StrDictionary.GetClientDictionaryString("#{4746}", -_ReplaceMoneyConsume);
}
else
{
OnLvUpClickOK();
return;
}
MessageBoxLogic.OpenOKCancelBox(tips, "", OnLvUpClickOK);
}
void OnLvUpClickOK()
{
_ReplaceExpConsume = 0;
_ReplaceMoneyConsume = 0;
if (_IsCanLevelUpSkill)
{
DoLevelUp();
//升级完毕判断下一级是否能升级
}
//if (_SelectedSkill.SkillLevelUp.SkillLevel == 1)
//{
// GlobalEffectMgr.PlayerNormalEffect("TX_ui_jihuochenggong");
//}
//else
//{
// GlobalEffectMgr.PlayerNormalEffect("TX_ui_shenjichenggong");
//}
}
public void LevelUp()
{
if (_SelectedSkill.SkillLevelUp.SkillLevel == 1)
{
GlobalEffectMgr.PlayerNormalEffect("TX_ui_jihuochenggong");
}
else
{
GlobalEffectMgr.PlayerNormalEffect("TX_ui_shenjichenggong");
}
AdjustLvUpBtn();
}
void AdjustLvUpBtn()
{
if (_IsCanLevelUpSkill)
{
_BtnLvUp.interactable = true;
}
else
{
_BtnLvUp.interactable = false;
}
}
void DoLevelUp()
{
//发包
CG_ASK_LEVELUPSKILL packet = (CG_ASK_LEVELUPSKILL)PacketDistributed.CreatePacket(MessageID.PACKET_CG_ASK_LEVELUPSKILL);
packet.SetSkillId(_SelectedSkill.SkillLevelUp.Id);
packet.SendPacket();
}
public void OnHelpClick()
{
}
#endregion
#region Skill Use
public const string TALENT_PAGE_LOCK_STR = "Locked";
public UISubScollMenu _TalentPageContainer; // 技能页菜单容器
public UIContainerBase _TalentContainer;
public Text _TalentPageName;
public SkillBarItem[] _SkillBarItems;
public GameObject _PageOpenPanel;
public GameObject _PageLockPanel;
public UIContainerBase _PageConditionContainer;
public Image _DragIcon;
public int _DragSkillOwnIdx { get; set; }
public SkillBarItem _DragSkillBar { get; set; }
private List<string> _TalentPageStrs;
public UserConfigData.SkillSavePage _CurSkillPage;
// 显示技能组合面板
public void InitChangeInfo(int pageCount)
{
// 显示技能组合面板左侧菜单
if (_TalentPageStrs == null)
{
_TalentPageStrs = new List<string>();
_TalentPageStrs.Add(StrDictionary.GetClientDictionaryString("#{4720}"));
_TalentPageStrs.Add(StrDictionary.GetClientDictionaryString("#{4721}"));
_TalentPageStrs.Add(StrDictionary.GetClientDictionaryString("#{4722}"));
_TalentPageStrs.Add(StrDictionary.GetClientDictionaryString("#{4723}"));
_TalentPageStrs.Add(StrDictionary.GetClientDictionaryString("#{4724}"));
}
// 获取开启技能页数
//int pageCount = GetActiveTalentPageCount();
_TalentPageContainer.Clear();
// 先显示已被使用的页面
for (int i = 0; i < pageCount; ++i)
{
_TalentPageContainer.PushMenu(_TalentPageStrs[i]);
}
// 未被开启的给与提示
for (int i = pageCount; i < _TalentPageStrs.Count; ++i)
{
_TalentPageContainer.PushMenu(TALENT_PAGE_LOCK_STR);
}
UserConfigData.LoadAllSkillPage(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid.ToString());
if (UserConfigData._CurSkillPage == null)
{
_TalentPageContainer.ShowDefaultFirst();
}
else
{
_TalentPageContainer.ShowMenu(_TalentPageStrs[UserConfigData._CurSkillPage.PageIdx]);
}
//OnTalentPageSelect(_TalentPageStrs[0]);
}
// 选中技能组合页面按钮回调
public void OnTalentPageSelect(object selectPage)
{
string pageName = selectPage as string;
// 显示被锁界面
if (pageName == TALENT_PAGE_LOCK_STR)
{
_PageOpenPanel.SetActive(false);
_PageLockPanel.SetActive(true);
_PageConditionContainer.InitContentItem(TableManager.GetSkillBoxOpen().Values);
}
else
{
// 更具页面索引,显示玩家具体组合页面的技能
_PageOpenPanel.SetActive(true);
_PageLockPanel.SetActive(false);
int idx = _TalentPageStrs.IndexOf(pageName);
InitSkillPage(idx);
// 显示技能图标
for (int i = 0; i < _CurSkillPage.SkillIdxs.Length; ++i)
{
if (i < _SkillBarItems.Length)
{
_SkillBarItems[i].InitSkillBar(_CurSkillPage.SkillIdxs[i], i);
}
}
UserConfigData._CurSkillPage = _CurSkillPage;
}
}
public void InitSkillPage(int idx)
{
if (UserConfigData._SkillPages == null)
return;
if (_CurSkillPage != null)
{
_CurSkillPage.IsUsing = 0;
_CurSkillPage = null;
}
foreach (var skillPage in UserConfigData._SkillPages)
{
if (skillPage.RoleGuid == GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid
&& skillPage.PageIdx == idx)
{
_CurSkillPage = skillPage;
_CurSkillPage.IsUsing = 1;
break;
}
}
// 当玩家没有使用任一种组合,制定一套基础的代替
if (_CurSkillPage == null)
{
_TalentPageName.text = StrDictionary.GetClientDictionaryString("#{4726}");
_CurSkillPage = new UserConfigData.SkillSavePage();
_CurSkillPage.RoleGuid = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid;
_CurSkillPage.PageIdx = idx;
_CurSkillPage.PageName = _TalentPageName.text;
_CurSkillPage.IsUsing = 1;
_CurSkillPage.SkillIdxs = new int[UserConfigData.SkillSavePage.PAGE_SKILL_NUM]
{
-1,-1,-1,-1
};
var mainPlayer = Singleton<ObjManager>.GetInstance().MainPlayer;
LogModule.WarningLog("OnTalentPageSelect : " + Time.realtimeSinceStartup);
for (int _skillIndex = 0; _skillIndex < mainPlayer.OwnSkillInfo.Length; _skillIndex++)
{
if (mainPlayer.OwnSkillInfo[_skillIndex].SkillBaseTable == null)
continue;
if ((mainPlayer.OwnSkillInfo[_skillIndex].SkillBaseTable.SkillClass & (int)SKILLCLASS.SIMPLEATTACK) != 0)
continue;
if ((mainPlayer.OwnSkillInfo[_skillIndex].SkillBaseTable.SkillClass & (int)SKILLCLASS.AUTOREPEAT) == 0 &&
(mainPlayer.OwnSkillInfo[_skillIndex].SkillBaseTable.SkillClass & (int)SKILLCLASS.XP) == 0)
{
for (int _skillBarIndex = 0; _skillBarIndex < _CurSkillPage.SkillIdxs.Length; _skillBarIndex++)
{
if (_CurSkillPage.SkillIdxs[_skillBarIndex] < 0)
{
_CurSkillPage.SkillIdxs[_skillBarIndex] = _skillIndex;
break;
}
}
}
}
UserConfigData._SkillPages.Add(_CurSkillPage);
}
else
{
_TalentPageName.text = _CurSkillPage.PageName;
}
_SkillInfoPage.RefreshEquipedTag();
}
public void OnTalentPageNameChange()
{
InputBoxLogic.ShowInputBoxStatic(StrDictionary.GetClientDictionaryString("#{4725}"), "", OnTalentPageNameChangeReturn, 7);
}
private void OnTalentPageNameChangeReturn(string changeName)
{
if (string.IsNullOrEmpty(changeName))
return;
_TalentPageName.text = changeName;
_CurSkillPage.PageName = changeName;
}
private void SaveSkillPage()
{
if(_CurSkillPage!=null)
{
UserConfigData._CurSkillPage = _CurSkillPage;
UserConfigData.SaveSkillPages();
}
if(SkillBarLogic.Instance() != null)
SkillBarLogic.Instance().RefreshSkillBarInfo();
}
public bool CanDragSkillItem()
{
if (_TagPanel.GetShowingPage() == 1)
return true;
return false;
}
public void SetDragSkillIdx(SkillRootItem.SkillShowInfo showInfo)
{
if (showInfo == null || showInfo.SkillExTab == null)
{
_DragSkillOwnIdx = -1;
return;
}
for (int i = 0; i < Singleton<ObjManager>.GetInstance().MainPlayer.OwnSkillInfo.Length; ++i)
{
if (showInfo.SkillExTab.SkillExID == Singleton<ObjManager>.GetInstance().MainPlayer.OwnSkillInfo[i].SkillId)
{
_DragSkillOwnIdx = i;
return;
}
}
_DragSkillOwnIdx = -1;
}
public void ChangeSkillBar(int skillItemIdx)
{
if (_DragSkillOwnIdx < 0)
return;
if (skillItemIdx >= _CurSkillPage.SkillIdxs.Length)
return;
//SYK修改
for (int index = 0; index < _CurSkillPage.SkillIdxs.Length; index++)
{
//技能已经存在的情况
if (_CurSkillPage.SkillIdxs[index] == _DragSkillOwnIdx)
{
//index 技能存在位置下标
//目标位置ID与拖拽过来的技能ID相同
if (_CurSkillPage.SkillIdxs[skillItemIdx] == _DragSkillOwnIdx)
{
//不做操作 直接返回
return;
}
else
{
//目标位置技能ID置为拖拽过来的ID
_CurSkillPage.SkillIdxs[skillItemIdx] = _DragSkillOwnIdx;
//将存在技能的ID置为-1
_CurSkillPage.SkillIdxs[index] = -1;
}
//刷新界面
for (int i = 0; i < _CurSkillPage.SkillIdxs.Length; ++i)
{
if (i < _SkillBarItems.Length)
{
_SkillBarItems[index].InitSkillBar(_CurSkillPage.SkillIdxs[index], index);
}
}
return;
}
}
_CurSkillPage.SkillIdxs[skillItemIdx] = _DragSkillOwnIdx;
_SkillInfoPage.RefreshEquipedTag();
}
public void ExChangeSkillBar(int skillItemIdx)
{
if (_DragSkillOwnIdx < 0)
return;
if (skillItemIdx >= _CurSkillPage.SkillIdxs.Length)
return;
if (_DragSkillBar != null)
{
int tempIdx = _CurSkillPage.SkillIdxs[skillItemIdx];
_CurSkillPage.SkillIdxs[skillItemIdx] = _CurSkillPage.SkillIdxs[_DragSkillBar.SkillItemIdx];
_CurSkillPage.SkillIdxs[_DragSkillBar.SkillItemIdx] = tempIdx;
}
}
public void ClearSkillBar(int skillItemIdx)
{
if (skillItemIdx >= _CurSkillPage.SkillIdxs.Length)
return;
_CurSkillPage.SkillIdxs[skillItemIdx] = -1;
_SkillInfoPage.RefreshEquipedTag();
}
#endregion
#region
public GameObject RedTips;
public void UpdateRedTips()
{
if (CanAnySkillLvUp())
{
RedTips.SetActive(true);
foreach (var subItem in _SkillClasses.SubBtns)
{
((UISkillSubMenu)subItem.Key).UpdateTips();
}
foreach (var skillItem in _SkillInfoPage.SkillItems)
{
skillItem.UpdateRedTips();
}
}
else
{
RedTips.SetActive(false);
foreach (var subItem in _SkillClasses.SubBtns)
{
((UISkillSubMenu)subItem.Key).UpdateTips();
}
foreach (var skillItem in _SkillInfoPage.SkillItems)
{
skillItem.UpdateRedTips();
}
}
}
private static List<SkillRootItem.SkillShowInfo> totleList = null;
public static List<SkillRootItem.SkillShowInfo> GetAllSkillList()
{
// 全部可学技能列表,为未分类
totleList = new List<SkillRootItem.SkillShowInfo>();
// 保存玩家已经学的技能
var _MainPlayerOwnSkillInfo = Singleton<ObjManager>.GetInstance().MainPlayer.OwnSkillInfo;
for (int index = 0; index < _MainPlayerOwnSkillInfo.Length; index++)
{
var showInfo = new SkillRootItem.SkillShowInfo();
showInfo.SkillExTab = _MainPlayerOwnSkillInfo[index].SkillExTable;
if (showInfo.SkillExTab == null)
continue;
showInfo.SkillBase = _MainPlayerOwnSkillInfo[index].SkillBaseTable;
Tab_SkillLevelUp skillnext = TableManager.GetSkillLevelUpByID(_MainPlayerOwnSkillInfo[index].SkillExTable.NextSkillId, 0);
showInfo.SkillLevelUp = skillnext;
if (!IsSimpleAttack(skillnext)) //脑残普攻
totleList.Add(showInfo);
}
// 获得所有可学技能列表
var learnList = TableManager.GetSkillLearn().Values;
foreach (var tabAct in learnList)
{
if (tabAct.Profession != GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession)
continue;
// 获取每个技能相关信息
Tab_SkillEx skillEx = TableManager.GetSkillExByID(tabAct.SkillId, 0);
Tab_SkillBase skillBase = TableManager.GetSkillBaseByID(skillEx.BaseId, 0);
var skillInfo = totleList.Find((showInfo) =>
{
if (showInfo.SkillBase.Id == skillEx.BaseId)
{
return true;
}
return false;
});
if (skillInfo != null)
{
skillInfo.SkillLearn = tabAct;
}
else
{
SkillRootItem.SkillShowInfo showInfo = new SkillRootItem.SkillShowInfo();
showInfo.SkillLearn = tabAct;
showInfo.SkillBase = skillBase;
showInfo.SkillLevelUp = TableManager.GetSkillLevelUpByID(skillEx.SkillExID, 0);
totleList.Add(showInfo);
}
}
return totleList;
}
public static bool CanAnySkillLvUp()
{
//Debug.LogError("Count : " + GetAllSkillList().Count);
for(int i = 0; i < GetAllSkillList().Count; i++)
{
var skillInfo = SkillRootLogic.totleList[i];
var _IsOwnSkill = false;
var skillnext = skillInfo.SkillLevelUp;
if (skillnext == null)
continue;
if (IsSimpleAttack(skillnext))
continue;
if (!IsAlreadyHaveNeedSkill(skillnext, skillInfo.SkillBase))
continue;
if (skillnext == null)
continue;
if (skillnext.IsMaxLevel > 0)
continue;
if (skillnext.Level > GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level)
continue;
var isItemEnough = true;
var isMoneyEnough = true;
var isExpEnough = true;
for (int index = 0; index < skillnext.getConsumTypeCount(); index++)
{
var type = skillnext.GetConsumTypebyIndex(index);
if (type != -1)
{
switch (type)
{
case (int)CONSUM_TYPE.PROPVAL:
{
if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.SkillExp < skillnext.GetConsumValbyIndex(0))
isExpEnough = false;
}
break;
case (int)CONSUM_TYPE.PROPPER:
{
//没配
}
break;
case (int)CONSUM_TYPE.ITEM:
{
if (GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(skillnext.GetConsumIdbyIndex(index)) < skillnext.GetConsumValbyIndex(index))
isItemEnough = false;
}
break;
case (int)CONSUM_TYPE.MONEY:
{
if (GameManager.gameManager.PlayerDataPool.Money.GetMoneyByType(MONEYTYPE.MONEYTYPE_COIN_BIND) < skillnext.GetConsumValbyIndex(1))
isMoneyEnough = false;
}
break;
}
}
}
if (isExpEnough && isItemEnough && isMoneyEnough)
{
UpdateFunctionTips(true);
return true;
}
}
UpdateFunctionTips(false);
return false;
}
static bool IsSimpleAttack(Tab_SkillLevelUp skillTab)
{
if (skillTab == null)
return false;
if (skillTab.IsMaxLevel == 1)
return false;
for(int index = 0; index < skillTab.getConsumValCount(); index++)
{
if (skillTab.GetConsumValbyIndex(index) != -1)
return false;
}
return true;
}
public static void UpdateFunctionTips(bool state)
{
RedTipPoint.RedPointStateChange(RedTipPoint.PointType.Skill, state);
}
public static bool IsAlreadyHaveNeedSkill(Tab_SkillLevelUp skillNext, Tab_SkillBase skillBase)
{
var alreadyHaveSkill = true;
var isOwnSkill = false;
for(int index = 0; index < skillNext.getNeedSkillIdCount(); index++)
{
if(skillNext.GetNeedSkillIdbyIndex(index) != -1)
{
var needSkill = TableManager.GetSkillExByID(skillNext.GetNeedSkillIdbyIndex(index), 0);
if (needSkill == null)
continue;
if (needSkill.BaseId != skillBase.Id) //2级需要判断有1级这个是不用判断的必然有1级技能已经学会才能升级为2级
{
foreach (var ownSkill in Singleton<ObjManager>.GetInstance().MainPlayer.OwnSkillInfo)
{
var skillEx = ownSkill.SkillExTable;
if (skillEx == null)
continue;
if (needSkill.BaseId == skillEx.BaseId)
isOwnSkill = true;
if (needSkill.BaseId == skillEx.BaseId && skillEx.Level < needSkill.Level)
{
alreadyHaveSkill = false;
break;
}
}
if (!isOwnSkill)
return false;
}
}
}
return alreadyHaveSkill;
}
public static bool CanSkillItemLvUp(SkillRootItem.SkillShowInfo skillShowInfo)
{
Tab_SkillLevelUp skillnext = skillShowInfo.SkillLevelUp;
if (skillnext == null)
return false;
if (skillnext.IsMaxLevel > 0)
return false;
if (IsSimpleAttack(skillnext))
return false;
if (!IsAlreadyHaveNeedSkill(skillnext, skillShowInfo.SkillBase))
return false;
if (skillnext.Level > GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level)
return false;
for (int index = 0; index < skillnext.getConsumTypeCount(); index++)
{
var type = skillnext.GetConsumTypebyIndex(index);
if (type != -1)
{
switch (type)
{
case (int)CONSUM_TYPE.PROPVAL:
{
if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.SkillExp < skillnext.GetConsumValbyIndex(0))
return false;
}
break;
case (int)CONSUM_TYPE.PROPPER:
{
//没配
}
break;
case (int)CONSUM_TYPE.ITEM:
{
if (GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(skillnext.GetConsumIdbyIndex(index)) < skillnext.GetConsumValbyIndex(index))
return false;
}
break;
case (int)CONSUM_TYPE.MONEY:
{
if (GameManager.gameManager.PlayerDataPool.Money.GetMoneyByType(MONEYTYPE.MONEYTYPE_COIN_BIND) < skillnext.GetConsumValbyIndex(index))
return false;
}
break;
}
}
}
return true;
}
#endregion
}