示例#1
0
    public override void Update(AIAgent _agent)
    {
        HostileAgent agent = (HostileAgent)_agent;

        enemiesWithinRange.Value = !waiting;
        lookingAtEnemy.Value     = agent.LookingAtTarget;
        canAttack.Value          = !agent.ShouldReload;
        hasTarget.Value          = agent.HasTarget;
    }
示例#2
0
 private void CheckHp()
 {
     //just does a condition if dead
     if (health <= 0)
     {
         HostileAgent hostileAgent = hostile.GetComponent <HostileAgent>();
         hostileAgent.agentsDestroyed++;
         hostileAgent.remainingAgents--;
         this.gameObject.SetActive(false);
     }
 }
示例#3
0
    // thing rotates until it can get a shot
    // rotation speed determines a good part of firing speed
    // but firing speed is still a thing

    /// <summary>
    /// shoot at enemy
    /// </summary>
    private void Shoot()
    {
        shotElapsedTime = 0;
        HostileAgent agent = NearestEnemy();

        if (null == agent)
        {
            return;
        }

        GameObject proj = Instantiate(projectile, transform.position, transform.rotation, transform);

        proj.transform.LookAt(agent.transform);
    }
示例#4
0
    private void Danger()
    {
        hostile = GameObject.FindGameObjectWithTag("Hostile");

        if (Vector3.Distance(this.transform.position, hostile.transform.position) <= dangerRange)
        {
            fear++;
            safe = -1;

            adrenaline += 3;
            //Debug.Log("in danger" + this.name);
        }
        if (Vector3.Distance(this.transform.position, hostile.transform.position) <= dangerRange / 2)
        {
            fear        = fear * 2;
            safe        = -5;
            happiness   = happiness / 2;
            adrenaline += 13;
        }
        if (Vector3.Distance(this.transform.position, hostile.transform.position) <= damageRange)
        {
            HostileAgent hostileAgent = hostile.GetComponent <HostileAgent>();
            int          hpLost       = hostileAgent.damage;

            health       = health - hpLost;
            damaged      = true;
            helplesness += helplesness + 10;
            adrenaline  += 33;
            safe         = -40;
            Debug.Log("damage taken" + this.name);
        }
        if (Vector3.Distance(this.transform.position, hostile.transform.position) <= damageRange / 2)
        {
            trapped = true;
        }

        if (escaped == true)
        {
            HostileAgent hostileAgent = hostile.GetComponent <HostileAgent>();
            hostileAgent.remainingAgents--;
            escaped = true;
            this.gameObject.SetActive(false);
        }
    }
示例#5
0
    /// <summary>
    /// spawns the enemy at the beginning of the set,
    /// adds it to the current level
    /// </summary>
    private void SpawnEnemy()
    {
        EnemySO eso =
            (EnemySO)
            ((ICollectionManager <EnemyType>)DefendState.Instance.enemyManager)
            .Get(enemySet[0].enemy);

        GameObject prefab = eso.prefab;

        HostileAgent ho = Instantiate(
            prefab,
            transform.position,
            Quaternion.identity,
            DefendState.Instance.enemyParent)
                          .GetComponent <HostileAgent>();

        // assign enemy path
        ((OrganicAgent)ho).AssignPath(pathToGoal);

        DefendState.CurrentLevel.AddEnemy(ho); // To Do: lots of casting bad
    }
示例#6
0
    /// <returns>the closest enemy</returns>
    private HostileAgent NearestEnemy()
    {
        HostileAgent[] enemies = FindObjectsOfType <HostileAgent>();
        if (enemies.Length == 0)
        {
            return(null);
        }

        HostileAgent ret  = enemies[0];
        float        dist = Vector3.Distance(transform.position, ret.transform.position);

        foreach (HostileAgent agent in enemies)
        {
            float n = Vector3.Distance(transform.position, agent.transform.position);
            if (n < dist)
            {
                dist = n;
                ret  = agent;
            }
        }
        return(ret);
    }
示例#7
0
 public Turn(HostileAgent agent) : base(agent)
 {
 }
示例#8
0
 public Rest(HostileAgent agent) : base(agent)
 {
 }
示例#9
0
 public BreakWall(HostileAgent agent) : base(agent)
 {
 }
示例#10
0
 public AssignNextAttackTarget(HostileAgent agent) : base(agent)
 {
 }
示例#11
0
 public Attack(HostileAgent agent) : base(agent)
 {
 }