private void OnDestroy() { foreach (Vector2Int d in data) { FlowFieldGenerator.GetInstance().Regenerate(d); } }
//Attack and deal damage if a player was hit public void Attack() { action = E_ACTION.ATTACK; //If there is no valid target in the attackbox then the attack is missed if (attackHitbox.target != null) { attackHitbox.target.transform.GetComponent <PlayerHealth>().DamagePlayer(attackDamage); if (attackHitbox.target.transform.GetComponent <PlayerHealth>().playerState == PlayerHealth.PlayerState.ALIVE) { //Set 0 to 1 and 1 to 0 path = FlowFieldGenerator.GetInstance().AttemptTarget(path * -1 + 1); } //DEBUG //transform.Find("AttackEffect").GetComponent<ParticleSystem>().Play(); Debug.Log("attacking " + attackHitbox.target.name); } }
// Use this for initialization void Start() { behaviours.Add(new EnemyPathing(this, pathingWeight)); behaviours.Add(new EnemyFlocking(this, flockingWeight)); behaviours.Add(new EnemyWander(this, wanderWeight)); //This one needs work cc = GetComponent <CharacterController>(); anim = GetComponent <Animator>(); health = GetComponent <EnemyHealth>(); attackHitbox = transform.Find("AttackBox").GetComponent <EnemyAttackBox>(); p1HP = FlowFieldGenerator.GetInstance().targets[0].GetComponent <PlayerHealth>(); p2HP = FlowFieldGenerator.GetInstance().targets[1].GetComponent <PlayerHealth>(); }
//Initialization public EnemyPathing(Enemy _enemy, float _weight = 1.0f) : base(_enemy, _weight) { FFG = FlowFieldGenerator.GetInstance(); }