Exemplo n.º 1
0
    private string GetMessage(EventCode code, int actorNumber, params object[] additionalParams)
    {
        switch (code)
        {
        case EventCode.FIRST_TURN_PHASE_ONE:

            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is placing their first settlement.");

        case EventCode.FIRST_TURN_PHASE_TWO:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is placing their first road.");

        case EventCode.SECOND_TURN_PHASE_ONE:

            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is placing their second settlement.");

        case EventCode.SECOND_TURN_PHASE_TWO:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is placing their second road.");

        case EventCode.ROAD_CONSTRUCTED:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has constructed a road.");

        case EventCode.SETTLEMENT_CONSTRUCTED:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has constructed a settlement.");

        case EventCode.CITY_CONSTRUCTED:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has upgraded a settlement into a city.");

        case EventCode.PRE_DICE_ROLL:

            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is rolling the dice.");

        case EventCode.DICE_ROLLED:
            int    diceValue       = (int)additionalParams[0];
            string diceValueString = "";
            if (diceValue == 7)
            {
                diceValueString = "<color=black>";
            }
            else if (diceValue == 6 || diceValue == 8)
            {
                diceValueString = "<color=red>";
            }

            diceValueString += diceValue;
            if (diceValue >= 6 && diceValue <= 8)
            {
                diceValueString += "</color>";
            }
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has rolled a " + diceValueString + ".");

        case EventCode.PLAYER_IDLE:

            return("Waiting for an action from " + ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + ".");

        case EventCode.RESOURCE_EARNED:

            int resourceType = (int)additionalParams[0];
            int amount       = (int)additionalParams[1];

            Debug.Log("resourceType = " + resourceType + ", amount = " + amount);

            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has earned " + amount + "x" + ColourUtility.GetResourceText((Inventory.UnitCode)resourceType) + ".");

        case EventCode.NO_RESOURCE_EARNED:

            return("No player has earned any resources from this roll.");

        case EventCode.TRADE_SUPPLY_INITIATED:

            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is trading with the supply.");

        case EventCode.TRADE_PLAYERS_INITIATED:
            int secondPlayerId = (int)additionalParams[0];
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " is trading with " + ColourUtility.GetPlayerDisplayNameFromId(secondPlayerId) + ".");

        case EventCode.TRADE_CANCELLED:

            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has cancelled the trade.");

        case EventCode.TRADE_SUPPLY_COMPLETED:

            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has finished trading with the supply.");

        case EventCode.TRADE_PLAYERS_COMPLETED:
            secondPlayerId = (int)additionalParams[0];
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has finished trading with " + ColourUtility.GetPlayerDisplayNameFromId(secondPlayerId) + ".");

        case EventCode.SHOULD_DISCARD:

            string resultText = "Waiting for ";

            if (actorNumber == -1)
            {
                // Initial set.
                discardList = ((int[])additionalParams[0]).OfType <int>().ToList();

                bool first = true;
                for (int i = 0; i < discardList.Count; i++)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        resultText += ", ";
                    }
                    //discardlist[i] is null for some reason
                    resultText += ColourUtility.GetPlayerDisplayNameFromId(discardList[i]);
                }
                resultText += " to discard half of their resource cards.";
            }
            else
            {
                // Update. Remove the player from the discard list and then repeat.
                if (discardList.IndexOf(actorNumber) != -1)
                {
                    discardList.Remove(actorNumber);
                }

                bool first = true;
                for (int i = 0; i < discardList.Count; i++)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        resultText += ", ";
                    }
                    resultText += ColourUtility.GetPlayerDisplayNameFromId(discardList[i]);
                }
                resultText += " to discard half of their resource cards.";
            }

            Debug.Log(resultText);
            return(resultText);

        case EventCode.BANDIT_MOVE:
            return("Waiting for " + ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " to move the bandit to another hex.");

        case EventCode.SELECTING_STEAL_VICTIM:
            return("Waiting for " + ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " to select a player to steal from.");

        case EventCode.STEAL_NO_ADJACENT_PLAYER:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " had nobody to steal from.");

        case EventCode.NO_RESOURCE_STOLEN:
            Player stealPlayer = PhotonNetwork.CurrentRoom.GetPlayer((int)additionalParams[0]);
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " had no cards to steal from " + ColourUtility.GetPlayerDisplayName(stealPlayer) + ".");

        case EventCode.RESOURCE_STOLEN:
            stealPlayer = PhotonNetwork.CurrentRoom.GetPlayer((int)additionalParams[0]);
            string resourceText = (string)additionalParams[1];
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has stolen 1x" + resourceText + " from " + ColourUtility.GetPlayerDisplayName(stealPlayer) + ".");

        case EventCode.DEVELOPMENT_CARD_PURCHASED:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has purchased a development card from the supply.");

        case EventCode.DEVELOPMENT_CARD_PLAYED:
            Inventory.UnitCode cardCode = (Inventory.UnitCode)additionalParams[0];
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has played a " + ColourUtility.GetDevelopmentText(cardCode) + " card!");

        case EventCode.YEAR_OF_PLENTY_INITIATED:
            return("Waiting for " + ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " to take 2 free Resource cards.");

        case EventCode.YEAR_OF_PLENTY_COMPLETED:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has taken two resource cards.");

        case EventCode.MONOPOLY_COMPLETE:
            resourceText = (string)additionalParams[0];
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has stolen all " + resourceText + " cards from the other players!");

        case EventCode.LARGEST_ARMY_TAKE_FIRST_TIME:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has received the <color=black>Largest Army</color> card!");

        case EventCode.LARGEST_ARMY_STEAL:
            stealPlayer = PhotonNetwork.CurrentRoom.GetPlayer((int)additionalParams[0]);
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has stolen the <color=black>Largest Army</color> card from " + ColourUtility.GetPlayerDisplayName(stealPlayer) + "!");

        case EventCode.LONGEST_ROAD_TAKE_FIRST_TIME:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has received the <color=black>Longest Road</color> card!");

        case EventCode.LONGEST_ROAD_STEAL:
            stealPlayer = PhotonNetwork.CurrentRoom.GetPlayer((int)additionalParams[0]);
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has stolen the <color=black>Longest Road</color> card from " + ColourUtility.GetPlayerDisplayName(stealPlayer) + "!");

        case EventCode.LONGEST_ROAD_RETURNED:
            return("The <color=black>Longest Road</color> card no longer belongs to any player!");

        case EventCode.GAME_OVER:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has won the game! Press ESC to return to the main menu.");

        case EventCode.END_TURN:
            return(ColourUtility.GetPlayerDisplayNameFromId(actorNumber) + " has ended their turn.");
        }


        return("<invalid_text_code>");
    }