Functionnal navigation / service
This commit is contained in:
parent
7a7fcb6ac1
commit
81dfbfaa57
5 changed files with 170 additions and 155 deletions
|
@ -145,7 +145,7 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
consumeTime: 3
|
consumeTime: 3
|
||||||
waitingTime: 10
|
waitingTime: 1
|
||||||
--- !u!195 &8842024822361446808
|
--- !u!195 &8842024822361446808
|
||||||
NavMeshAgent:
|
NavMeshAgent:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -124,80 +124,49 @@ NavMeshSettings:
|
||||||
debug:
|
debug:
|
||||||
m_Flags: 0
|
m_Flags: 0
|
||||||
m_NavMeshData: {fileID: 0}
|
m_NavMeshData: {fileID: 0}
|
||||||
--- !u!1001 &47257443
|
--- !u!1 &128722682
|
||||||
PrefabInstance:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 2
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
m_Modification:
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_TransformParent: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Modifications:
|
serializedVersion: 6
|
||||||
- target: {fileID: 5304524770463492230, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
m_Component:
|
||||||
type: 3}
|
- component: {fileID: 128722683}
|
||||||
propertyPath: m_Name
|
- component: {fileID: 128722684}
|
||||||
value: Oldman
|
m_Layer: 0
|
||||||
objectReference: {fileID: 0}
|
m_Name: ClientManager
|
||||||
- target: {fileID: 5304524770463492230, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
m_TagString: Untagged
|
||||||
type: 3}
|
m_Icon: {fileID: 0}
|
||||||
propertyPath: m_IsActive
|
m_NavMeshLayer: 0
|
||||||
value: 0
|
m_StaticEditorFlags: 0
|
||||||
objectReference: {fileID: 0}
|
m_IsActive: 1
|
||||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
--- !u!4 &128722683
|
||||||
type: 3}
|
Transform:
|
||||||
propertyPath: m_RootOrder
|
m_ObjectHideFlags: 0
|
||||||
value: 1
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
objectReference: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
m_PrefabAsset: {fileID: 0}
|
||||||
type: 3}
|
m_GameObject: {fileID: 128722682}
|
||||||
propertyPath: m_LocalPosition.x
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
value: 2.64
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
objectReference: {fileID: 0}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
m_Children: []
|
||||||
type: 3}
|
m_Father: {fileID: 1160225022}
|
||||||
propertyPath: m_LocalPosition.y
|
m_RootOrder: 1
|
||||||
value: 0.39
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
objectReference: {fileID: 0}
|
--- !u!114 &128722684
|
||||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
MonoBehaviour:
|
||||||
type: 3}
|
m_ObjectHideFlags: 0
|
||||||
propertyPath: m_LocalPosition.z
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
value: 0
|
m_PrefabInstance: {fileID: 0}
|
||||||
objectReference: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
m_GameObject: {fileID: 128722682}
|
||||||
type: 3}
|
m_Enabled: 1
|
||||||
propertyPath: m_LocalRotation.w
|
m_EditorHideFlags: 0
|
||||||
value: 1
|
m_Script: {fileID: 11500000, guid: 2bc1593400bcb054db0179d45fa332e9, type: 3}
|
||||||
objectReference: {fileID: 0}
|
m_Name:
|
||||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
m_EditorClassIdentifier:
|
||||||
type: 3}
|
|
||||||
propertyPath: m_LocalRotation.x
|
|
||||||
value: -0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
|
||||||
type: 3}
|
|
||||||
propertyPath: m_LocalRotation.y
|
|
||||||
value: -0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
|
||||||
type: 3}
|
|
||||||
propertyPath: m_LocalRotation.z
|
|
||||||
value: -0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
|
||||||
type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
|
||||||
type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 5304524770463492235, guid: 2dde00c8c5857d2438fd92435d8c3abb,
|
|
||||||
type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
m_RemovedComponents: []
|
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 2dde00c8c5857d2438fd92435d8c3abb, type: 3}
|
|
||||||
--- !u!1 &268005788
|
--- !u!1 &268005788
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -2972,12 +2941,12 @@ Transform:
|
||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 322056902}
|
m_GameObject: {fileID: 322056902}
|
||||||
m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068}
|
m_LocalRotation: {x: -0.7071068, y: -0, z: 0, w: 0.7071068}
|
||||||
m_LocalPosition: {x: 6.17, y: -0.66, z: -2.4934947}
|
m_LocalPosition: {x: 6.383482, y: -4.752509, z: -0.3424089}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 1160225022}
|
||||||
m_RootOrder: 9
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
|
||||||
--- !u!1 &519420028
|
--- !u!1 &519420028
|
||||||
GameObject:
|
GameObject:
|
||||||
|
@ -3060,7 +3029,7 @@ Transform:
|
||||||
m_LocalScale: {x: 0.5, y: 0.5, z: 1}
|
m_LocalScale: {x: 0.5, y: 0.5, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 3
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &698542424
|
--- !u!1 &698542424
|
||||||
GameObject:
|
GameObject:
|
||||||
|
@ -3170,7 +3139,7 @@ Transform:
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
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 &706948613
|
--- !u!1 &706948613
|
||||||
GameObject:
|
GameObject:
|
||||||
|
@ -3293,7 +3262,67 @@ Transform:
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 6
|
m_RootOrder: 5
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &827096820
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 827096821}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Chair 3
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 6519382022992737161, guid: 0000000000000000d000000000000000, type: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &827096821
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 827096820}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: -5.6, y: -2.07, z: 2.5482712}
|
||||||
|
m_LocalScale: {x: 0.099999994, y: 0.099999994, z: 0.099999994}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1863361785}
|
||||||
|
m_RootOrder: 2
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &863760954
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 863760955}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Chair 2
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 6519382022992737161, guid: 0000000000000000d000000000000000, type: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &863760955
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 863760954}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: -2.89, y: -0.784, z: 2.5482712}
|
||||||
|
m_LocalScale: {x: 0.099999994, y: 0.099999994, z: 0.099999994}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1863361785}
|
||||||
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &966209153
|
--- !u!1 &966209153
|
||||||
GameObject:
|
GameObject:
|
||||||
|
@ -3340,7 +3369,7 @@ Transform:
|
||||||
- {fileID: 268005789}
|
- {fileID: 268005789}
|
||||||
- {fileID: 2115704629}
|
- {fileID: 2115704629}
|
||||||
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}
|
||||||
--- !u!1 &1145481934
|
--- !u!1 &1145481934
|
||||||
GameObject:
|
GameObject:
|
||||||
|
@ -7029,6 +7058,8 @@ Transform:
|
||||||
m_LocalPosition: {x: -0.21348187, y: 4.0925093, z: -2.1510859}
|
m_LocalPosition: {x: -0.21348187, y: 4.0925093, z: -2.1510859}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
|
- {fileID: 322056904}
|
||||||
|
- {fileID: 128722683}
|
||||||
- {fileID: 1863361785}
|
- {fileID: 1863361785}
|
||||||
- {fileID: 1486551544}
|
- {fileID: 1486551544}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
|
@ -7129,7 +7160,7 @@ Transform:
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 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!61 &1163880825
|
--- !u!61 &1163880825
|
||||||
BoxCollider2D:
|
BoxCollider2D:
|
||||||
|
@ -7283,7 +7314,7 @@ Transform:
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
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!1 &1486551543
|
--- !u!1 &1486551543
|
||||||
GameObject:
|
GameObject:
|
||||||
|
@ -7313,7 +7344,7 @@ Transform:
|
||||||
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
|
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1160225022}
|
m_Father: {fileID: 1160225022}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 3
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &1520733216
|
--- !u!1 &1520733216
|
||||||
GameObject:
|
GameObject:
|
||||||
|
@ -32093,7 +32124,6 @@ GameObject:
|
||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 1678986453}
|
- component: {fileID: 1678986453}
|
||||||
- component: {fileID: 1678986452}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Chair 1
|
m_Name: Chair 1
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -32101,58 +32131,6 @@ GameObject:
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 1
|
||||||
--- !u!212 &1678986452
|
|
||||||
SpriteRenderer:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1678986451}
|
|
||||||
m_Enabled: 0
|
|
||||||
m_CastShadows: 0
|
|
||||||
m_ReceiveShadows: 0
|
|
||||||
m_DynamicOccludee: 1
|
|
||||||
m_MotionVectors: 1
|
|
||||||
m_LightProbeUsage: 1
|
|
||||||
m_ReflectionProbeUsage: 1
|
|
||||||
m_RayTracingMode: 0
|
|
||||||
m_RayTraceProcedural: 0
|
|
||||||
m_RenderingLayerMask: 1
|
|
||||||
m_RendererPriority: 0
|
|
||||||
m_Materials:
|
|
||||||
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
|
|
||||||
m_StaticBatchInfo:
|
|
||||||
firstSubMesh: 0
|
|
||||||
subMeshCount: 0
|
|
||||||
m_StaticBatchRoot: {fileID: 0}
|
|
||||||
m_ProbeAnchor: {fileID: 0}
|
|
||||||
m_LightProbeVolumeOverride: {fileID: 0}
|
|
||||||
m_ScaleInLightmap: 1
|
|
||||||
m_ReceiveGI: 1
|
|
||||||
m_PreserveUVs: 0
|
|
||||||
m_IgnoreNormalsForChartDetection: 0
|
|
||||||
m_ImportantGI: 0
|
|
||||||
m_StitchLightmapSeams: 1
|
|
||||||
m_SelectedEditorRenderState: 0
|
|
||||||
m_MinimumChartSize: 4
|
|
||||||
m_AutoUVMaxDistance: 0.5
|
|
||||||
m_AutoUVMaxAngle: 89
|
|
||||||
m_LightmapParameters: {fileID: 0}
|
|
||||||
m_SortingLayerID: 0
|
|
||||||
m_SortingLayer: 0
|
|
||||||
m_SortingOrder: 0
|
|
||||||
m_Sprite: {fileID: -1209127185579228243, guid: bfabe3920bf35724b9a95bf95f5431a9,
|
|
||||||
type: 3}
|
|
||||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
|
||||||
m_FlipX: 0
|
|
||||||
m_FlipY: 0
|
|
||||||
m_DrawMode: 0
|
|
||||||
m_Size: {x: 0.175, y: 0.2}
|
|
||||||
m_AdaptiveModeThreshold: 0.5
|
|
||||||
m_SpriteTileMode: 0
|
|
||||||
m_WasSpriteAssigned: 1
|
|
||||||
m_MaskInteraction: 0
|
|
||||||
m_SpriteSortPoint: 0
|
|
||||||
--- !u!4 &1678986453
|
--- !u!4 &1678986453
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -32195,8 +32173,10 @@ Transform:
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 1678986453}
|
- {fileID: 1678986453}
|
||||||
|
- {fileID: 863760955}
|
||||||
|
- {fileID: 827096821}
|
||||||
m_Father: {fileID: 1160225022}
|
m_Father: {fileID: 1160225022}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 2
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &2115704628
|
--- !u!1 &2115704628
|
||||||
GameObject:
|
GameObject:
|
||||||
|
|
|
@ -9,7 +9,7 @@ using UnityEngine.AI;
|
||||||
public class Client_controller : MonoBehaviour, IUsable
|
public class Client_controller : MonoBehaviour, IUsable
|
||||||
{
|
{
|
||||||
public float consumeTime = 3.0f; //Time to consume currentMug
|
public float consumeTime = 3.0f; //Time to consume currentMug
|
||||||
public float waitingTime = 10.0f; //Patience after ordering
|
public float waitingTime = 10.0f; //Patience after reaching seat
|
||||||
|
|
||||||
string _status;
|
string _status;
|
||||||
HashSet<string> _availStatus = new HashSet<string>(){"entering", "waiting", "consuming", "leaving"};
|
HashSet<string> _availStatus = new HashSet<string>(){"entering", "waiting", "consuming", "leaving"};
|
||||||
|
@ -85,6 +85,8 @@ public class Client_controller : MonoBehaviour, IUsable
|
||||||
agent.updateUpAxis = false;
|
agent.updateUpAxis = false;
|
||||||
//Get target
|
//Get target
|
||||||
agent.destination = ClientManager.Instance.assignTarget();
|
agent.destination = ClientManager.Instance.assignTarget();
|
||||||
|
//Assign Random priority to prevent two agent blocking each other
|
||||||
|
agent.avoidancePriority=Random.Range(0, 99);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
|
@ -93,8 +95,7 @@ public class Client_controller : MonoBehaviour, IUsable
|
||||||
//Navigation
|
//Navigation
|
||||||
// Debug.Log(gameObject.name + " navigation : "+ agent.isStopped + " " + agent.remainingDistance);
|
// Debug.Log(gameObject.name + " navigation : "+ agent.isStopped + " " + agent.remainingDistance);
|
||||||
|
|
||||||
//Reached seat
|
if(status=="entering" && !agent.pathPending && agent.remainingDistance==0) //Reached seat ?
|
||||||
if(status=="entering" && agent.remainingDistance==0)
|
|
||||||
{
|
{
|
||||||
status="waiting";
|
status="waiting";
|
||||||
waitTimer=waitingTime;
|
waitTimer=waitingTime;
|
||||||
|
@ -112,7 +113,8 @@ public class Client_controller : MonoBehaviour, IUsable
|
||||||
}
|
}
|
||||||
|
|
||||||
//Consume Timer
|
//Consume Timer
|
||||||
if (status=="consuming" && agent.remainingDistance==0) //Consuming mug if there's one and reached destination
|
//TODO : Make Client Obstacle when consumming
|
||||||
|
if(status=="consuming" && !agent.pathPending && agent.remainingDistance==0) //Consuming mug if there's one and reached destination
|
||||||
{
|
{
|
||||||
consumeTimer -= Time.deltaTime;
|
consumeTimer -= Time.deltaTime;
|
||||||
if (consumeTimer < 0) //Finished consuming mug ?
|
if (consumeTimer < 0) //Finished consuming mug ?
|
||||||
|
@ -131,5 +133,10 @@ public class Client_controller : MonoBehaviour, IUsable
|
||||||
agent.destination = ClientManager.Instance.assignTarget(agent.destination); //Request next target
|
agent.destination = ClientManager.Instance.assignTarget(agent.destination); //Request next target
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(status=="leaving" && !agent.pathPending && agent.remainingDistance==0)
|
||||||
|
{
|
||||||
|
ClientManager.Instance.clientLeave(gameObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,15 @@ using UnityEditor;
|
||||||
//Define the system managing the clients. (Singleton)
|
//Define the system managing the clients. (Singleton)
|
||||||
public sealed class ClientManager : MonoBehaviour
|
public sealed class ClientManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
int currentNbClient = 0;
|
int nbMaxClients = 3;
|
||||||
int nbMaxClients = 1;
|
|
||||||
bool clientSpawnReady = false;
|
bool clientSpawnReady = false;
|
||||||
float clientSpawnTimer = 0.5f; //Intial time before first spawn (pseudo-random after that)
|
float clientSpawnTimer = 0.5f; //Intial time before first spawn (pseudo-random after that)
|
||||||
float maxTimeNewClients = 10.0f;
|
float maxTimeNewClients = 10.0f;
|
||||||
|
|
||||||
string ClientRessourceFolder = "Clients";
|
string ClientRessourceFolder = "Clients";
|
||||||
private Object[] clients;
|
private Object[] clients;
|
||||||
|
GameObject ClientContainer = null;
|
||||||
|
List<int> clientIDs = new List<int>();
|
||||||
|
|
||||||
Vector2 spawnPoint;
|
Vector2 spawnPoint;
|
||||||
Dictionary<Vector2, bool> targets_dict; //Dict with target and wether they're taken by a client
|
Dictionary<Vector2, bool> targets_dict; //Dict with target and wether they're taken by a client
|
||||||
|
@ -22,20 +23,32 @@ public sealed class ClientManager : MonoBehaviour
|
||||||
//Return wether a new client was created
|
//Return wether a new client was created
|
||||||
public bool clientRequest()
|
public bool clientRequest()
|
||||||
{
|
{
|
||||||
if(clientSpawnReady && currentNbClient<nbMaxClients && targets_dict.ContainsValue(false))
|
if(clientSpawnReady && clientIDs.Count<nbMaxClients && targets_dict.ContainsValue(false))
|
||||||
{
|
{
|
||||||
GameObject newClient = (GameObject)clients[Random.Range(0, clients.Length)];
|
int prefabChoice = Random.Range(0, clients.Length);
|
||||||
// Debug.Log("Spawning "+clientPrefab.name+" at "+spawnPosition);
|
GameObject newClient = Instantiate((GameObject)clients[prefabChoice], spawnPoint, Quaternion.identity, ClientContainer.transform); //Instantiate new client inside ClientManager
|
||||||
Instantiate(newClient, spawnPoint, Quaternion.identity);
|
clientIDs.Add(newClient.GetInstanceID()); //Save ID
|
||||||
currentNbClient+=1;
|
// Debug.Log(newClient.GetInstanceID());
|
||||||
|
newClient.name = newClient.name.Split('(')[0]+clientIDs[clientIDs.Count-1]; //Rename new client
|
||||||
|
|
||||||
clientSpawnTimer=Random.Range(1.0f, maxTimeNewClients); //Need more random ?
|
clientSpawnTimer=Random.Range(1.0f, maxTimeNewClients); //Need more random ?
|
||||||
clientSpawnReady=false;
|
clientSpawnReady=false;
|
||||||
|
|
||||||
|
// Debug.Log("Spawning "+clientPrefab.name+" at "+spawnPosition);
|
||||||
return true; //New client instantiated
|
return true; //New client instantiated
|
||||||
}
|
}
|
||||||
return false; //No new client
|
return false; //No new client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Destroy a client
|
||||||
|
public void clientLeave(GameObject client)
|
||||||
|
{
|
||||||
|
clientIDs.Remove(-int.Parse(client.name.Split('-')[1]));
|
||||||
|
Destroy(client);
|
||||||
|
// Debug.Log(client.name+" destroyed"+clientIDs.Count);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//Assign a random available target.
|
//Assign a random available target.
|
||||||
public Vector2 assignTarget(Vector2? prevTarget=null)
|
public Vector2 assignTarget(Vector2? prevTarget=null)
|
||||||
{
|
{
|
||||||
|
@ -57,6 +70,10 @@ public sealed class ClientManager : MonoBehaviour
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
ClientContainer = GameObject.Find("/GameSystem/ClientManager");
|
||||||
|
if (ClientContainer is null)
|
||||||
|
throw new System.Exception("No ClientManager found under GameSystem");
|
||||||
|
|
||||||
// Load clients prefabs //
|
// Load clients prefabs //
|
||||||
|
|
||||||
// Find all assets labelled with 'usable' :
|
// Find all assets labelled with 'usable' :
|
||||||
|
@ -70,9 +87,13 @@ public sealed class ClientManager : MonoBehaviour
|
||||||
|
|
||||||
clients = Resources.LoadAll(ClientRessourceFolder);
|
clients = Resources.LoadAll(ClientRessourceFolder);
|
||||||
|
|
||||||
foreach (var c in clients)
|
// foreach (var c in clients)
|
||||||
|
// {
|
||||||
|
// Debug.Log(gameObject.name+" : "+c.name + " loaded");
|
||||||
|
// }
|
||||||
|
if (clients.Length<nbMaxClients)
|
||||||
{
|
{
|
||||||
Debug.Log(gameObject.name+" : "+c.name + " loaded");
|
Debug.LogWarning("ClientManager doesn't have enough client prefab to manage unique MaxClients : "+clients.Length+"/"+nbMaxClients);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load Client spawn point //
|
// Load Client spawn point //
|
||||||
|
@ -95,10 +116,14 @@ public sealed class ClientManager : MonoBehaviour
|
||||||
if(target.gameObject.name != "Targets")
|
if(target.gameObject.name != "Targets")
|
||||||
{
|
{
|
||||||
targets_dict.Add(target.position, false);
|
targets_dict.Add(target.position, false);
|
||||||
Debug.Log("Client target : "+ target.gameObject.name + target.position);
|
// Debug.Log("Client target : "+ target.gameObject.name + target.position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (targets_dict.Count<nbMaxClients)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("ClientManager doesn't have enough target to manage MaxClients : "+targets_dict.Count+"/"+nbMaxClients);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
|
@ -110,6 +135,7 @@ public sealed class ClientManager : MonoBehaviour
|
||||||
if(clientSpawnTimer<=0)
|
if(clientSpawnTimer<=0)
|
||||||
clientSpawnReady=true;
|
clientSpawnReady=true;
|
||||||
}
|
}
|
||||||
|
// Debug.Log("Client Spawn : "+clientSpawnTimer+" / Seat available: "+targets_dict.ContainsValue(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
//// Singleton Implementation (https://jlambert.developpez.com/tutoriels/dotnet/implementation-pattern-singleton-csharp/#LIII) ////
|
//// Singleton Implementation (https://jlambert.developpez.com/tutoriels/dotnet/implementation-pattern-singleton-csharp/#LIII) ////
|
||||||
|
|
|
@ -8,7 +8,7 @@ public sealed class GameSystem : MonoBehaviour
|
||||||
{
|
{
|
||||||
//Time
|
//Time
|
||||||
bool serviceOpen = false;
|
bool serviceOpen = false;
|
||||||
float serviceTime = 10.0f;
|
float serviceTime = 30.0f;
|
||||||
float serviceTimer = 0.0f;
|
float serviceTimer = 0.0f;
|
||||||
float slowScale = 0.5f; //Default scale for slow mode
|
float slowScale = 0.5f; //Default scale for slow mode
|
||||||
private float fixedDeltaTime;
|
private float fixedDeltaTime;
|
||||||
|
@ -69,8 +69,10 @@ public sealed class GameSystem : MonoBehaviour
|
||||||
{
|
{
|
||||||
serviceTimer-= Time.deltaTime;
|
serviceTimer-= Time.deltaTime;
|
||||||
if (serviceTimer < 0)
|
if (serviceTimer < 0)
|
||||||
|
{
|
||||||
serviceOpen = false;
|
serviceOpen = false;
|
||||||
|
Debug.Log("Service closed");
|
||||||
|
}
|
||||||
ClientManager.Instance.clientRequest();
|
ClientManager.Instance.clientRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue