Beispiel #1
0
    /**
     * This method is activated when input is received from a player
     **/

    public bool GetInput(BoxPeekPlr plr)
    {
        if (plr == player_one)
        {
            if (player_one_cooldown <= 0.0f)
            {
                if (!player_one_is_peek)
                {
                    return(Peek(plr));
                }
                else
                {
                    return(StopPeek(plr));
                }
            }
        }
        if (plr == player_two)
        {
            if (player_two_cooldown <= 0.0f)
            {
                if (!player_two_is_peek)
                {
                    return(Peek(plr));
                }
                else
                {
                    return(StopPeek(plr));
                }
            }
        }
        return(false);
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        //If game state has changed due to a counter peek occuring or someone winning, also basically end the game

        if (game_status != (int)game_states.GAME_OVER)
        {
            if (game_status != (int)game_states.NO_WIN)
            {
                print("Game ended due to counter peek! Player " + game_status + "Wins!");
                player_one = player_two = null;// Causes a null pointer error prob
            }

            //Otherwise increment whoever is peeking and check if someone has won!
            else
            {
                //Cooldown time tickdown
                if (player_one_cooldown > 0)
                {
                    player_one_cooldown -= Time.deltaTime;
                }
                if (player_two_cooldown > 0)
                {
                    player_two_cooldown -= Time.deltaTime;
                }

                //Peek Time for if a player is peeking
                if (player_one_is_peek)
                {
                    player_one_peek_time += Time.deltaTime;
                }
                if (player_two_is_peek)
                {
                    player_two_peek_time += Time.deltaTime;
                }

                if (player_one_peek_time >= COMPLETE_PEEK_TIME)
                {
                    game_status = (int)game_states.player_one;
                    print("Game ended due complete peek! Player " + game_status + "Wins!");
                    player_one  = player_two = null;// Causes a null pointer error prob
                    game_status = (int)game_states.GAME_OVER;
                }
                if (player_two_peek_time >= COMPLETE_PEEK_TIME)
                {
                    game_status = (int)game_states.player_two;
                    print("Game ended due complete peek! Player " + game_status + "Wins!");
                    player_one  = player_two = null;// Causes a null pointer error prob
                    game_status = (int)game_states.GAME_OVER;
                }
            }
        }
        else
        {
            //Logic for starting a new game
        }
    }
Beispiel #3
0
 /**
  * Stops a player from peeking, if they are allowed per box peek rules.
  * Can prob have a more intelligent way of checking which player initiates the action....
  * */
 public bool StopPeek(BoxPeekPlr plr)
 {
     if (plr == player_one && player_one_peek_time >= RETREAT_TIME)
     {
         player_one_is_peek   = false;
         player_one_peek_time = 0.0f;
         player_one_cooldown  = COOLDOWN_TIME;
         return(true);
     }
     if (plr == player_two && player_two_peek_time >= RETREAT_TIME)
     {
         player_two_is_peek   = false;
         player_two_peek_time = 0.0f;
         player_two_cooldown  = COOLDOWN_TIME;
         return(true);
     }
     return(false);
 }
Beispiel #4
0
 /**
  * This method will begin the peek for a player.
  * **/
 public bool Peek(BoxPeekPlr plr)
 {
     if (plr == player_one)
     {
         if (player_two_is_peek)
         {
             game_status = (int)game_states.player_one;
             return(true);
         }
         player_one_is_peek = true;
         return(true);
     }
     if (plr == player_two)
     {
         if (player_one_is_peek)
         {
             game_status = (int)game_states.player_two;
             return(true);
         }
         player_two_is_peek = true;
         return(true);
     }
     return(false);
 }