Last active
November 23, 2018 08:58
-
-
Save pouhiro1224/5a487a1de2dd675193e3c656ea8f2146 to your computer and use it in GitHub Desktop.
勝敗判定スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Update () { | |
if (isGameStart) { | |
//試合中にPlayer1.zが8fより少なくなったら負け | |
if (GameObject.Find ("Player1").transform.position.z <= 8f) { | |
//ゲーム開始フラグをOFF | |
isGameStart = false; | |
gameTimer.Stop (); | |
Vector3 player1Pos = GameObject.Find ("Player1").transform.position; | |
GameObject.Find ("Player1").transform.DOMove (new Vector3(player1Pos.x, -10f, player1Pos.z), 2f, false); | |
Timer timer = new Timer (); | |
timer.Start (2f, 1f); | |
timer.Finished += delegate { | |
gameStatusText.text = "You Lose..."; | |
//テキストを出したら、スタートボタンをアクティブ | |
startButton.interactable = true; | |
}; | |
} | |
//試合中にPlayer2.zが24fより少なくなったら負け | |
if (GameObject.Find ("Player2").transform.position.z >= 24f) { | |
//ゲーム開始フラグをOFF | |
isGameStart = false; | |
gameTimer.Stop (); | |
Vector3 player2Pos = GameObject.Find ("Player2").transform.position; | |
GameObject.Find ("Player2").transform.DOMove (new Vector3(player2Pos.x, -10f, player2Pos.z), 2f, false); | |
Timer timer = new Timer (); | |
timer.Start (2f, 1f); | |
timer.Finished += delegate { | |
gameStatusText.text = "You Win!!"; | |
//テキストを出したら、スタートボタンをアクティブ | |
startButton.interactable = true; | |
}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment