using Games.LogicObj; using UnityEngine; using UnityEngine.UI; using System.Collections; using GCGame; using Module.Log; using Games.GlobeDefine; using System.Collections.Generic; using System; using GCGame.Table; using Games.Events; public class MeridiaSoul : MonoBehaviour { class BloodVeinNodeData { public int nodeId; public int nodeLv; public int CanUP; public int OPenLv; } public class BloodVeinAttrData { public int ProId; public long ProVal; } public GameObject VesselWnd; public UIContainerSelect m_Left; public UIContainerSelect m_Right; public UIContainerBase m_AllAdd; public UIContainerBase m_OneAdd; public Image PayQuilityIcon; public Image PayIcon; public Text PayName; public Text PayNum; public GameObject GetButtonObj; public Image CurrentSelectImage; public Text CurrentSelectName; public UIImgText _Power; public Text Have; public Toggle IsAutoBuy; public Text Sual; public GameObject SualEffect; public Text AttrName; public GameObject ChildWnd; public MeridiaSoulPoint BreakPointChildObj; public Transform[] BreakPointObjs; private List BreakPoints = new List(); public Text VesselState; public Text VesselCondition; public Text VesselCur; public GameObject AttrAdd; public Text VesselNextState; public Text VesselNextCondition; public Text VesselNextCur; public GameObject AttrNextAdd; public GameObject AutoUPStopBtn; public Text speedText; private int totleLevel; private int m_CurrentSelVeinID = -1; private int m_CurrentSelNodeID = -1; public LayoutElement Current; public LayoutElement Next; private int initCount = 0; // 用于记录左右两边Container初始次数,到达两次代表均初始化,用于红点更新。 private void CreatePoint() { for(int i=0;i< BreakPointObjs.Length;i++) { MeridiaSoulPoint point = GameObject.Instantiate(BreakPointChildObj); if(point==null) { continue; } point.gameObject.SetActive(true); point.transform.SetParent(BreakPointObjs[i]); point.transform.localPosition = Vector3.zero; point.transform.localEulerAngles = Vector3.zero; point.transform.localScale = Vector3.one; BreakPoints.Add(point); } } private void OnDisable() { AutoStop(); } private void Update() { if (DataDuty) { switch(ShowStep) { case 0: Show();ShowStep = 1 ;return; case 1: FreshItem(); ShowStep = 2; return; case 2: FreshAllAttr(); ShowStep = -1; DataDuty = false; return; } } if(AutoUping) { if(_LastUpTime > 0 && _LastUpTime - Time.realtimeSinceStartup <=0) { AutoUp(); } } } bool DataDuty = false; int ShowStep = 0; public void SetDataDuty() { DataDuty = true; ShowStep = 0; } public void Show() { ShowVeins(); totleLevel = MeridiaSoulData.Instance.GetAllNodeLevelCount(); Sual.text = StrDictionary.GetClientDictionaryString("#{46007}", totleLevel); SualEffect.SetActive(GetLinkLevel() >= 1); } public void UpGrade(object args) { FreshShowInfo(m_CurrentSelVeinID,(int)args); totleLevel = MeridiaSoulData.Instance.GetAllNodeLevelCount(); Sual.text = StrDictionary.GetClientDictionaryString("#{46007}", totleLevel); SualEffect.SetActive(GetLinkLevel() >= 1); FreshItem(); FreshAllAttr(); } private float speed = 1; private bool AutoUping = false; private float _LastUpTime = 0; public void AddSpeed() { speed = speed * 2; if (speed > 4.0f) speed = 1.0f; speedText.text = StrDictionary.GetClientDictionaryString("#{5303}", speed); } private void AutoUp() { Tab_BloodVeinConfig bloodVonfig = TableManager.GetBloodVeinConfigByID(m_CurrentSelVeinID, 0); if (bloodVonfig == null) return; int SelNodeID = -1; int lastNodeOpenLevel = -1; int lastNodeLevel = -1; bool IsAllMaX = true; for (int index = 0;index 0) { CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, PayIcon.transform); } else { CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, PayIcon.transform); } GetButtonObj.SetActive(has<=0); } public void ItemToolTip() { ItemTooltipsLogic.ShowItemTooltip(923, ItemTooltipsLogic.ShowType.Info,Vector3.zero); } public void GetItem() { ItemTooltipsLogic.ShowItemTooltip(923, ItemTooltipsLogic.ShowType.GetPath, transform.position); } public void FreshAllAttr() { var totlePower = 0; Dictionary AllAttrs = new Dictionary(); var tabs = TableManager.GetBloodVeinConfig().Values; foreach (var VeinConfig in tabs) { //计算所有属性加成 for (int j = 0; j < VeinConfig.getNodeCount(); j++) { int nodeId = VeinConfig.GetNodebyIndex(j); MeridiaSoulData.VeinNodeData veinData = MeridiaSoulData.Instance.GetNodeData(VeinConfig.VeinID, nodeId); nodeId = nodeId * 1000; if (veinData != null) { nodeId = nodeId + veinData.level; } Tab_BloodVeinNode veinNode = TableManager.GetBloodVeinNodeByID(nodeId, 0); if (veinNode == null) continue; for (int pro = 0; pro < veinNode.getPropIdCount(); pro++) { BloodVeinAttrData attr = new BloodVeinAttrData(); attr.ProId = veinNode.GetPropIdbyIndex(pro); attr.ProVal = veinNode.GetPropValbyIndex(pro); if (attr.ProId == -1) continue; if (AllAttrs.ContainsKey(attr.ProId)) { BloodVeinAttrData attdata = AllAttrs[attr.ProId]; attdata.ProVal = attdata.ProVal + attr.ProVal; AllAttrs[attr.ProId] = attdata; } else { BloodVeinAttrData attdata = new BloodVeinAttrData(); attdata.ProId = attr.ProId; attdata.ProVal = attr.ProVal; AllAttrs[attr.ProId] = attdata; } } totlePower += veinNode.Power; } } totlePower += CountNodeBonus(AllAttrs); List attrs = new List(AllAttrs.Values); m_AllAdd.InitContentItem(attrs); _Power.text = totlePower.ToString(); } public int CountNodeBonus(Dictionary AllAttrs) { Tab_BloodVeinNodeBonus nodeBonus = TableManager.GetBloodVeinNodeBonusByID(GetLinkLevel(), 0); if(nodeBonus!=null) { for (int j = 0; j < nodeBonus.getPropIdCount(); j++) { int ProId = nodeBonus.GetPropIdbyIndex(j); int ProValue = nodeBonus.GetPropValbyIndex(j); if (ProId == -1) continue; if (AllAttrs.ContainsKey(ProId)) { BloodVeinAttrData attdata = AllAttrs[ProId]; attdata.ProVal = attdata.ProVal + ProValue; AllAttrs[ProId] = attdata; } else { BloodVeinAttrData attdata = new BloodVeinAttrData(); attdata.ProId = ProId; attdata.ProVal = ProValue; AllAttrs[ProId] = attdata; } } return nodeBonus.Power; } return 0; } public void ShowVeins() { List lefts = new List(); var tabs = TableManager.GetBloodVeinConfig().Values; var n = 0; foreach (var VeinConfig in tabs) { MeridiaItem.MeridiaItemData data = new MeridiaItem.MeridiaItemData(); data.VeinID = VeinConfig.VeinID; data.icon = VeinConfig.Icon; data.attrName = VeinConfig.AttrName; data.name = VeinConfig.Name; data.openLevel = VeinConfig.VeinOpenLevel; lefts.Add(data); n++; } List selects = new List(); if (lefts.Count > 0) selects.Add(lefts[0]); m_Left.InitSelectContent(lefts, selects, ItemClick); } public void ContentReFresh() { m_Left.RefreshItems(); m_Right.RefreshItems(); FreshItem(); if (AutoUping) _LastUpTime = Time.realtimeSinceStartup + 1f / speed; FreshShowInfo(m_CurrentSelVeinID); } public void UP_Click(int index) { AutoStop(); Tab_BloodVeinConfig bloodVonfig = TableManager.GetBloodVeinConfigByID(m_CurrentSelVeinID, 0); if (bloodVonfig == null) return; //判断开启等级 if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level < bloodVonfig.GetOpenLvbyIndex(index)) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{47300}")); return; } //判断消耗 int nodeID = bloodVonfig.GetNodebyIndex(index); m_CurrentSelNodeID = nodeID; MeridiaSoulData.VeinNodeData VeinData = MeridiaSoulData.Instance.GetNodeData(m_CurrentSelVeinID, nodeID); nodeID *= 1000; if (VeinData != null) { nodeID += VeinData.level; } Tab_BloodVeinNode node = TableManager.GetBloodVeinNodeByID(nodeID, 0); if (node == null) return; Tab_BloodVeinNode nodeNext = TableManager.GetBloodVeinNodeByID(nodeID + 1, 0); if (nodeNext == null) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("{#25125}")); return; } long hasCount0 = Utils.GetConstHas(node.GetCostTypebyIndex(0), node.GetCostSubbyIndex(0)); long hasCount1 = Utils.GetConstHas(node.GetCostTypebyIndex(1), node.GetCostSubbyIndex(1)); int needCount0 = node.GetCostValbyIndex(0); int needCount1 = node.GetCostValbyIndex(1); if(hasCount0 < needCount0 && hasCount1 < needCount1) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("{#47304}")); return; } ReqUpgradeVein cmd = new ReqUpgradeVein(); cmd.isMoney = 0; cmd.nodeId = m_CurrentSelNodeID; cmd.SendMsg(); } public void PayLinyu() { ReqUpgradeVein cmd = new ReqUpgradeVein(); cmd.isMoney = 1; cmd.nodeId = m_CurrentSelNodeID; cmd.SendMsg(); } public void FreshShowInfo(int VeinID, int UpnodeId = -1) { Tab_BloodVeinConfig bloodVonfig = TableManager.GetBloodVeinConfigByID(VeinID, 0); if (bloodVonfig == null) return; if(BreakPoints.Count<=0) { CreatePoint(); } CurrentSelectImage.gameObject.SetActive(true); LoadAssetBundle.Instance.SetImageSprite(CurrentSelectImage, bloodVonfig.Icon); Dictionary AllAttrs = new Dictionary(); AttrName.text = bloodVonfig.Name; m_CurrentSelVeinID = VeinID; for(int i=0;i i) { int result = BreakPoints[i].ShowInfo(VeinID, nodeID, bloodVonfig.GetOpenLvbyIndex(i)); if(result > 0) CountOneAttr(result, AllAttrs); if (UpnodeId != -1 && UpnodeId != nodeID) continue; if (UpnodeId == nodeID) { BreakPoints[i].UPLevel(); } } } List attrs = new List(AllAttrs.Values); m_OneAdd.InitContentItem(attrs); if(attrs.Count>0) { CurrentSelectName.text = string.Format("{0} {1}", PropID.GetAttrName((PropID.PropertyID)attrs[0].ProId), attrs[0].ProVal); } else { CurrentSelectName.text = bloodVonfig.Name; } } public void CountOneAttr(int nodeID , Dictionary AllAttrs) { Tab_BloodVeinNode node = TableManager.GetBloodVeinNodeByID(nodeID, 0); if (node == null) { return; } for (int pro = 0; pro < node.getPropIdCount(); pro++) { BloodVeinAttrData attr = new BloodVeinAttrData(); attr.ProId = node.GetPropIdbyIndex(pro); attr.ProVal = node.GetPropValbyIndex(pro); if (attr.ProId == -1) continue; if (AllAttrs.ContainsKey(attr.ProId)) { BloodVeinAttrData attdata = AllAttrs[attr.ProId]; attdata.ProVal = attdata.ProVal + attr.ProVal; AllAttrs[attr.ProId] = attdata; } else { BloodVeinAttrData attdata = new BloodVeinAttrData(); attdata.ProId = attr.ProId; attdata.ProVal = attr.ProVal; AllAttrs[attr.ProId] = attdata; } } } public void ShowNodeModel(Animator anim,int VeinID, int nodeID) { MeridiaSoulData.VeinNodeData VeinData = MeridiaSoulData.Instance.GetNodeData(VeinID, nodeID); nodeID *= 1000; if (VeinData != null) { nodeID += VeinData.level; } Tab_BloodVeinNode node = TableManager.GetBloodVeinNodeByID(nodeID, 0); if (node == null) { return; } anim.CrossFade(node.Icon, 0); } public void ItemClick(object initInfo) { AutoStop(); MeridiaItem.MeridiaItemData info = initInfo as MeridiaItem.MeridiaItemData; if (info == null) { //LogModule.DebugLog("GuildPreviewInfo is null"); return; } FreshShowInfo(info.VeinID); } List attrObjs = new List(); public void Close_Vessel() { ChildWnd.SetActive(false); VesselWnd.SetActive(false); } public int GetLinkLevel() { var links = TableManager.GetBloodVeinNodeBonus().Values; foreach (var link in links) { if (totleLevel >= link.TotalLvMin && totleLevel <= link.TotalLvMax) { return link.Id; } } return 0; } public void Vessel_Click() { ChildWnd.SetActive(true); VesselWnd.SetActive(true); for (int i=0;i= link.TotalLvMin && totleLevel <= link.TotalLvMax) { VesselState.text = StrDictionary.GetClientDictionaryString("#{1166}", link.Id) + " " + string.Format("({0})", StrDictionary.GetClientDictionaryString("#{41015}")); Current.preferredHeight = VesselState.preferredHeight; VesselCondition.text = StrDictionary.GetClientDictionaryString("#{46000}", link.TotalLvMin); VesselCur.text = string.Format("{0}/{1}", totleLevel, link.TotalLvMin); for (int j = 0; j < link.getPropIdCount(); j++) { int proId = link.GetPropIdbyIndex(j); int proVal = link.GetPropValbyIndex(j); if (proId == -1) continue; GameObject attObj = GameObject.Instantiate(AttrAdd); if (attObj == null) continue; Text attText = attObj.GetComponent(); attObj.transform.SetParent(AttrAdd.transform.parent); attObj.SetActive(true); attObj.transform.localPosition = AttrAdd.transform.localPosition; attObj.transform.localScale = AttrAdd.transform.localScale; PropID.GetAttrName((PropID.PropertyID)proId); attText.text = PropID.GetAttrName((PropID.PropertyID)proId) + string.Format(" +{0}", proVal.ToString()); attrObjs.Add(attObj); } next++; continue; } if(next==1) { VesselNextState.text = StrDictionary.GetClientDictionaryString("#{1166}", link.Id) + " " + string.Format("({0})", StrDictionary.GetClientDictionaryString("#{43014}")); Next.preferredHeight = VesselNextState.preferredHeight; VesselNextCondition.text = StrDictionary.GetClientDictionaryString("#{46000}", link.TotalLvMin); VesselNextCur.text = string.Format("{0}/{1}", totleLevel, link.TotalLvMin); for (int j = 0; j < link.getPropIdCount(); j++) { int proId = link.GetPropIdbyIndex(j); int proVal = link.GetPropValbyIndex(j); if (proId == -1) continue; GameObject attObj = GameObject.Instantiate(AttrNextAdd); if (attObj == null) continue; Text attText = attObj.GetComponent(); attObj.transform.SetParent(AttrNextAdd.transform.parent); attObj.SetActive(true); attObj.transform.localPosition = AttrNextAdd.transform.localPosition; attObj.transform.localScale = AttrNextAdd.transform.localScale; PropID.GetAttrName((PropID.PropertyID)proId); attText.text = PropID.GetAttrName((PropID.PropertyID)proId) + string.Format(" +{0}", proVal.ToString()); attrObjs.Add(attObj); } next++; } } if (next == 1) { VesselNextState.text = StrDictionary.GetClientDictionaryString("#{47303}"); ; VesselNextCur.text = ""; VesselNextCondition.text = ""; return; } if (next == 0) { if (firstData != null) { VesselState.text = StrDictionary.GetClientDictionaryString("#{1166}", firstData.Id) + " " + string.Format("({0})", StrDictionary.GetClientDictionaryString("#{43014}")); VesselCur.text = string.Format("{0}/{1}", totleLevel, firstData.TotalLvMin); VesselCondition.text = StrDictionary.GetClientDictionaryString("#{46000}", firstData.TotalLvMin); for (int j = 0; j < firstData.getPropIdCount(); j++) { int proId = firstData.GetPropIdbyIndex(j); int proVal = firstData.GetPropValbyIndex(j); if (proId == -1) continue; GameObject attObj = GameObject.Instantiate(AttrAdd); if (attObj == null) continue; Text attText = attObj.GetComponent(); if(attText==null) { GameObject.Destroy(attObj); continue; } attObj.transform.SetParent(AttrAdd.transform.parent); attObj.SetActive(true); attObj.transform.localPosition = AttrAdd.transform.localPosition; attObj.transform.localScale = AttrAdd.transform.localScale; PropID.GetAttrName((PropID.PropertyID)proId); attText.text = PropID.GetAttrName((PropID.PropertyID)proId) + string.Format(" +{0}", proVal.ToString()); attrObjs.Add(attObj); } } if(SecondData != null) { VesselNextState.text = StrDictionary.GetClientDictionaryString("#{1166}", SecondData.Id) + " " + string.Format("({0})", StrDictionary.GetClientDictionaryString("#{43014}")); VesselNextCondition.text = StrDictionary.GetClientDictionaryString("#{46000}", SecondData.TotalLvMin); VesselNextCur.text = string.Format("{0}/{1}", totleLevel, SecondData.TotalLvMin); for (int i = 0; i < SecondData.getPropIdCount(); i++) { int proId = SecondData.GetPropIdbyIndex(i); int proVal = SecondData.GetPropValbyIndex(i); if (proId == -1) continue; GameObject attObj = GameObject.Instantiate(AttrNextAdd); if (attObj == null) continue; Text attText = attObj.GetComponent(); if (attText == null) { GameObject.Destroy(attObj); continue; } attObj.transform.SetParent(AttrNextAdd.transform.parent); attObj.SetActive(true); attObj.transform.localPosition = AttrNextAdd.transform.localPosition; attObj.transform.localScale = AttrNextAdd.transform.localScale; PropID.GetAttrName((PropID.PropertyID)proId); attText.text = PropID.GetAttrName((PropID.PropertyID)proId) + string.Format(" +{0}", proVal.ToString()); attrObjs.Add(attObj); } } } } }