public void DecreaseHp(int cnt) { if (state == EnemyState.die || state == EnemyState.hit) { return; } hp -= cnt; oldState = state; state = EnemyState.hit; velocity = 0; EnemyExplosion enemyExplosion = GetComponentInChildren <EnemyExplosion>(); enemyExplosion.isEnemyAtked = true; Runaway(enemiesManager.playerTarget); //Debug.Log("데미지: " + cnt); if (hp <= 0) { //Debug.Log("주겄당!!"); state = EnemyState.die; oldRotation = transform.rotation; animator.SetTrigger("dieTrigger"); } //Debug.Log("enemy hp: " + hp); }
public void DecreaseHpByWolf(int cnt, TrainingWolf wolf = null) { if (state == EnemyState.die || state == EnemyState.hit) { return; } hp -= cnt; oldState = state; state = EnemyState.hit; velocity = 0; EnemyExplosion enemyExplosion = GetComponentInChildren <EnemyExplosion>(); enemyExplosion.isEnemyAtked = true; if (wolf != null) { enemiesManager.AtkReward(atk, wolf); Runaway(wolf.gameObject); } if (hp <= 0) { //Debug.Log("주겄당!!"); if (wolf != null) { enemiesManager.DieReward(wolf); } state = EnemyState.die; oldRotation = transform.rotation; animator.SetTrigger("dieTrigger"); } }
// Start is called before the first frame update void Start() { timer = 0; player = GameObject.FindGameObjectWithTag("Player"); spawner = GameObject.FindGameObjectWithTag("Spawner"); spawnerScript = spawner.GetComponent <Spawner>(); explosionScript = explosionGO.GetComponent <EnemyExplosion>(); playerScript = player.GetComponent <Player>(); rb = gameObject.GetComponent <Rigidbody>(); }
private static void CreateExplosion(Bug bug, AnimationService animationService, GameService gameService) { var exp = new EnemyExplosion() { DrawPath = false, RotateAlongPath = false, Started = true, DestroyAfterComplete = false, IsMoving = false, PathIsLine = true, Location = new PointF(bug.Location.X + 5, bug.Location.Y) }; exp.SpriteBankIndex = -1; exp.SpriteBank.Add(new Sprite(Sprite.SpriteTypes.EnemyExplosion1)); exp.SpriteBank.Add(new Sprite(Sprite.SpriteTypes.EnemyExplosion2)); exp.SpriteBank.Add(new Sprite(Sprite.SpriteTypes.EnemyExplosion3)); exp.SpriteBank.Add(new Sprite(Sprite.SpriteTypes.EnemyExplosion4)); exp.SpriteBank.Add(new Sprite(Sprite.SpriteTypes.EnemyExplosion5)); animationService.Animatables.Add(exp); if (bug.Sprite.SpriteType == Sprite.SpriteTypes.RedBug) { gameService.Score += bug.IsDiveBomber || bug.IsDiving ? Constants.Score_RedBugDiving : Constants.Score_RedBug; } if (bug.Sprite.SpriteType == Sprite.SpriteTypes.BlueBug) { gameService.Score += bug.IsDiveBomber || bug.IsDiving ? Constants.Score_BlueBugDiving : Constants.Score_BlueBug; } if (bug.Sprite.SpriteType == Sprite.SpriteTypes.GreenBug) { gameService.Score += bug.IsDiveBomber || bug.IsDiving ? Constants.Score_GreenBugDiving : Constants.Score_GreenBug; } }