Update Event system + Add basic HardObstacle

This commit is contained in:
Antoine H 2021-01-22 17:34:44 +01:00
parent ca8790bb19
commit fd8306645b
39 changed files with 1248 additions and 69 deletions

View file

@ -0,0 +1,105 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: clientFight
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves:
- curve:
- time: 0
value: {fileID: -9087577266532155448, guid: 4253ee9838e8504419ade6abdae8ca57,
type: 3}
- time: 0.083333336
value: {fileID: -1106684591460216115, guid: 4253ee9838e8504419ade6abdae8ca57,
type: 3}
- time: 0.16666667
value: {fileID: -5983078005227543334, guid: 4253ee9838e8504419ade6abdae8ca57,
type: 3}
- time: 0.25
value: {fileID: 7818055727696256662, guid: 4253ee9838e8504419ade6abdae8ca57,
type: 3}
- time: 0.33333334
value: {fileID: 8013849657407384527, guid: 4253ee9838e8504419ade6abdae8ca57,
type: 3}
- time: 0.41666666
value: {fileID: -5181280606106272151, guid: 4253ee9838e8504419ade6abdae8ca57,
type: 3}
- time: 0.5
value: {fileID: -7197358887858680917, guid: 4253ee9838e8504419ade6abdae8ca57,
type: 3}
- time: 0.5833333
value: {fileID: 5016423947855932505, guid: 4253ee9838e8504419ade6abdae8ca57,
type: 3}
- time: 0.6666667
value: {fileID: 9222936549612893643, guid: 4253ee9838e8504419ade6abdae8ca57,
type: 3}
- time: 0.75
value: {fileID: -8405810056075184875, guid: 4253ee9838e8504419ade6abdae8ca57,
type: 3}
attribute: m_Sprite
path:
classID: 212
script: {fileID: 0}
m_SampleRate: 12
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 0
attribute: 0
script: {fileID: 0}
typeID: 212
customType: 23
isPPtrCurve: 1
pptrCurveMapping:
- {fileID: -9087577266532155448, guid: 4253ee9838e8504419ade6abdae8ca57, type: 3}
- {fileID: -1106684591460216115, guid: 4253ee9838e8504419ade6abdae8ca57, type: 3}
- {fileID: -5983078005227543334, guid: 4253ee9838e8504419ade6abdae8ca57, type: 3}
- {fileID: 7818055727696256662, guid: 4253ee9838e8504419ade6abdae8ca57, type: 3}
- {fileID: 8013849657407384527, guid: 4253ee9838e8504419ade6abdae8ca57, type: 3}
- {fileID: -5181280606106272151, guid: 4253ee9838e8504419ade6abdae8ca57, type: 3}
- {fileID: -7197358887858680917, guid: 4253ee9838e8504419ade6abdae8ca57, type: 3}
- {fileID: 5016423947855932505, guid: 4253ee9838e8504419ade6abdae8ca57, type: 3}
- {fileID: 9222936549612893643, guid: 4253ee9838e8504419ade6abdae8ca57, type: 3}
- {fileID: -8405810056075184875, guid: 4253ee9838e8504419ade6abdae8ca57, type: 3}
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.8333333
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View file

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

View file

@ -0,0 +1,159 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1101 &-2207836258054923399
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 2
m_ConditionEvent: active fight
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 4800364795622535310}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.7
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &-476213691089259077
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: clientFight
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: -2207836258054923399}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: b4a8d327ed204ff44b68b1c6df1c66eb, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: clientFight_animator
serializedVersion: 5
m_AnimatorParameters:
- m_Name: active fight
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
m_StateMachine: {fileID: 7885178700017951334}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1101 &1878572531684579299
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: active fight
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -476213691089259077}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &4800364795622535310
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Wait
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 1878572531684579299}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 0}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1107 &7885178700017951334
AnimatorStateMachine:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 4800364795622535310}
m_Position: {x: 419.1192, y: 250.46849, z: 0}
- serializedVersion: 1
m_State: {fileID: -476213691089259077}
m_Position: {x: 487.31512, y: 97.02763, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_EntryPosition: {x: 140, y: 160, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 4800364795622535310}

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View file

@ -0,0 +1,346 @@
fileFormatVersion: 2
guid: 4253ee9838e8504419ade6abdae8ca57
TextureImporter:
internalIDToNameTable:
- first:
213: -9087577266532155448
second: smoke_0
- first:
213: -1106684591460216115
second: smoke_1
- first:
213: -5983078005227543334
second: smoke_2
- first:
213: 7818055727696256662
second: smoke_3
- first:
213: 8013849657407384527
second: smoke_4
- first:
213: -5181280606106272151
second: smoke_5
- first:
213: -7197358887858680917
second: smoke_6
- first:
213: 5016423947855932505
second: smoke_7
- first:
213: 9222936549612893643
second: smoke_8
- first:
213: -8405810056075184875
second: smoke_9
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 2
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites:
- serializedVersion: 2
name: smoke_0
rect:
serializedVersion: 2
x: 0
y: 0
width: 128
height: 128
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 8cf7f67cf9072e180800000000000000
internalID: -9087577266532155448
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: smoke_1
rect:
serializedVersion: 2
x: 128
y: 0
width: 128
height: 128
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: dc29d9f3a3444a0f0800000000000000
internalID: -1106684591460216115
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: smoke_2
rect:
serializedVersion: 2
x: 256
y: 0
width: 128
height: 128
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: ad4a5f20146d7fca0800000000000000
internalID: -5983078005227543334
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: smoke_3
rect:
serializedVersion: 2
x: 384
y: 0
width: 128
height: 128
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 69e1b8333405f7c60800000000000000
internalID: 7818055727696256662
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: smoke_4
rect:
serializedVersion: 2
x: 512
y: 0
width: 128
height: 128
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: fcb2721edc9e63f60800000000000000
internalID: 8013849657407384527
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: smoke_5
rect:
serializedVersion: 2
x: 640
y: 0
width: 128
height: 128
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 96e3a678db46818b0800000000000000
internalID: -5181280606106272151
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: smoke_6
rect:
serializedVersion: 2
x: 768
y: 0
width: 128
height: 128
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: babce288938dd1c90800000000000000
internalID: -7197358887858680917
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: smoke_7
rect:
serializedVersion: 2
x: 896
y: 0
width: 128
height: 128
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 95c27be900bed9540800000000000000
internalID: 5016423947855932505
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: smoke_8
rect:
serializedVersion: 2
x: 1024
y: 0
width: 128
height: 128
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: bc5b4a93de37eff70800000000000000
internalID: 9222936549612893643
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: smoke_9
rect:
serializedVersion: 2
x: 1152
y: 0
width: 128
height: 128
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 5157b363a40985b80800000000000000
internalID: -8405810056075184875
vertices: []
indices:
edges: []
weights: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View file

@ -15,6 +15,7 @@ GameObject:
- component: {fileID: 5304524770463492233}
- component: {fileID: 8842024822361446808}
- component: {fileID: -7733974610363878313}
- component: {fileID: 3997251302917059352}
m_Layer: 8
m_Name: Client
m_TagString: Usable
@ -158,7 +159,7 @@ NavMeshAgent:
m_GameObject: {fileID: 5304524770463492230}
m_Enabled: 1
m_AgentTypeID: 0
m_Radius: 0.32
m_Radius: 0.25
m_Speed: 1
m_Acceleration: 8
avoidancePriority: 50
@ -167,8 +168,8 @@ NavMeshAgent:
m_AutoTraverseOffMeshLink: 1
m_AutoBraking: 1
m_AutoRepath: 1
m_Height: 1.28
m_BaseOffset: 0.64
m_Height: 0.3
m_BaseOffset: 0.025
m_WalkableMask: 4294967295
m_ObstacleAvoidanceType: 4
--- !u!208 &-7733974610363878313
@ -187,6 +188,27 @@ NavMeshObstacle:
m_CarveOnlyStationary: 1
m_Center: {x: 0, y: 0.2, z: 0}
m_TimeToStationary: 0.1
--- !u!50 &3997251302917059352
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5304524770463492230}
m_BodyType: 1
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 1
m_Material: {fileID: 0}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 4
--- !u!1 &5453982149135371002
GameObject:
m_ObjectHideFlags: 0

View file

@ -0,0 +1,162 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2827306491375899988
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2607014449971772197}
- component: {fileID: -4161144385216632757}
- component: {fileID: 3584062944757385923}
- component: {fileID: 1835648757843523848}
- component: {fileID: 1725399312431511591}
- component: {fileID: 3189895248152533610}
m_Layer: 0
m_Name: HardObstacle
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2607014449971772197
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2827306491375899988}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -2.6143043, y: -0.40863657, z: -1.5327958}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &-4161144385216632757
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2827306491375899988}
m_Enabled: 1
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: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 0
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!95 &3584062944757385923
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2827306491375899988}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 69f9597ecec38b842969d718306a8a66, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!61 &1835648757843523848
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2827306491375899988}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0.023439527, y: 0.038105845}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 1.28, y: 1.28}
newSize: {x: 1.28, y: 1.28}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1.0314424, y: 1.0260323}
m_EdgeRadius: 0
--- !u!208 &1725399312431511591
NavMeshObstacle:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2827306491375899988}
m_Enabled: 1
serializedVersion: 3
m_Shape: 1
m_Extents: {x: 0.65, y: 0.65, z: 0.5}
m_MoveThreshold: 0.1
m_Carve: 1
m_CarveOnlyStationary: 1
m_Center: {x: 0, y: 0, z: 0}
m_TimeToStationary: 0.5
--- !u!114 &3189895248152533610
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2827306491375899988}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6bcb4ca5242cefc4bb06adff707d9c5f, type: 3}
m_Name:
m_EditorClassIdentifier:
lifeTime: 3

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a1ecb144f5ffc8c468342fd128328af3
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

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

View file

@ -0,0 +1,76 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &4510937209002914880
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2607014449971772197, guid: a1ecb144f5ffc8c468342fd128328af3,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2607014449971772197, guid: a1ecb144f5ffc8c468342fd128328af3,
type: 3}
propertyPath: m_LocalPosition.x
value: -2.2624502
objectReference: {fileID: 0}
- target: {fileID: 2607014449971772197, guid: a1ecb144f5ffc8c468342fd128328af3,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.114923835
objectReference: {fileID: 0}
- target: {fileID: 2607014449971772197, guid: a1ecb144f5ffc8c468342fd128328af3,
type: 3}
propertyPath: m_LocalPosition.z
value: -1.5327958
objectReference: {fileID: 0}
- target: {fileID: 2607014449971772197, guid: a1ecb144f5ffc8c468342fd128328af3,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2607014449971772197, guid: a1ecb144f5ffc8c468342fd128328af3,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2607014449971772197, guid: a1ecb144f5ffc8c468342fd128328af3,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2607014449971772197, guid: a1ecb144f5ffc8c468342fd128328af3,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2607014449971772197, guid: a1ecb144f5ffc8c468342fd128328af3,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2607014449971772197, guid: a1ecb144f5ffc8c468342fd128328af3,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2607014449971772197, guid: a1ecb144f5ffc8c468342fd128328af3,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2701532041091318685, guid: a1ecb144f5ffc8c468342fd128328af3,
type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2827306491375899988, guid: a1ecb144f5ffc8c468342fd128328af3,
type: 3}
propertyPath: m_Name
value: HardObstacle Variant
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a1ecb144f5ffc8c468342fd128328af3, type: 3}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1415a21a1be86c941823ed672062410d
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

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

View file

@ -32568,6 +32568,12 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2157073178828809470, guid: dfb09d229e85c1446bee2e4f9357610e,
type: 3}
propertyPath: m_NavMeshData
value:
objectReference: {fileID: 23800000, guid: 6bdd1fd9cb47841418b4891635a20f56,
type: 2}
- target: {fileID: 2157073179154264261, guid: dfb09d229e85c1446bee2e4f9357610e,
type: 3}
propertyPath: nbMaxClients
@ -32581,7 +32587,7 @@ PrefabInstance:
- target: {fileID: 2157073179154264261, guid: dfb09d229e85c1446bee2e4f9357610e,
type: 3}
propertyPath: clientSpawnChance
value: 50
value: 100
objectReference: {fileID: 0}
- target: {fileID: 2157073180203202244, guid: dfb09d229e85c1446bee2e4f9357610e,
type: 3}
@ -32653,6 +32659,16 @@ PrefabInstance:
propertyPath: range
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7408334756516261553, guid: dfb09d229e85c1446bee2e4f9357610e,
type: 3}
propertyPath: maxHardObs
value: 4
objectReference: {fileID: 0}
- target: {fileID: 7408334756516261553, guid: dfb09d229e85c1446bee2e4f9357610e,
type: 3}
propertyPath: maxSoftObs
value: 10
objectReference: {fileID: 0}
- target: {fileID: 7408334756516261553, guid: dfb09d229e85c1446bee2e4f9357610e,
type: 3}
propertyPath: nbMaxEvents
@ -32663,6 +32679,16 @@ PrefabInstance:
propertyPath: spawnChance
value: 30
objectReference: {fileID: 0}
- target: {fileID: 7408334756516261553, guid: dfb09d229e85c1446bee2e4f9357610e,
type: 3}
propertyPath: EventRessourceFolder
value: Events/SoftObstalces
objectReference: {fileID: 0}
- target: {fileID: 7408334756516261553, guid: dfb09d229e85c1446bee2e4f9357610e,
type: 3}
propertyPath: coroutineRefreshRate
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: dfb09d229e85c1446bee2e4f9357610e, type: 3}
--- !u!1 &1809057616

View file

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

View file

@ -4,6 +4,8 @@ using UnityEngine;
using UnityEngine.AI;
//Define the behavior of a client
[RequireComponent(typeof(Animator))]
[RequireComponent(typeof(Rigidbody2D))]
[RequireComponent(typeof(Collider2D))]
[RequireComponent(typeof(NavMeshAgent))]
[RequireComponent(typeof(NavMeshObstacle))]
@ -13,14 +15,18 @@ public class Client_controller : MonoBehaviour, IUsable
public float waitingTime = 10.0f; //Patience after reaching seat
public UITimer UIWaitingTimer = null;
Animator animator;
string _status;
HashSet<string> _availStatus = new HashSet<string>(){"entering", "waiting", "consuming", "leaving"};
string _prevStatus;
HashSet<string> _availStatus = new HashSet<string>(){"entering", "waiting", "consuming", "leaving", "event"};
public string status
{
get{ return _status;}
set{
if (_availStatus.Contains(value))
_prevStatus=_status;
_status = value;
animator.SetTrigger(_status); //Update status in animator
// Debug.Log(gameObject.name+" "+_status);
switch (value)
{
@ -31,8 +37,9 @@ public class Client_controller : MonoBehaviour, IUsable
UIWaitingTimer.gameObject.SetActive(false);
break;
case "waiting":
EventManager.Instance.startCoroutine(gameObject);
//Switch Agent to obstacle if waiting
agent.Warp(agent.destination); //Make sure agent become static at right position
agent.Warp(assigedPos); //Make sure agent become static at right position
agent.enabled = false;
navObstacle.enabled = true;
@ -48,6 +55,7 @@ public class Client_controller : MonoBehaviour, IUsable
if(UIWaitingTimer != null)
UIWaitingTimer.gameObject.SetActive(false);
break;
case "event":
case "leaving":
EventManager.Instance.stopCoroutine(gameObject);
navObstacle.enabled = false;
@ -69,7 +77,7 @@ public class Client_controller : MonoBehaviour, IUsable
GameObject currentMug = null; //Mug currently held by the client
//Navigation
Vector2 destination;
Vector2 assigedPos; //Chair to sit or destination to stay (leave)
NavMeshAgent agent;
NavMeshObstacle navObstacle; //Obstacle for other agents
@ -111,6 +119,27 @@ public class Client_controller : MonoBehaviour, IUsable
}
}
//Assign client to an event/destination. Restore its previous status if no event/destination is given.
public void assignToEvent(Vector2? destination=null)
{
if(destination is null)
{
status=_prevStatus;
// NavMeshHit hit;
// NavMesh.SamplePosition(gameObject.transform.position, out hit, agent.height*2, NavMesh.AllAreas);
// agent.Warp(hit.position);
if(agent.enabled)
agent.SetDestination(assigedPos);
else
gameObject.transform.position=assigedPos;
}
else
{
status="event";
agent.SetDestination((Vector2)destination);
}
}
// Start is called before the first frame update
void Start()
{
@ -124,6 +153,8 @@ public class Client_controller : MonoBehaviour, IUsable
else
UIWaitingTimer.gameObject.SetActive(false);
animator = GetComponent<Animator>();
// Navigation //
agent = GetComponent<NavMeshAgent>();
navObstacle = GetComponent<NavMeshObstacle>();
@ -132,7 +163,8 @@ public class Client_controller : MonoBehaviour, IUsable
agent.updateRotation = false;
agent.updateUpAxis = false;
//Get target
agent.SetDestination(ClientManager.Instance.assignTarget());
assigedPos = ClientManager.Instance.assignTarget(); //Chair to go
agent.SetDestination(assigedPos);
//Assign Random priority to prevent two agent blocking each other
agent.avoidancePriority=Random.Range(0, 99);
@ -154,21 +186,22 @@ public class Client_controller : MonoBehaviour, IUsable
UIWaitingTimer.DisplayIcon(StockManager.Instance.consumableSprite(order));
}
if(status=="waiting")
else if(status=="waiting")
{
waitTimer -= Time.deltaTime;
if (waitTimer < 0) //Waited too long
{
//Leave tavern
status = "leaving";
agent.SetDestination(ClientManager.Instance.assignTarget(agent.destination, true)); //Request next target
assigedPos = ClientManager.Instance.assignTarget(assigedPos, true); //Request leaving target
agent.SetDestination(assigedPos);
}
else if(UIWaitingTimer != null) //Update UI Waiting timer
UIWaitingTimer.SetValue(waitTimer/waitingTime);
}
//Consume Timer
if(status=="consuming") //Consuming mug if there's one and reached destination
else if(status=="consuming") //Consuming mug if there's one and reached destination
{
consumeTimer -= Time.deltaTime;
if(consumeTimer < 0) //Finished consuming mug ?
@ -190,11 +223,12 @@ public class Client_controller : MonoBehaviour, IUsable
//Leave tavern
status = "leaving";
agent.SetDestination(ClientManager.Instance.assignTarget(agent.destination, true)); //Request next target
assigedPos = ClientManager.Instance.assignTarget(assigedPos, true); //Request leaving target
agent.SetDestination(assigedPos);
}
}
if(status=="leaving" && !agent.pathPending && agent.remainingDistance==0)
else if(status=="leaving" && !agent.pathPending && agent.remainingDistance==0)
{
Destroy(gameObject);
}

View file

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

View file

@ -0,0 +1,92 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
//Define the behavior of a hard obstacle (Block movement)
[RequireComponent(typeof(Animator))]
[RequireComponent(typeof(Collider2D))]
[RequireComponent(typeof(NavMeshObstacle))]
public class HardObstacle : MonoBehaviour
{
[SerializeField]
float lifeTime = -1.0f; //Time before self-destruct (Negative value to prevent self-destruct)
float lifeTimer;
List<Client_controller> angryClients = new List<Client_controller>(); //Clients in the fight
Collider2D ObsCollider;
NavMeshObstacle Obstacle;
// SpriteRenderer ObsRenderer;
Animator animator;
bool gameRunning = true;
// Start is called before the first frame update
void Start()
{
lifeTimer=lifeTime;
ObsCollider = GetComponent<Collider2D>();
Obstacle = GetComponent<NavMeshObstacle>();
Obstacle.enabled=false; //Don't block movement before client entounter
animator = GetComponent<Animator>();
animator.SetBool("active fight", false); //Disable animation before client encounter
}
// Update is called once per frame
void Update()
{
if(animator.GetBool("active fight") && lifeTimer>0)
{
lifeTimer -= Time.deltaTime;
if(lifeTimer<0)
{
Destroy(gameObject);
}
}
}
void OnTriggerEnter2D(Collider2D other)
{
Client_controller newClient = other.GetComponent<Client_controller>();
if(newClient!=null && !angryClients.Contains(newClient))
{
if(newClient.status!="event") //Make sure to set right status
newClient.assignToEvent(gameObject.transform.position);
angryClients.Add(newClient);
// Debug.Log("New fighting client. Current nb : "+angryClients.Count);
if(angryClients.Count>1)//Start fight
{
foreach(Client_controller client in angryClients) //Turn off client (to merge for a fight)
client.gameObject.SetActive(false);
animator.SetBool("active fight", true);
//Block movement
Obstacle.enabled=true;
ObsCollider.isTrigger=false; //Trigger becoming solid
}
}
}
void OnDestroy()
{
if(gameRunning) //Only apply if game is still running
foreach(Client_controller client in angryClients) //Clients return to their previous behavior
{
client.gameObject.SetActive(true);
client.assignToEvent(); //Restore previous behavior
}
EventManager.Instance.destroyEvent(gameObject);
}
void OnApplicationQuit()
{
gameRunning=false;
}
}

View file

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

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
//Define the behavior of a soft obstacle
//Define the behavior of a soft obstacle (Slow movement and chance of falling)
//TODO : Effect on clients ? (Lower Tips/Repu ?)
[RequireComponent(typeof(Collider2D))]
public class SoftObstacle : MonoBehaviour
@ -13,7 +13,7 @@ public class SoftObstacle : MonoBehaviour
float mvtSlow = 1.0f; //Scale of movement slowdown (1.0f = no change).
[SerializeField]
float lifeTime = 3.0f; //Time to consume currentMug
float lifeTime = -1.0f; //Time before self-destruct (Negative value to prevent self-destruct)
float lifeTimer;
Tavernkeeper_controller player;
@ -27,10 +27,13 @@ public class SoftObstacle : MonoBehaviour
// Update is called once per frame
void Update()
{
lifeTimer -= Time.deltaTime;
if(lifeTimer<0)
if(lifeTimer>0)
{
Destroy(gameObject);
lifeTimer -= Time.deltaTime;
if(lifeTimer<0)
{
Destroy(gameObject);
}
}
}
//TODO : Trigger falling animation on tavernkeeper

View file

@ -36,9 +36,15 @@ public sealed class ClientManager : MonoBehaviour
[SerializeField]
string ClientRessourceFolder = "Clients";
private Object[] clients;
private Object[] clientsPrefab;
GameObject ClientContainer = null;
List<int> clientIDs = new List<int>();
private List<GameObject> _clientList = new List<GameObject>();
public List<GameObject> clientList
{
get{return _clientList;}
private set{_clientList=value;}
}
Vector2 spawnPoint;
Dictionary<Vector2, bool> targets_dict; //Dict with target and wether they're taken by a client
@ -49,13 +55,14 @@ public sealed class ClientManager : MonoBehaviour
//Return wether a new client was created
public bool clientRequest(float SpawnChance=100.0f)
{
if(Random.Range(0.0f, 99.9f)<SpawnChance && clientIDs.Count<nbMaxClients && targets_dict.ContainsValue(false))
if(Random.Range(0.0f, 99.9f)<SpawnChance && clientList.Count<nbMaxClients && targets_dict.ContainsValue(false))
{
int prefabChoice = Random.Range(0, clients.Length);
GameObject newClient = Instantiate((GameObject)clients[prefabChoice], spawnPoint, Quaternion.identity, ClientContainer.transform); //Instantiate new client inside ClientManager
clientIDs.Add(newClient.GetInstanceID()); //Save ID
int prefabChoice = Random.Range(0, clientsPrefab.Length);
GameObject newClient = Instantiate((GameObject)clientsPrefab[prefabChoice], spawnPoint, Quaternion.identity, ClientContainer.transform); //Instantiate new client inside ClientManager
// Debug.Log(newClient.GetInstanceID());
newClient.name = newClient.name.Split('(')[0]+clientIDs[clientIDs.Count-1]; //Rename new client
newClient.name = newClient.name.Split('(')[0]+newClient.GetInstanceID(); //Rename new client
clientList.Add(newClient); //Save client ref
// clientSpawnTimer=Random.Range(1.0f, maxTimeNewClients); //Need more random ?
// clientSpawnReady=false;
@ -75,7 +82,7 @@ public sealed class ClientManager : MonoBehaviour
//Destroy a client
public void clientLeave(GameObject client)
{
clientIDs.Remove(client.GetInstanceID());
clientList.Remove(client);
// Debug.Log(client.name+" destroyed"+clientIDs.Count);
//Prevent immediate spawn of a new client after one leaving
@ -156,15 +163,15 @@ public sealed class ClientManager : MonoBehaviour
// Instantiate(guid, spawnPosition, Quaternion.identity);
// }
clients = Resources.LoadAll(ClientRessourceFolder);
clientsPrefab = Resources.LoadAll(ClientRessourceFolder);
// foreach (var c in clients)
// {
// Debug.Log(gameObject.name+" : "+c.name + " loaded");
// }
if (clients.Length<nbMaxClients)
if (clientsPrefab.Length<nbMaxClients)
{
Debug.LogWarning("ClientManager doesn't have enough client prefab to manage unique MaxClients : "+clients.Length+"/"+nbMaxClients);
Debug.LogWarning("ClientManager doesn't have enough client prefab to manage unique MaxClients : "+clientsPrefab.Length+"/"+nbMaxClients);
}
// Load Client spawn point //

View file

@ -24,9 +24,10 @@ public sealed class EventManager : MonoBehaviour
[SerializeField]
float SpawnRange = 1.0f; //Range of an event spawn from its origin (real max distance = 2*range)
[SerializeField]
int nbMaxEvents = 1; //Maximum active clients
float spawnChance = 100.0f; //Probability of an event to spawn (%)
[SerializeField]
float spawnChance = 100.0f; //Probability of an event to spawn
int maxSoftObs = 1, maxHardObs = 1; //Maximum active events
// [SerializeField]
// float eventSpawnTimer = 0.5f; //Intial time before first spawn (pseudo-random after that)
// [SerializeField]
@ -34,46 +35,68 @@ public sealed class EventManager : MonoBehaviour
// bool eventSpawnReady = false;
[SerializeField]
string EventRessourceFolder = "Events"; //Ressource folder w/ events prefabs
private Object[] events;
string SoftObsRessourceFolder = "Events/SoftObstacles", HardObsRessourceFolder = "Events/HardObstacles"; //Ressource folder w/ events prefabs
private Dictionary<string,Object[]> eventPrefabs = new Dictionary<string,Object[]>();
GameObject EventContainer=null;
List<int> eventIDs = new List<int>(); //List of active event ID
//List of active event ID
List<GameObject> softObsList = new List<GameObject>();
List<GameObject> hardObsList = new List<GameObject>();
[SerializeField]
float coroutineRefreshRate = 1.0f; //Time (s) before refreshing a coroutine
private Dictionary<int,IEnumerator> coroutines= new Dictionary<int,IEnumerator>(); //Dict of EventManager coroutines associated to each client ID
//Spawn an event near position with a probability of spawnChance%
public void spawnEvent(Vector2 position, float spawnChance = 100.0f)
public void spawnSoftObs(Vector2 position, float spawnChance = 100.0f)
{
Vector3 spawnPoint;
if (Random.Range(0.0f, 99.9f)<spawnChance && eventIDs.Count<nbMaxEvents && RandomPoint(position, SpawnRange, out spawnPoint))
if (Random.Range(0.0f, 99.9f)<spawnChance && softObsList.Count<maxSoftObs && RandomPoint(position, SpawnRange, out spawnPoint))
{
// Debug.DrawRay(spawnPoint, Vector3.up, Color.blue, 2.0f);
int prefabChoice = Random.Range(0, events.Length);
GameObject newEvent = Instantiate((GameObject)events[prefabChoice], spawnPoint, Quaternion.identity, EventContainer.transform); //Instantiate new event inside ClientManager
eventIDs.Add(newEvent.GetInstanceID()); //Save ID
newEvent.name = newEvent.name.Split('(')[0]+eventIDs[eventIDs.Count-1]; //Rename new client
int prefabChoice = Random.Range(0, eventPrefabs["soft"].Length);
GameObject newEvent = Instantiate((GameObject)eventPrefabs["soft"][prefabChoice], spawnPoint, Quaternion.identity, EventContainer.transform); //Instantiate new event inside ClientManager
softObsList.Add(newEvent); //Save event to list
newEvent.name = newEvent.name.Split('(')[0]+newEvent.GetInstanceID(); //Rename new event
// eventSpawnTimer=Random.Range(1.0f, maxTimeNewEvents); //Need more random ?
// eventSpawnReady=false;
}
}
public void spawnHardObs(List<Client_controller> targetClients, Vector2 position, float spawnChance = 100.0f)
{
//TODO: Orienté client vers event + prefab
Vector3 spawnPoint;
if (Random.Range(0.0f, 99.9f)<spawnChance && hardObsList.Count<maxHardObs && RandomPoint(position, SpawnRange, out spawnPoint))
{
// Debug.DrawRay(spawnPoint, Vector3.up, Color.blue, 2.0f);
int prefabChoice = Random.Range(0, eventPrefabs["hard"].Length);
GameObject newEvent = Instantiate((GameObject)eventPrefabs["hard"][prefabChoice], spawnPoint, Quaternion.identity, EventContainer.transform); //Instantiate new event inside ClientManager
hardObsList.Add(newEvent); //Save event to list
newEvent.name = newEvent.name.Split('(')[0]+newEvent.GetInstanceID(); //Rename new event
foreach(Client_controller client in targetClients)
client.assignToEvent(spawnPoint);
}
}
//Remove an event from the EventManager
public void destroyEvent(GameObject eventObj)
{
eventIDs.Remove(eventObj.GetInstanceID());
softObsList.Remove(eventObj);
hardObsList.Remove(eventObj);
}
//Start an event coroutine for client
public void startCoroutine(GameObject client)
{
Debug.Log("EventManager: Start coroutine "+client.name);
// Debug.Log("EventManager: Start coroutine "+client.name);
int clientID = client.GetInstanceID();
if(coroutines.ContainsKey(clientID)) //Stop previous coroutine of the client
StopCoroutine(coroutines[clientID]);
IEnumerator newCoroutine = clientCoroutine(client.transform.position);
IEnumerator newCoroutine = clientCoroutine(client);
coroutines[clientID]=newCoroutine;
StartCoroutine(newCoroutine);
}
@ -85,22 +108,77 @@ public sealed class EventManager : MonoBehaviour
if(coroutines.ContainsKey(clientID))
{
Debug.Log("EventManager: Stop coroutine "+client.name);
// Debug.Log("EventManager: Stop coroutine "+client.name);
StopCoroutine(coroutines[clientID]);
}
}
//InvokeRepeating() is another option
//Coroutine to be started in a parallel process.
private IEnumerator clientCoroutine(Vector2 position)
private IEnumerator clientCoroutine(GameObject clientObj)
{
Client_controller client = clientObj.GetComponent<Client_controller>();
while(EventManager.Instance!=null){
if(GameSystem.Instance.serviceOpen)
EventManager.Instance.spawnEvent(position, spawnChance);
yield return new WaitForSeconds(1.0f); //Called every second
{
//Try to spawn softObs or hardObs randomly
if(Random.value<0.5 && client.status=="consuming")
EventManager.Instance.spawnSoftObs(clientObj.transform.position, spawnChance);
else
{
List<GameObject> otherClients = findNearClients(clientObj, 1.0f);
if(otherClients.Count>0)
{
foreach(GameObject ocl in otherClients)
Debug.DrawLine(clientObj.transform.position, ocl.transform.position, Color.red, coroutineRefreshRate);
// Debug.Log("Clients near");
GameObject tgtClient = otherClients[Random.Range(0, otherClients.Count)];
//TODO : Compute spawnChance w/ clients happiness
Vector2 eventPos=(clientObj.transform.position+tgtClient.transform.position)/2; //Event pos between clients
List<Client_controller> targetClients = new List<Client_controller>(){client, tgtClient.GetComponent<Client_controller>()};
EventManager.Instance.spawnHardObs(targetClients, eventPos, spawnChance);
}
}
}
yield return new WaitForSeconds(coroutineRefreshRate); //Called every coroutineRefreshRate second
}
}
//Return the list of other clients in range of client. The client in event status are ignored.
List<GameObject> findNearClients(GameObject client, float range)
{
List<GameObject> res = new List<GameObject>();
List<GameObject> clientList = ClientManager.Instance.clientList;
Vector3 originPos = client.transform.position;
Vector3 otherPos;
foreach(GameObject cl in clientList)
{
otherPos=cl.transform.position;
if(Vector2.Distance(originPos, otherPos)<range && originPos!=otherPos)
if(cl.GetComponent<Client_controller>().status!="event")//Ignore clients already in event status
res.Add(cl);
}
return res;
}
//Try to find a random point on NavMesh inside a range circle. A result would at a maximum distance of 2*range.
bool RandomPoint(Vector3 center, float range, out Vector3 result)
{
for (int i = 0; i < 50; i++)
{
Vector3 randomPoint = center + (Vector3)Random.insideUnitCircle * range;
NavMeshHit hit;
if (NavMesh.SamplePosition(randomPoint, out hit, range, NavMesh.AllAreas))
{
result = hit.position;
return true;
}
}
result = Vector3.zero;
return false;
}
//Awake is called when the script instance is being loaded.
void Awake()
{
@ -116,10 +194,15 @@ public sealed class EventManager : MonoBehaviour
if (EventContainer is null)
throw new System.Exception("No EventManager found under GameSystem");
events = Resources.LoadAll(EventRessourceFolder);
if (events.Length==0)
eventPrefabs["soft"] = Resources.LoadAll(SoftObsRessourceFolder);
eventPrefabs["hard"] = Resources.LoadAll(HardObsRessourceFolder);
if (eventPrefabs["soft"].Length==0)
{
Debug.LogWarning("EventManager didn't find events prefab in ressource folder : "+EventRessourceFolder);
Debug.LogWarning("EventManager didn't find events prefab in ressource folder : "+SoftObsRessourceFolder);
}
if (eventPrefabs["hard"].Length==0)
{
Debug.LogWarning("EventManager didn't find events prefab in ressource folder : "+HardObsRessourceFolder);
}
ready = true;
@ -146,21 +229,4 @@ public sealed class EventManager : MonoBehaviour
{
StopAllCoroutines();
}
//Try to find a random point on NavMesh inside a range circle. A result would at a maximum distance of 2*range.
bool RandomPoint(Vector3 center, float range, out Vector3 result)
{
for (int i = 0; i < 50; i++)
{
Vector3 randomPoint = center + (Vector3)Random.insideUnitCircle * range;
NavMeshHit hit;
if (NavMesh.SamplePosition(randomPoint, out hit, range, NavMesh.AllAreas))
{
result = hit.position;
return true;
}
}
result = Vector3.zero;
return false;
}
}

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(Rigidbody2D))]
[RequireComponent(typeof(Animator))]
public class Tavernkeeper_controller : MonoBehaviour
{

View file

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

View file

@ -11,7 +11,7 @@ NavMeshProjectSettings:
cost: 1
- name: Jump
cost: 2
- name:
- name: No Event
cost: 1
- name:
cost: 1