// Use this for initialization void Start() { transform.position = instructionMenuWayPoint.position; transform.rotation = instructionMenuWayPoint.rotation; currentPanel = Panel.MENU; currentMenu = instructionMenu; currentMenu.activatePanel(); newGameMenu.deactivatePanel(); continueMenu.deactivatePanel(); }
// Update is called once per frame void Update() { // if currently in the process of switching panels // moving and turning are checked seperately if (turning || moving) { if (moving) { transform.position = Vector3.Lerp(transform.position, targetLocation, Time.deltaTime * turningSpeed * 2f); if (Vector3.Distance(transform.position, targetLocation) < 0.01) { moving = false; transform.position = targetLocation; } } if (turning) { transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, Time.deltaTime * turningSpeed); if (Mathf.Abs(transform.rotation.y - targetRotation.y) < 0.01) { turning = false; transform.rotation = targetRotation; } } if (!turning && !moving) { currentMenu.activatePanel(); } } else { // switching panels can occur using the buttons or the keyboard control if (Input.GetKeyDown(KeyCode.A) || InputManager.Player1Strafe < -1 * float.Epsilon || InputManager.Player2HorizontalInput < -1 * float.Epsilon) { if (currentPanel == Panel.MENU) { toNewGame(); } else if (currentPanel == Panel.CONTINUE) { toInstructionMenu(); } } else if (Input.GetKeyDown(KeyCode.D) || InputManager.Player1Strafe > float.Epsilon || InputManager.Player2HorizontalInput > float.Epsilon) { if (currentPanel == Panel.MENU) { toContinue(); } else if (currentPanel == Panel.NEWGAME) { toInstructionMenu(); } } } }
// Use this for initialization void Start() { transform.position = instructionMenuWayPoint.position; transform.rotation = instructionMenuWayPoint.rotation; currentPanel = Panel.MENU; currentMenu = instructionMenu; currentMenu.activatePanel (); newGameMenu.deactivatePanel (); continueMenu.deactivatePanel (); }