Exemplo n.º 1
0
    public void nextAuctionPhase()
    {
        Debug.Log("Begin new auction phase");
        //   waitASec(0.8f);

        AuctionHandler auction     = State.getAuctionHandler();
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            humanIndex  = app.GetHumanIndex();
        Nation         humanPlayer = State.getNations()[humanIndex];

        updateAuctionPanel();
        if (auction.checkIfAuctionIsOver())
        {
            Debug.Log("Auction Should be Over now");
            continueToNextTurn();
            AuctionPanel.SetActive(false);
            auction.concludeAuction();
            prepareWinnerPanel();
            AuctionWinnerPanel.SetActive(true);
            terrainUpdater.ColourContries();
        }
        else
        {
            Debug.Log("Auction Will Continue");
            //If all players have bid and auction is not over - go back to the first bidder
            //  Debug.Log(auction.CurrentBidPosition);
            //  if(auction.CurrentBidPosition == State.getMajorNations().Count)
            //  {
            //      Debug.Log("Return to first remaining bidder");
            //      auction.CurrentBidPosition = 0;
            //  }
            // Go to auction control flow - it will have each AI player bid or pass until reaching the Human controlled player
            auctionControlFlow();
            updateAuctionPanel();
            // If human has passed
            Debug.Log("Human has passed?: " + humanPlayer.getIndex());
            if (auction.getIfPlayerPass(humanPlayer.getIndex()))
            {   // Check if all players have now passed
                Debug.Log("Human Player has passed");

                /*  if (auction.checkIfAuctionIsOver())
                 * {
                 *
                 *    Debug.Log("Auction Should be Over now");
                 *    continueToNextTurn();
                 *    AuctionPanel.SetActive(false);
                 *    auction.concludeAuction();
                 *    prepareWinnerPanel();
                 *    AuctionWinnerPanel.SetActive(true);
                 *    terrainUpdater.ColourContries();
                 * } */
                // NextPhaseAfterPlayerPasses(1.5f);
                // else
                // {
                Debug.Log("Bidding continues without human");
                auctionControlFlow();
                // }
            }
            Debug.Log(auction.CurrentBidPosition);
            int indexOfCurrentBidder = auction.getBiddingOrder()[auction.CurrentBidPosition];
            if (indexOfCurrentBidder != humanIndex)
            {
                auctionControlFlow();
            }
            // nextAuctionPhase();
            Debug.Log("Should be player's turn now?");
            //If player has not passed, control will now be handed to the player
        }
    }