//Works like initialization method when EnemyAims state is the current one public void StartShootSequence() { //First assinging a random aim duration m_RandomAimDuration = Random.Range(0.5f, 1.7f); //Then reset the lerp timer m_AimTimer = 0f; //assigning a random shoot angle m_ShootAngle = Random.Range(30f, 70f); //and a random zoom out float m_RandomZoomOutTarget = Random.Range(3f, 5f); //finally start the aim process m_CurShootState = ShootStates.Aiming; }
//Used for State controll private void StateUpdate() { switch (m_CurShootState) { //When aiming starts case ShootStates.Aiming: //Lerping the aim angle used for rotating the Enemy's arms m_AimAngle = Mathf.Lerp(0f, m_ShootAngle, m_AimTimer); //Lerping the Zoom distance to give the look of Powering up m_ZoomOutDistance = Mathf.Lerp(0f, m_RandomZoomOutTarget, m_AimTimer); //Rotating the Arms SetArmsRotation(m_AimAngle); //Setting the Orthographic size CameraManager.Instance.SetCameraSize(m_ZoomOutDistance); //Controlling the lerping if (m_AimTimer < 1) { //making it last the desired duration m_AimTimer += Time.deltaTime / m_RandomAimDuration; } else { //reseting the timer and setting the next state m_AimTimer = 0f; m_CurShootState = ShootStates.Shoot; } break; case ShootStates.Shoot: //Playing the throw sound AudioManager.Instance.PlayThrowSound(); //Shoots the projectile Shoot(); //Changing Game State GameManager.Instance.SetState(GameState.EnemyShoots); //And Shoot Behaviour state m_CurShootState = ShootStates.Iddle; break; case ShootStates.Iddle: break; default: break; } }