Nearly finished auction

This commit is contained in:
Anthony 2020-12-15 13:15:50 +00:00
parent b3d01f4c08
commit 5975277213
3 changed files with 39 additions and 7 deletions

View File

@ -4172,6 +4172,7 @@ MonoBehaviour:
tradeButton: {fileID: 839394544} tradeButton: {fileID: 839394544}
tradeCompletedButton: {fileID: 1476609748} tradeCompletedButton: {fileID: 1476609748}
AuctionUI: {fileID: 1651024356} AuctionUI: {fileID: 1651024356}
auctionButtonGameObject: {fileID: 597381241}
auctionButton: {fileID: 597381243} auctionButton: {fileID: 597381243}
auctionCompleteButton: {fileID: 321526181} auctionCompleteButton: {fileID: 321526181}
--- !u!114 &310476700 --- !u!114 &310476700
@ -22496,7 +22497,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: -0.3999939, y: 0.23999023} m_AnchoredPosition: {x: -0.4000244, y: 0.23999023}
m_SizeDelta: {x: 200, y: 50} m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0, y: 1} m_Pivot: {x: 0, y: 1}
--- !u!114 &1417539915 --- !u!114 &1417539915
@ -25762,7 +25763,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!224 &1651024357 --- !u!224 &1651024357
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -46,9 +46,9 @@ public class Auction : MonoBehaviour
highestBidValue = 0; //This is the starting value for the highest bid. highestBidValue = 0; //This is the starting value for the highest bid.
//Assigning players to the queue //Assigning players to the queue
List<Player> auctionPlayerQueue = main.board.players; //This gets a temporary list of all of the players in the game. auctionPlayerQueue = main.board.players; //This gets a temporary list of all of the players in the game.
currentAuctionPlayer = 0; //This sets the auction queue to 0. currentAuctionPlayer = main.board.currentPlayer; //This sets the auction queue to the current player.
int currentPlayer = main.board.currentPlayer - 1; //This gets the current player from the board. int currentPlayer = main.board.currentPlayer; //This gets the current player from the board.
int playerPosition = main.board.players[currentPlayer].position; //This gets the position of the player that started the auction. int playerPosition = main.board.players[currentPlayer].position; //This gets the position of the player that started the auction.
@ -82,7 +82,7 @@ public class Auction : MonoBehaviour
private void UpdateCurrentBidders() private void UpdateCurrentBidders()
{ {
currentBidders.text = $"Current Bidder: {auctionPlayerQueue[currentAuctionPlayer]}\n" + currentBidders.text = $"Current Bidder: {auctionPlayerQueue[currentAuctionPlayer].name}\n" +
$"Bidders Left: {auctionPlayerQueue.Count}"; $"Bidders Left: {auctionPlayerQueue.Count}";
} }
@ -91,7 +91,7 @@ public class Auction : MonoBehaviour
{ {
//Incrementing to the next player //Incrementing to the next player
if (currentAuctionPlayer >= auctionPlayerQueue.Count) if (currentAuctionPlayer >= auctionPlayerQueue.Count - 1)
{ {
currentAuctionPlayer = 0; currentAuctionPlayer = 0;
} }
@ -187,6 +187,31 @@ public class Auction : MonoBehaviour
NextPlayer(); NextPlayer();
} }
private void QuitAuction()
{
auctionPlayerQueue.RemoveAt(currentAuctionPlayer); //This removes the specified player.
if (currentAuctionPlayer <= auctionPlayerQueue.Count - 1) //This moves the player back a bit for the queue
{
currentAuctionPlayer--;
}
if (auctionPlayerQueue.Count == 1) //This checks if there is only one player left.
{
WinAuction(); //This gives the player the property.
return; //Ends the function.
}
NextPlayer(); //Moves on to the next player to bid.
}
private void WinAuction()
{
int winningPlayer = auctionPlayerQueue[0].playerNumber; //This stores the winning player's number on the board.
}
void Awake() void Awake()
{ {
main = FindObjectOfType<Main>(); //This gets the data from the main file. main = FindObjectOfType<Main>(); //This gets the data from the main file.
@ -201,5 +226,8 @@ public class Auction : MonoBehaviour
//Custom bid //Custom bid
customBidButton.onClick.AddListener(BidCustom); //This allows the player to bid a custom amount. customBidButton.onClick.AddListener(BidCustom); //This allows the player to bid a custom amount.
//Quit auction
quitAuction.onClick.AddListener(QuitAuction);
} }
} }

View File

@ -31,6 +31,7 @@ public class ButtonHandler : MonoBehaviour
//Auction //Auction
public GameObject AuctionUI; public GameObject AuctionUI;
public GameObject auctionButtonGameObject;
public Button auctionButton; public Button auctionButton;
public Button auctionCompleteButton; public Button auctionCompleteButton;
private Auction auction; private Auction auction;
@ -47,11 +48,13 @@ public class ButtonHandler : MonoBehaviour
public void DisableBuying() public void DisableBuying()
{ {
auctionButtonGameObject.SetActive(false);
buyButton.SetActive(false); buyButton.SetActive(false);
} }
public void EnableBuying() public void EnableBuying()
{ {
auctionButtonGameObject.SetActive(true);
buyButton.SetActive(true); buyButton.SetActive(true);
} }