コード例 #1
0
ファイル: Action_GS.cs プロジェクト: hofcsabaGit/Unity-GOAP_S
        //Used to iterate all the previous loop methods
        public ACTION_RESULT Execute()
        {
            //Action execution result
            Action_GS.ACTION_RESULT execution_result = Action_GS.ACTION_RESULT.A_ERROR;
            //Execute the current action
            switch (_state)
            {
            case Action_GS.ACTION_STATE.A_START:
            {
                execution_result = ActionStart();
            }
            break;

            case Action_GS.ACTION_STATE.A_UPDATE:
            {
                //Execute behaviour in action update
                execution_result = ActionUpdate();
            }
            break;

            case Action_GS.ACTION_STATE.A_COMPLETE:
            {
                execution_result = ActionEnd();
            }
            break;
            }
            //React with the action result
            if (execution_result == Action_GS.ACTION_RESULT.A_NEXT)
            {
                _state += 1;
            }
            else if (execution_result == Action_GS.ACTION_RESULT.A_ERROR)
            {
                ActionBreak();
            }

            return(execution_result);
        }
コード例 #2
0
    public override bool InActionUpdate(Action_GS.ACTION_RESULT current_action_result, Action_GS.ACTION_STATE current_action_state)
    {
        if (global_blackboard.GetValue <int>("current_rock") >= global_blackboard.GetValue <int>("rock_goal"))
        {
            if (blackboard.GetValue <int>("rock") > 0 || going_for_rock)
            {
                blackboard.SetVariable <int>("rock", 0);
                blackboard.SetVariable <Vector3>("target_position", new Vector3(0.0f, 0.0f, 0.0f));
                blackboard.SetVariable <bool>("in_pos", false);
                going_for_rock = false;
                targeted_slot.slot_available = true;
                targeted_slot = null;

                return(false);
            }
        }

        if (global_blackboard.GetValue <int>("current_diamond") >= global_blackboard.GetValue <int>("diamond_goal"))
        {
            if (blackboard.GetValue <int>("diamond") > 0 || going_for_diamond)
            {
                blackboard.SetVariable <int>("diamond", 0);
                blackboard.SetVariable <Vector3>("target_position", new Vector3(0.0f, 0.0f, 0.0f));
                blackboard.SetVariable <bool>("in_pos", false);
                going_for_diamond = false;

                if (targeted_slot != null)
                {
                    targeted_slot.slot_available = true;
                    targeted_slot = null;
                }

                return(false);
            }
        }
        return(true);
    }
コード例 #3
0
 public virtual bool InActionUpdate(Action_GS.ACTION_RESULT current_action_result, Action_GS.ACTION_STATE current_action_state)
 {
     //InAction
     //Here we code the actions that the agent should do depending of the results/state generated from the previous actions
     return(true);
 }