public void Init() { var achievementsNodeBank = Rm_RPGHandler.Instance.Nodes.AchievementsNodeBank; foreach (var achievementTree in achievementsNodeBank.NodeTrees) { var achievementInfoNode = achievementTree.Nodes.FirstOrDefault(n => n is AchievementStartNode); var id = achievementTree.ID; var name = (string)achievementInfoNode.ValueOf("Name"); var description = (string)achievementInfoNode.ValueOf("Description"); var spritePath = (string)achievementInfoNode.ValueOf("Image"); var hasProgress = (bool)achievementInfoNode.ValueOf("Has Progress?"); var achievement = new Achievement(id, name, spritePath, description, 1) { HasProgress = hasProgress }; if (achievement.HasProgress) { var nodeTree = Rm_RPGHandler.Instance.Nodes.AchievementsNodeBank.NodeTrees.FirstOrDefault(n => n.ID == achievement.ID); var maxProgressChain = new NodeChain(nodeTree, typeof(AchievementMaxProgress)); while (!maxProgressChain.Done) { maxProgressChain.Evaluate(); } achievement.Progress.TargetValue = maxProgressChain.IntValue; } Achievements.Add(achievement); } }
private IEnumerator CheckAchievement(Achievement achievement) { checkingAchievements = true; bool completed = false; //todo: optimise the achievement checking var nodeTree = Rm_RPGHandler.Instance.Nodes.AchievementsNodeBank.NodeTrees.FirstOrDefault(n => n.ID == achievement.ID); if (nodeTree != null) { var nodeChain = new NodeChain(nodeTree, typeof(AchievementStartNode)); while (!nodeChain.Done) { nodeChain.Evaluate(); yield return(null); } if (achievement.HasProgress) { var minProgressChain = new NodeChain(nodeTree, typeof(AchievementMinProgress)); while (!minProgressChain.Done) { minProgressChain.Evaluate(); yield return(null); } achievement.Progress.CurrentValue = minProgressChain.IntValue; } if (nodeChain.CurrentNode is AchievementEndNode) { completed = true; } } if (completed) { CompleteAchievement(achievement); } checkingAchievements = false; }
void Update() { Interacting = DialogNodeChain != null; if (DialogNodeChain != null) { if (DialogNodeChain.Done) { EndDialog(); } else { if (!(DialogNodeChain.CurrentNode is DialogNode)) { DialogNodeChain.Evaluate(); CheckForUpdate(); } } } }
public void BeginQuestDialog(string nodeTreeId, InteractiveObjectMono dialogObject = null, bool isQuest = false, string questId = "") { var nodeTree = Rm_RPGHandler.Instance.Nodes.DialogNodeBank.NodeTrees.FirstOrDefault(n => n.ID == nodeTreeId); if (nodeTree != null) { if (isQuest) { EvaluatingQuestDialog = true; EvaluatingQuestID = questId; PostQuestEvaluationNodeID = string.IsNullOrEmpty(CurrentNode.NextNodeLinks[0].ID) ? null : CurrentNode.NextNodeLinks[0].ID; } var nodeChain = new NodeChain(nodeTree, typeof(DialogStartNode)); OldNodeChain = DialogNodeChain; DialogNodeChain = nodeChain; DialogNodeChain.Evaluate(); } //CheckForUpdate(); }
public void ScaleStats() { var statScalingTree = Rm_RPGHandler.Instance.Nodes.StatScalingTree; for (int i = 0; i < Stats.Count; i++) { var stat = Stats[i]; var statBaseValue = stat.BaseValue; var nodeChain = new NodeChain(statScalingTree, typeof(CombatStartNode), stat.ID) { Combatant = this, FloatValue = statBaseValue }; while (!nodeChain.Done) { nodeChain.Evaluate(); } stat.ScaledBaseValue = nodeChain.FloatValue; } var vitalScalingTree = Rm_RPGHandler.Instance.Nodes.VitalScalingTree; for (int i = 0; i < Vitals.Count; i++) { var vital = Vitals[i]; int vitBaseValue = vital.BaseValue; var nodeChain = new NodeChain(vitalScalingTree, typeof(CombatStartNode), vital.ID) { Combatant = this, IntValue = vitBaseValue }; while (!nodeChain.Done) { nodeChain.Evaluate(); } vital.ScaledBaseValue = (int)nodeChain.IntValue; } }
public void CheckResponses() { _responses = new List <PlayerResponseNode>(); if (DialogNodeChain != null) { GetObject.PlayerMono.Controller.Interacting = true; if (CurrentNode is DialogNode) { var npcResponseNode = CurrentNode as DialogNode; foreach (var nextPoint in npcResponseNode.NextNodeLinks.Where(n => !string.IsNullOrEmpty(n.ID))) { var node = DialogNodeChain.GetNode(nextPoint.ID); if (node is PlayerResponseNode) { var playerReponseNode = node as PlayerResponseNode; _responses.Add(playerReponseNode); } else { var subChain = new NodeChain(DialogNodeChain, node.ID); while (!(subChain.CurrentNode is PlayerResponseNode) && subChain.CurrentNode != null) { subChain.Evaluate(); } if (subChain.CurrentNode is PlayerResponseNode) { var playerReponseNode = subChain.CurrentNode as PlayerResponseNode; _responses.Add(playerReponseNode); } } } } } }
public void BeginDialog(string nodeTreeId, InteractiveObjectMono dialogObject = null) { if (DialogNodeChain != null) { EndDialog(); } DialogNpc = dialogObject ?? InteractiveObjectMono.CurrentInteraction; //Debug.Log(nodeTreeId); var nodeTree = Rm_RPGHandler.Instance.Nodes.DialogNodeBank.NodeTrees.FirstOrDefault(n => n.ID == nodeTreeId); if (nodeTree != null) { var nodeChain = new NodeChain(nodeTree, typeof(DialogStartNode)); DialogNodeChain = nodeChain; DialogNodeChain.Evaluate(); } else { EndDialog(); } CheckForUpdate(); }