void DrawEngineSelect() { GUIContent[] selectionContent = new GUIContent[3]; selectionContent[0] = new GUIContent("ballista"); selectionContent[1] = new GUIContent("catapult"); selectionContent[2] = new GUIContent("trebuchet"); Rect engineSelectPosition = new Rect(10, 20, 100, 100); engineSelectNumber = GUI.SelectionGrid(engineSelectPosition, engineSelectNumber, selectionContent, 1); switch (engineSelectNumber) { case 0: MainGameCode.SetEngine(ENGINE.BALLISTA); break; case 1: MainGameCode.SetEngine(ENGINE.CATAPULT); break; case 2: MainGameCode.SetEngine(ENGINE.TREBUCHET); break; } }
void DrawResetPuckButton() { if (GUI.Button(new Rect(Screen.width - buttonSize - buttonOffset, Screen.height - buttonOffset - buttonSize, buttonSize, buttonSize), resetTexture)) { MainGameCode.ResetPuck(); } }
void OnTriggerEnter(Collider col) { //Debug.Log("EndZoneCode: collider name " + col.gameObject.name); if (col.gameObject.name == "Puck") { MainGameCode.EndZoneResetPuck(); } }
// Update is called once per frame void Update() { DIRECTION direction = DIRECTION.NONE; //Debug.Log(rigidbody.velocity.magnitude); if (rigidbody.velocity.magnitude > 1) { puckMoving = true; } if (puckMoving) { cameraResetFlag = true; moveCamera.GetComponent <Camera>().enabled = true; moveCamera.transform.position = transform.position + rigidbody.velocity.normalized * -100; if (moveCamera.transform.position.y < 20) { moveCamera.transform.position = new Vector3(moveCamera.transform.position.x, 20, moveCamera.transform.position.z); } moveCamera.transform.LookAt(transform.position); } if (cameraResetFlag && !puckMoving) { cameraResetFlag = false; MainGameCode.MainCameraSetBehindPuck(); } if (puckMoving && rigidbody.velocity.magnitude < 1) { puckMoving = false; transform.rotation = Quaternion.Euler(0, 0, 0); moveCamera.GetComponent <Camera>().enabled = false; } if (Input.GetKey(KeyCode.LeftArrow)) { direction = DIRECTION.LEFT; } if (Input.GetKey(KeyCode.RightArrow)) { direction = DIRECTION.RIGHT; } if (MainGameCode.gamestate == GAMESTATE.AIM && direction != DIRECTION.NONE) { int rotationSwitch = 1; if (direction == DIRECTION.LEFT) { rotationSwitch = -1; } transform.Rotate(0, (RotationSpeed * Time.deltaTime * rotationSwitch), 0, Space.World); } }
// Update is called once per frame void Update() { switch (MainGameCode.gamestate) { case GAMESTATE.TITLE: if (Input.GetMouseButtonDown(0)) { MainGameCode.PlayGame(); } break; case GAMESTATE.GAMEOVER: if (Input.GetMouseButtonDown(0)) { MainGameCode.ResetGame(); } break; case GAMESTATE.PLAY: if (Input.GetKey(KeyCode.Return)) { MainGameCode.AimMode(); } break; case GAMESTATE.AIM: if (Input.GetKey(KeyCode.Escape)) { MainGameCode.EndAim(); } if (Input.GetKey(KeyCode.Space)) { MainGameCode.PowerCharge(); } if (Input.GetKeyUp(KeyCode.Space) && MainGameCode.currentPower > 0) { MainGameCode.ShootPuck(); } break; } //cursor hide and show if (Input.GetKey(KeyCode.LeftControl) || (MainGameCode.gamestate != GAMESTATE.PLAY && MainGameCode.gamestate != GAMESTATE.AIM)) { Screen.showCursor = true; } else { Screen.showCursor = false; } }
// Update is called once per frame void Update() { //if the king gets knocked off pedestal then its gameover if (transform.position.y < 20) { MainGameCode.GameOver(); } if (stabilizeTimer > 0) { stabilizeTimer -= Time.deltaTime; } if (stabilizeTimer < 0) { stabilizeTimer = 0; rigidbody.WakeUp(); } }
void DrawSettingsWindow() { GUILayout.BeginArea(new Rect(Screen.width * .5f - Screen.width * .5f * .01f * settingsWindowWidth, Screen.height * .5f - Screen.height * .5f * .01f * settingsWindowHeight, Screen.width * .01f * settingsWindowWidth, Screen.height * .01f * settingsWindowHeight)); if (GUILayout.Button("Back To Game")) { MainGameCode.gamestate = GAMESTATE.PLAY; } if (GUILayout.Button("Quit Game")) { MainGameCode.QuitGame(); } GUILayout.EndArea(); }
// Update is called once per frame void Update() { switch (MainGameCode.gamestate) { case GAMESTATE.TITLE: if (Input.GetMouseButtonDown(0)) { MainGameCode.PlayGame(); } break; case GAMESTATE.GAMEOVER: if (Input.GetMouseButtonDown(0)) { MainGameCode.ResetGame(); } break; case GAMESTATE.PLAY: if (Input.GetKey(KeyCode.Return)) { MainGameCode.AimMode(); } break; case GAMESTATE.AIM: if (Input.GetKey(KeyCode.Escape)) { MainGameCode.EndAim(); } if (Input.GetKey(KeyCode.Space)) { MainGameCode.PowerCharge(); } if (Input.GetKeyUp(KeyCode.Space) && MainGameCode.currentPower > 0) { MainGameCode.ShootPuck(); } break; } }