protected virtual void MoveAndAttack() { switch (baddieType) { case EnemyConstants.EnemyTypes.Baddie: GetComponent <NavMeshAgent2D>().destination = actions.DetectAndChase(transform.position, player.transform.position, 1); actions.MeleeAttack(damage, 1.5f); break; case EnemyConstants.EnemyTypes.DistanceBaddie: GetComponent <NavMeshAgent2D>().destination = actions.KeepDistance(transform.position, player.transform.position, Vector2.Distance(transform.position, player.transform.position)); break; case EnemyConstants.EnemyTypes.Boss: GetComponent <NavMeshAgent2D>().destination = bossMoves(); break; default: break; } }
protected override Vector2 bossMoves() { switch (state) { case BossStates.Shuffle: if (shuffleTimer >= shuffleTimerMax) { shuffleTimer = 0; actions.MeleeAttack(12, 8); print("Get Random Attack"); //state = BossStates.ChangeType; state = (BossStates)getRandomAttack(); randomSpawn(); print("State: " + state); break; } shuffleTimer += Time.deltaTime; return(transform.position); case BossStates.Chase: actions.SetDetectionDistance(50); if (chaseTimer >= chaseTimerMax) { chaseTimer = 0; actions.MeleeAttack(12, 8); print("attack!"); state = BossStates.Shuffle; break; } chaseTimer += Time.deltaTime; return(actions.DetectAndChase(transform.position, player.transform.position, 4)); case BossStates.Shoot: if (shootTimer <= shootTimerMax) { actions.bossFireGun(); } else { shootTimer = 0; state = BossStates.Shuffle; break; } shootTimer += Time.deltaTime; return(actions.DetectAndChase(transform.position, player.transform.position, 4)); case BossStates.Smash: if (smashTimer >= smashTimerMax) { smashTimer = 0; actions.MeleeAttack(12, 8); state = BossStates.Shuffle; } smashTimer += Time.deltaTime; return(transform.position); case BossStates.ChangeType: weakness = (WeaponController.EnergyTypes)getRandomType(); switch (weakness) { case WeaponController.EnergyTypes.Fire: GetComponent <SpriteRenderer>().color = new Color(.85f, .185f, .194f); break; case WeaponController.EnergyTypes.Electric: GetComponent <SpriteRenderer>().color = new Color(1f, 0.84f, 0.07f); break; case WeaponController.EnergyTypes.Freeze: GetComponent <SpriteRenderer>().color = new Color(0f, 0.8f, 1f); break; case WeaponController.EnergyTypes.Kinetic: GetComponent <SpriteRenderer>().color = new Color(0.39f, 1f, 0.51f); break; case WeaponController.EnergyTypes.Explosion: GetComponent <SpriteRenderer>().color = Color.grey; break; } state = BossStates.Shuffle; break; case BossStates.Spawn: if (spawnTimer >= spawnTimerMax) { spawnTimer = 0; randomSpawn(); state = BossStates.Shuffle; } spawnTimer += Time.deltaTime; break; default: break; } return(transform.position); }