void Update() { Vector2 moveInput = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); moveVelocity = moveInput.normalized * speed; RotateChar(); ArmaControl(); if (moveVelocity != Vector2.zero) { isMoving = true; } else { isMoving = false; } healthBar.value = health; if (health <= 0) { gOver.GameOver(); this.gameObject.GetComponent <SpriteRenderer>().enabled = false; } if (gOver.GameOverCheck) { this.gameObject.GetComponent <Player>().enabled = false; } }
void Update() { if (health <= 0) { Instantiate(DeadExplosion, transform.position, Quaternion.identity); gOver.GameOver(); this.gameObject.GetComponent <SpriteRenderer>().enabled = false; } if (gOver.GameOverCheck) { this.gameObject.GetComponent <Boss>().enabled = false; } if (finiteStateMachine != null && finiteStateMachine.currentlyRunningState == null) { int r = Random.Range(0, 3); myState = (StateType)r; State nextState = null; switch (myState) { case StateType.Chase1: nextState = new ChasePlayer(this, player, speed, projectile[0]); break; case StateType.Chase2: nextState = new ChasePlayer2(this, player, speed, projectile[1]); break; case StateType.Idle: nextState = new IdleState(idleTime); break; default: break; } finiteStateMachine.ReciveState(nextState); } finiteStateMachine.ExecuteState(); healthBar.value = health; }