Ejemplo n.º 1
0
    private void AddGoal(GOAP_Worldstate goal)
    {
        GoalListPanel p = Instantiate(goalsPrefab, goalsParent).GetComponent <GoalListPanel>();

        p.SetContent(characterData, worldStateOptions, boolOptions, ItemTypeOptions, itemTypes, (int)goal.key, goal.value);
        Debug.Log("Add Goal " + goal.ToString());
    }
Ejemplo n.º 2
0
    public void ChangeCurrentWorldState(GOAP_Worldstate newState)
    {
        if (currentWorldstates.ContainsKey(newState))
        {
            if (newState.type == WorldStateType.UNIQUE)
            {
                currentWorldstates.Remove(newState); //this should find the state based on the key only
                currentWorldstates.Add(newState);
                Debug.Log(Character.characterData.characterName + " <color=#cc0000>Updated state:</color> " + newState.ToString());
            }
            else
            {
                if (!currentWorldstates.ContainsExactly(newState))
                {
                    Character.Log(Character.characterData.characterName + " <color=#cc0000>Add state:</color> " + newState.ToString());
                    currentWorldstates.Add(newState);
                }
            }
        }

        //Otherwise, if the newstate is not contained in the currentworldstate, add it
        else
        {
            Character.Log(Character.characterData.characterName + " <color=#cc0000>Add state:</color> " + newState.ToString());
            currentWorldstates.Add(newState);
        }
    }
Ejemplo n.º 3
0
 public void RemoveCurrentWorldState(GOAP_Worldstate state)
 {
     if (currentWorldstates.ContainsKey(state))
     {
         Character.Log(Character.characterData.characterName + " <color=#cc0000>Remove state:</color> " + state.ToString());
         currentWorldstates.Remove(state);
     }
 }
Ejemplo n.º 4
0
    /// <summary>
    /// Checks if the goal worldstate is already satisfied within the current worldstate
    /// </summary>
    /// <param name="currentWorldState"></param>
    /// <param name="goalWorldState"></param>
    /// <returns></returns>
    public static bool IsGoalSatisfied(List_GOAP_Worldstate currentWorldState, GOAP_Worldstate goalWorldState)
    {
        //First, check if we have not already reached the goal, by checking it against our currentWorldstate

        if (!currentWorldState.ContainsExactly(goalWorldState))
        {
            return(false);
        }
        return(true);
    }
Ejemplo n.º 5
0
    /// <summary>
    /// This action chooses a goal from among the personal goals after checking if there are completed quests to finish first
    /// </summary>
    public void ChooseGoal()
    {
        activeGoal.Clear();
        string msg = "<color=#0000cc><b>CHECKING GOALS</b>:" + character.characterData.characterName + "</color>\n";

        //Check goals top to bottom, to see which need to be fulfilled
        for (int i = 0; i < character.characterData.goals.Count; i++)
        {
            GOAP_Worldstate goal = character.characterData.goals[i];

            //Check if the goal is already satisfied
            if (!GOAP_Planner.IsGoalSatisfied(currentWorldstates, goal))
            {
                //And if it has been checked before
                if (!checkedCharacterGoals.ContainsExactly(goal))
                {
                    checkedCharacterGoals.Add(character.characterData.goals[i]);
                    activeGoal.Add(goal);
                    msg += character.characterData.goals[i].key + ":" + character.characterData.goals[i].value + " not yet satisfied\n";
                    break;
                }
                else
                {
                    msg += character.characterData.goals[i].key + ":" + character.characterData.goals[i].value + " not yet satisfied, but was already checked\n";
                }
            }
            else
            {
                if (checkedCharacterGoals.ContainsExactly(character.characterData.goals[i]))
                {
                    checkedCharacterGoals.Remove(character.characterData.goals[i]);
                }
                msg += character.characterData.goals[i].key + ":" + character.characterData.goals[i].value + " already satisfied\n";
            }
        }
        Character.Log(msg);

        timeSincePlanned = 0.0f;
    }
Ejemplo n.º 6
0
        public void AddSatisfyWorldState(WorldStateKey key, int value, IActionTarget target = null)
        {
            GOAP_Worldstate state = new GOAP_Worldstate(key, value, target);

            SatisfyWorldstates.Add(state);
        }
Ejemplo n.º 7
0
    protected void AddRequiredWorldState(WorldStateKey key, int value, IActionTarget target = null)
    {
        GOAP_Worldstate state = new GOAP_Worldstate(key, value, target);

        RequiredWorldstates.Add(state);
    }
Ejemplo n.º 8
0
 public void AddQuestWorldstate(GOAP_Worldstate state)
 {
     SatisfyWorldstates.Add(state);
 }
Ejemplo n.º 9
0
 public void AddProvided(GOAP_Worldstate state)
 {
     providedStates.Add(state);
 }
Ejemplo n.º 10
0
 public void AddRequired(GOAP_Worldstate state)
 {
     requiredStates.Add(state);
 }
Ejemplo n.º 11
0
 public void AddQuestWorldstate(GOAP_Worldstate state)
 {
     questData.AddRequired(state);
 }
Ejemplo n.º 12
0
    public void RemoveCurrentWorldState(ItemType type)
    {
        GOAP_Worldstate state = new GOAP_Worldstate(WorldStateKey.eHasItem, (int)type);

        RemoveCurrentWorldState(state);
    }