41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
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;
|
|
}
|
|
|
|
|
|
} |