public void SetState(State newState) { if (newState == currentState) { return; } switch (currentState) { case State.Walking: walkController.EndWalk(); break; } currentState = newState; switch (currentState) { case State.Walking: walkController.BeginWalk(); break; case State.Dead: SpriteRenderer renderer = GetComponent <SpriteRenderer>(); //renderer.sortingOrder = 0; //renderer.sprite = deadSprite; animator.SetTrigger("die"); gameLevelManager.killEnemy(); Debug.Log("Dead"); Destroy(gameObject, 1.5f); Debug.Log("Yaki kaki"); break; } }
private void Start() { player = GameObject.Find("Henchman").gameObject; enemyRb = GetComponent <Rigidbody2D>(); playerRb = player.GetComponent <Rigidbody2D>(); walkController = EnemyWalkController.Create(walkingStyle, enemyBaseSpeed, playerRb, enemyRb); walkController.BeginWalk(); spriteRenderer = GetComponent <SpriteRenderer>(); bulletController = EnemyBulletController.Create(bulletStyle, bulletSpeed, playerRb, enemyRb, bulletPrefab, minDeltaT, maxDeltaT); gameLevelManager = FindObjectOfType <LevelManager>(); }