using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
using System.Linq;
|
using System.Text.RegularExpressions;
|
using System;
|
namespace vnxbqy.UI
|
{
|
public class MethodToWin : Window, SecondWindowInterface
|
{
|
//心法
|
[SerializeField] ScrollerController m_ScrollerController;
|
private int indexID = -1;//获取默认选中
|
|
[SerializeField] Transform _SkillContentBGM;//右侧信息面板
|
[SerializeField] Text _SkillLevelText;//当前技能等级信息
|
[SerializeField] Image _SkillImage;//技能图标
|
[SerializeField] Text m_LowerCurrentAttribute;//当前属性文本框
|
[SerializeField] Text m_Properties;//下级属性框文本
|
[SerializeField] Text m_PrimaryAttribute;//基本属性文本
|
[SerializeField] Text m_PrimaryAttributeA;//当前属性
|
[SerializeField] Text _NeedNum;//所需的贡献度
|
[SerializeField] Button _UpSkillBtn;//升级按钮
|
[SerializeField] RedpointBehaviour m_RedpointBehaviourUpBtn;
|
[SerializeField] GameObject m_gameObject;
|
[SerializeField] Button m_ApproachButton;
|
public bool _request = false;//控制刷新
|
Dictionary<int, int> _dicFamilylv;//心法学习等级
|
Dictionary<int, string> _dicFamilyIcon;//心法Icon
|
Dictionary<int, string> _dicFamilyName;//心法名
|
|
private AchievementGuideEffect AchievementGuideEffect1;
|
enum BasicAttribute
|
{
|
BasicsAttack = 1,//基础攻击
|
BasicsLife = 2,//基础生命
|
BasicsDefense = 3,//基础防御
|
BasicsScoreAHit = 4,//基础命中
|
BasicsDodge = 5,//基础闪避
|
Hurt = 6,//真实伤害
|
Resistance = 7,//真实抵抗
|
//后续IL开发添加预设
|
default1,
|
default2,
|
default3,
|
default4,
|
default5,
|
default6,
|
default7,
|
default8,
|
default9,
|
default10,
|
}
|
public void Basic_Attribute(int id)
|
{
|
var config = FamilyTechConfig.Get(id * 1000 + 1);
|
if (config == null)
|
{
|
return;
|
}
|
var propertyConfig = PlayerPropertyConfig.Get(config.attrType);
|
switch ((BasicAttribute)id)
|
{
|
case BasicAttribute.BasicsAttack:
|
m_PrimaryAttribute.text = Language.Get("MethodTo_C", propertyConfig.ISPercentage == 0 ? (int)UIHelper.GetPropertyValue((PropertyType)config.attrType)
|
: PlayerDatas.Instance.baseData.BasicsMaxAttack);
|
break;
|
case BasicAttribute.BasicsLife:
|
m_PrimaryAttribute.text = Language.Get("MethodTo_D", propertyConfig.ISPercentage == 0 ? (int)UIHelper.GetPropertyValue((PropertyType)config.attrType) :
|
PlayerDatas.Instance.baseData.BasicsLife);
|
break;
|
case BasicAttribute.BasicsDefense:
|
m_PrimaryAttribute.text = Language.Get("MethodTo_E", propertyConfig.ISPercentage == 0 ? (int)UIHelper.GetPropertyValue((PropertyType)config.attrType) :
|
PlayerDatas.Instance.baseData.BasicsDefense);
|
break;
|
case BasicAttribute.BasicsScoreAHit:
|
m_PrimaryAttribute.text = Language.Get("MethodTo_F", propertyConfig.ISPercentage == 0 ? (int)UIHelper.GetPropertyValue((PropertyType)config.attrType) :
|
PlayerDatas.Instance.baseData.BasicsScoreAHit);
|
break;
|
case BasicAttribute.BasicsDodge:
|
m_PrimaryAttribute.text = Language.Get("MethodTo_G", propertyConfig.ISPercentage == 0 ? (int)UIHelper.GetPropertyValue((PropertyType)config.attrType) :
|
PlayerDatas.Instance.baseData.BasicsDodge);
|
break;
|
case BasicAttribute.Hurt:
|
m_PrimaryAttribute.text = Language.Get("MethodTo_H", propertyConfig.ISPercentage == 0 ? (int)UIHelper.GetPropertyValue((PropertyType)config.attrType) :
|
PlayerDatas.Instance.extersion.realATK);
|
break;
|
case BasicAttribute.Resistance:
|
m_PrimaryAttribute.text = Language.Get("MethodTo_I", propertyConfig.ISPercentage == 0 ? (int)UIHelper.GetPropertyValue((PropertyType)config.attrType) :
|
PlayerDatas.Instance.extersion.realDEF);
|
break;
|
}
|
|
}
|
PlayerMethodData M_Method;
|
PlayerMethodData method { get { return M_Method ?? (M_Method = ModelCenter.Instance.GetModel<PlayerMethodData>()); } }
|
PlayerMainDate M_mainModel;
|
PlayerMainDate mainModel { get { return M_mainModel ?? (M_mainModel = ModelCenter.Instance.GetModel<PlayerMainDate>()); } }
|
|
public Button close { get; set; }
|
|
protected override void BindController()
|
{
|
if (this is SecondWindowInterface)
|
{
|
var frame = this.GetComponentInChildren<SecondFrameLoader2>();
|
frame.Create();
|
close = frame.GetComponentInChildren<Button>();
|
}
|
|
_dicFamilylv = ConfigParse.GetDic<int, int>(FuncConfigConfig.Get("FamilyTechNeedLV").Numerical1);
|
_dicFamilyIcon = ConfigParse.GetDic<int, string>(FuncConfigConfig.Get("FamilyTechIcon").Numerical1);
|
_dicFamilyName = ConfigParse.GetDic<int, string>(FuncConfigConfig.Get("FamilyTechIcon").Numerical2);
|
}
|
|
protected override void AddListeners()
|
{
|
_UpSkillBtn.onClick.AddListener(UpSkillButton);
|
close.onClick.AddListener(CloseButton);
|
m_ApproachButton.AddListener(ApproachButton);
|
}
|
|
protected override void OnPreOpen()
|
{
|
m_ScrollerController.OnRefreshCell += OnRefreshGridCell;
|
PlayerMethodData.Event_CepaContribution += OnCepaContribution;//刷新战盟贡献度
|
PlayerMethodData.EventHA504 += HA504;//心法刷新
|
PlayerDatas.Instance.playerDataRefreshEvent += Updatefighting;//数据的刷新(h0418)
|
GetIndexID();
|
OnCreateGridLineCell(m_ScrollerController);
|
m_ScrollerController.JumpIndex(JunpIndex() - 1);
|
|
}
|
|
protected override void OnAfterOpen()
|
{
|
HandleAchievement();
|
}
|
|
protected override void OnPreClose()
|
{
|
indexID = -1;
|
}
|
|
protected override void OnAfterClose()
|
{
|
m_ScrollerController.OnRefreshCell -= OnRefreshGridCell;
|
PlayerMethodData.EventHA504 -= HA504;//心法刷新
|
PlayerDatas.Instance.playerDataRefreshEvent -= Updatefighting;//数据的刷新(h0418)
|
PlayerMethodData.Event_CepaContribution -= OnCepaContribution;//刷新战盟贡献度
|
|
}
|
|
private void Updatefighting(PlayerDataType _tCDBPlayerRefresh)
|
{
|
switch (_tCDBPlayerRefresh)
|
{
|
case PlayerDataType.LV://等级的刷新8
|
m_ScrollerController.m_Scorller.RefreshActiveCellViews();
|
break;
|
default:
|
if (indexID != -1)
|
{
|
Basic_Attribute(indexID);
|
}
|
break;
|
}
|
}
|
|
private void GetIndexID()
|
{
|
foreach (int key in method._DicSkill.Keys)
|
{
|
if (method.MethodRedPointBtnDic.ContainsKey(key))
|
{
|
if (method.MethodRedPointBtnDic[key].state == RedPointState.Simple)
|
{
|
indexID = key;
|
return;
|
}
|
}
|
}
|
indexID = 1;
|
|
}
|
|
private int JunpIndex()
|
{
|
foreach (int key in method._DicSkill.Keys)
|
{
|
if (method.MethodRedPointBtnDic.ContainsKey(key))
|
{
|
if (method.MethodRedPointBtnDic[key].state == RedPointState.Simple)
|
{
|
indexID = key;
|
return key;
|
}
|
}
|
}
|
return 0;
|
}
|
|
void OnCreateGridLineCell(ScrollerController gridCtrl)//预制体创建
|
{
|
gridCtrl.Refresh();
|
foreach (int key in method._DicSkill.Keys)
|
{
|
gridCtrl.AddCell(ScrollerDataType.Header, key);
|
}
|
gridCtrl.Restart();
|
}
|
void OnRefreshGridCell(ScrollerDataType type, CellView cell)
|
{
|
int id = cell.index;
|
MethodToButton methToButton = cell.GetComponent<MethodToButton>();
|
methToButton.RedPoint.redpointId = method.MethodRedPointDic[id].id;
|
methToButton.SelectedImage.SetActive(false);
|
int playerLV = PlayerDatas.Instance.baseData.LV;
|
if (_dicFamilylv.ContainsKey(id))
|
{
|
methToButton.SkillIcom.SetSprite(_dicFamilyIcon[id]);
|
if (playerLV >= _dicFamilylv[id])
|
{
|
if (method._DicSkill[id].SkillLV > 0)
|
{
|
methToButton.SkillName.text = "<color=#401c06>" + _dicFamilyName[id] + "</color>";
|
methToButton.LV_Text.SetActive(true);
|
methToButton.LV_Text.text = "<color=#109d06>LV" + method._DicSkill[id].SkillLV + "</color>";
|
}
|
else
|
{
|
methToButton.LV_Text.SetActive(false);
|
methToButton.SkillName.text = "<color=#401c06>" + _dicFamilyName[id] + "</color>" + "</r>" + Language.Get("Z1039");
|
}
|
}
|
else
|
{
|
methToButton.LV_Text.SetActive(false);
|
methToButton.SkillName.text = "<color=#401c06>" + _dicFamilyName[id] + "</color>" + "</r>" + string.Format(Language.Get("Z1040"), _dicFamilylv[id]);
|
}
|
}
|
|
if (indexID == id)
|
{
|
methToButton.SelectedImage.SetActive(true);
|
m_RedpointBehaviourUpBtn.redpointId = method.MethodRedPointBtnDic[id].id;
|
DynamicAssignment(id);
|
}
|
methToButton.MethodTobtn.RemoveAllListeners();
|
methToButton.MethodTobtn.AddListener(() =>
|
{
|
if (AchievementGuideEffect1 != null)
|
{
|
AchievementGuideEffectPool.Recycle(AchievementGuideEffect1);
|
}
|
indexID = id;
|
m_ScrollerController.m_Scorller.RefreshActiveCellViews();
|
|
});
|
}
|
void CloseButton()
|
{
|
Close();
|
}
|
|
private void ApproachButton()
|
{
|
ItemTipUtility.Show(mainModel.GetCurrencyItemID[6]);
|
|
}
|
|
void DynamicAssignment(int id)//右侧面板赋值
|
{
|
//心法可学习等级
|
Basic_Attribute(id);
|
_SkillImage.SetSprite(_dicFamilyIcon[id]);
|
var configFamilyTech = FamilyTechConfig.Get(method._DicSkill[id].SkillID + 1);
|
var configFamilyTechOne = FamilyTechConfig.Get(method._DicSkill[id].SkillID + 2);
|
int _attrValue = 0;
|
if (method._DicSkill[id].SkillLV > 0)
|
{
|
_SkillLevelText.text = _dicFamilyName[id] + " " + Language.Get("LoadIconLV", method._DicSkill[id].SkillLV);
|
var configFamilyNow = FamilyTechConfig.Get(method._DicSkill[id].SkillID);
|
var propertyConfig = PlayerPropertyConfig.Get(configFamilyNow.attrType);
|
if (configFamilyTech != null)
|
{
|
_attrValue = configFamilyTech.attrType;
|
m_LowerCurrentAttribute.text = string.Format(Language.Get("MethodTo_A"),
|
propertyConfig.Name, UIHelper.ReplacePercentage(configFamilyNow.attrValue, propertyConfig.ISPercentage) +
|
(propertyConfig.ISPercentage == 1 ? "%" : string.Empty));
|
}
|
else
|
{
|
var configFamilyTechMax = FamilyTechConfig.Get(method._DicSkill[id].SkillID);
|
int _attrValueMax = configFamilyTechMax.attrType;
|
m_LowerCurrentAttribute.text = string.Format(Language.Get("MethodTo_A"),
|
propertyConfig.Name, UIHelper.ReplacePercentage(configFamilyNow.attrValue, propertyConfig.ISPercentage) +
|
(propertyConfig.ISPercentage == 1 ? "%" : string.Empty));
|
}
|
if (configFamilyTech != null)
|
{
|
|
m_Properties.text = string.Format(Language.Get("MethodTo_B"),
|
propertyConfig.Name, UIHelper.ReplacePercentage(configFamilyTech.attrValue, propertyConfig.ISPercentage) +
|
(propertyConfig.ISPercentage == 1 ? "%" : string.Empty));
|
}
|
else
|
{
|
m_Properties.text = Language.Get("L1055");
|
}
|
if (configFamilyTech != null)
|
{
|
m_gameObject.SetActive(true);
|
if (method._ContributionNumber >= configFamilyTech.needPoint)
|
{
|
_NeedNum.text = "<color=#109d06>" + method._ContributionNumber.ToString() + "</color>/" + configFamilyTech.needPoint.ToString();
|
}
|
else
|
{
|
_NeedNum.text = "<color=#fa0101>" + method._ContributionNumber.ToString() + "</color>/" + configFamilyTech.needPoint.ToString();
|
}
|
}
|
else
|
{
|
m_gameObject.SetActive(false);
|
|
}
|
|
|
}
|
else
|
{
|
_SkillLevelText.text = _dicFamilyName[id] + " " + Language.Get("LoadIconLV", (method._DicSkill[id].SkillLV + 1));
|
var propertyConfig = PlayerPropertyConfig.Get(configFamilyTechOne.attrType);
|
m_LowerCurrentAttribute.text = string.Format(Language.Get("MethodTo_A"),
|
propertyConfig.Name, UIHelper.ReplacePercentage(0, propertyConfig.ISPercentage) +
|
(propertyConfig.ISPercentage == 1 ? "%" : string.Empty));
|
m_Properties.SetActive(true);
|
m_Properties.text = string.Format(Language.Get("MethodTo_B"),
|
propertyConfig.Name, UIHelper.ReplacePercentage(configFamilyTech.attrValue, propertyConfig.ISPercentage) +
|
(propertyConfig.ISPercentage == 1 ? "%" : string.Empty));
|
m_gameObject.SetActive(true);
|
if (method._ContributionNumber >= configFamilyTech.needPoint)
|
{
|
_NeedNum.text = "<color=#109d06>" + method._ContributionNumber.ToString() + "</color>/" + configFamilyTech.needPoint.ToString();
|
}
|
else
|
{
|
_NeedNum.text = "<color=#fa0101>" + method._ContributionNumber.ToString() + "</color>/" + configFamilyTech.needPoint.ToString();
|
}
|
}
|
}
|
|
void UpSkillButton()//提升按钮
|
{
|
int Playerlv = PlayerDatas.Instance.baseData.LV;
|
var Skill = _dicFamilylv[indexID];
|
var configFamilyTech = FamilyTechConfig.Get(method._DicSkill[indexID].SkillID + 1);
|
if (configFamilyTech == null)
|
{
|
ScrollTip.ShowTip(Language.Get("FullHeart_Z"));
|
return;
|
}
|
if (Playerlv >= Skill)
|
{
|
if (Conditional())
|
{
|
|
CA607_tagCMFamilyTechLVUP tag_CA607 = new CA607_tagCMFamilyTechLVUP();
|
tag_CA607.TechID = (uint)indexID;
|
GameNetSystem.Instance.SendInfo(tag_CA607);
|
// DebugEx.LogError("输出心法科技需要提升的技能IndexID"+ indexID);
|
}
|
else
|
{
|
ItemTipUtility.Show(mainModel.GetCurrencyItemID[6]);
|
}
|
}
|
else
|
{
|
ScrollTip.ShowTip(Language.Get("SkillNotUnlocked_Z"));
|
}
|
|
}
|
|
bool Conditional()//条件判断(是否能够提升)
|
{
|
int Playerlv = PlayerDatas.Instance.baseData.LV;
|
if (method._DicSkill[indexID].SkillLV > 0)
|
{
|
if (method._ContributionNumber >= FamilyTechConfig.Get(method._DicSkill[indexID].SkillID + 1).needPoint)
|
{
|
return true;
|
}
|
}
|
else
|
{
|
if (method._ContributionNumber >= FamilyTechConfig.Get(method._DicSkill[indexID].SkillID + 1).needPoint && Playerlv >= _dicFamilylv[indexID])
|
{
|
return true;
|
}
|
}
|
|
return false;
|
}
|
|
void HA504()//获取心法技能信息
|
{
|
m_ScrollerController.m_Scorller.RefreshActiveCellViews();
|
}
|
|
void OnCepaContribution()//刷新仙盟贡献度
|
{
|
m_ScrollerController.m_Scorller.RefreshActiveCellViews();
|
}
|
private void HandleAchievement()
|
{
|
if (AchievementGoto.achievementType == AchievementGoto.MethodToUpgrade1)//心法升级(破军216,强壮217,218坚固)
|
{
|
SuccessConfig successConfig = SuccessConfig.Get(AchievementGoto.guideAchievementId);
|
int[] MethodId = successConfig.Condition;
|
indexID = MethodId[0];
|
m_ScrollerController.JumpIndex(indexID - 1);
|
m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
|
|
if (AchievementGoto.guideAchievementId == 216)
|
{
|
if (Conditional())
|
{
|
AchievementGuideEffect1 = AchievementGuideEffectPool.Require(1);
|
if (AchievementGuideEffect1.effect != null)
|
{
|
AchievementGuideEffect1.effect.ResetOrder(3500);
|
}
|
AchievementGuideEffect1.transform.SetParentEx(_UpSkillBtn.transform, Vector3.zero, Vector3.zero, Vector3.one);
|
}
|
else
|
{
|
SysNotifyMgr.Instance.ShowTip("MethodShowTipAchievement1 ");
|
}
|
|
}
|
else if (AchievementGoto.guideAchievementId == 217)
|
{
|
if (Conditional())
|
{
|
AchievementGuideEffect1 = AchievementGuideEffectPool.Require(1);
|
if (AchievementGuideEffect1.effect != null)
|
{
|
AchievementGuideEffect1.effect.ResetOrder(3500);
|
}
|
AchievementGuideEffect1.transform.SetParentEx(_UpSkillBtn.transform, Vector3.zero, Vector3.zero, Vector3.one);
|
}
|
else
|
{
|
SysNotifyMgr.Instance.ShowTip("MethodShowTipAchievement1 ");
|
}
|
}
|
else if (AchievementGoto.guideAchievementId == 218)
|
{
|
if (Conditional())
|
{
|
AchievementGuideEffect1 = AchievementGuideEffectPool.Require(1);
|
if (AchievementGuideEffect1.effect != null)
|
{
|
AchievementGuideEffect1.effect.ResetOrder(3500);
|
}
|
AchievementGuideEffect1.transform.SetParentEx(_UpSkillBtn.transform, Vector3.zero, Vector3.zero, Vector3.one);
|
}
|
else
|
{
|
SysNotifyMgr.Instance.ShowTip("MethodShowTipAchievement1 ");
|
}
|
}
|
|
}
|
|
|
}
|
}
|
}
|