Selling Functionality, Picking up items, Basic computer
This commit is contained in:
49
Assets/Interactables/EmptyCounter/EmptyCounter.cs
Normal file
49
Assets/Interactables/EmptyCounter/EmptyCounter.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EmptyCounter : BaseCounter {
|
||||
|
||||
[SerializeField] private ObjectSO _objectSo;
|
||||
|
||||
[SerializeField] private bool _shouldSpawnOnInteract;
|
||||
|
||||
|
||||
public override void Interact() {
|
||||
InteractionBehaviour interactionBehaviour = PlayerController.Instance.InteractionBehaviour;
|
||||
if (_shouldSpawnOnInteract) {
|
||||
if (_currentObject == null) {
|
||||
Transform objectTransform = Instantiate(_objectSo.prefab, _counterObjectHandle);
|
||||
objectTransform.GetComponent<Object>().setObjectParent(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!HasObject()) {
|
||||
//No item on the counter
|
||||
//Check player if he has something
|
||||
if (interactionBehaviour.HasObject()) {
|
||||
Object obj = interactionBehaviour.GetObject();
|
||||
obj.setObjectParent(this);
|
||||
}
|
||||
else {
|
||||
//Player has no item
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
//Item on Counter
|
||||
//Check player if he has something
|
||||
if (interactionBehaviour.HasObject()) {
|
||||
//Player has something
|
||||
}
|
||||
else {
|
||||
//Player has nothing
|
||||
//Take the object
|
||||
GetObject().setObjectParent(interactionBehaviour);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user