Skip to content

Instantly share code, notes, and snippets.

@pouhiro1224
Last active November 23, 2018 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pouhiro1224/5a487a1de2dd675193e3c656ea8f2146 to your computer and use it in GitHub Desktop.
Save pouhiro1224/5a487a1de2dd675193e3c656ea8f2146 to your computer and use it in GitHub Desktop.
勝敗判定スクリプト
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