示例#1
0
        private static void UpdateNodes()
        {
            var damageTakenTree  = Rm_RPGHandler.Instance.Nodes.DamageTakenTree;
            var damageDealtTree  = Rm_RPGHandler.Instance.Nodes.DamageDealtTree;
            var statScalingTree  = Rm_RPGHandler.Instance.Nodes.StatScalingTree;
            var vitalScalingTree = Rm_RPGHandler.Instance.Nodes.VitalScalingTree;
            var worldNodeBank    = Rm_RPGHandler.Instance.Nodes.WorldMapNodeBank;

            #region "Damage taken + dealt"
            if (damageTakenTree.Variables.FirstOrDefault(n => n.Name == "Attacker" && n.PropType == PropertyType.CombatCharacter) == null)
            {
                damageTakenTree.Variables.Add(new NodeTreeVar("Attacker", PropertyType.CombatCharacter));
            }
            if (statScalingTree.Variables.FirstOrDefault(n => n.Name == "Attacker" && n.PropType == PropertyType.CombatCharacter) == null)
            {
                statScalingTree.Variables.Add(new NodeTreeVar("Attacker", PropertyType.CombatCharacter));
            }
            if (vitalScalingTree.Variables.FirstOrDefault(n => n.Name == "Attacker" && n.PropType == PropertyType.CombatCharacter) == null)
            {
                vitalScalingTree.Variables.Add(new NodeTreeVar("Attacker", PropertyType.CombatCharacter));
            }
            if (damageTakenTree.Variables.FirstOrDefault(n => n.Name == "Defender" && n.PropType == PropertyType.CombatCharacter) == null)
            {
                damageTakenTree.Variables.Add(new NodeTreeVar("Defender", PropertyType.CombatCharacter));
            }

            if (damageDealtTree.Variables.FirstOrDefault(n => n.Name == "Attacker" && n.PropType == PropertyType.CombatCharacter) == null)
            {
                damageDealtTree.Variables.Add(new NodeTreeVar("Attacker", PropertyType.CombatCharacter));
            }

            //remove no longer existing elementals
            var damageTakenTreeVars = damageTakenTree.Variables.Where(n => n.ID.StartsWith("DamageDealtVar_") && n.ID != "DamageDealtVar_Physical").ToList();

            for (int i = 0; i < damageTakenTreeVars.Count; i++)
            {
                var v           = damageTakenTreeVars[i];
                var elementalId = v.ID.Replace("DamageDealtVar_", "");
                var exists      = Rm_RPGHandler.Instance.ASVT.ElementalDamageDefinitions.FirstOrDefault(e => e.ID == elementalId);
                if (exists == null)
                {
                    damageTakenTree.Variables.RemoveAt(i);
                    i--;
                }
            }

            //add non-existing elementals to damage tbl
            foreach (var wa in Rm_RPGHandler.Instance.ASVT.ElementalDamageDefinitions)
            {
                var exists = damageTakenTree.Variables.FirstOrDefault(a => a.ID.Replace("DamageDealtVar_", "") == wa.ID);
                if (exists == null)
                {
                    damageTakenTree.Variables.Add(new NodeTreeVar(wa.Name + " Damage", PropertyType.Int)
                    {
                        ID = "DamageDealtVar_" + wa.ID
                    });
                }
                else
                {
                    exists.Name = wa.Name;
                }
            }

            foreach (var n in damageTakenTree.Nodes.Where(n => n is CustomDamageCombatNode))
            {
                var customDamageNode = n as CustomDamageCombatNode;
                customDamageNode.NewName = RPG.Combat.GetElementalNameById(customDamageNode.DamageId) + " Damage";
            }

            var d = damageTakenTree.Nodes.Where(n => n is CustomDamageCombatNode).ToList();
            for (int index = 0; index < d.Count; index++)
            {
                var n      = d[index] as CustomDamageCombatNode;
                var exists = Rm_RPGHandler.Instance.ASVT.ElementalDamageDefinitions.FirstOrDefault(e => e.ID == n.DamageId);
                if (exists == null)
                {
                    damageTakenTree.Nodes.Remove(n);
                }
            }

            #endregion

            //delete non existing world areas
            for (int index = 0; index < worldNodeBank.NodeTrees.Count; index++)
            {
                var w = worldNodeBank.NodeTrees[index];
                var existingWorldArea = Rm_RPGHandler.Instance.Customise.WorldMapLocations.FirstOrDefault(a => a.ID == w.ID);
                if (existingWorldArea == null)
                {
                    worldNodeBank.NodeTrees.RemoveAt(index);
                    index--;
                }
            }

            //locations
            foreach (var w in worldNodeBank.NodeTrees)
            {
                var existingWorldArea = Rm_RPGHandler.Instance.Customise.WorldMapLocations.First(a => a.ID == w.ID);
                //delete non-existing locations
                for (int index = 0; index < w.Nodes.Count; index++)
                {
                    var n = w.Nodes[index];
                    var existingLocation = existingWorldArea.Locations.FirstOrDefault(a => a.ID == n.ID);
                    if (existingLocation == null)
                    {
                        w.Nodes.RemoveAt(index);
                        index--;
                    }
                }
            }

            //add non-existing world locations
            foreach (var wa in Rm_RPGHandler.Instance.Customise.WorldMapLocations)
            {
                var waTree = worldNodeBank.NodeTrees.FirstOrDefault(a => a.ID == wa.ID);
                if (waTree != null)
                {
                    foreach (var loc in wa.Locations)
                    {
                        var locNode = waTree.Nodes.FirstOrDefault(a => a.ID == loc.ID);
                        if (locNode == null)
                        {
                            var nodePos   = Vector2.zero;
                            var nodeToAdd = new LocationNode();
                            var nextId    = updateNode_GetNextID(worldNodeBank);
                            waTree.AddNode(nodeToAdd, nodePos, nextId, loc.ID);
                        }
                        else
                        {
                            var locationNode = locNode as LocationNode;
                            locationNode.LocName = loc.Name;
                        }
                    }
                }
            }

            //update node tree var variable names
            foreach (var wa in Rm_RPGHandler.Instance.Nodes.AllTrees)
            {
                var s = wa.Nodes.OfType <NodeTreeVarNode>().ToList();
                for (int i = 0; i < s.Count(); i++)
                {
                    var n       = s[i];
                    var treeVar = wa.Variables.FirstOrDefault(v => v.ID == n.VariableId);
                    if (treeVar == null)
                    {
                        wa.Nodes.Remove(n);
                        continue;
                    }
                    n.NewName = treeVar.Name;
                }
            }

            //todo: update min max damage dealt node names

            //Delete damage dealt nodes
            var nodesToDelete = damageDealtTree.Nodes.Where(
                n => n.GetType() == typeof(CombatStartNode) && n.Identifier != "MIN_Physical" && n.Identifier != "MAX_Physical" &&
                Rm_RPGHandler.Instance.ASVT.ElementalDamageDefinitions.All(e => ("MIN_" + e.ID) != n.Identifier) &&
                Rm_RPGHandler.Instance.ASVT.ElementalDamageDefinitions.All(e => ("MAX_" + e.ID) != n.Identifier)
                ).ToList();

            for (int index = 0; index < nodesToDelete.Count; index++)
            {
                var delete = nodesToDelete.ToList()[index];
                updateNode_DeleteNode(delete, damageDealtTree);
            }

            //Delete skill damage dealt nodes
            var skillsWithScaling = Rm_RPGHandler.Instance.Repositories.Skills.AllSkills.Where(s => !string.IsNullOrEmpty(s.DamageScalingTreeID)).ToList();

            foreach (var customSkillTree in skillsWithScaling)
            {
                var tree = Rm_RPGHandler.Instance.Nodes.CombatNodeBank.NodeTrees.FirstOrDefault(n => n.ID == customSkillTree.DamageScalingTreeID);
                if (tree == null)
                {
                    continue;
                }

                var nodeListToDelete = tree.Nodes.Where(
                    n => n.GetType() == typeof(CombatStartNode) && n.Identifier != "MIN_Physical" && n.Identifier != "MAX_Physical" &&
                    Rm_RPGHandler.Instance.ASVT.ElementalDamageDefinitions.All(e => ("MIN_" + e.ID) != n.Identifier) &&
                    Rm_RPGHandler.Instance.ASVT.ElementalDamageDefinitions.All(e => ("MAX_" + e.ID) != n.Identifier)
                    ).ToList();

                for (int index = 0; index < nodeListToDelete.Count; index++)
                {
                    var delete = nodeListToDelete.ToList()[index];
                    updateNode_DeleteNode(delete, damageDealtTree);
                }
            }

            // Delete scaling nodes
            nodesToDelete = statScalingTree.Nodes.Where(n => n.GetType() == typeof(CombatStartNode) && Rm_RPGHandler.Instance.ASVT.StatisticDefinitions.All(e => e.ID != n.Identifier)).ToList();
            for (int index = 0; index < nodesToDelete.Count; index++)
            {
                var delete = nodesToDelete.ToList()[index];
                updateNode_DeleteNode(delete, statScalingTree);
            }

            nodesToDelete = vitalScalingTree.Nodes.Where(n => n.GetType() == typeof(CombatStartNode) && Rm_RPGHandler.Instance.ASVT.VitalDefinitions.All(e => e.ID != n.Identifier)).ToList();
            for (int index = 0; index < nodesToDelete.Count; index++)
            {
                var delete = nodesToDelete.ToList()[index];
                updateNode_DeleteNode(delete, vitalScalingTree);
            }

            //damage dealt: add non-existing element damages
            var notAdded    = Rm_RPGHandler.Instance.ASVT.ElementalDamageDefinitions.Where(c => damageDealtTree.Nodes.All(n => n.Identifier != "MAX_" + c.ID)).ToList();
            var existingAmt = Rm_RPGHandler.Instance.ASVT.ElementalDamageDefinitions.Count - notAdded.Count;
            for (int index = 0; index < notAdded.Count; index++)
            {
                var element = notAdded[index];

                if (Rm_RPGHandler.Instance.Items.DamageHasVariance)
                {
                    var newNode = new CombatStartNode("Min \"" + element.Name + "\" Damage", "Min Damage for " + element.Name, "Damage dealt by an element starts at 0. You can add additional calculations to increase this amount. Example: Create a statistic called fire damage and add this amount.")
                    {
                        Identifier = "MIN_" + element.ID
                    };
                    newNode.WindowID = updateNode_GetNextID(Rm_RPGHandler.Instance.Nodes.CombatNodeBank);
                    newNode.Rect     = new Rect(25, 250 + ((existingAmt + index) * 200), 50, 50);
                    newNode.OnCreate();
                    damageDealtTree.Nodes.Add(newNode);
                }

                var newNodeMax = new CombatStartNode("Max \"" + element.Name + "\" Damage", "Max Damage for " + element.Name, "Damage dealt by an element starts at 0. You can add additional calculations to increase this amount. Example: Create a statistic called fire damage and add this amount.")
                {
                    Identifier = "MAX_" + element.ID
                };
                newNodeMax.WindowID = updateNode_GetNextID(Rm_RPGHandler.Instance.Nodes.CombatNodeBank);
                newNodeMax.Rect     = new Rect(25, 350 + ((existingAmt + index) * 200), 50, 50);
                newNodeMax.OnCreate();
                damageDealtTree.Nodes.Add(newNodeMax);
            }

            //skill damage dealt: add non-existing element damages
            foreach (var customSkillTree in skillsWithScaling)
            {
                var tree               = Rm_RPGHandler.Instance.Nodes.CombatNodeBank.NodeTrees.FirstOrDefault(n => n.ID == customSkillTree.DamageScalingTreeID);
                var notAddedNodes      = Rm_RPGHandler.Instance.ASVT.ElementalDamageDefinitions.Where(c => tree.Nodes.All(n => n.Identifier != "MAX_" + c.ID)).ToList();
                var existingAmtOfNodes = Rm_RPGHandler.Instance.ASVT.ElementalDamageDefinitions.Count - notAddedNodes.Count;
                for (int index = 0; index < notAddedNodes.Count; index++)
                {
                    var element = notAddedNodes[index];

                    if (Rm_RPGHandler.Instance.Items.DamageHasVariance)
                    {
                        var newNode = new CombatStartNode("Min \"" + element.Name + "\" Damage", "Min Damage for " + element.Name, "Damage dealt by an element starts at 0. You can add additional calculations to increase this amount. Example: Create a statistic called fire damage and add this amount.")
                        {
                            Identifier = "MIN_" + element.ID
                        };
                        newNode.WindowID = updateNode_GetNextID(Rm_RPGHandler.Instance.Nodes.CombatNodeBank);
                        newNode.Rect     = new Rect(25, 250 + ((existingAmtOfNodes + index) * 200), 50, 50);
                        newNode.OnCreate();
                        tree.Nodes.Add(newNode);
                    }

                    var newNodeMax = new CombatStartNode("Max \"" + element.Name + "\" Damage", "Max Damage for " + element.Name, "Damage dealt by an element starts at 0. You can add additional calculations to increase this amount. Example: Create a statistic called fire damage and add this amount.")
                    {
                        Identifier = "MAX_" + element.ID
                    };
                    newNodeMax.WindowID = updateNode_GetNextID(Rm_RPGHandler.Instance.Nodes.CombatNodeBank);
                    newNodeMax.Rect     = new Rect(25, 350 + ((existingAmtOfNodes + index) * 200), 50, 50);
                    newNodeMax.OnCreate();
                    tree.Nodes.Add(newNodeMax);
                }
            }


            foreach (var x in damageDealtTree.Nodes.Where(n => n.GetType() == typeof(CombatStartNode) && !n.Identifier.Contains("Physical")))
            {
                //Substring 3 to ignore (MAX_) or (MIN_)
                var element = Rm_RPGHandler.Instance.ASVT.ElementalDamageDefinitions.FirstOrDefault(e => e.ID == x.Identifier.Substring(4));
                if (element != null)
                {
                    var n = (CombatStartNode)x;
                    n.NodeChainName = n.Identifier.Substring(0, 3) + " [" + element.Name + "] Damage";
                    n.NewName       = element.Name;
                    n.NewSubText    = "Damage for " + element.Name;
                }
            }

            foreach (var customSkillTree in skillsWithScaling)
            {
                var tree = Rm_RPGHandler.Instance.Nodes.CombatNodeBank.NodeTrees.FirstOrDefault(n => n.ID == customSkillTree.DamageScalingTreeID);
                foreach (var x in tree.Nodes.Where(n => n.GetType() == typeof(CombatStartNode) && !n.Identifier.Contains("Physical")))
                {
                    //Substring 3 to ignore (MAX_) or (MIN_)
                    var element = Rm_RPGHandler.Instance.ASVT.ElementalDamageDefinitions.FirstOrDefault(e => e.ID == x.Identifier.Substring(4));
                    if (element != null)
                    {
                        var n = (CombatStartNode)x;
                        n.NodeChainName = n.Identifier.Substring(0, 3) + " [" + element.Name + "] Damage";
                        n.NewName       = element.Name;
                        n.NewSubText    = "Damage for " + element.Name;
                    }
                }
            }


            //stat scaling: add non-existing stats
            var statsNotAdded   = Rm_RPGHandler.Instance.ASVT.StatisticDefinitions.Where(c => statScalingTree.Nodes.All(n => n.Identifier != c.ID)).ToList();
            var existingStatAmt = Rm_RPGHandler.Instance.ASVT.StatisticDefinitions.Count - statsNotAdded.Count;
            for (int index = 0; index < statsNotAdded.Count; index++)
            {
                var element = statsNotAdded[index];
                var newNode = new CombatStartNode(element.Name, "Scaling for " + element.Name, "Add additional nodes to modify base value of a statistic based on other values, e.g. an attribute. Remember: don't cause circular scaling as this can result in an infinite loop.")
                {
                    Identifier = element.ID
                };
                newNode.WindowID = updateNode_GetNextID(Rm_RPGHandler.Instance.Nodes.CombatNodeBank);
                newNode.Rect     = new Rect(25, 87.5f + ((existingStatAmt + index) * 200), 50, 50);
                newNode.OnCreate();
                statScalingTree.Nodes.Add(newNode);
            }

            foreach (var x in statScalingTree.Nodes.Where(n => n.GetType() == typeof(CombatStartNode)))
            {
                var element = Rm_RPGHandler.Instance.ASVT.StatisticDefinitions.FirstOrDefault(e => e.ID == x.Identifier);
                if (element != null)
                {
                    var n = (CombatStartNode)x;
                    n.NewName    = element.Name;
                    n.NewSubText = "Scaling for " + element.Name;
                }
            }


            //stat scaling: add non-existing stats
            var vitNotAdded    = Rm_RPGHandler.Instance.ASVT.VitalDefinitions.Where(c => vitalScalingTree.Nodes.All(n => n.Identifier != c.ID)).ToList();
            var existingVitAmt = Rm_RPGHandler.Instance.ASVT.VitalDefinitions.Count - vitNotAdded.Count;
            for (int index = 0; index < vitNotAdded.Count; index++)
            {
                var element = vitNotAdded[index];
                var newNode = new CombatStartNode(element.Name, "Scaling for " + element.Name, "Add additional nodes to modify base value of a vital based on other values, e.g. an attribute. Remember: don't cause circular scaling as this can result in an infinite loop.")
                {
                    Identifier = element.ID
                };
                newNode.WindowID = updateNode_GetNextID(Rm_RPGHandler.Instance.Nodes.CombatNodeBank);
                newNode.Rect     = new Rect(25, 87.5f + ((existingVitAmt + index) * 200), 50, 50);
                newNode.OnCreate();
                vitalScalingTree.Nodes.Add(newNode);
            }

            foreach (var x in vitalScalingTree.Nodes.Where(n => n.GetType() == typeof(CombatStartNode)))
            {
                var element = Rm_RPGHandler.Instance.ASVT.VitalDefinitions.FirstOrDefault(e => e.ID == x.Identifier);
                if (element != null)
                {
                    var n = (CombatStartNode)x;
                    n.NewName    = element.Name;
                    n.NewSubText = "Scaling for " + element.Name;
                }
            }
        }
示例#2
0
        public Rmh_Nodes()
        {
            var x = new NodeTree {
                ID = DamageTakenTreeName, Name = DamageTakenTreeName, Required = true, Type = NodeTreeType.Combat
            };
            var n = new NodeTree {
                ID = DamageDealtTreeName, Name = DamageDealtTreeName, Required = true, Type = NodeTreeType.Combat
            };
            var y = new NodeTree {
                ID = StatScalingTreeName, Name = StatScalingTreeName, Required = true, Type = NodeTreeType.Combat
            };
            var p = new NodeTree {
                ID = VitalScalingTreeName, Name = VitalScalingTreeName, Required = true, Type = NodeTreeType.Combat
            };


            var node = new CombatStartNode("Min Physical Damage", "Start node for dealt physical",
                                           "Physical Damage represents weapon damage, or base combatant damage. You can then add additional nodes to add onto this value. Example: Add 10x Strength")
            {
                Identifier = "MIN_Physical"
            };

            node.OnCreate();
            n.AddNode(node, new Vector2(25, 87.5f), 0);
            var nodeMax = new CombatStartNode("Max Physical Damage", "Start node for dealt physical",
                                              "Physical Damage represents weapon damage, or base combatant damage. You can then add additional nodes to add onto this value. Example: Add 10x Strength")
            {
                Identifier = "MAX_Physical"
            };

            nodeMax.OnCreate();
            n.AddNode(nodeMax, new Vector2(25, 287.5f), 1);

            var damageTakenNode = new CombatStartNode("Damage To Be Dealt", "Represents damage about to be taken",
                                                      "This is the incoming damage. It can be modified to take into account other stats. E.g. Damage - Defender's Armor value.")
            {
                Identifier = "DamageTaken"
            };
            var missedNode     = new MissedHitNode();
            var evadedNode     = new EvadedHitNode();
            var successHitNode = new SuccessHitEndNode();

            damageTakenNode.OnCreate();
            missedNode.OnCreate();
            successHitNode.OnCreate();
            evadedNode.OnCreate();
            x.AddNode(damageTakenNode, new Vector2(25, 87.5f), 0);
            x.AddNode(successHitNode, new Vector2(700, 87.5f), 1);
            x.AddNode(missedNode, new Vector2(700, 237.5f), 2);
            x.AddNode(evadedNode, new Vector2(700, 387.5f), 3);

            n.Variables.Add(new NodeTreeVar("Attacker", PropertyType.CombatCharacter));

            y.Variables.Add(new NodeTreeVar("Attacker", PropertyType.CombatCharacter));
            p.Variables.Add(new NodeTreeVar("Attacker", PropertyType.CombatCharacter));

            x.Variables.Add(new NodeTreeVar("Attacker", PropertyType.CombatCharacter));
            x.Variables.Add(new NodeTreeVar("Defender", PropertyType.CombatCharacter));
            x.Variables.Add(new NodeTreeVar("Physical Damage", PropertyType.Int)
            {
                ID = "DamageDealtVar_Physical"
            });

            AchievementsNodeBank = new NodeBank()
            {
                Type      = NodeTreeType.Achievements,
                NodeTrees = new List <NodeTree>()
            };

            CombatNodeBank = new NodeBank
            {
                Type      = NodeTreeType.Combat,
                NodeTrees = new List <NodeTree>()
                {
                    x, n, y, p
                }
            };

            EventNodeBank = new NodeBank
            {
                Type      = NodeTreeType.Event,
                NodeTrees = new List <NodeTree>()
            };

            DialogNodeBank = new NodeBank
            {
                Type      = NodeTreeType.Dialog,
                NodeTrees = new List <NodeTree>()
            };

            WorldMapNodeBank = new NodeBank
            {
                Type      = NodeTreeType.WorldMap,
                NodeTrees = new List <NodeTree>()
                {
                    new NodeTree()
                    {
                        ID = CoreInitialMap, Name = CoreInitialMap, Required = true, Type = NodeTreeType.Combat
                    }
                }
            };
        }