Create Production_workshop.prefab + Start UI display for prep
This commit is contained in:
parent
998cc81e0a
commit
6cce785d2c
8 changed files with 530 additions and 144 deletions
|
@ -6,12 +6,17 @@ using UnityEngine;
|
|||
[RequireComponent(typeof(Collider2D))]
|
||||
public abstract class Workshop : MonoBehaviour, IUsable
|
||||
{
|
||||
public float prepTime = 2.0f; //Time for preparation of product
|
||||
protected GameObject currentMug = null; //Mug currently stocked in workshop
|
||||
|
||||
public float prepTime = 2.0f; //Time for preparation of product
|
||||
protected float prepTimer= 0.0f;
|
||||
public UITimer UIPrepTimer = null; //Script of the UI display
|
||||
protected bool playerInteracting = false; //Wether the player is interacting w/ the workshop
|
||||
// bool playerInteractFrame = false; //Wether the player used the workshop in the current frame
|
||||
|
||||
//Handle objects interactions w/ Workshop
|
||||
//Return wether the object is taken from tavernkeeper
|
||||
public abstract bool use(GameObject userObject);
|
||||
public abstract bool use(GameObject userObject);
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
|
@ -20,5 +25,23 @@ public abstract class Workshop : MonoBehaviour, IUsable
|
|||
Debug.LogWarning(gameObject.name+" layer should be set to 'Interactions' to work properly");
|
||||
if(gameObject.tag != "Usable")
|
||||
Debug.LogWarning(gameObject.name+" tag should be set to 'Usable' to work properly");
|
||||
if(UIPrepTimer is null)
|
||||
Debug.LogWarning(gameObject.name+" doesn't have a UIPrepTimer set");
|
||||
else
|
||||
UIPrepTimer.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
if(playerInteracting)
|
||||
{
|
||||
if(prepTimer<prepTime) //Update UI Prep timer
|
||||
{
|
||||
prepTimer+=Time.deltaTime;
|
||||
UIPrepTimer.SetValue(prepTimer/prepTime);
|
||||
}
|
||||
|
||||
playerInteracting=false; //Reset interaction indicator for next frame
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue