/// <summary> /// Gets called from the decision master with the command to /// Move the player either forward or turn the player 90 degree left or right; Then /// set the internal state of the class to move appropriately which will be carried out /// by the Update function. /// </summary> /// <param name="direction"> /// 0 is for direction forward /// 1 is for direction turn left /// 2 is for direction turn right /// </param> public void Move(int direction) { if (direction == 0) { if (!IsPossibleToMoveForward()) { Destroy(m_progressbarCloned); m_moveForward.Start(); m_endMotionDetector = new EndMotionDetector(); } } if (direction == 1) { Destroy(m_progressbarCloned); m_direction.TurnLeft(); m_endMotionDetector = new EndMotionDetector(); } if (direction == 2) { Destroy(m_progressbarCloned); m_direction.TurnRight(); m_endMotionDetector = new EndMotionDetector(); } }
public void EndLevelStop() { // hide (make not show) the progress bar. m_endMotionDetector = null; Destroy(m_progressbarCloned); AudioSource audioSource = GetComponent <AudioSource>(); audioSource.Stop(); }
void Start() { m_rigidbody = GetComponent <Rigidbody>(); m_endMotionDetector = new EndMotionDetector(); m_moveForward = new MoveForward(m_rigidbody.transform); m_direction = new Direction(); }
// Update is called once per frame void Update() { RotateToDestination(m_direction.getDirection(), m_turningSpeed); m_moveForward.Update(); // detect player end movement. if (m_endMotionDetector != null && m_endMotionDetector.IsMotionEnded(m_rigidbody.transform.position, m_rigidbody.transform.rotation)) { // the variable is not null once the player started moving and once the movement ended the variable must // be set to null again m_endMotionDetector = null; m_progressbarCloned = Instantiate(m_progressbar, new Vector3(Screen.width / 2, Screen.height / 4, 0), Quaternion.identity); } }
/// <summary> /// Gets called from the decision master with the command to /// Move the player either forward or turn the player 90 degree left or right; Then /// set the internal state of the class to move appropriately which will be carried out /// by the Update function. /// </summary> /// <param name="direction"> /// 0 is for direction forward /// 1 is for direction turn left /// 2 is for direction turn right /// </param> public void Move(int direction) { if (direction == 0) { if (!IsThereAWallAhead()) { m_moveForward.Start(); m_endMotionDetector = new EndMotionDetector(); } } if (direction == 1) { m_direction.TurnLeft(); m_endMotionDetector = new EndMotionDetector(); } if (direction == 2) { m_direction.TurnRight(); m_endMotionDetector = new EndMotionDetector(); } }