Example #1
0
        public static ActionCommand GenerateActionCommand(RPS_Player player)
        {
            // skip default option at end of enum
            var lengthOfValidEntries = Enum.GetNames(typeof(ActionType)).Length - 1;

            int rand = UnityEngine.Random.Range(0, lengthOfValidEntries);

            return(new ActionCommand((ActionType)rand, player));
        }
Example #2
0
 public void DetermineMatchEnded(RPS_Player winner)
 {
     if (winner == null)
     {
         // another round
     }
     else
     {
         // match is over
     }
 }
        internal void Initialize()
        {
            this.match = owner.match;
            // find player by id rather than control mode
            // OR assign control mode based on some params
            this.localPlayer = match.Players.Find(player => player.controlMode == ControlMode.LOCAL);

            if (localPlayer == null)
            {
                return;
            }
            ButtonEventSender.onChooseRock     += SelectRock;
            ButtonEventSender.onChoosePaper    += SelectPaper;
            ButtonEventSender.onChooseScissors += SelectScissors;
        }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        if (canRestart)
        {
            if (Input.GetKeyDown(KeyCode.Return))
            {
                EditorSceneManager.LoadScene(0);
            }
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Application.Quit();
            }
        }
        else
        {
            switch ((int)Time.timeSinceLevelLoad)
            {
            case 2:
                timeText.text = "Rock...";
                break;

            case 3:
                timeText.text = "Rock...Paper...";
                break;

            case 4:
                timeText.text = "Rock...Paper...Scissors...";
                break;

            case 5:
                timeText.text = "Rock...Paper...Scissors...GO!";
                RPS_Player winP = find_winner();

                string victorText;
                if (winP == null)
                {
                    victorText = "Tie\n\n";
                }
                else
                {
                    victorText = winP.pName + " Wins!\n\n";
                };



                //different for players>2
                victorText += "Player 1: " + player1.getCard().value() + "\nPlayer 2: " + player2.getCard().value();

                victorText += "\n\n\'Enter\' to replay\n\'Escape\' to quit";

                //EditorUtility.DisplayDialog("Test!", victorText, "OK");

                winScreen.text    = victorText;
                winScreen.enabled = true;

                canRestart = true;

                break;

            default:
                break;
            }
        }
    }
Example #5
0
 // Use this for initialization
 void Start()
 {
     controller = GetComponent <TextController>();
     player     = GetComponent <RPS_Player>();
 }
Example #6
0
 public ActionCommand(ActionType action, RPS_Player owner)
 {
     this.action = action;
     this.owner  = owner;
 }
Example #7
0
 public static ActionCommand GenerateActionCommand(ActionType actionType, RPS_Player player)
 {
     return(new ActionCommand(actionType, player));
 }