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; }
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); } }
// 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); }
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); } }
/// <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 }
/// <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); }
public Turn(HostileAgent agent) : base(agent) { }
public Rest(HostileAgent agent) : base(agent) { }
public BreakWall(HostileAgent agent) : base(agent) { }
public AssignNextAttackTarget(HostileAgent agent) : base(agent) { }
public Attack(HostileAgent agent) : base(agent) { }