Add cutting progress bar
This commit is contained in:
parent
8194937cd8
commit
4ad7bf281c
8 changed files with 761 additions and 42 deletions
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
@ -5,6 +6,13 @@ using UnityEngine;
|
|||
public class CuttingCounter : BaseCounter
|
||||
{
|
||||
|
||||
public event EventHandler<OnProgressChangeEventsArgs> OnProgressChange;
|
||||
public class OnProgressChangeEventsArgs : EventArgs
|
||||
{
|
||||
public float progressNormalized;
|
||||
}
|
||||
public event EventHandler OnCut;
|
||||
|
||||
[SerializeField] private CuttingRecipeSO[] cuttingRecipeSOArray;
|
||||
|
||||
private int cuttingProgress;
|
||||
|
@ -22,6 +30,13 @@ public class CuttingCounter : BaseCounter
|
|||
// player is carrying an object that can be chopped
|
||||
player.GetKitchenObject().SetKitchenObjectParent(this);
|
||||
cuttingProgress = 0;
|
||||
|
||||
CuttingRecipeSO cuttingRecipeSO = GetCuttingRecipeSOWithInput(GetKitchenObject().GetKitchenObjectSO());
|
||||
|
||||
OnProgressChange?.Invoke(this, new OnProgressChangeEventsArgs
|
||||
{
|
||||
progressNormalized = (float)cuttingProgress / cuttingRecipeSO.cuttingProgressMax,
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -51,9 +66,16 @@ public class CuttingCounter : BaseCounter
|
|||
// there is a KitchenObject AND it is able to be cut
|
||||
|
||||
cuttingProgress++;
|
||||
|
||||
|
||||
OnCut?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
CuttingRecipeSO cuttingRecipeSO = GetCuttingRecipeSOWithInput(GetKitchenObject().GetKitchenObjectSO());
|
||||
|
||||
OnProgressChange?.Invoke(this, new OnProgressChangeEventsArgs
|
||||
{
|
||||
progressNormalized = (float)cuttingProgress / cuttingRecipeSO.cuttingProgressMax,
|
||||
});
|
||||
|
||||
if (cuttingProgress >= cuttingRecipeSO.cuttingProgressMax)
|
||||
{
|
||||
KitchenObjectSO outputKitchenSO = GetOutputForInput(GetKitchenObject().GetKitchenObjectSO());
|
||||
|
|
Reference in a new issue