public void Resign(GameObject activeCamera) { Ray ray = new Ray(activeCamera.transform.position, activeCamera.transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.collider.gameObject == resign) { load.Loading(); rayhit = true; if (load.LoadComp()) { if (activeCamera.tag == "Player1") { ResultManager.PResult = Result.player1lose; } else { ResultManager.PResult = Result.player1win; } SceneManager.LoadScene("Result"); } } } else if (rayhit == true) { load.Loadinit(); rayhit = false; } }
// Update is called once per frame void Update() { Ray ray1 = new Ray(Player1Camera.transform.position, Player1Camera.transform.forward); RaycastHit hit1; if (Physics.Raycast(ray1, out hit1)) { if (hit1.collider.gameObject == bottum) { load1.Loading(); rayhit1 = true; if (load1.LoadComp()) { SceneManager.LoadScene("Start"); } } } else if (rayhit1 == true) { load1.Loadinit(); rayhit1 = false; } Ray ray2 = new Ray(Player2Camera.transform.position, Player2Camera.transform.forward); RaycastHit hit2; if (Physics.Raycast(ray2, out hit2)) { if (hit2.collider.gameObject == bottum) { load2.Loading(); rayhit2 = true; if (load2.LoadComp()) { SceneManager.LoadScene("Start"); } } } else if (rayhit2 == true) { load2.Loadinit(); rayhit2 = false; } }
// Update is called once per frame void Update() { Ray ray = new Ray(MainCamera.transform.position, MainCamera.transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.collider.gameObject == start) { load.Loading(); rayhit = true; if (load.LoadComp()) { SceneManager.LoadScene("Main"); } } } else if (rayhit == true) { load.Loadinit(); rayhit = false; } }
public void PlayerSelect() { Ray ray = new Ray(this.transform.position, this.transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { hittedObj = hit.collider.gameObject; rayhitted = true; switch (selectState) { case SelectState.playerSelect: if (hittedObj.transform.parent.tag == playerName) { if (hittedPlayer == null) { hittedPlayer = hittedObj; playerLoad = hittedPlayer.GetComponentInChildren <ILoading>(); hittedPlayer.GetComponent <IMovable>().MovableSS(); } else { if (hittedPlayer.GetComponent <IMovable>().Movable()) { playerLoad.Loading(); if (playerLoad.LoadComp()) { selectState = SelectState.squareSelect; } } } } break; case SelectState.squareSelect: //playseselect cancel if (hittedObj.transform.parent.tag == playerName && hittedObj.tag == "Player") { if (hesHittedPlayer == null) { hesHittedPlayer = hittedObj; playerLoad = hesHittedPlayer.GetComponentInChildren <ILoading>(); } else { playerLoad.Loading(); if (playerLoad.LoadComp()) { hittedPlayer.GetComponent <IMovable>().SSinit(); hittedPlayer = null; selectState = SelectState.playerSelect; } } } //square select if (hittedObj.tag == "SelectableSquare") { if (hittedSquare == null) { hittedSquare = hittedObj; squareLoad = hittedSquare.GetComponentInChildren <ILoading>(); } else { squareLoad.Loading(); if (squareLoad.LoadComp()) { hittedSquare.GetComponent <IDestroy>().SetDestroyer(); GameManager.GameState = GameState.moverdy; } } } break; } } //initiallization else if (rayhitted) { hittedObj = null; rayhitted = false; switch (selectState) { case SelectState.playerSelect: if (hittedPlayer != null) { hittedPlayer.GetComponent <IMovable>().SSinit(); hittedPlayer = null; if (playerLoad != null) { playerLoad.Loadinit(); } } break; case SelectState.squareSelect: //playseselect cancel if (hesHittedPlayer != null) { playerLoad.Loadinit(); hesHittedPlayer = null; } //square select if (hittedSquare != null) { squareLoad.Loadinit(); hittedSquare = null; } break; } } }