コード例 #1
0
    public void auctionControlFlow()
    {
        AuctionHandler auction = State.getAuctionHandler();

        Debug.Log("Begin Auction Control Flow");
        App    app         = UnityEngine.Object.FindObjectOfType <App>();
        int    playerIndex = app.GetHumanIndex();
        Nation humanPlayer = State.getNations()[playerIndex];

        // int start = currentBidPosition;
        //for (int i = start; i < biddingOrder.Count; i++)
        //{
        while (true)
        {
            Debug.Log("Top of while loop");
            Nation currentPlayer = State.getNations()[auction.getBiddingOrder()[auction.CurrentBidPosition]];
            State.setCurrentPlayer(auction.getBiddingOrder()[auction.CurrentBidPosition]);

            Debug.Log("Current Position is: " + auction.CurrentBidPosition);
            Debug.Log("Current Bidder is: " + currentPlayer.getName());
            Debug.Log("Curret Bidder Index is: " + currentPlayer.getIndex());
            //Debug.Log("Current player - " + currentPlayer.nationName);
            Debug.Log("Current player passed already? :" + auction.getIfPlayerPass(currentPlayer.getIndex()));
            if (humanPlayer.getIndex() == currentPlayer.getIndex() && !auction.getIfPlayerPass(humanPlayer.getIndex()))
            //  if (humanPlayer.getIndex() == currentPlayer.getIndex())
            {
                Debug.Log("Current is human");
                return;
            }
            if (humanPlayer.getIndex() == currentPlayer.getIndex() && auction.getIfPlayerPass(humanPlayer.getIndex()))
            {
                auction.incrementBiddingPosition();
                return;
            }

            else if (currentPlayer.getIndex() == auction.getHighestBidderSoFar())
            {
                Debug.Log("Returned to highest bidder (auction presumably over) " + auction.CurrentBidPosition);
                return;
            }
            else
            {
                Debug.Log("AI bid");
                auction.newBid(currentPlayer);
            }
            auction.incrementBiddingPosition();
        }
    }
コード例 #2
0
    public void prepareWinnerPanel()
    {
        Debug.Log("Prepare winner Panel");
        AuctionHandler auction    = State.getAuctionHandler();
        int            itemIndex  = auction.getIndexOfCurrentItem();
        Nation         itemNation = State.getNations()[itemIndex];

        Debug.Log(itemNation.getNationName());
        GameObject itemFlag = Instantiate(Resources.Load <GameObject>("Flags/Prefabs/" + itemNation.getNationName()));

        itemFlag2.ObjectPrefab = itemFlag.transform;

        Nation     winner      = State.getNations()[auction.getHighestBidderSoFar()];
        GameObject _winnerFlag = Instantiate(Resources.Load <GameObject>("Flags/Prefabs/" + winner.getNationName()));

        winnerFlag.ObjectPrefab = _winnerFlag.transform;

        auctionPrizeText.text  = "The colony of " + itemNation.getName();
        auctionWinnerText.text = "Goes to " + winner.getName() + "!";
    }
コード例 #3
0
    private void declareAuctionResults()
    {
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            playerIndex = app.GetHumanIndex();
        Nation         player      = State.getNations()[playerIndex];
        AuctionHandler auction     = State.getAuctionHandler();
        Nation         winner      = State.getNations()[auction.getHighestBidderSoFar()];
        Nation         item        = State.getNations()[0];

        item = State.getNations()[auction.getIndexCurrentCol()];
        if (winner.getIndex() == player.getIndex())
        {
            ministerText.text = "Congratulations! We may now bring the light of civilization to the people of " + item.getNationName() +
                                " asking for nothing in return other than unrestricted access to their resources and labour!";
            //  ministerPanel.SetActive(true);
        }
        else
        {
            ministerText.text = "It looks like " + winner.getNationName() + " has managed to seal control of " + item.getNationName() +
                                " for now.... Not that we really wanted anything to do with that insignifigant nation anyway.";
        }
        ministerPanel.SetActive(true);
    }
コード例 #4
0
    private void updateAuctionPanel()
    {
        Debug.Log("Update Auction Panel ___________________________");
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            playerIndex = app.GetHumanIndex();
        Nation         player      = State.getNations()[playerIndex];
        AuctionHandler auction     = State.getAuctionHandler();
        Nation         item        = State.getNations()[auction.getIndexOfCurrentItem()];

        // Debug.Log(playerIndex);
        //TextMeshProUGUI currentPlayerBid = currentBidAmount.GetComponent<TextMeshProUGUI>();
        currentBidAmount.text = auction.getPlayerBid(playerIndex).ToString();
        if (auction.getPlayerBid(playerIndex) > 0 && !auction.getIfPlayerPass(playerIndex))
        {
            decreaseBid.interactable = true;
        }
        else
        {
            decreaseBid.interactable = false;
        }

        if (player.ColonialPoints <= State.CurrentColonyAuctionBid || player.RecognizingTheseClaims.Contains(item.getIndex()) ||
            auction.getIfPlayerPass(playerIndex) || player.landForces.Strength < 2)
        {
            increaseBid.interactable = false;
        }
        else
        {
            increaseBid.interactable = true;
        }

        biddingTable.ClearRows();
        for (int i = 0; i < auction.getBiddingOrder().Count; i++)
        {
            int    currNationIndex = auction.getBiddingOrder()[i];
            Nation currNat         = State.getNations()[currNationIndex];

            TableRow newRow = Instantiate <TableRow>(biddingRow);
            newRow.gameObject.SetActive(true);
            newRow.preferredHeight = 30;
            newRow.name            = currNat.getIndex().ToString();
            biddingTable.AddRow(newRow);
            biddingConnector.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (biddingTable.transform as RectTransform).rect.height);

            int currNatIndex = currNat.getIndex();
            //   Debug.Log("Current Nation: " + currNatIndex);
            int currentNatBid = auction.getPlayerBid(currNatIndex);

            newRow.Cells[0].GetComponentInChildren <Text>().text = currentNatBid.ToString();
            newRow.Cells[1].GetComponentInChildren <Text>().text = currNat.getNationName().ToString();
            // Transform res = newRow.Cells[2].transform.GetChild(0);

            UIObject3D flagImage = newRow.Cells[2].GetComponentInChildren <UIObject3D>();
            // flagImage.sprite = Resources.Load("Flags/" + currNat.getNationName().ToString(), typeof(Sprite)) as Sprite;
            GameObject flagPrefab = Instantiate(Resources.Load <GameObject>("Flags/Prefabs/" + currNat.getNationName()));
            flagImage.ObjectPrefab   = flagPrefab.transform;
            flagImage.RenderScale    = 0;
            flagImage.LightIntensity = 1;
            Transform statusTransform = newRow.Cells[3].transform.GetChild(0);
            Image     statusImage     = statusTransform.GetComponent <Image>();
            if (auction.getIfPlayerPass(currNatIndex) == true)
            {
                statusImage.sprite = Resources.Load("Sprites/GUI/Dark_Red_x", typeof(Sprite)) as Sprite;
            }
            else
            {
                statusImage.sprite = Resources.Load("Sprites/GUI/AuctionHammer", typeof(Sprite)) as Sprite;
            }
        }
        if (auction.getPlayerBid(playerIndex) > State.CurrentColonyAuctionBid)
        {
            bid.interactable = true;
        }
        else
        {
            bid.interactable = false;
        }
        TextMeshProUGUI passButtonText = pass.GetComponentInChildren <TextMeshProUGUI>();

        if (auction.getIfPlayerPass(playerIndex) || auction.getHighestBidderSoFar() == playerIndex)
        {
            passButtonText.SetText("Continue");
        }
        else
        {
            passButtonText.SetText("Pass");
        }
    }