diff --git a/Assets/Scenes/monopoly.unity b/Assets/Scenes/monopoly.unity index 37d6a6c..9245147 100644 --- a/Assets/Scenes/monopoly.unity +++ b/Assets/Scenes/monopoly.unity @@ -3080,7 +3080,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: -0.2000122, y: 0.41001892} + m_AnchoredPosition: {x: -0.2000122, y: 0.41003418} m_SizeDelta: {x: 200, y: 50} m_Pivot: {x: 1, y: 1} --- !u!114 &224120108 @@ -4032,6 +4032,7 @@ GameObject: - component: {fileID: 310476699} - component: {fileID: 310476700} - component: {fileID: 310476701} + - component: {fileID: 310476702} m_Layer: 5 m_Name: Canvas m_TagString: Untagged @@ -4170,6 +4171,9 @@ MonoBehaviour: TradeUI: {fileID: 485577677} tradeButton: {fileID: 839394544} tradeCompletedButton: {fileID: 1476609748} + AuctionUI: {fileID: 1651024356} + auctionButton: {fileID: 597381243} + auctionCompleteButton: {fileID: 321526181} --- !u!114 &310476700 MonoBehaviour: m_ObjectHideFlags: 0 @@ -4312,6 +4316,29 @@ MonoBehaviour: confirmationButtonYes: {fileID: 1194858181} confirmationButtonNo: {fileID: 654028984} CompletionBox: {fileID: 679464474} +--- !u!114 &310476702 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 310476693} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e97b3592055162a41b2733dba0478243, type: 3} + m_Name: + m_EditorClassIdentifier: + AuctionScreen: {fileID: 509093248} + AuctionWon: {fileID: 1647668061} + propertyDetails: {fileID: 2014704928} + biddingInfo: {fileID: 1312039402} + currentBidders: {fileID: 1572348688} + bid1: {fileID: 942226723} + bid10: {fileID: 1378888396} + bid100: {fileID: 1312102276} + customBidInput: {fileID: 1362157339} + customBidButton: {fileID: 1084299228} + quitAuction: {fileID: 1166653497} --- !u!1 &311884834 GameObject: m_ObjectHideFlags: 0 @@ -4491,7 +4518,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -0.000015258789} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &321526179 @@ -5482,6 +5509,140 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 4.699951} m_SizeDelta: {x: 258.55328, y: 38.5} m_Pivot: {x: 0, y: 0} +--- !u!1 &398948850 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 398948851} + - component: {fileID: 398948853} + - component: {fileID: 398948852} + m_Layer: 5 + m_Name: Text (TMP) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &398948851 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 398948850} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1166653496} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &398948852 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 398948850} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: Quit Auction + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4281479730 + m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 24 + m_fontSizeBase: 24 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 1 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &398948853 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 398948850} + m_CullTransparentMesh: 0 --- !u!1 &399521301 GameObject: m_ObjectHideFlags: 0 @@ -6593,7 +6754,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &485577678 RectTransform: m_ObjectHideFlags: 0 @@ -7119,6 +7280,7 @@ RectTransform: - {fileID: 1362157338} - {fileID: 1312039401} - {fileID: 1572348687} + - {fileID: 1166653496} m_Father: {fileID: 1651024357} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -17785,6 +17947,126 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1157611928} m_CullTransparentMesh: 0 +--- !u!1 &1166653495 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1166653496} + - component: {fileID: 1166653499} + - component: {fileID: 1166653498} + - component: {fileID: 1166653497} + m_Layer: 5 + m_Name: Quit Auction + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1166653496 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1166653495} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 398948851} + m_Father: {fileID: 509093249} + m_RootOrder: 10 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0.47000122, y: 30.380005} + m_SizeDelta: {x: 160, y: 30} + m_Pivot: {x: 0, y: 0} +--- !u!114 &1166653497 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1166653495} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1166653498} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &1166653498 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1166653495} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1166653499 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1166653495} + m_CullTransparentMesh: 0 --- !u!1 &1172449488 GameObject: m_ObjectHideFlags: 0 @@ -19063,7 +19345,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: Bid +100 + m_text: Bid Custom m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} @@ -22214,7 +22496,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: -0.3999939, y: 0.2400055} + m_AnchoredPosition: {x: -0.3999939, y: 0.23999023} m_SizeDelta: {x: 200, y: 50} m_Pivot: {x: 0, y: 1} --- !u!114 &1417539915 @@ -25480,7 +25762,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &1651024357 RectTransform: m_ObjectHideFlags: 0 @@ -31112,88 +31394,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2018452652} m_CullTransparentMesh: 0 ---- !u!1 &2021050761 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2021050763} - - component: {fileID: 2021050762} - m_Layer: 0 - m_Name: TickMark 1 - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!212 &2021050762 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2021050761} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 0 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_Sprite: {fileID: 21300000, guid: 3404d4488402b104db6dc3724bf4773a, type: 3} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 1, y: 1} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 0 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 ---- !u!4 &2021050763 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2021050761} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 90.361084, y: 194.69046, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 11 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &2026813601 GameObject: m_ObjectHideFlags: 0 @@ -32167,7 +32367,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 1} m_AnchorMax: {x: 0.5, y: 1} - m_AnchoredPosition: {x: -0.000015258789, y: 0.41001892} + m_AnchoredPosition: {x: -0.000015258789, y: 0.41003418} m_SizeDelta: {x: 200, y: 50} m_Pivot: {x: 0.5, y: 1} --- !u!114 &2081268580 diff --git a/Assets/Scripts/monopoly/Auction.cs b/Assets/Scripts/monopoly/Auction.cs new file mode 100644 index 0000000..9940a57 --- /dev/null +++ b/Assets/Scripts/monopoly/Auction.cs @@ -0,0 +1,205 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; +using TMPro; + +public class Auction : MonoBehaviour +{ + + //Essentials + private Main main; //This is the main class in the game. + + //Screens + public GameObject AuctionScreen; //This is the main auction screen. + public GameObject AuctionWon; //This displays what player won the auction. + + //Text Displays + public TMP_Text propertyDetails; //This is meant to give the name and value of the property. + public TMP_Text biddingInfo; //This is meant to show who has the highest bid and what that highest bid is. + public TMP_Text currentBidders; //This is meant to show who is meant to go next and how many are left. + + //Buttons + //Preset amounts + public Button bid1; //This is the button to bid 1. + public Button bid10; //This is the button to bid 10. + public Button bid100; //This is the button to bid 100. + //Custom amounts + public TMP_InputField customBidInput; //This is where the user can input however much they want. + public Button customBidButton; //This is where the user can confirm how much they want to bid. + //Quit auction + public Button quitAuction; //This is where the user stops bidding and removes themselves from the auction. + + //Information + private int highestBidValue; //This is the highest value for the property in the bid. + private int highestBidPlayer; //This is the player with the highest bid. + private List auctionPlayerQueue; //This will be the queue for the players that are bidding. + private int currentAuctionPlayer; //This is the current player in the queue for the auction. + private Property property; //This is the property that will be auctioned + + //Starting function for the auction + public void OpenTrade() + { + AuctionWon.SetActive(false); //This turns off the auction won screen from before. + + highestBidValue = 0; //This is the starting value for the highest bid. + + //Assigning players to the queue + List 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. + int currentPlayer = main.board.currentPlayer - 1; //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. + + property = main.board.existingProperties[playerPosition]; //This gets the property that is being auctioned. + + UpdatePropertyDetails(); //This shows the details of the property on the screen. + UpdateBiddingInfo(true); //This updates the highest bidder information. + NextPlayer(); //This increments the player. + AuctionScreen.SetActive(true); //This shows the auction screen. + } + + private void UpdatePropertyDetails() + { + propertyDetails.text = $"Property Name: {property.property_name}\n" + + $"Property Value: {property.property_value}"; + } + + private void UpdateBiddingInfo(bool start) + { + //This checks if it wants to show the information if its the start of the auction. + if (start) + { + biddingInfo.text = $"Highest Bidder: -\n" + + $"Highest Bid: {highestBidValue}"; + return; + } + + biddingInfo.text = $"Highest Bidder: {auctionPlayerQueue[highestBidPlayer].name}\n" + + $"Highest Bid: {highestBidValue}"; + } + + private void UpdateCurrentBidders() + { + currentBidders.text = $"Current Bidder: {auctionPlayerQueue[currentAuctionPlayer]}\n" + + $"Bidders Left: {auctionPlayerQueue.Count}"; + } + + //This moves on to the next player in the auction queue. + private void NextPlayer() + { + + //Incrementing to the next player + if (currentAuctionPlayer >= auctionPlayerQueue.Count) + { + currentAuctionPlayer = 0; + } + else + { + currentAuctionPlayer++; + } + + int money = auctionPlayerQueue[currentAuctionPlayer].money; //Gets the money of the current player in the queue + int biddableMoney = money - highestBidValue; + + //Adds a maximum value to the custom bid. + customBidInput.text = ""; + customBidInput.characterLimit = money.ToString().Length; + + //This disables each amounts of money if the player cannot afford to bid that amount. + if (biddableMoney >= 100) + { + bid1.interactable = true; + bid10.interactable = true; + bid100.interactable = true; + } + else if (biddableMoney < 1) + { + bid1.interactable = false; + bid10.interactable = false; + bid100.interactable = false; + } + else if (biddableMoney < 10) + { + bid1.interactable = true; + bid10.interactable = false; + bid100.interactable = false; + } + else + { + bid1.interactable = true; + bid10.interactable = true; + bid100.interactable = false; + } + + UpdateCurrentBidders(); //Updates the displayed text. + } + + //This increases the bid by 1. + private void Bid1() + { + highestBidValue += 1; //Increase the highest bid by 1. + highestBidPlayer = currentAuctionPlayer; //Sets the highest bidding player to the current person who auctioned. + UpdateBiddingInfo(false); //Updates the highest bidding information. + + //Moves on to the next player + NextPlayer(); + } + + //This increases the bid by 10. + private void Bid10() + { + highestBidValue += 10; //Increase the highest bid by 10. + highestBidPlayer = currentAuctionPlayer; //Sets the highest bidding player to the current person who auctioned. + UpdateBiddingInfo(false); //Updates the highest bidding information. + + //Moves on to the next player + NextPlayer(); + } + + //This increases the bid by 100. + private void Bid100() + { + highestBidValue += 100; //Increase the highest bid by 100. + highestBidPlayer = currentAuctionPlayer; //Sets the highest bidding player to the current person who auctioned. + UpdateBiddingInfo(false); //Updates the highest bidding information. + + //Moves on to the next player + NextPlayer(); + } + + //This is for custom bids. + private void BidCustom() + { + int money = Convert.ToInt32(customBidInput.text); //This sets the custom input value into a temporary variable, money converted to an integer. + + if (money == 0 || money + highestBidValue > auctionPlayerQueue[currentAuctionPlayer].money) //This checks if the player hasn't bid 0 or more than how much they own + { + return; + } + + highestBidValue += money; //This increases the highest bid value by the custom amount. + highestBidPlayer = currentAuctionPlayer; //Sets the highest bidding player to the current person who auctioned. + UpdateBiddingInfo(false); //Updates the highest bidding information. + + //Moves on to the next player + NextPlayer(); + } + + void Awake() + { + main = FindObjectOfType
(); //This gets the data from the main file. + } + + void Start() + { + //Add predefined bid buttons with its own function + bid1.onClick.AddListener(Bid1); //For bids of 1. + bid10.onClick.AddListener(Bid10); //For bids of 10. + bid100.onClick.AddListener(Bid100); //For bids of 10. + + //Custom bid + customBidButton.onClick.AddListener(BidCustom); //This allows the player to bid a custom amount. + } +} diff --git a/Assets/Scripts/monopoly/Auction.cs.meta b/Assets/Scripts/monopoly/Auction.cs.meta new file mode 100644 index 0000000..e17ae90 --- /dev/null +++ b/Assets/Scripts/monopoly/Auction.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e97b3592055162a41b2733dba0478243 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/monopoly/ButtonHandler.cs b/Assets/Scripts/monopoly/ButtonHandler.cs index 12a14b3..e89c81c 100644 --- a/Assets/Scripts/monopoly/ButtonHandler.cs +++ b/Assets/Scripts/monopoly/ButtonHandler.cs @@ -28,6 +28,12 @@ public class ButtonHandler : MonoBehaviour public Button tradeCompletedButton; private bool tradeOpen = false; private Trade trade; + + //Auction + public GameObject AuctionUI; + public Button auctionButton; + public Button auctionCompleteButton; + private Auction auction; public void DisableRollDice() { @@ -122,6 +128,18 @@ public class ButtonHandler : MonoBehaviour tradeOpen = false; } } + void OpenAuction() + { + auction.OpenTrade(); + GameUI.SetActive(false); + AuctionUI.SetActive(true); + } + + void CloseAuction() + { + AuctionUI.SetActive(false); + GameUI.SetActive(true); + } private Main main; @@ -130,16 +148,25 @@ public class ButtonHandler : MonoBehaviour main = FindObjectOfType
(); inventoryClass = FindObjectOfType(); trade = FindObjectOfType(); + auction = FindObjectOfType(); } void Start() { + //Core game button function assignment buyButtonButton.onClick.AddListener(BuyPropertyClick); nextTurn.onClick.AddListener(NextTurn); + + //Inventory button function assignment inventory.onClick.AddListener(ToggleInventory); cardButton.onClick.AddListener(CloseCard); + + //Trade button function assignment tradeButton.onClick.AddListener(ToggleTrade); tradeCompletedButton.onClick.AddListener(ToggleTrade); + + //Auction button function assignment + auctionButton.onClick.AddListener(OpenAuction); } void BuyPropertyClick() { diff --git a/Assets/Scripts/monopoly/Trade.cs b/Assets/Scripts/monopoly/Trade.cs index b9aeb78..9e44d71 100644 --- a/Assets/Scripts/monopoly/Trade.cs +++ b/Assets/Scripts/monopoly/Trade.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;