Fix Cleaning_workshop for multiple Mugs

This commit is contained in:
Antoine H 2021-01-13 16:03:20 +01:00
parent e2a9931788
commit 8c2c988c70
4 changed files with 82 additions and 9 deletions

View file

@ -7520,6 +7520,75 @@ Transform:
type: 3} type: 3}
m_PrefabInstance: {fileID: 1745031502} m_PrefabInstance: {fileID: 1745031502}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
--- !u!1001 &1323637777
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 886581777645042261, guid: 48d421824701a084db0b64ed8eb13372,
type: 3}
propertyPath: m_RootOrder
value: 8
objectReference: {fileID: 0}
- target: {fileID: 886581777645042261, guid: 48d421824701a084db0b64ed8eb13372,
type: 3}
propertyPath: m_LocalPosition.x
value: -0.65
objectReference: {fileID: 0}
- target: {fileID: 886581777645042261, guid: 48d421824701a084db0b64ed8eb13372,
type: 3}
propertyPath: m_LocalPosition.y
value: 3.45
objectReference: {fileID: 0}
- target: {fileID: 886581777645042261, guid: 48d421824701a084db0b64ed8eb13372,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 886581777645042261, guid: 48d421824701a084db0b64ed8eb13372,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 886581777645042261, guid: 48d421824701a084db0b64ed8eb13372,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 886581777645042261, guid: 48d421824701a084db0b64ed8eb13372,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 886581777645042261, guid: 48d421824701a084db0b64ed8eb13372,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 886581777645042261, guid: 48d421824701a084db0b64ed8eb13372,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 886581777645042261, guid: 48d421824701a084db0b64ed8eb13372,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 886581777645042261, guid: 48d421824701a084db0b64ed8eb13372,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 886581777645042264, guid: 48d421824701a084db0b64ed8eb13372,
type: 3}
propertyPath: m_Name
value: Mug (1)
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 48d421824701a084db0b64ed8eb13372, type: 3}
--- !u!1 &1476057779 --- !u!1 &1476057779
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -21,14 +21,6 @@ public class Cleaning_workshop : Workshop
if (mug!= null) if (mug!= null)
{ {
Debug.Log(userObject.name+ " stocked in "+gameObject.name); Debug.Log(userObject.name+ " stocked in "+gameObject.name);
if(mug.content != null)//Empty mug
{
mug.consume();
prepTimer=0.0f;
}
else if(!mug.dirty)//Mug already clean
prepTimer=prepTime;
stock.Add(userObject); stock.Add(userObject);
return true; //Object taken return true; //Object taken
@ -61,12 +53,23 @@ public class Cleaning_workshop : Workshop
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if(currentMug!=null)
Debug.Log(stock.Count+ " - CurrentMug: "+currentMug.name+" "+currentMug.GetComponent<Mug>().dirty);
//Set current mug if there's stock //Set current mug if there's stock
if(currentMug is null && stock.Count>0) if(currentMug is null && stock.Count>0)
{ {
currentMug=stock[0]; currentMug=stock[0];
stock.RemoveAt(0); stock.RemoveAt(0);
Mug mug = currentMug.GetComponent<Mug>();
if(mug.content != null)//Empty mug
{
mug.consume();
prepTimer=0.0f;
}
else if(!mug.dirty)//Mug already clean
prepTimer=prepTime;
if(UIPrepTimer != null) //Display UI prep timer if(UIPrepTimer != null) //Display UI prep timer
{ {
UIPrepTimer.SetValue(prepTimer/prepTime); UIPrepTimer.SetValue(prepTimer/prepTime);

View file

@ -21,7 +21,7 @@ public class Client_controller : MonoBehaviour, IUsable
set{ set{
if (_availStatus.Contains(value)) if (_availStatus.Contains(value))
_status = value; _status = value;
Debug.Log(gameObject.name+" "+_status); // Debug.Log(gameObject.name+" "+_status);
//Switch Agent to obstacle if waiting //Switch Agent to obstacle if waiting
if(value=="waiting") if(value=="waiting")

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using UnityEngine; using UnityEngine;
//Define the behavior of a workshop //Define the behavior of a workshop
//TODO : Only stock Component instead of GameObject in currentMug ?
[RequireComponent(typeof(Collider2D))] [RequireComponent(typeof(Collider2D))]
public abstract class Workshop : MonoBehaviour, IUsable public abstract class Workshop : MonoBehaviour, IUsable
{ {