Selling Functionality, Picking up items, Basic computer

This commit is contained in:
2024-10-21 01:07:44 +02:00
parent f594bdf112
commit 19b7964f83
117 changed files with 9452 additions and 540 deletions

View File

@@ -0,0 +1,39 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 19101, guid: 0000000000000000e000000000000000, type: 0}
m_Name: ItemSellScreen
m_EditorClassIdentifier:
themeUss: {fileID: -4733365628477956816, guid: 63ef76e262723ce4790482d0537e3d6b,
type: 3}
m_TargetTexture: {fileID: 0}
m_ScaleMode: 0
m_ReferenceSpritePixelsPerUnit: 100
m_Scale: 1
m_ReferenceDpi: 120
m_FallbackDpi: 96
m_ReferenceResolution: {x: 1200, y: 800}
m_ScreenMatchMode: 0
m_Match: 0
m_SortingOrder: 0
m_TargetDisplay: 0
m_ClearDepthStencil: 1
m_ClearColor: 0
m_ColorClearValue: {r: 0, g: 0, b: 0, a: 0}
m_DynamicAtlasSettings:
m_MinAtlasSize: 64
m_MaxAtlasSize: 4096
m_MaxSubTextureSize: 64
m_ActiveFilters: -1
m_AtlasBlitShader: {fileID: 9101, guid: 0000000000000000f000000000000000, type: 0}
m_RuntimeShader: {fileID: 9100, guid: 0000000000000000f000000000000000, type: 0}
m_RuntimeWorldShader: {fileID: 9102, guid: 0000000000000000f000000000000000, type: 0}
textSettings: {fileID: 0}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c332681d8d6ed4b43a0db286dbc9ecd8
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 878bef87725804d40b00535fec3d61f9
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0

View File

@@ -0,0 +1,12 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<Style src="project://database/Assets/HUD/ItemSellScreen/ItemSellScreen.uss?fileID=7433441132597879392&amp;guid=878bef87725804d40b00535fec3d61f9&amp;type=3#ItemSellScreen" />
<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="100 Barkie" parse-escape-sequences="true" display-tooltip-when-elided="true" name="PriceLabel" 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>
</ui:UXML>

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 6f1f93c5c9a999342ab6c4eaea371c0b
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}

View File

@@ -0,0 +1,50 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UIElements;
using Button = UnityEngine.UIElements.Button;
public class SellScreenController : MonoBehaviour {
private UIDocument _document;
private Label _itemNameLabel;
private Label _paidPriceLabel;
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() {
_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");
if (_itemNameLabel == null) {
Debug.LogError("Item name not found");
}
}
//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();
_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
Debug.Log("Selling: " + _itemNameLabel.text);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 52846a6aaec3a5b408d91c8153b93c04
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: