0% found this document useful (0 votes)
3 views1 page

Gamemanager

The document is a Unity C# script for a simple Rock-Paper-Scissors game. It allows a player to make a choice, randomly generates a computer choice, and determines the winner based on the rules of the game. The result is displayed through a UI text element, indicating whether the player wins, loses, or ties.

Uploaded by

mr.emkay001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Gamemanager

The document is a Unity C# script for a simple Rock-Paper-Scissors game. It allows a player to make a choice, randomly generates a computer choice, and determines the winner based on the rules of the game. The result is displayed through a UI text element, indicating whether the player wins, loses, or ties.

Uploaded by

mr.emkay001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

using System.

Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;-

public class GameManager : MonoBehaviour


{
public Text resultText; //Reference to the result text
private string[] choices = {"Rock","Paper","Scissors"};

public void PlayerChoice(string PlayerChoice)


{
string computerChoice = choices[Random.Range(0, choices.Length)];
DetermineWinner(playerChoice, computerChoice);
}
private void DetermineWinner(string player, string computer)
{
if (player == computer)
{
resultText.text = "It's a Tie! Both chose" + player;
}
else if ((player == "Rock" && computer == "Scissors") ||
(player == "Paper" && computer == "Rock") ||
(player == "Scissors" && computer == "Paper"))
{
resultText.text = "You Win! " + player + player + "beats" +
computer;
}
else
{
resultText.text = "You Lose!" + computer + "beats" + player;
}
}

You might also like