Beispiel #1
0
    public void BuyDevelopmentCardsButtonPress()
    {
        action = ActionCode.BUY_DEVELOPMENT_CARD;

        // Set up the status panel.
        TextMeshProUGUI popupText = statusPanel.transform.GetChild(0).gameObject.transform.GetChild(0).GetComponent <TextMeshProUGUI>();

        popupText.text = "One development card costs 1x" + ColourUtility.GetResourceText(Inventory.UnitCode.GRAIN) + ", 1x" + ColourUtility.GetResourceText(Inventory.UnitCode.ORE) + ", and 1x" + ColourUtility.GetResourceText(Inventory.UnitCode.WOOL) + ".\n";

        if (!deck.IsEmpty())
        {
            if (inventory.CanBuyDevelopmentCard())
            {
                popupText.text            += "<color=green>You have enough resources to buy a development card.</color>";
                confirmButton.interactable = true;
            }
            else
            {
                popupText.text            += "<color=red>You do not have enough resources to buy a development card.</color>";
                confirmButton.interactable = false;
            }
        }
        else
        {
            popupText.text            += "<color=red>The development card deck is empty.</color>";
            confirmButton.interactable = false;
        }

        // Open panel.
        statusPanel.SetActive(true);
    }
Beispiel #2
0
    private void SetHarbourText()
    {
        string harbourText = "";

        switch (harbourBonus)
        {
        case HarbourBonus.THREE_TO_ONE:
            harbourText = "3:1";
            break;

        case HarbourBonus.TWO_TO_ONE_BRICK:
            harbourText = "2:1\n" + ColourUtility.GetResourceText(Inventory.UnitCode.BRICK);
            break;

        case HarbourBonus.TWO_TO_ONE_GRAIN:
            harbourText = "2:1\n" + ColourUtility.GetResourceText(Inventory.UnitCode.GRAIN);
            break;

        case HarbourBonus.TWO_TO_ONE_LUMBER:
            harbourText = "2:1\n" + ColourUtility.GetResourceText(Inventory.UnitCode.LUMBER);
            break;

        case HarbourBonus.TWO_TO_ONE_ORE:
            harbourText = "2:1\n" + ColourUtility.GetResourceText(Inventory.UnitCode.ORE);
            break;

        case HarbourBonus.TWO_TO_ONE_WOOL:
            harbourText = "2:1\n" + ColourUtility.GetResourceText(Inventory.UnitCode.WOOL);
            break;
        }

        gameObject.transform.GetChild(HARBOUR_TEXT_CHILD_ID).gameObject.SetActive(true);
        gameObject.transform.GetChild(HARBOUR_TEXT_CHILD_ID).GetComponent <TextMeshPro>().text = harbourText;
    }
Beispiel #3
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>");
    }
Beispiel #4
0
    public void ReceiveStolenCard(int senderId, int receivedResourceId)
    {
        // If the resource id is -1, the selected player had no card to give.

        if (receivedResourceId == -1)
        {
            GameObject.Find("EventTextController").GetComponent <EventTextController>().SendEvent(EventTextController.EventCode.NO_RESOURCE_STOLEN, PhotonNetwork.LocalPlayer, senderId);
        }
        else
        {
            UnitCode receivedResource = (UnitCode)receivedResourceId;
            this.GiveToPlayer(receivedResource, 1);
            GameObject.Find("EventTextController").GetComponent <EventTextController>().SendEvent(EventTextController.EventCode.RESOURCE_STOLEN, PhotonNetwork.LocalPlayer, senderId, ColourUtility.GetResourceText(receivedResource));
        }
    }
Beispiel #5
0
    public void MonopolyReplyReceived(int amount)
    {
        // Give the received resources to the player.
        inventory.GiveToPlayer(this.monopolyResource, amount);

        monopolyReplies++;
        if (monopolyReplies == 3)
        {
            // All players have replied. The Monopoly card effect is complete.

            // switch to idle phase

            GameObject.Find("EventTextController").GetComponent <EventTextController>().SendEvent(EventTextController.EventCode.MONOPOLY_COMPLETE, PhotonNetwork.LocalPlayer, ColourUtility.GetResourceText(monopolyResource));

            GameObject.Find("EventTextController").GetComponent <EventTextController>().SendEvent(EventTextController.EventCode.PLAYER_IDLE, PhotonNetwork.LocalPlayer);
        }
    }