Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        //makes sure the goals are not being added to
        ResetAllGoals();
        //function to check health
        CheckHealth();

        // if the AI is close to the power up. update the utility of the AI
        if (_agentSenses.GetObjectInViewByName("Power Up"))
        {
            TheAI.UpdateGoalValue(AIGoals.PowerUp, 10);
        }
        else
        {
            // if not update the Utility of the Ai again for a differnt goals
            CheckEnemyflag();
            TheAI.UpdateGoalValue(AIGoals.PowerUp, -10);
        }

        //final update depending on what flags they have captured
        if (!NeedsHealth)
        {
            CheckEnemyflag();
        }

        //depending on the utility value of each of the actions pick one that satifys the highest goal
        ActionSequence CurrentAction = TheAI.ChooseAction();

        CurrentAction.Execute(this);

        Startcheck = true;
    }
Ejemplo n.º 2
0
    private void Simulation(int option)
    {
        switch (option)
        {
        case 1:
            if (this.tag == Tags.BlueTeam)
            {
                _agentActions.MoveTo(GameObject.Find(Names.RedFlag).transform.position);
            }
            else if (this.tag == Tags.RedTeam)
            {
                _agentActions.MoveTo(GameObject.Find(Names.BlueFlag).transform.position);
            }
            break;

        case 2:
            _agentActions.MoveTo(_agentData.FriendlyBase);
            break;

        case 3:
            _agentActions.MoveTo(_agentSenses.GetObjectInViewByName(Names.HealthKit));
            break;

        case 4:
            _agentActions.MoveTo(_agentSenses.GetObjectInViewByName(Names.PowerUp));
            break;

        case 5:
            _agentActions.MoveToRandomLocation();
            break;

        case 6:
            if (this.tag == Tags.BlueTeam)
            {
                _agentActions.MoveTo(_agentSenses.GetObjectInViewByName(Names.BlueFlag));
            }
            else if (this.tag == Tags.RedTeam)
            {
                _agentActions.MoveTo(_agentSenses.GetObjectInViewByName(Names.RedFlag));
            }
            break;

        default:
            break;
        }
    }