Example #1
0
    private void ShowUsername()
    {
        List <Player> players = mRestaurantScript.getAlivePlayers();

        Debug.Log("PLAYER COUNT: " + players.Count);

        mUsernameText.text = players[mTurnManagerScript.GetCurrentPlayerIndex()].getName();
    }
Example #2
0
    void PopulateSurvivorsList()
    {
        List <Player> alivePlayers = mRestaurantScript.getAlivePlayers();

        for (int i = 0; i < alivePlayers.Count; i++)
        {
            mSurvivorsText.text += alivePlayers [i].getName() + "\n";
        }
    }
Example #3
0
    private void PlacePlayersInCircle()
    {
        tieButton = Instantiate(mTiePrefab, mTableCenter.transform);
        tieButton.onClick.AddListener(delegate
        {
            VoteForPlayer(tieButton);
        });

        List <Player> players = mRestaurantScript.getAlivePlayers();

        float distanceBetweenAngle = 360.0f / players.Count;

        //Have the current player be at the bottom so it's closest to the user.
        float currentAngle = 270.0f;

        //Scale radius by screen size to keep it consistent.
        float radius = mCanvas.pixelRect.width / 3.0f;

        int i;

        for (i = 0; i < players.Count; ++i)
        {
            Player currentPlayer = players[i];

            Button userButton = Instantiate(mPlayerPrefab, mTableCenter.transform);
            userButton.transform.GetChild(0).GetComponent <Text>().text = players[i].getName();
            userButton.onClick.AddListener(delegate
            {
                VoteForPlayer(userButton);
            });

            Vector3 pos = mTableCenter.transform.position;

            pos.x += radius * Mathf.Cos(Mathf.Deg2Rad * currentAngle);
            pos.y += radius * Mathf.Sin(Mathf.Deg2Rad * currentAngle);

            userButton.transform.position = pos;

            Vector3 rot = userButton.transform.eulerAngles;

            if ((currentAngle > 270 && currentAngle < 360) || (currentAngle < 90 && currentAngle > 0))
            {
                rot.z = currentAngle;
            }
            else if (currentAngle > 90 && currentAngle < 270)
            {
                rot.z = currentAngle - 180;
            }

            currentAngle = ((currentAngle + distanceBetweenAngle) % 360);

            mPlayerNamecards.Add(userButton);
        }
    }
Example #4
0
    public void ServeFood()
    {
        Debug.Log("SERVING FOOD! ;D");

        int i;

        for (i = 0; i < mRestaurantScript.getAlivePlayers().Count; ++i)
        {
            //In the future create fun meals here depending on theme/course number.
            mRestaurantScript.addMeal(new Meal());
        }
    }
Example #5
0
    public void UpdateButtonColors()
    {
        List <Player> alivePlayers     = mRestaurantScript.getAlivePlayers();
        List <Player> playersWithTurns = mRestaurantScript.getPlayersWithTurnsLeft();

        //Reset all colors.
        for (int i = 0; i < mPlayerNamecards.Count; ++i)
        {
            Button b = mPlayerNamecards[i];
            if (b.enabled)
            {
                b.image.color = mPlayerNamecards[i].colors.normalColor;
            }
            else
            {
                b.image.color = mPlayerNamecards[i].colors.disabledColor;
            }
        }

        for (int i = 0; i < mPlayerNamecards.Count; ++i)
        {
            //If the player is out of turns, disable their button
            Button b = mPlayerNamecards[i];

            //will turn selected player yellow and all others as active color
            if (mRestaurantScript.mSelectedPlayer != null)
            {
                if (alivePlayers [i] == mRestaurantScript.mSelectedPlayer)
                {
                    mPlayerNamecards [i].image.color = Color.yellow;
                }
                else
                {
                    b.image.color = mPlayerNamecards [i].colors.normalColor;
                }
            }
            //will turn all players their correct color
            else
            {
                if (playersWithTurns.Contains(alivePlayers [i]))
                {
                    b.image.color = mPlayerNamecards [i].colors.normalColor;
                }
                else
                {
                    b.image.color = mPlayerNamecards [i].colors.disabledColor;
                }
            }
        }
    }
Example #6
0
    private void RandomizeRoles()
    {
        //shuffles the roles around into a new list
        List <EnumPlayerRole> shuffedRoles = new List <EnumPlayerRole>();
        int randomIndex;

        while (mValidUserRoles.Count > 0)
        {
            randomIndex = Random.Range(0, mValidUserRoles.Count);
            shuffedRoles.Add(mValidUserRoles[randomIndex]);
            mValidUserRoles.RemoveAt(randomIndex);
        }

        Debug.Log("ROLE COUNT: " + shuffedRoles.Count);

        int i;

        for (i = 0; i < shuffedRoles.Count; ++i)
        {
            Player player = new Player(mUsernames[i], shuffedRoles[i]);
            mRestaurantScript.addPlayer(player);
            Debug.Log("PLAYER COUNT: " + mRestaurantScript.getAlivePlayers().Count);
            Debug.Log(player.ToString());
        }
    }
Example #7
0
    private void ShowPlayerToPassTo()
    {
        List <Player> players = mRestaurantScript.getAlivePlayers();

        Debug.Log("PLAYER COUNT: " + players.Count);
        //In the future the text could be flashing or something :D
        mPassText.text = "PASS TO " + players[mTurnManagerScript.GetCurrentPlayerIndex()].getName().ToUpper() + " SO THEY CAN SEE THEIR ROLE.";
    }
Example #8
0
    public void OnConfirmButtonClicked()
    {
        List <Player>  players = mRestaurantScript.getAlivePlayers();
        EnumPlayerRole role    = players[mTurnManagerScript.GetCurrentPlayerIndex()].getRole();

        //requires the player to click the button three times if their role doesn't have them clicking otherwise
        if ((role == EnumPlayerRole.CHEMIST || role == EnumPlayerRole.FOOD_CRITIC || role == EnumPlayerRole.PARTY_GOER ||
             role == EnumPlayerRole.WEALTHY_COUPLE || role == EnumPlayerRole.SCAPEGOAT) &&
            mClickTracker > 1)
        {
            mClickTracker--;
            RandomizeActionButtonLocation();
        }
        else
        {
            mClickTracker = 3;
            mActionButton.transform.position = mActionButtonLocation;

            DeactivateButtons();

            if (mTurnManagerScript.GoToNextPlayer())
            {
                SceneManager.LoadScene(DinnerPartyScenes.PASS_PATH);
            }
            else
            {
                SceneManager.LoadScene(DinnerPartyScenes.START_GAME_PATH);
            }
        }
    }
Example #9
0
    public void UpdateButtonColors()
    {
        //List<Player> outOfTurnPlayers = mRestaurantScript.getOutOfTurnPlayers();
        List <Player> alivePlayers = mRestaurantScript.getAlivePlayers();

        //Reset all colors.
        for (int i = 0; i < mPlayerNamecards.Count; ++i)
        {
            Button b = mPlayerNamecards[i];
            if (b.enabled)
            {
                b.image.color = mPlayerNamecards[i].colors.normalColor;
            }
            else
            {
                b.image.color = mPlayerNamecards[i].colors.disabledColor;
            }
        }

        Debug.Log("CLEAR SELECT");

        for (int i = 0; i < mPlayerNamecards.Count; ++i)
        {
            //If the player is selected then make them gold.
            if (mRestaurantScript.mSelectedPlayer != null && alivePlayers[i] == mRestaurantScript.mSelectedPlayer)
            {
                mPlayerNamecards[i].image.color = Color.yellow;
            }

            //This is what it should be in the future instead of restaurant holding everything
            //if (alivePlayers[i].isTurn())
            //{
            //set golden
            //}

            //if (alivePlayers[i].outOfTurns())
            //{
            //Set disabled
            //}
        }

        Debug.Log("YELLOW SELECT");
    }
Example #10
0
    void Start()
    {
        //mTurnManagerScript = GameManagerScript.GetInstance().GetComponent<TurnManagerScript>();
        mRestaurantScript = GameManagerScript.GetInstance().GetComponent <RestaurantScript>();
        //mPlayerList = GameManagerScript.GetInstance().GetComponent<TurnManagerScript>().getPlayers();
        mAngleBetweenPlayers = 360.0f / mRestaurantScript.getAlivePlayers().Count;

        mRotation         = Vector3.zero;
        mPrevRotation     = 0;
        mAccumulatedAngle = 0;
    }
Example #11
0
    void Start()
    {
        mTurnManagerScript = GameManagerScript.GetInstance().GetComponent <TurnManagerScript>();
        mRestaurantScript  = GameManagerScript.GetInstance().GetComponent <RestaurantScript>();

        List <Player> players = mRestaurantScript.getAlivePlayers();

        if (mTurnManagerScript.GetCurrentPlayerIndex() <= players.Count - 1)
        {
            ShowPlayerToPassTo();
        }
    }
    private void RandomizeRoles()
    {
        //removes 3 random unnecessary roles from the pool
        List <EnumPlayerRole> nonNecessaryRoles = new List <EnumPlayerRole>();

        for (int j = 0; j < mValidUserRoles.Count; j++)
        {
            if (mValidUserRoles[j] != EnumPlayerRole.ASSASSIN &&
                mValidUserRoles[j] != EnumPlayerRole.WEALTHY_COUPLE &&
                mValidUserRoles[j] != EnumPlayerRole.DISTANT_COUSIN)
            {
                nonNecessaryRoles.Add(mValidUserRoles [j]);
            }
        }

        List <int> randomNums = new List <int>();

        for (int k = 0; k < 3; k++)
        {
            int rand = -1;
            do
            {
                rand = Random.Range(0, nonNecessaryRoles.Count);
            } while(randomNums.Contains(rand));
            randomNums.Add(rand);
            mValidUserRoles.Remove(nonNecessaryRoles[rand]);
        }

        //shuffles the roles around into a new list
        List <EnumPlayerRole> shuffedRoles = new List <EnumPlayerRole>();
        int randomIndex;

        while (mValidUserRoles.Count > 0)
        {
            randomIndex = Random.Range(0, mValidUserRoles.Count);
            shuffedRoles.Add(mValidUserRoles[randomIndex]);
            mValidUserRoles.RemoveAt(randomIndex);
        }

        Debug.Log("ROLE COUNT: " + shuffedRoles.Count);

        int i;

        for (i = 0; i < shuffedRoles.Count; ++i)
        {
            Player player = new Player(mUsernames[i], shuffedRoles[i]);
            mRestaurantScript.addPlayer(player);
            Debug.Log("PLAYER COUNT: " + mRestaurantScript.getAlivePlayers().Count);
            Debug.Log(player.ToString());
        }
    }
Example #13
0
    private void FindDead()
    {
        List <Meal>   mealsList        = mRestaurantScript.getMeals();
        List <Player> alivePlayersList = mRestaurantScript.getAlivePlayers();

        for (int i = 0; i < mealsList.Count; i++)
        {
            if (mealsList [i].isPoisoned())
            {
                Debug.Log("Poisoned meal number is: " + i.ToString());
                if (alivePlayersList [i].getRole() == EnumPlayerRole.ASSASSIN || alivePlayersList [i].getLastMealEaten() == EnumSpecialMeal.STOMACHACHE)
                {
                    Debug.Log("No one has been poisoned!");
                    mVoteScreenTitleText.text     = "NO ONE HAS BEEN POISONED!";
                    mVoteScreenSecondaryText.text = "NO NEED TO CALL THE COPS, I GUESS?.";
                    mVotingIsHappening            = false;
                }
                else if (alivePlayersList.Count > 4)
                {
                    Debug.Log(alivePlayersList [i].getName() + " has been poisoned!");
                    mVoteScreenTitleText.text     = alivePlayersList [i].getName().ToUpper() + " HAS BEEN POISONED!";
                    mVoteScreenSecondaryText.text = "DECIDE WHO YOU WANT TO CALL THE COPS ON.";
                    mRestaurantScript.VotePlayerOffTheIsland(alivePlayersList [i]);
                    mVotingIsHappening = true;
                }
                else
                {
                    Debug.Log(alivePlayersList [i].getName() + " has been poisoned!");
                    mVoteScreenTitleText.text     = alivePlayersList [i].getName().ToUpper() + " HAS BEEN POISONED!";
                    mVoteScreenSecondaryText.text = "YOU DON'T HAVE ENOUGH PEOPLE AS WITNESSES FOR THE COPS TO BELIEVE YOU.";
                    mRestaurantScript.VotePlayerOffTheIsland(alivePlayersList [i]);
                    mVotingIsHappening = false;
                }
                break;
            }
        }
    }
Example #14
0
    private bool isAssassinAlive()
    {
        List <Player> players = mRestaurantScript.getAlivePlayers();
        bool          isAlive = false;

        for (int i = 0; i < players.Count; ++i)
        {
            if (players[i].getRole() == EnumPlayerRole.ASSASSIN)
            {
                isAlive = true;
            }
        }

        return(isAlive);
    }
Example #15
0
    private void FindDead()
    {
        List <Meal>   mealsList        = mRestaurantScript.getMeals();
        List <Player> alivePlayersList = mRestaurantScript.getAlivePlayers();

        for (int i = 0; i < mealsList.Count; i++)
        {
            if (mealsList [i].isPoisoned())
            {
                Debug.Log("Poisoned meal number is: " + i.ToString());
                if (alivePlayersList[i].getRole() == EnumPlayerRole.ASSASSIN || alivePlayersList[i].getLastMealEaten() == EnumSpecialMeal.STOMACHACHE)
                {
                    Debug.Log("No one has been poisoned!");
                }
                else
                {
                    Debug.Log(alivePlayersList[i].getName() + " has been poisoned!");
                    mRestaurantScript.VotePlayerOffTheIsland(alivePlayersList [i]);
                }
                break;
            }
        }
    }
Example #16
0
    public void UpdateButtonColors()
    {
        //List<Player> outOfTurnPlayers = mRestaurantScript.getOutOfTurnPlayers();
        List <Player> alivePlayers     = mRestaurantScript.getAlivePlayers();
        List <Player> playersWithTurns = mRestaurantScript.getPlayersWithTurnsLeft();

        //Reset all colors.
        for (int i = 0; i < mPlayerNamecards.Count; ++i)
        {
            Button b = mPlayerNamecards[i];
            if (b.enabled)
            {
                b.image.color = mPlayerNamecards[i].colors.normalColor;
            }
            else
            {
                b.image.color = mPlayerNamecards[i].colors.disabledColor;
            }
        }

        //Debug.Log("CLEAR SELECT");

        //for (int i = 0; i < mPlayerNamecards.Count; ++i)
        //{
        //    //If the player is selected then make them gold.
        //    if (mRestaurantScript.mSelectedPlayer != null && alivePlayers[i] == mRestaurantScript.mSelectedPlayer)
        //    {
        //        mPlayerNamecards[i].image.color = Color.yellow;
        //    }
        //
        //    //This is what it should be in the future instead of restaurant holding everything
        //    //if (alivePlayers[i].isTurn())
        //    //{
        //        //set golden
        //    //}
        //
        //    //if (alivePlayers[i].outOfTurns())
        //    //{
        //        //Set disabled
        //    //}
        //}

        for (int i = 0; i < mPlayerNamecards.Count; ++i)
        {
            //If the player is out of turns, disable their button
            Button b = mPlayerNamecards[i];

            //will turn selected player yellow and all others as active color
            if (mRestaurantScript.mSelectedPlayer != null)
            {
                if (alivePlayers [i] == mRestaurantScript.mSelectedPlayer)
                {
                    mPlayerNamecards [i].image.color = Color.yellow;
                }
                else
                {
                    b.image.color = mPlayerNamecards [i].colors.normalColor;
                }
            }
            //will turn all players their correct color
            else
            {
                if (playersWithTurns.Contains(alivePlayers [i]))
                {
                    b.image.color = mPlayerNamecards [i].colors.normalColor;
                }
                else
                {
                    b.image.color = mPlayerNamecards [i].colors.disabledColor;
                }
            }
        }

        //Debug.Log("YELLOW SELECT");
    }
Example #17
0
    public void ServeFood()
    {
        Debug.Log("SERVING FOOD! ;D");
        List <Color> plateColors = new List <Color>(mRestaurantScript.mPossibleColors);

        for (int i = 0; i < mRestaurantScript.getAlivePlayers().Count; ++i)
        {
            Debug.Log("HELLOOOO: " + mRestaurantScript.mPossibleColors.Length + " | " + i.ToString());

            int randomIndex = getRandomNumber(0, plateColors.Count);

            //In the future create fun meals here depending on theme/course number.
            mRestaurantScript.addMeal(new Meal(mRestaurantScript.mMenuItems[(int)mCurrentRound], plateColors[randomIndex]));
            plateColors.RemoveAt(randomIndex);
        }

        List <Meal> mealsList = mRestaurantScript.getMeals();

        //sets # of special meals depending on player count
        int numOfSpecialMeals = 0;

        switch (mRestaurantScript.getAlivePlayers().Count)
        {
        case 5:
            numOfSpecialMeals = 1;
            break;

        case 6:
        case 7:
            numOfSpecialMeals = 2;
            break;

        case 8:
        case 9:
        case 10:
            numOfSpecialMeals = 3;
            break;
        }

        //finds what meals to set as special
        List <int> specialMealIndices = new List <int>();

        for (int j = 0; j < numOfSpecialMeals; j++)
        {
            int randomNum;
            do
            {
                randomNum = Random.Range(0, mRestaurantScript.getAlivePlayers().Count);
            } while(specialMealIndices.Contains(randomNum));
            specialMealIndices.Add(randomNum);
        }

        //sets the randomly-selected meals
        for (int k = 0; k < mealsList.Count; k++)
        {
            if (specialMealIndices.Contains(k))
            {
                mealsList [k].setSpecial(true);
            }
            else
            {
                mealsList [k].setSpecial(false);
            }
        }
    }
Example #18
0
    public void ServeFood()
    {
        Debug.Log("SERVING FOOD! ;D");

        int i;

        for (i = 0; i < mRestaurantScript.getAlivePlayers().Count; ++i)
        {
            //In the future create fun meals here depending on theme/course number.
            mRestaurantScript.addMeal(new Meal());
        }

        List <Meal> mealsList = mRestaurantScript.getMeals();

        //sets # of special meals depending on player count
        int numOfSpecialMeals = 0;

        switch (mRestaurantScript.getAlivePlayers().Count)
        {
        case 5:
            numOfSpecialMeals = 1;
            break;

        case 6:
        case 7:
            numOfSpecialMeals = 2;
            break;

        case 8:
        case 9:
        case 10:
            numOfSpecialMeals = 3;
            break;
        }

        //finds what meals to set as special
        List <int> specialMealIndices = new List <int>();

        for (int j = 0; j < numOfSpecialMeals; j++)
        {
            int randomNum;
            do
            {
                randomNum = Random.Range(0, mRestaurantScript.getAlivePlayers().Count);
            } while(specialMealIndices.Contains(randomNum));
            specialMealIndices.Add(randomNum);
        }

        //sets the randomly-selected meals
        for (int k = 0; k < mealsList.Count; k++)
        {
            if (specialMealIndices.Contains(k))
            {
                mealsList [k].setSpecial(true);
            }
            else
            {
                mealsList [k].setSpecial(false);
            }
        }
    }