Add Delivery Manager logic and random recipe request generation

This commit is contained in:
BuyMyMojo 2023-03-03 02:53:43 +11:00
parent 7e1cbafa47
commit 8c5f4f2acf
21 changed files with 360 additions and 13 deletions

2
.erp
View file

@ -5,7 +5,7 @@
<resetOnSceneChange>false</resetOnSceneChange> <resetOnSceneChange>false</resetOnSceneChange>
<debugMode>false</debugMode> <debugMode>false</debugMode>
<EditorClosed>true</EditorClosed> <EditorClosed>true</EditorClosed>
<LastTimestamp>1677772071</LastTimestamp> <LastTimestamp>1677776311</LastTimestamp>
<LastSessionID>5977929065333740048</LastSessionID> <LastSessionID>5977929065333740048</LastSessionID>
<Errored>false</Errored> <Errored>false</Errored>
</ERPSettings> </ERPSettings>

View file

@ -50,7 +50,7 @@ MeshRenderer:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 601817793532135484} m_GameObject: {fileID: 601817793532135484}
m_Enabled: 1 m_Enabled: 1
m_CastShadows: 1 m_CastShadows: 0
m_ReceiveShadows: 1 m_ReceiveShadows: 1
m_DynamicOccludee: 1 m_DynamicOccludee: 1
m_StaticShadowCaster: 0 m_StaticShadowCaster: 0

View file

@ -747,8 +747,9 @@ Transform:
- {fileID: 149281692} - {fileID: 149281692}
- {fileID: 1176625748} - {fileID: 1176625748}
- {fileID: 154850159} - {fileID: 154850159}
- {fileID: 1627630072}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 10 m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &370799796 --- !u!1001 &370799796
PrefabInstance: PrefabInstance:
@ -894,7 +895,7 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 9 m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &399068439 --- !u!1001 &399068439
PrefabInstance: PrefabInstance:
@ -1099,7 +1100,7 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 3 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!114 &410087042 --- !u!114 &410087042
MonoBehaviour: MonoBehaviour:
@ -1449,7 +1450,7 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 7 m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &751018959 --- !u!1001 &751018959
PrefabInstance: PrefabInstance:
@ -1735,7 +1736,7 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 4 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &974939165 --- !u!1 &974939165
GameObject: GameObject:
@ -1769,7 +1770,7 @@ Transform:
- {fileID: 1139635725} - {fileID: 1139635725}
- {fileID: 408182762} - {fileID: 408182762}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 6 m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &974939167 --- !u!114 &974939167
MonoBehaviour: MonoBehaviour:
@ -2084,6 +2085,51 @@ Transform:
type: 3} type: 3}
m_PrefabInstance: {fileID: 1705190436} m_PrefabInstance: {fileID: 1705190436}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!1 &1147620365
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1147620367}
- component: {fileID: 1147620366}
m_Layer: 0
m_Name: DeliveryManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1147620366
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1147620365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1debfee2f418c744e8ab7d25885ef70a, type: 3}
m_Name:
m_EditorClassIdentifier:
recipeListSO: {fileID: 11400000, guid: bff9d77b1ada74346ab474d72033959b, type: 2}
--- !u!4 &1147620367
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1147620365}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1176625747 --- !u!1001 &1176625747
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2169,7 +2215,7 @@ PrefabInstance:
serializedVersion: 2 serializedVersion: 2
m_Modification: m_Modification:
serializedVersion: 3 serializedVersion: 3
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 369744370}
m_Modifications: m_Modifications:
- target: {fileID: 6981026837827529820, guid: 5bc7927ba1b8e4242be0761fa07e2039, - target: {fileID: 6981026837827529820, guid: 5bc7927ba1b8e4242be0761fa07e2039,
type: 3} type: 3}
@ -2179,7 +2225,7 @@ PrefabInstance:
- target: {fileID: 7482973359124119346, guid: 5bc7927ba1b8e4242be0761fa07e2039, - target: {fileID: 7482973359124119346, guid: 5bc7927ba1b8e4242be0761fa07e2039,
type: 3} type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 1 value: -1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7482973359124119346, guid: 5bc7927ba1b8e4242be0761fa07e2039, - target: {fileID: 7482973359124119346, guid: 5bc7927ba1b8e4242be0761fa07e2039,
type: 3} type: 3}
@ -2346,7 +2392,7 @@ Transform:
m_ConstrainProportionsScale: 1 m_ConstrainProportionsScale: 1
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 5 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1329055550 --- !u!1001 &1329055550
PrefabInstance: PrefabInstance:
@ -2743,6 +2789,12 @@ Transform:
type: 3} type: 3}
m_PrefabInstance: {fileID: 1617745535} m_PrefabInstance: {fileID: 1617745535}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!4 &1627630072 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 7482973359124119346, guid: 5bc7927ba1b8e4242be0761fa07e2039,
type: 3}
m_PrefabInstance: {fileID: 1182424335}
m_PrefabAsset: {fileID: 0}
--- !u!4 &1641322150 stripped --- !u!4 &1641322150 stripped
Transform: Transform:
m_CorrespondingSourceObject: {fileID: 6616006834372177299, guid: ae14b9e7a32963047a859cc7ab07f505, m_CorrespondingSourceObject: {fileID: 6616006834372177299, guid: ae14b9e7a32963047a859cc7ab07f505,
@ -3226,7 +3278,7 @@ RectTransform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 8 m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
@ -3613,5 +3665,5 @@ Transform:
m_Children: m_Children:
- {fileID: 691696597} - {fileID: 691696597}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 46, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 46, y: 0, z: 0}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bc8bbe1487efb5c4e9976685bcf67742
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cd1640ffe24e9eb469a834432b0eaf46, type: 3}
m_Name: Burger
m_EditorClassIdentifier:
kitchenObjectSoList:
- {fileID: 11400000, guid: 6a1e97e49ac17314c872f2ef05c80dcf, type: 2}
- {fileID: 11400000, guid: cf77ec56d13b4c7478384a548ab18277, type: 2}
recipeName: Burger

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 088cb8280aaeb21478559efc94964011
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cd1640ffe24e9eb469a834432b0eaf46, type: 3}
m_Name: CheeseBurger
m_EditorClassIdentifier:
kitchenObjectSoList:
- {fileID: 11400000, guid: 6a1e97e49ac17314c872f2ef05c80dcf, type: 2}
- {fileID: 11400000, guid: cf77ec56d13b4c7478384a548ab18277, type: 2}
- {fileID: 11400000, guid: adbde85b933684c4992834e8bb9d893b, type: 2}
recipeName: Cheese Burger

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7ad4476f256556c45bd180052bf8aa7d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cd1640ffe24e9eb469a834432b0eaf46, type: 3}
m_Name: Salad
m_EditorClassIdentifier:
kitchenObjectSoList:
- {fileID: 11400000, guid: 109b320dd13683c4abc574781815cbbd, type: 2}
- {fileID: 11400000, guid: f00d7c6ba063ee6448dd26fac2bf4ce4, type: 2}
recipeName: Salad

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 85d83b88e3a7eae4b9c20abbe7c80a81
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,21 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cd1640ffe24e9eb469a834432b0eaf46, type: 3}
m_Name: UltraDeluxBurger
m_EditorClassIdentifier:
kitchenObjectSoList:
- {fileID: 11400000, guid: 6a1e97e49ac17314c872f2ef05c80dcf, type: 2}
- {fileID: 11400000, guid: cf77ec56d13b4c7478384a548ab18277, type: 2}
- {fileID: 11400000, guid: adbde85b933684c4992834e8bb9d893b, type: 2}
- {fileID: 11400000, guid: 109b320dd13683c4abc574781815cbbd, type: 2}
- {fileID: 11400000, guid: f00d7c6ba063ee6448dd26fac2bf4ce4, type: 2}
recipeName: Ultra Delux Burger

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a4760a58d8ed72c42b16855f884b9416
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 46220a004a45c204795d21699178fcd2, type: 3}
m_Name: _RecipeListSO
m_EditorClassIdentifier:
recipeSOList:
- {fileID: 11400000, guid: 088cb8280aaeb21478559efc94964011, type: 2}
- {fileID: 11400000, guid: 7ad4476f256556c45bd180052bf8aa7d, type: 2}
- {fileID: 11400000, guid: 85d83b88e3a7eae4b9c20abbe7c80a81, type: 2}
- {fileID: 11400000, guid: a4760a58d8ed72c42b16855f884b9416, type: 2}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bff9d77b1ada74346ab474d72033959b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -11,6 +11,8 @@ public class DeliveryCounter : BaseCounter
if (player.GetKitchenObject().TryGetPlate(out PlateKitchenObject plateKitchenObject)) if (player.GetKitchenObject().TryGetPlate(out PlateKitchenObject plateKitchenObject))
{ {
// only takes plate objects // only takes plate objects
DeliveryManager.Instance.DeliverRecipe(plateKitchenObject);
player.GetKitchenObject().DestroySelf(); player.GetKitchenObject().DestroySelf();
} }
} }

View file

@ -0,0 +1,95 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DeliveryManager : MonoBehaviour
{
public static DeliveryManager Instance { get; private set; }
[SerializeField] private RecipeListSO recipeListSO;
private List<RecipeSO> waitingRecipeSOList;
private float spawnRecipeTimer;
private float spawnRecipeTimerMax = 4f;
private int waitingRecipesMax = 4;
private void Awake()
{
Instance = this;
waitingRecipeSOList = new List<RecipeSO>();
}
private void Update()
{
spawnRecipeTimer -= Time.deltaTime;
if (spawnRecipeTimer <= 0f)
{
spawnRecipeTimer = spawnRecipeTimerMax;
if (waitingRecipeSOList.Count < waitingRecipesMax)
{
RecipeSO waitingRecipeSO = recipeListSO.recipeSOList[Random.Range(0, recipeListSO.recipeSOList.Count)];
Debug.Log(waitingRecipeSO.recipeName);
waitingRecipeSOList.Add(waitingRecipeSO);
}
}
}
public void DeliverRecipe(PlateKitchenObject plateKitchenObject)
{
for (int i=0; i < waitingRecipeSOList.Count; ++i)
{
RecipeSO waitingRecipeSO = waitingRecipeSOList[i];
if (waitingRecipeSO.kitchenObjectSoList.Count == plateKitchenObject.GetKitchenObjectSOList().Count)
{
// Has equal ingreedients on plate
bool plateContentsMatchesRecipe = true;
foreach (KitchenObjectSO recipeKitchenObjectSO in waitingRecipeSO.kitchenObjectSoList)
{
// Cycle through all ingreedients within recipe
bool ingreedientFound = false;
foreach (KitchenObjectSO plateKitchenObjectSO in plateKitchenObject.GetKitchenObjectSOList())
{
// Cycle through all ingreedients within plate
if (plateKitchenObjectSO == recipeKitchenObjectSO)
{
// Ingreedient matches!
ingreedientFound = true;
break;
}
}
if (!ingreedientFound)
{
// This Recipe ingreedient was not on plate
plateContentsMatchesRecipe = false;
}
if (plateContentsMatchesRecipe)
{
// Player delivered correct recipe
Debug.Log("Player delivered a recipe from the waiting list!");
waitingRecipeSOList.RemoveAt(i);
return;
}
}
}
}
// No matches found!
// Player brought the wrong recipe!
Debug.Log("Player brought the wrong recipe!");
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1debfee2f418c744e8ab7d25885ef70a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Commented out for saftey. There should only be one master list of valid recipes.
// [CreateAssetMenu()]
public class RecipeListSO : ScriptableObject
{
public List<RecipeSO> recipeSOList;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 46220a004a45c204795d21699178fcd2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu()]
public class RecipeSO : ScriptableObject
{
public List<KitchenObjectSO> kitchenObjectSoList;
public string recipeName;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cd1640ffe24e9eb469a834432b0eaf46
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: