private void ApplyTalentAction( ref string attackSkill, ref int actionPointsIncome, ref ICollection <string> skills, ref ICollection <string> startBuffs, TalentNode talent, IEnumerable <TalentNode> talents, ICollection <int> appliedTalents) { if (talent.Prerequisites.Count() > 0) { var requiredTalents = talents.Where(x => !appliedTalents.Contains(x.Position) && talent.Prerequisites.Contains(x.Id)); foreach (var requiredTalent in requiredTalents) { ApplyTalentAction(ref attackSkill, ref actionPointsIncome, ref skills, ref startBuffs, requiredTalent, talents, appliedTalents); } } var action = (TalentActionDelegates.Action)Delegate.CreateDelegate( typeof(TalentActionDelegates.Action), typeof(TalentActionDelegates).GetMethod(talent.UniqueAction, BindingFlags.Public | BindingFlags.Static)); action(ref attackSkill, ref actionPointsIncome, ref skills, ref startBuffs); appliedTalents.Add(talent.Position); }
public bool FindPath(TalentNode node, IEnumerable <TalentNode> characterTalents, IList <TalentNode> procesedNodes) { procesedNodes.Add(node); var(x, y) = TalentPositionHelper.GetCoordinatesFromPosition(node.Position); if ((Math.Abs(x - _centerX) == 1 && y == _centerY) || (Math.Abs(y - _centerY) == 1 && x == _centerX)) { return(true); } var leftTalent = characterTalents.FirstOrDefault(k => { var coordinates = TalentPositionHelper.GetCoordinatesFromPosition(k.Position); return(coordinates.x == x + 1 && coordinates.y == y); }); if (leftTalent != null && !procesedNodes.Contains(leftTalent) && FindPath(leftTalent, characterTalents, procesedNodes)) { return(true); } var rightTalent = characterTalents.FirstOrDefault(k => { var coordinates = TalentPositionHelper.GetCoordinatesFromPosition(k.Position); return(coordinates.x == x - 1 && coordinates.y == y); }); if (rightTalent != null && !procesedNodes.Contains(rightTalent) && FindPath(rightTalent, characterTalents, procesedNodes)) { return(true); } var topTalent = characterTalents.FirstOrDefault(k => { var coordinates = TalentPositionHelper.GetCoordinatesFromPosition(k.Position); return(coordinates.x == x && coordinates.y == y - 1); }); if (topTalent != null && !procesedNodes.Contains(topTalent) && FindPath(topTalent, characterTalents, procesedNodes)) { return(true); } var bottomTalent = characterTalents.FirstOrDefault(k => { var coordinates = TalentPositionHelper.GetCoordinatesFromPosition(k.Position); return(coordinates.x == x && coordinates.y == y + 1); }); if (bottomTalent != null && !procesedNodes.Contains(bottomTalent) && FindPath(bottomTalent, characterTalents, procesedNodes)) { return(true); } return(false); }
public static bool JumpTalentPatch(WgTalentTreeController __instance, TalentNode talentNode) { var t = Traverse.Create(__instance); bool flag = t.Method("CheckCondition", talentNode).GetValue <bool>();//__instance.CheckCondition(talentNode); int a = 1; if (jumpTalent.Value) { a = (flag ? 1 : 5); flag = (flag || __instance.talentPoint >= talentNode.NeedPoints * a); } if (flag) { StringTableItem stringTableItem = Game.Data.Get <StringTableItem>("UITalentNodeClickDialog"); string text = (stringTableItem != null) ? stringTableItem.StringValue : null; text = string.Format(text, talentNode.Item.Name, talentNode.NeedPoints * a); Action <bool> onResult = delegate(bool confirm) { if (confirm) { talentNode.CurrentState = eSkillNodeType.Clicked; __instance.Model.TalentData.ClickedNodes.Add(talentNode.Item.Id); TalentNode talentNode2 = talentNode; if (talentNode2 == null) { flag = false; } else { TalentItem item = talentNode2.Item; flag = (((item != null) ? item.Values : null) != null); } if (flag) { __instance.Model.TalentData.AddValues(talentNode.Item.Values); } if (talentNode.Item != null && talentNode.Item.PropertyValues != null) { __instance.Model.PropertiesChange(talentNode.Item.PropertyValues, true, false); } Action <string> talentLearned = __instance.Model.TalentData.TalentLearned; if (talentLearned != null) { talentLearned(talentNode.Item.Id); } __instance.talentPoint -= talentNode.NeedPoints * a; Action <int> updateCurrentExp = __instance.UpdateCurrentExp; if (updateCurrentExp != null) { updateCurrentExp(__instance.talentPoint); } __instance.Model.TalentData.NewPoint -= talentNode.NeedPoints * a; t.Method("AdjacentUpdata", talentNode).GetValue();//__instance.AdjacentUpdata(talentNode); Action <string> learnNode = __instance.LearnNode; if (learnNode != null) { learnNode(talentNode.Id); } Action <int> onTalentPointChanged = __instance.OnTalentPointChanged; if (onTalentPointChanged != null) { onTalentPointChanged(__instance.Model.TalentData.NewPoint); } if (talentNode.IsStart) { Action closeOtherStartNodes = __instance.CloseOtherStartNodes; if (closeOtherStartNodes != null) { closeOtherStartNodes(); } } if (__instance.talentPoint == 0) { t.Method("UpdateCanClicked").GetValue();//__instance.UpdateCanClicked(); } if (!talentNode.Item.OpenNextId.IsNullOrEmpty()) { Action <string> openNextNode = __instance.OpenNextNode; if (openNextNode != null) { openNextNode(talentNode.Item.OpenNextId); } } new SoundEffect("LearnTalent").PlayOnce(); Heluo.Logger.Log("學會天賦" + talentNode.Item.Id + ". " + talentNode.Item.Name, Heluo.Logger.LogLevel.MESSAGE, "white", "NodeClick", "D:\\JingYong\\Assets\\Script\\UI\\View\\TalentTree\\WgSkillTreeController.cs", 874); return; } }; Game.UI.ShowDialog(string.Empty, text, onResult, false).buttonConfirm.ConfrimSoundEffect = new SoundEffect(GameConfig.MuteSoundID); } return(false); }
public TalentRank(int rank, string[] values, TalentNode talent) { Rank = rank; Values = values; Talent = talent; }