コード例 #1
0
    public void displayPanelForAssets(AssetTuple playerAssets, int delta, bool isPositive)
    {
        neededDiscards = delta;
        leftDiscards   = neededDiscards;

        foreach (Text text in assetNumTexts)
        {
            text.text = "0";
        }

        for (int i = 0; i < assetSliders.Length; i++)
        {
            if (isPositive)
            {
                assetSliders [i].maxValue = delta;
            }
            else
            {
                assetSliders [i].maxValue = playerAssets.GetValueAtIndex(i);
            }

            assetSliders [i].minValue = assetSliders [i].value = 0;
        }

        currentTuple  = playerAssets;
        selectionMade = false;
        this.gameObject.SetActive(true);
    }
コード例 #2
0
    public void upgradeScience()
    {
        CityImprovementType science = CityImprovementType.Science;

        if (CatanManager.instance.currentPlayerTurn == PhotonNetwork.player.ID - 1 && CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].canUpgrade(science))
        {
            AssetTuple upgradeCost = CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].cityImprovements.nextImprovementCost(science);
            if (CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].playedCrane)
            {
                upgradeCost.SetValueAtIndex(5, upgradeCost.GetValueAtIndex(5) - 1);
                CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].playedCrane = false;
            }

            EventTransferManager.instance.OnTradeWithBank(CatanManager.instance.currentPlayerTurn, false, upgradeCost);
            EventTransferManager.instance.OnUpgradeCity(CatanManager.instance.currentPlayerTurn, (int)science);

            int scienceLevel  = CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].cityImprovements.cityImprovements [CityImprovementType.Science];
            int politicsLevel = CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].cityImprovements.cityImprovements [CityImprovementType.Politics];
            int tradeLevel    = CatanManager.instance.players [CatanManager.instance.currentPlayerTurn].cityImprovements.cityImprovements [CityImprovementType.Trade];

            openPanel(tradeLevel, politicsLevel, scienceLevel);
        }
    }
コード例 #3
0
    public void OpenPanel(AssetTuple playerAssets)
    {
        for (int i = 0; i < FishTokens.Length; i++)
        {
            FishTokens [i].maxValue = playerAssets.GetValueAtIndex(i + 8);
            FishTokens [i].minValue = FishTokens [i].value = 0;
        }

        //set texts to 0
        for (int i = 0; i < TokensText.Length; i++)
        {
            TokensText [i].text = "0";
        }
        tokensValue = 0;
        //all rewards disabled
        for (int i = 0; i < optionsPanel.Count; i++)
        {
            optionsPanel [i].GetComponent <FishTradePanelButton> ().instance = this;
            optionsPanel [i].gameObject.SetActive(false);
        }
        selectionGlow.gameObject.SetActive(false);
        this.gameObject.SetActive(true);
    }
コード例 #4
0
    public void OpenRespond(Player sender, AssetTuple give, AssetTuple recieve)
    {
        this.gameObject.SetActive(true);
        selectionGlow.gameObject.SetActive(false);

        //setting texts
        confirmtext.text = "Accept Offer";
        canceltext.text  = "Reject Offer";
        playertext.text  = "Offer From";
        waiting.text     = "Waiting For Response...";

        confirm.onClick.RemoveAllListeners();
        cancel.onClick.RemoveAllListeners();

        //texts start out disabled
        confirmtext.gameObject.SetActive(false);
        canceltext.gameObject.SetActive(false);
        waiting.gameObject.SetActive(false);

        //confirm is now accept trade
        confirm.onClick.AddListener(sendResponse);

        //activate counter button and add listener
        counter.onClick.AddListener(Counter);
        counter.gameObject.SetActive(true);

        //change cancel to reject
        cancel.onClick.AddListener(Reject);

        selectionGlow.gameObject.SetActive(false);

        //fill assets in reverse and disable changing them
        for (int i = 0; i < giveAssetSliders.Length; i++)
        {
            giveAssetSliders [i].maxValue = 10;
            getAssetSliders [i].maxValue  = 10;
            giveAssetSliders [i].value    = recieve.GetValueAtIndex(i);
            getAssetSliders [i].value     = give.GetValueAtIndex(i);
            giveAssetSliders [i].enabled  = false;
            getAssetSliders [i].enabled   = false;
        }

        //only 1 player display is needed
        optionsPanel [0].gameObject.SetActive(true);
        optionsPanel [1].gameObject.SetActive(false);
        optionsPanel [2].gameObject.SetActive(false);

        //1st player panel is enabled but changing it is not possible
        optionsPanel [0].enabled = false;

        //set the color and avatar of the panel
        optionsPanel [0].image.color = sender.playerColor;
        TradePlayerPanelButton current = optionsPanel [0].GetComponentInChildren <TradePlayerPanelButton>();

        //set values for the buttons
        current.instance = this;
        //no offset this is correct
        current.playernumber  = sender.playerNumber - 1;
        current.avatar.sprite = sender.avatar;
        selectionMade         = true;
        ahack = current;
        //set button glow
        current.UpdateSelection();
        this.gameObject.SetActive(false);
        this.gameObject.SetActive(true);
    }
コード例 #5
0
    private IEnumerator playMasterMerchant()
    {
        CatanManager clientCatanManager = GameObject.FindGameObjectWithTag("CatanManager").GetComponent <CatanManager> ();
        //first get possible players
        List <Player> possibleplayer = new List <Player>();

        for (int i = 0; i < PhotonNetwork.playerList.Length; i++)
        {
            if (PhotonNetwork.player.ID - 1 != i && clientCatanManager.players [i].getVpPoints() >= clientCatanManager.players [PhotonNetwork.player.ID].getVpPoints())
            {
                possibleplayer.Add(clientCatanManager.players [i]);
            }
        }
        //make user select 1 of the players
        clientCatanManager.uiManager.robberStealPanel.displayPanelForChoices(possibleplayer);
        bool selectionMade = false;

        //get the selection
        while (!selectionMade)
        {
            if (!CatanManager.instance.uiManager.robberStealPanel.selectionMade)
            {
                yield return(StartCoroutine(CatanManager.instance.uiManager.robberStealPanel.waitUntilButtonDown()));
            }
            if (CatanManager.instance.uiManager.robberStealPanel.selectionMade)
            {
                selectionMade = true;
            }
        }
        //get player selection
        int selection = clientCatanManager.uiManager.robberStealPanel.selection;

        Debug.Log("selection: " + selection);
        //take off robber steal panel
        clientCatanManager.uiManager.robberStealPanel.selectionMade = false;
        clientCatanManager.uiManager.robberStealPanel.gameObject.SetActive(false);
        //now show resource selection
        clientCatanManager.uiManager.discardPanel.title.text = "Select 2 resources to take";
        clientCatanManager.uiManager.discardPanel.displayPanelMasterMerchant(clientCatanManager.players [selection].assets, 2);

        selectionMade = false;

        while (!selectionMade)
        {
            if (!CatanManager.instance.uiManager.discardPanel.selectionMade)
            {
                yield return(StartCoroutine(CatanManager.instance.uiManager.discardPanel.waitUntilButtonDown()));
            }
            if (CatanManager.instance.uiManager.discardPanel.selectionMade)
            {
                selectionMade = true;
            }
        }
        AssetTuple temptuple = clientCatanManager.uiManager.discardPanel.discardTuple;

        clientCatanManager.uiManager.discardPanel.selectionMade = false;
        clientCatanManager.uiManager.discardPanel.gameObject.SetActive(false);
        clientCatanManager.uiManager.discardPanel.title.text = "Discard:";

        EventTransferManager.instance.OnTradeWithBank(selection, false, temptuple);
        EventTransferManager.instance.OnTradeWithBank(PhotonNetwork.player.ID - 1, true, temptuple);
        //build notification message
        string message = clientCatanManager.players [PhotonNetwork.player.ID - 1].playerName + " has played the Master Merchant card.and forced you to give: ";

        for (int i = 0; i < 8; i++)
        {
            if (temptuple.GetValueAtIndex(i) > 0)
            {
                if (i < 5)
                {
                    message = message + temptuple.GetValueAtIndex(i) + " " + ((ResourceType)i).ToString() + " and ";
                }
                else
                {
                    message = message + temptuple.GetValueAtIndex(i) + " " + ((CommodityType)(i - 5)).ToString() + " and ";
                }
            }
        }
        message = message.Substring(0, message.Length - 4);
        EventTransferManager.instance.sendNotification(message, selection);
        returnCardToStack(ProgressCardColor.Yellow, ProgressCardType.MasterMerchant);
    }