Example #1
0
    public void DecreaseBid()
    {
        AuctionHandler auction     = State.getAuctionHandler();
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            playerIndex = app.GetHumanIndex();
        Nation         player      = State.getNations()[playerIndex];

        auction.decreasePlayerBid(playerIndex);
        TextMeshProUGUI playerBid = playerBidText.GetComponent <TextMeshProUGUI>();

        playerBid.text = auction.getPlayerBid(playerIndex).ToString();
        if (auction.getPlayerBid(playerIndex) == 0)
        {
            increceBid.gameObject.SetActive(true);
            decreaseBid.gameObject.SetActive(false);
        }
        if (auction.getPlayerBid(playerIndex) > auction.getCurrentBid())
        {
            bid.interactable = true;
        }
        else
        {
            bid.interactable = false;
        }
    }
Example #2
0
    public void DecreaseBid()
    {
        Debug.Log("Decrease bid");
        AuctionHandler auction     = State.getAuctionHandler();
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            playerIndex = app.GetHumanIndex();
        Nation         player      = State.getNations()[playerIndex];

        auction.decreasePlayerTempBid(playerIndex);
        // TextMeshProUGUI playerBid = playerBidText.GetComponent<TextMeshProUGUI>();
        playersCurrentBid.text   = auction.getTempHumanBidLevel().ToString();
        increaseBid.interactable = true;
        if (auction.getPlayerBid(playerIndex) == 0)
        {
            decreaseBid.interactable = false;
        }
        Debug.Log("Current high bid: " + State.CurrentColonyAuctionBid);
        if (auction.getTempHumanBidLevel() > State.CurrentColonyAuctionBid)
        {
            bid.interactable = true;
        }
        else
        {
            bid.interactable = false;
        }
        playerRemainingPoints.text = (player.GetColonialPoints() - auction.getTempHumanBidLevel()).ToString();

        Debug.Log("Colonial Points: " + player.GetColonialPoints());
        Debug.Log("Player Bid: " + auction.getPlayerBid(playerIndex));
    }
Example #3
0
    private void playerBid()
    {
        AuctionHandler auction     = State.getAuctionHandler();
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            playerIndex = app.GetHumanIndex();

        auction.setIndexOfHighestBidderSoFar(playerIndex);
        auction.setCurrentBid(auction.getPlayerBid(playerIndex));
        playerTurn = false;
    }
Example #4
0
    private void playerPass()
    {
        Debug.Log("Player Passes  >>>>>>>>>>>>>>>>>>>>>>>>>>");
        AuctionHandler auction     = State.getAuctionHandler();
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            playerIndex = app.GetHumanIndex();
        Text           bidText     = bid.GetComponentInChildren <Text>();

        auction.tempHumanBidLevel = auction.getPlayerBid(playerIndex);
        auction.passOnBid(playerIndex);
        auction.incrementBiddingPosition();
        nextAuctionPhase();
        // Nation player = State.getNations()[playerIndex];
    }
Example #5
0
    private void playerBid()
    {
        Debug.Log("Player bids >>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        AuctionHandler auction     = State.getAuctionHandler();
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            playerIndex = app.GetHumanIndex();
        int            playerBid   = auction.getTempHumanBidLevel();

        auction.setPlayerBid(playerIndex, playerBid);
        auction.setIndexOfHighestBidderSoFar(playerIndex);
        //State.CurrentColonyAuctionBid = auction.getPlayerBid(playerIndex);
        State.UpdateColonyAuctionBid(auction.getPlayerBid(playerIndex));
        auction.incrementBiddingPosition();

        nextAuctionPhase();
    }
Example #6
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");
        }
    }