From f4e4d78758547520d81d959ea24b929d1721409b Mon Sep 17 00:00:00 2001 From: lightyears Date: Wed, 22 Feb 2023 10:52:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E8=B1=A1=20Goal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Models/Goal.cs | 45 ++++++++++++++++++++++++++++++++---- Nodes/BattleCharacterNode.cs | 2 +- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/Models/Goal.cs b/Models/Goal.cs index 5c863a5..e0307dd 100644 --- a/Models/Goal.cs +++ b/Models/Goal.cs @@ -1,20 +1,55 @@ +using System.Collections.Generic; + namespace CMSGame { - public class Goal + public class Goal { public string Name = string.Empty; - public bool IsValid; - public int BasePriority; + + public List> ValidityModifiers = new(); + + public List> PriorityModifiers = new(); + + public bool IsValid() + { + return ValidityModifiers.All(modifier => modifier.Execute()); + } + + public int Priority() + { + return BasePriority + PriorityModifiers.Sum(modifier => modifier.Execute()); + } } - public class BattleGoal : Goal + public abstract class GoalModifier { + public string Name = string.Empty; + + public TContext Context; + + protected GoalModifier(TContext context) + { + Context = context; + } + } + + public abstract class GoalValidityModifier : GoalModifier + { + protected GoalValidityModifier(TContext context) : base(context) + { + } + + public abstract bool Execute(); } - public class GoalModifier + public abstract class GoalPriorityModifier : GoalModifier { + protected GoalPriorityModifier(TContext context) : base(context) + { + } + public abstract int Execute(); } } diff --git a/Nodes/BattleCharacterNode.cs b/Nodes/BattleCharacterNode.cs index 6e0b054..e2e1035 100644 --- a/Nodes/BattleCharacterNode.cs +++ b/Nodes/BattleCharacterNode.cs @@ -41,7 +41,7 @@ namespace CMSGame public void UpdateUI() { - StatusLabel!.Text = $"HP {120}\nAP {ActionPoint}"; + StatusLabel!.Text = $"HP {Character!.HealthPoint}/{Character.MaxHealthPoint}\nAP {ActionPoint}"; } public override void _InputEvent(Camera3D camera, InputEvent @event, Vector3 position, Vector3 normal, int shapeIdx)