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,41 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SellCounter : BaseCounter {
private bool _isSelling = false;
private Object _currentObject;
protected void Awake() {
}
public override void Interact() {
InteractionBehaviour interactionBehaviour = PlayerController.Instance.InteractionBehaviour;
if (!_isSelling) {
//This counter is not selling an item yet
if (interactionBehaviour.HasObject()) {
//the player has something to sell
Object obj = interactionBehaviour.GetObject();
//Check if the object is sellable
if (obj.TryGetComponent(out Object objectComponent)) {
HUDManager.Instance.SellItem(this, objectComponent);
}
else {
Debug.Log("Player has something but it is not sellable");
}
}
}
}
//Gets called if an item is being sold on this counter
//This should prevent the counter thinking it's selling something if the user cancels the UI sell
public void ConfirmSell(Object obj) {
_isSelling = true;
obj.setObjectParent(this);
_currentObject = obj;
}
}