Inheritance: MonoBehaviour
    public AttackNearbyEnemy(AgentActions actions, Sensing senses, float attackDelay)
    {
        this.actions = actions;
        this.senses  = senses;

        attackTimer = new WaitForSeconds(attackDelay);
    }
 public CollectItem(AgentActions actions, Sensing senses, InventoryController inventory, GameObject itemToCollect)
 {
     this.actions       = actions;
     this.senses        = senses;
     this.inventory     = inventory;
     this.itemToCollect = itemToCollect;
 }
Esempio n. 3
0
 // Use this constructor to set own tolerance to reach if you have problems reaching a specific point on the NavMesh
 public GoToPos(AI agent, AgentActions actions, GameObject target, float tolerance)
 {
     this.agent     = agent;
     this.actions   = actions;
     this.target    = target;
     this.tolerance = tolerance;
 }
Esempio n. 4
0
    void Start()
    {
        //Fetching infromation from AgentActions script
        agentScript = this.gameObject.GetComponent <AgentActions>();

        //Applying the same properties to the second enemy
        EnemyObject = agentScript.Enemy;

        //Creating a second enemy and assigning it as an enemy
        EnemyScript = EnemyObject.GetComponent <AgentActions>();

        //Assigning the enemy
        AgentName = this.gameObject.name;

        // Specifying and setting the enemies
        if (AgentName == "AIAgent2")
        {
            EnemyName = "AIAgent1";
        }

        else
        {
            EnemyName = "AIAgent2";
        }
        //Set enemies to begin in state random wander
        currentState = State.Wander;
    }
Esempio n. 5
0
 // Initialise target with a blackboard entry
 public GoToPos(AI agent, AgentActions actions, string blackboardEntry, Blackboard bbData)
 {
     this.agent           = agent;
     this.actions         = actions;
     this.blackboardEntry = blackboardEntry;
     this.bbData          = bbData;
 }
 public bool Equals(UnityRLInput other)
 {
     if (ReferenceEquals(other, null))
     {
         return(false);
     }
     if (ReferenceEquals(other, this))
     {
         return(true);
     }
     if (!AgentActions.Equals(other.AgentActions))
     {
         return(false);
     }
     if (!object.Equals(EnvironmentParameters, other.EnvironmentParameters))
     {
         return(false);
     }
     if (IsTraining != other.IsTraining)
     {
         return(false);
     }
     if (Command != other.Command)
     {
         return(false);
     }
     return(Equals(_unknownFields, other._unknownFields));
 }
Esempio n. 7
0
    // a function that allows the enemy to move towards the powerup if they see it and if they are within range they will be able to use the power up
    public bool FindPowerUp(Sensing sense, AgentData data, AgentActions actions, bool PowerUpZone)
    {
        List <GameObject> objects = sense.GetCollectablesInView();

        for (int i = 0; i < objects.Count; i++)
        {
            if (objects[i].name == "Power Up")
            {
                if (sense.IsItemInReach(objects[i]))
                {
                    objects[i].GetComponent <PowerUp>().Use(data);
                }
            }
        }

        if (!PowerUpZone)
        {
            if (data.FriendlyTeamTag == Tags.BlueTeam)
            {
                actions.MoveTo(GameObject.FindGameObjectWithTag("Powerup"));
            }
            else if (data.FriendlyTeamTag == Tags.RedTeam)
            {
                actions.MoveTo(GameObject.FindGameObjectWithTag("Powerup"));
            }
        }

        return(true);
    }
Esempio n. 8
0
    // a function that once the Ai becomes low on health they will begin to move away from the fight and is they see the health kit within view then they will use it
    public bool Fleeing(AgentActions actions, AgentData data, Sensing sensing, bool HealthZone)
    {
        List <GameObject> objects = sensing.GetCollectablesInView();

        for (int i = 0; i < objects.Count; i++)
        {
            if (objects[i].name == "Health Kit")
            {
                objects[i].GetComponent <HealthKit>().Use(data);
            }
        }

        if (!HealthZone)
        {
            if (data.FriendlyTeamTag == Tags.BlueTeam)
            {
                actions.MoveTo(GameObject.FindGameObjectWithTag("HealthKit"));
            }
            else if (data.FriendlyTeamTag == Tags.RedTeam)
            {
                actions.MoveTo(GameObject.FindGameObjectWithTag("HealthKit"));
            }
        }



        return(true);
    }
Esempio n. 9
0
 // Use this constructor to set own tolerance and an interruptable action
 public GoToPos(AI agent, AgentActions actions, GameObject target, float tolerance, BaseNode attackAction)
 {
     this.agent        = agent;
     this.actions      = actions;
     this.target       = target;
     this.tolerance    = tolerance;
     this.attackAction = attackAction;
 }
Esempio n. 10
0
    /// <summary>
    /// We've died, destroy our gameobject
    /// </summary>
    public void Die()
    {
        _aiMood = AiMood.Dead;
        AgentActions actions = gameObject.GetComponent <AgentActions>();

        actions.DropAllItems();
        Destroy(gameObject);
    }
Esempio n. 11
0
 // Use this for initialization
 void Start()
 {
     // Initialise the accessable script components
     _agentData      = GetComponent <AgentData>();
     _agentActions   = GetComponent <AgentActions>();
     _agentSenses    = GetComponentInChildren <Sensing>();
     _agentInventory = GetComponentInChildren <InventoryController>();
 }
Esempio n. 12
0
    // an action to determine if we have the flag if we do then we will begin to move home
    public bool MoveHomeWithOurFlag(AgentActions actions, GameObject HomeBase, bool flag)
    {
        if (flag)
        {
            actions.MoveTo(HomeBase);
        }

        return(true);
    }
Esempio n. 13
0
    // a function that allows the Ai to be able to drop the flag when they are within thier base
    public bool DropItemAtBase(GameObject FriendlyBase, AI TheAi, AgentActions TheActions, bool flag)
    {
        if (TheAi.transform.position.x == FriendlyBase.transform.position.x || TheAi.transform.position.y == FriendlyBase.transform.position.y)
        {
            TheActions.DropAllItems();
        }


        return(true);
    }
Esempio n. 14
0
 // Use this for initialization
 void Start()
 {
     // Initialise the accessable script components
     _agentData      = GetComponent <AgentData>();
     _agentActions   = GetComponent <AgentActions>();
     _agentSenses    = GetComponentInChildren <Sensing>();
     _agentInventory = GetComponentInChildren <InventoryController>();
     currentNode     = rootNode;
     startingPostion = transform.position;
     // nodeOptions = NodeOptions.Nothing;
 }
        private void InitializeActions()
        {
            AccountControllerTest accountTest = new AccountControllerTest();

            agentActions = new AgentActions();
            AutorizationCheck(AutorizationType);
            if (AutorizationType == AutorizationType.Authorize)
            {
                agentActions.CreateHeaders(AutorizationType, LoginResult);
            }
        }
    void Awake()
    {
        //assign agent actions var
        agentActions = GetComponent<AgentActions>();
        actionDataList = agentActions.proactiveActions;
        agent = GetComponent<TileAgent>();
        agent.agentActions = agentActions;

        //create ui for the agent
        CreateUI ();
    }
    //******************************************************************************************************************//
    //******************************************************************************************************************//

    // A decision to check if the agent's attack power is equal to
    // or greater than the opponent's attack power
    public static bool IsAttackPowerHigher(AgentActions agent, GameObject enemy, GameObject powerPickup, GameObject healthKit)
    {
        if (agent.PowerUp >= enemy.GetComponent <AgentActions>().PowerUp)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Esempio n. 18
0
 // a function that checks to see if the Ai has low health and if they do they will begin to flee
 public bool LowHealth(AgentData data, AgentActions actions, Sensing sensing, bool Retreated, bool HealthZone)
 {
     if (data.CurrentHitPoints < 15)
     {
         if (sensing.GetEnemiesInView().Count == 0)
         {
             Fleeing(actions, data, sensing, HealthZone);
             return(true);
         }
     }
     return(false);
 }
Esempio n. 19
0
    void Start()
    {
        // Initialise the accessable script components
        _agentData      = GetComponent <AgentData>();
        _agentActions   = GetComponent <AgentActions>();
        _agentSenses    = GetComponentInChildren <Sensing>();
        _agentInventory = GetComponentInChildren <InventoryController>();


        StateMachine = new StateMachineController <AI>(this);  //Creates a state machine for this AI Agent
        StateMachine.ChangeState(GotoEnemyBaseState.Instance); //Set the initial state of the AI Player
    }
    //******************************************************************************************************************//
    //******************************************************************************************************************//

    // A decision to check if a health kit is in agent's sight
    public static bool IsHealthKitInSight(AgentActions agent, GameObject enemy, GameObject powerPickup, GameObject healthKit)
    {
        // If the game objects of HealthKit tag are in sight, the count
        // of the returned list will be greater than zero
        if (agent.GetGameObjectsInViewOfTag(Constants.HealthKitTag).Count > 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
 public override Node MakeDecision(AgentActions agent, GameObject enemy, GameObject powerPickup, GameObject healthKit)
 {
     // The reference pointer will now call the function it was assigned to
     // and return a boolean of either true or false
     if (m_decision.Invoke(agent, enemy, powerPickup, healthKit) == true)
     {
         return(true_child);
     }
     else
     {
         return(false_child);
     }
 }
Esempio n. 22
0
    // a function that allows the Ai to check to see if there are enemys near by. if there are then they will begin to move to wards them and attack. slowing down when they get close enough to attack
    public void Attack(Sensing view, AgentActions action)
    {
        //first see if an enemy comes into view
        foreach (GameObject G in view.GetEnemiesInView())
        {
            action.ResumeMovement();
            action.MoveTo(G);
            action.AttackEnemy(G);
            //this.GetComponent<AgentActions>().AttackEnemy(G);
        }

        //need to resume movement when enemyes are dead
    }
    //******************************************************************************************************************//
    //******************************************************************************************************************//

    public static bool IsHealthHigherThan25Percent(AgentActions agent, GameObject enemy, GameObject powerPickup, GameObject healthKit)
    {
        // If the agent's health is greater than 25% of its maximum
        // health, this function will return true
        if (agent.CurrentHitPoints > 0.25 * agent.MaxHitPoints)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
    public void Execute(AgentActions agent, GameObject enemy, GameObject powerPickup, GameObject healthKit)
    {
        sequence[slot].Execute(agent, enemy, powerPickup, healthKit);


        if (sequence[slot].IsComplete)
        {
            // This check is to make sure we
            // don't go out of array bounds
            if (slot + 1 < sequence.Count)
            {
                slot++;
            }
        }
    }
Esempio n. 25
0
    /// <summary>
    /// We've died, destroy our gameobject
    /// </summary>
    public void Die()
    {
        _isAlive = false;
        _aiMood  = AiMood.Dead;

        Dictionary <string, GameObject> inventory = gameObject.GetComponentInChildren <InventoryController>().Items;
        AgentActions actions = gameObject.GetComponent <AgentActions>();

        foreach (var item in inventory)
        {
            actions.DropItem(item.Value);
        }

        Destroy(gameObject);
    }
Esempio n. 26
0
    // Use this for initialization
    public virtual void Start()
    {
        // Initialise the accessable script components
        _agentData      = GetComponent <AgentData>();
        _agentActions   = GetComponent <AgentActions>();
        _agentSenses    = GetComponentInChildren <Sensing>();
        _agentInventory = GetComponentInChildren <InventoryController>();

        enemyFlag    = GameObject.Find(flag.ToString() + " Flag");
        friendlyFlag = GameObject.Find(getData().FriendlyFlagName);
        Base         = GameObject.Find(baseEnum.ToString() + " Base");
        agent        = GetComponent <NavMeshAgent>();
        powerup      = GameObject.Find("Power Up");
        health       = GameObject.Find("Health Kit");
        defencePoint = transform.position;
    }
    public void Execute(AgentActions agent, GameObject enemy, GameObject powerPickup, GameObject healthKit)
    {
        if (!is_complete)
        {
            // Timer increases with delta time
            timer += Time.deltaTime;

            Debug.Log(agent.name + " executing " + m_action.Method.Name);

            // If timer execeeds the delay in execution,
            // then execute the action
            if (timer >= delay)
            {
                is_complete = m_action.Invoke(agent, enemy, powerPickup, healthKit);
            }
        }
    }
    public void Traverse(Node cur_node, AgentActions agent, GameObject enemy, GameObject powerPickup, GameObject healthKit)
    {
        // If the current node is not an action node, then make a
        // decision
        if (cur_node.IsLeaf)
        {
            leaf_action = cur_node.GetAction();
        }
        else
        {
            current_node = cur_node.MakeDecision(agent, enemy, powerPickup, healthKit);

            // The function is called from within the function itself almost
            // like a loop until it arrives at an action node
            Traverse(current_node, agent, enemy, powerPickup, healthKit);
        }
    }
Esempio n. 29
0
        public override int GetHashCode()
        {
            int hash = 1;

            hash ^= AgentActions.GetHashCode();
            if (Command != global::MLAgents.CommunicatorObjects.CommandProto.Step)
            {
                hash ^= Command.GetHashCode();
            }
            if (SideChannel.Length != 0)
            {
                hash ^= SideChannel.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Esempio n. 30
0
        public override int GetHashCode()
        {
            int hash = 1;

            hash ^= AgentActions.GetHashCode();
            if (Command != 0)
            {
                hash ^= Command.GetHashCode();
            }
            if (SideChannel.Length != 0)
            {
                hash ^= SideChannel.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Esempio n. 31
0
        public override int GetHashCode()
        {
            int hash = 1;

            hash ^= AgentActions.GetHashCode();
            if (IsTraining != false)
            {
                hash ^= IsTraining.GetHashCode();
            }
            if (Command != 0)
            {
                hash ^= Command.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Esempio n. 32
0
    protected override void Start()
    {
        base.Start();

        RegisterWithTeam();

        _modelRotControl.SetDesiredLookDirec(-Vector3.forward);

        agentActions = GetComponent<AgentActions>();

        foreach (AgentActions.ActionData actionData in agentActions.proactiveActions) {
            if (actionData.action as MoveAction != null) {
                moveAction = actionData.action as MoveAction;
            }
        }
    }