public override bool perform(GameObject agent) { ZombieAgent za = agent.GetComponent <ZombieAgent>(); if (za.PlayerNear || za.nearbyEntities.Find(c => c ? c.gameObject.GetComponent <BasicZombie>() : null) == null) { Destroy(target.gameObject); return(false); } target.transform.position = targetZombie.gameObject.transform.position + (targetZombie.transform.position - targetPlayer.position).normalized * (za.attackRange / 4); za.moveAgent(this); if (Time.time - lastAttack > za.timeBetweenAttacks) { lastAttack = Time.time; agent.GetComponent <Animator>().SetBool("isAttacking", true); za.nearbyEntities.ForEach(c => { if (c && c.GetComponent <BasicZombie>()) { c.GetComponent <ZombieAgent>().Boost(); } }); } else { agent.GetComponent <Animator>().SetBool("isAttacking", false); } return(true); }
public override bool perform(GameObject agent) { ZombieAgent za = agent.GetComponent <ZombieAgent>(); if (!za.PlayerNear) { if (target) { Destroy(target.gameObject); } return(false); } target.transform.position = za.transform.position + (za.transform.position - targetPlayer.position).normalized * 2; za.moveAgent(this); return(true); }
// Realise the action. public override bool perform(GameObject agent) { ZombieAgent zombieAgent = GetComponent <ZombieAgent>(); zombieAgent.moveAgent(this); // if tank dead abort the plan if (target.GetComponentInParent <Com.MyCompany.MyGame.EnemyHealth>().IsDead) { return(false); } // If we are near the payload or if the tank is near the player, go to next action (isDone true) if ((payload != null && (agent.transform.position - payload.transform.position).magnitude <= agentToPayloadShiftRange) || ((target.transform.position - target.GetComponentInParent <ZombieAgent>().LastTarget.position).magnitude <= tankToPlayerShiftRange)) { IsHidden = true; } return(true); }