mirror of
https://github.com/smyalygames/monopoly.git
synced 2025-05-18 14:24:12 +02:00
Added the basics of houses to the properties UI
This commit is contained in:
parent
0bcb724c04
commit
bf26a088d1
@ -1232,6 +1232,8 @@ MonoBehaviour:
|
||||
backButton: {fileID: 2088896827}
|
||||
propertyName: {fileID: 1881411833}
|
||||
propertyColour: {fileID: 697882661}
|
||||
propertyRent: {fileID: 864765354}
|
||||
propertyHouses: {fileID: 845172791}
|
||||
buyHouse: {fileID: 569742455}
|
||||
sellHouse: {fileID: 505820772}
|
||||
mortgage: {fileID: 516041487}
|
||||
@ -3976,6 +3978,287 @@ Transform:
|
||||
m_Father: {fileID: 758519666}
|
||||
m_RootOrder: 26
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &845172788
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 845172789}
|
||||
- component: {fileID: 845172790}
|
||||
- component: {fileID: 845172791}
|
||||
m_Layer: 5
|
||||
m_Name: Houses
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &845172789
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 845172788}
|
||||
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: 1759702751}
|
||||
m_RootOrder: 7
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0.000016347, y: -66.93}
|
||||
m_SizeDelta: {x: 287.20508, y: 27.748215}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &845172790
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 845172788}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &845172791
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 845172788}
|
||||
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: 'Houses:'
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 5302535af1044152a457ed104f1f4b91, type: 2}
|
||||
m_sharedMaterial: {fileID: 2164040, guid: 5302535af1044152a457ed104f1f4b91, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontColor: {r: 1, g: 1, b: 1, 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: 18
|
||||
m_fontSizeBase: 18
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 2
|
||||
m_VerticalAlignment: 256
|
||||
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!1 &864765351
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 864765352}
|
||||
- component: {fileID: 864765353}
|
||||
- component: {fileID: 864765354}
|
||||
m_Layer: 5
|
||||
m_Name: Rent Values
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &864765352
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 864765351}
|
||||
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: 1759702751}
|
||||
m_RootOrder: 6
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0.20027, y: 29.4}
|
||||
m_SizeDelta: {x: 286.80457, y: 112.30502}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &864765353
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 864765351}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &864765354
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 864765351}
|
||||
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: 'Rent:
|
||||
|
||||
Colour Set:
|
||||
|
||||
1 House:
|
||||
|
||||
2 Houses:
|
||||
|
||||
3 Houses:
|
||||
|
||||
4
|
||||
Houses:
|
||||
|
||||
Hotel:'
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 5302535af1044152a457ed104f1f4b91, type: 2}
|
||||
m_sharedMaterial: {fileID: 2164040, guid: 5302535af1044152a457ed104f1f4b91, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontColor: {r: 1, g: 1, b: 1, 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: 13.5
|
||||
m_fontSizeBase: 13.5
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 2
|
||||
m_VerticalAlignment: 256
|
||||
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!1 &868351749
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -8053,6 +8336,8 @@ RectTransform:
|
||||
- {fileID: 569742454}
|
||||
- {fileID: 505820771}
|
||||
- {fileID: 516041486}
|
||||
- {fileID: 864765352}
|
||||
- {fileID: 845172789}
|
||||
m_Father: {fileID: 1871971151}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
@ -20,6 +20,8 @@ public class Inventory : MonoBehaviour
|
||||
public Button backButton;
|
||||
public TextMeshProUGUI propertyName;
|
||||
public Image propertyColour;
|
||||
public TextMeshProUGUI propertyRent;
|
||||
public TextMeshProUGUI propertyHouses;
|
||||
public Button buyHouse;
|
||||
public Button sellHouse;
|
||||
public Button mortgage;
|
||||
@ -64,9 +66,30 @@ public class Inventory : MonoBehaviour
|
||||
*/
|
||||
propertyName.text = property.property_name; //This sets the name of the property title on screen.
|
||||
propertyColour.color = button.image.color; //This changes the background colour of the title to the colour of the button that was pressed.
|
||||
propertyRent.text = property.ParseRentInformation(); //This shows the rent for each possibilities of houses.
|
||||
propertyHouses.text = property.ParseHouses(); //This shows how many houses there are.
|
||||
|
||||
backButton.onClick.AddListener(CloseProperties); //This adds a listener to go back to the main menu screen for the inventory.
|
||||
|
||||
buyHouse.onClick.AddListener(() => BuyHouse(currentProperty));
|
||||
sellHouse.onClick.AddListener(() => SellHouse(currentProperty));
|
||||
|
||||
switch (property.houses) //Checks how many houses the player has.
|
||||
{
|
||||
case 0: //This stops the player from selling a house when they have none.
|
||||
sellHouse.interactable = false;
|
||||
buyHouse.interactable = true;
|
||||
break;
|
||||
case 4: //This stops the player from buying a house when they cannot buy more.
|
||||
buyHouse.interactable = false;
|
||||
sellHouse.interactable = true;
|
||||
break;
|
||||
default: //This is the default case.
|
||||
buyHouse.interactable = true;
|
||||
sellHouse.interactable = true;
|
||||
break;
|
||||
}
|
||||
|
||||
//Buttons
|
||||
if (!main.board.players[main.board.currentPlayer].ownedProperties[currentProperty].mortgage) //This checks if the property is not mortgaged.
|
||||
{
|
||||
@ -83,6 +106,32 @@ public class Inventory : MonoBehaviour
|
||||
propertyPanel.SetActive(true); //This shows the property specific menu.
|
||||
}
|
||||
|
||||
void BuyHouse(int currentProperty)
|
||||
{
|
||||
main.board.players[main.board.currentPlayer].ownedProperties[currentProperty].addHouse();
|
||||
Property property = main.board.players[main.board.currentPlayer].ownedProperties[currentProperty];
|
||||
propertyHouses.text = property.ParseHouses();
|
||||
if (property.houses >= 4)
|
||||
{
|
||||
buyHouse.interactable = false;
|
||||
}
|
||||
|
||||
sellHouse.interactable = true;
|
||||
}
|
||||
|
||||
void SellHouse(int currentProperty)
|
||||
{
|
||||
main.board.players[main.board.currentPlayer].ownedProperties[currentProperty].removeHouse();
|
||||
Property property = main.board.players[main.board.currentPlayer].ownedProperties[currentProperty];
|
||||
propertyHouses.text = property.ParseHouses();
|
||||
if (property.houses == 0)
|
||||
{
|
||||
sellHouse.interactable = false;
|
||||
}
|
||||
|
||||
buyHouse.interactable = true;
|
||||
}
|
||||
|
||||
void Mortgage(int currentProperty) //This function runs when the Mortgage button has been pressed.
|
||||
{
|
||||
if (main.board.players[main.board.currentPlayer].Mortgage(currentProperty)) //This runs the mortgage function for the property and checks if it was done so successfully.
|
||||
|
@ -96,6 +96,26 @@ public class Property
|
||||
{
|
||||
return property_value != 0; //This checks if the value of the property is set and then returns a boolean
|
||||
}
|
||||
|
||||
public string ParseRentInformation()
|
||||
{
|
||||
string parsedString;
|
||||
parsedString = $"Rent: {property_rent}\n" +
|
||||
$"Colour Set: {property_rent*2}\n" +
|
||||
$"1 House: {property_house1}\n" +
|
||||
$"2 Houses: {property_house2}\n" +
|
||||
$"3 Houses: {property_house3}\n" +
|
||||
$"4 Houses: {property_house4}\n" +
|
||||
$"Hotel: {property_hotel}";
|
||||
return parsedString;
|
||||
}
|
||||
|
||||
public string ParseHouses()
|
||||
{
|
||||
string parsedString;
|
||||
parsedString = $"Houses: {houses}";
|
||||
return parsedString;
|
||||
}
|
||||
}
|
||||
|
||||
public class Board //Creating the class for the board mechanics.
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user