Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
勝敗判定スクリプト
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