Esempio n. 1
0
        public void TestActionShouldPassThroughPhases()
        {
            AgentAction selfAction = _agent.Actions[1];

            _agent.Actions.RemoveAt(0); //Removes other action for easier debugging
            _agent.CurrentCommand = new AgentCommand(selfAction, _agent, 10);
            selfAction.Cooldown   = 5f;
            selfAction.FocusTime  = 2f;

            Assert.AreEqual(ActionPhase.READY, selfAction.Phase);

            selfAction.TriggerAction(_agent);
            Assert.AreEqual(ActionPhase.FOCUS, selfAction.Phase);

            _agent.Update(1f);
            Assert.AreEqual(ActionPhase.FOCUS, selfAction.Phase);

            _agent.Update(1f);
            Assert.AreEqual(ActionPhase.COOLDOWN, selfAction.Phase);

            _agent.Update(4f);
            Assert.AreEqual(ActionPhase.COOLDOWN, selfAction.Phase);

            _agent.Update(1f);
            Assert.AreEqual(ActionPhase.READY, selfAction.Phase);
        }
Esempio n. 2
0
        public override bool TryExecute()
        {
            if (Action.Ready())
            {
                //TODO: check all action preconditions here -- in range, resource costs, condition preconditions, etc
                // If not satisfied, add the precondition to the action stack.
                if (!Action.InRange(Target))
                {
                    //Action.Agent.GetMobilityActions();
                    //TEMP:
                    //Action.Agent.GetMoveAction().TriggerAction(Target);
                    if (Action.Agent.Mobility.MoveTarget != Target)
                    {
                        Action.Agent.Mobility.SetMoveTarget(Target, 0.1f);
                    }
                    return(false);
                }
                else
                {
                    Action.Agent.Mobility.UnsetMoveTarget();
                }

                Action.TriggerAction(Target);
                return(true);
            }
            return(false);
        }