Add Alot of stuff, Computer, repairStation, Whole game, Many things!
This commit is contained in:
@@ -3,9 +3,13 @@
|
||||
<ui:VisualElement name="VisualElement" style="flex-grow: 1; width: 75%; align-self: center; margin-right: 0; margin-left: 0; padding-top: 0; padding-bottom: 0; background-color: rgb(255, 255, 255); padding-right: 0; padding-left: 0; height: auto; cursor: initial; margin-top: 50px; margin-bottom: 50px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); border-top-width: 10px; border-right-width: 10px; border-bottom-width: 10px; border-left-width: 10px;">
|
||||
<ui:Label tabindex="-1" text="ITEMNAME" parse-escape-sequences="true" display-tooltip-when-elided="true" name="ItemName" style="font-size: 93px; height: auto; width: auto; -unity-text-align: upper-center; margin-top: 30px; justify-content: flex-start;" />
|
||||
<ui:VisualElement style="flex-grow: 1; flex-direction: row; -unity-text-align: upper-center; align-items: center; justify-content: center; align-self: auto;">
|
||||
<ui:Label tabindex="-1" text="Paid Price:" parse-escape-sequences="true" display-tooltip-when-elided="true" style="font-size: 50px; height: auto; width: auto; -unity-text-align: middle-center; margin-top: 0; justify-content: flex-start; white-space: nowrap;" />
|
||||
<ui:Label tabindex="-1" text="Avg selling price: " parse-escape-sequences="true" display-tooltip-when-elided="true" style="font-size: 50px; height: auto; width: auto; -unity-text-align: middle-center; margin-top: 0; justify-content: flex-start; white-space: nowrap;" />
|
||||
<ui:Label tabindex="-1" text="100 Barkie" parse-escape-sequences="true" display-tooltip-when-elided="true" name="PriceLabel" style="font-size: 50px;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement style="flex-grow: 1; flex-direction: row; -unity-text-align: upper-center; align-items: center; justify-content: center; align-self: auto;">
|
||||
<ui:Label tabindex="-1" text="You paid: " parse-escape-sequences="true" display-tooltip-when-elided="true" style="font-size: 50px; height: auto; width: auto; -unity-text-align: middle-center; margin-top: 0; justify-content: flex-start; white-space: nowrap;" />
|
||||
<ui:Label tabindex="-1" text="100 Barkie" parse-escape-sequences="true" display-tooltip-when-elided="true" name="YouPaid" style="font-size: 50px;" />
|
||||
</ui:VisualElement>
|
||||
<ui:TextField picking-mode="Ignore" label="Your Price" value="20" name="YourPriceInputfield" password="false" keyboard-type="DecimalPad" style="flex-direction: column; margin-right: 150px; margin-left: 150px; font-size: 48px; -unity-text-align: upper-center; margin-top: 100px; align-self: auto;" />
|
||||
<ui:Button text="Place for Sale" parse-escape-sequences="true" display-tooltip-when-elided="true" name="SellButton" style="margin-right: 150px; margin-left: 150px; padding-bottom: 50px; padding-top: 50px; margin-top: 105px; -unity-text-align: middle-center; justify-content: flex-start; align-items: stretch; align-self: auto; font-size: 72px; margin-bottom: 105px;" />
|
||||
</ui:VisualElement>
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.UIElements;
|
||||
using Button = UnityEngine.UIElements.Button;
|
||||
|
||||
@@ -10,41 +7,57 @@ public class SellScreenController : MonoBehaviour {
|
||||
private UIDocument _document;
|
||||
|
||||
private Label _itemNameLabel;
|
||||
private Label _avgPriceLabel;
|
||||
private Label _paidPriceLabel;
|
||||
private TextField _YourPriceInputfield;
|
||||
private TextField _yourPriceInputfield;
|
||||
|
||||
private SellCounter _counter;
|
||||
private Object _sellingObject;
|
||||
|
||||
|
||||
//Becase we set the gameobject to active false, we need to use Awake
|
||||
private void Awake() {
|
||||
//Because we set the gameobject to active false, we need to use OnEnable
|
||||
private void OnEnable() {
|
||||
_document = GetComponent<UIDocument>();
|
||||
_itemNameLabel = _document.rootVisualElement.Q<Label>("ItemName");
|
||||
_document.rootVisualElement.Q<Button>("SellButton").clicked += SellItem;
|
||||
|
||||
_paidPriceLabel = _document.rootVisualElement.Q<Label>("PriceLabel");
|
||||
_YourPriceInputfield = _document.rootVisualElement.Q<TextField>("YourPrice");
|
||||
_avgPriceLabel = _document.rootVisualElement.Q<Label>("PriceLabel");
|
||||
_paidPriceLabel = _document.rootVisualElement.Q<Label>("YouPaid");
|
||||
_yourPriceInputfield = _document.rootVisualElement.Q<TextField>("YourPriceInputfield");
|
||||
|
||||
if (_itemNameLabel == null) {
|
||||
Debug.LogError("Item name not found");
|
||||
}
|
||||
}
|
||||
|
||||
//on sleep
|
||||
private void OnDisable() {
|
||||
// _document.rootVisualElement.Q<Button>("SellButton").clicked -= SellItem;
|
||||
_counter = null;
|
||||
_sellingObject = null;
|
||||
|
||||
_itemNameLabel.text = "";
|
||||
_paidPriceLabel.text = "";
|
||||
_avgPriceLabel.text = "";
|
||||
|
||||
_yourPriceInputfield.value = "";
|
||||
}
|
||||
|
||||
|
||||
//TODO: ask how to do this, since the gameobjec that renders the ui is not active
|
||||
public void SetItem(SellCounter counter, Object @object) {
|
||||
_counter = counter;
|
||||
_sellingObject = @object;
|
||||
_paidPriceLabel.text = @object.ObjectSo.basePrice.ToString();
|
||||
_paidPriceLabel.text = @object.PaidPrice.ToString();
|
||||
_avgPriceLabel.text = @object.ObjectSo.basePrice.ToString();
|
||||
_itemNameLabel.text = @object.ObjectSo.objectName;
|
||||
}
|
||||
|
||||
public void SellItem() {
|
||||
_counter.ConfirmSell(_sellingObject);
|
||||
HUDManager.Instance.HideCurrentHUD();
|
||||
//Sell the item
|
||||
//Trigger an event that the item was sold
|
||||
|
||||
private void SellItem() {
|
||||
Debug.Log("Selling: " + _itemNameLabel.text);
|
||||
Debug.Log("Selling for: " + _yourPriceInputfield.text);
|
||||
_counter.ConfirmSell(_sellingObject, float.Parse(_yourPriceInputfield.text));
|
||||
HUDManager.Instance.HideCurrentHUD();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user