Code refactor
This commit is contained in:
@@ -1,354 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!1 &8399722317111019355
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 3119355583710269351}
|
|
||||||
- component: {fileID: 3256707217429579543}
|
|
||||||
- component: {fileID: 6524694759401631761}
|
|
||||||
- component: {fileID: 5034232006488667909}
|
|
||||||
- component: {fileID: 7486695069966556586}
|
|
||||||
- component: {fileID: 6272804010592829304}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Wall
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!4 &3119355583710269351
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 8399722317111019355}
|
|
||||||
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: 9
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!114 &3256707217429579543
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 8399722317111019355}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 8233d90336aea43098adf6dbabd606a2, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
m_MeshFormatVersion: 2
|
|
||||||
m_Faces:
|
|
||||||
- m_Indexes: 000000000100000002000000010000000300000002000000
|
|
||||||
m_SmoothingGroup: 0
|
|
||||||
m_Uv:
|
|
||||||
m_UseWorldSpace: 0
|
|
||||||
m_FlipU: 0
|
|
||||||
m_FlipV: 0
|
|
||||||
m_SwapUV: 0
|
|
||||||
m_Fill: 1
|
|
||||||
m_Scale: {x: 1, y: 1}
|
|
||||||
m_Offset: {x: 0, y: 0}
|
|
||||||
m_Rotation: 0
|
|
||||||
m_Anchor: 9
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_SubmeshIndex: 0
|
|
||||||
m_ManualUV: 0
|
|
||||||
elementGroup: -1
|
|
||||||
m_TextureGroup: -1
|
|
||||||
- m_Indexes: 040000000500000006000000050000000700000006000000
|
|
||||||
m_SmoothingGroup: 0
|
|
||||||
m_Uv:
|
|
||||||
m_UseWorldSpace: 0
|
|
||||||
m_FlipU: 0
|
|
||||||
m_FlipV: 0
|
|
||||||
m_SwapUV: 0
|
|
||||||
m_Fill: 1
|
|
||||||
m_Scale: {x: 1, y: 1}
|
|
||||||
m_Offset: {x: 0, y: 0}
|
|
||||||
m_Rotation: 0
|
|
||||||
m_Anchor: 9
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_SubmeshIndex: 0
|
|
||||||
m_ManualUV: 0
|
|
||||||
elementGroup: -1
|
|
||||||
m_TextureGroup: -1
|
|
||||||
- m_Indexes: 08000000090000000a000000090000000b0000000a000000
|
|
||||||
m_SmoothingGroup: 0
|
|
||||||
m_Uv:
|
|
||||||
m_UseWorldSpace: 0
|
|
||||||
m_FlipU: 0
|
|
||||||
m_FlipV: 0
|
|
||||||
m_SwapUV: 0
|
|
||||||
m_Fill: 1
|
|
||||||
m_Scale: {x: 1, y: 1}
|
|
||||||
m_Offset: {x: 0, y: 0}
|
|
||||||
m_Rotation: 0
|
|
||||||
m_Anchor: 9
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_SubmeshIndex: 0
|
|
||||||
m_ManualUV: 0
|
|
||||||
elementGroup: -1
|
|
||||||
m_TextureGroup: -1
|
|
||||||
- m_Indexes: 0c0000000d0000000e0000000d0000000f0000000e000000
|
|
||||||
m_SmoothingGroup: 0
|
|
||||||
m_Uv:
|
|
||||||
m_UseWorldSpace: 0
|
|
||||||
m_FlipU: 0
|
|
||||||
m_FlipV: 0
|
|
||||||
m_SwapUV: 0
|
|
||||||
m_Fill: 1
|
|
||||||
m_Scale: {x: 1, y: 1}
|
|
||||||
m_Offset: {x: 0, y: 0}
|
|
||||||
m_Rotation: 0
|
|
||||||
m_Anchor: 9
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_SubmeshIndex: 0
|
|
||||||
m_ManualUV: 0
|
|
||||||
elementGroup: -1
|
|
||||||
m_TextureGroup: -1
|
|
||||||
- m_Indexes: 100000001100000012000000110000001300000012000000
|
|
||||||
m_SmoothingGroup: 0
|
|
||||||
m_Uv:
|
|
||||||
m_UseWorldSpace: 0
|
|
||||||
m_FlipU: 0
|
|
||||||
m_FlipV: 0
|
|
||||||
m_SwapUV: 0
|
|
||||||
m_Fill: 1
|
|
||||||
m_Scale: {x: 1, y: 1}
|
|
||||||
m_Offset: {x: 0, y: 0}
|
|
||||||
m_Rotation: 0
|
|
||||||
m_Anchor: 9
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_SubmeshIndex: 0
|
|
||||||
m_ManualUV: 0
|
|
||||||
elementGroup: -1
|
|
||||||
m_TextureGroup: -1
|
|
||||||
- m_Indexes: 140000001500000016000000150000001700000016000000
|
|
||||||
m_SmoothingGroup: 0
|
|
||||||
m_Uv:
|
|
||||||
m_UseWorldSpace: 0
|
|
||||||
m_FlipU: 0
|
|
||||||
m_FlipV: 0
|
|
||||||
m_SwapUV: 0
|
|
||||||
m_Fill: 1
|
|
||||||
m_Scale: {x: 1, y: 1}
|
|
||||||
m_Offset: {x: 0, y: 0}
|
|
||||||
m_Rotation: 0
|
|
||||||
m_Anchor: 9
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_SubmeshIndex: 0
|
|
||||||
m_ManualUV: 0
|
|
||||||
elementGroup: -1
|
|
||||||
m_TextureGroup: -1
|
|
||||||
m_SharedVertices:
|
|
||||||
- m_Vertices: 000000000d00000016000000
|
|
||||||
- m_Vertices: 010000000400000017000000
|
|
||||||
- m_Vertices: 020000000f00000010000000
|
|
||||||
- m_Vertices: 030000000600000011000000
|
|
||||||
- m_Vertices: 050000000800000015000000
|
|
||||||
- m_Vertices: 070000000a00000013000000
|
|
||||||
- m_Vertices: 090000000c00000014000000
|
|
||||||
- m_Vertices: 0b0000000e00000012000000
|
|
||||||
m_SharedTextures: []
|
|
||||||
m_Positions:
|
|
||||||
- {x: -0.000000059604645, y: 0.049504757, z: 1}
|
|
||||||
- {x: 0.099999964, y: 0.049504757, z: 1}
|
|
||||||
- {x: -0.000000059604645, y: 2.5495048, z: 1}
|
|
||||||
- {x: 0.099999964, y: 2.5495048, z: 1}
|
|
||||||
- {x: 0.099999964, y: 0.049504757, z: 1}
|
|
||||||
- {x: 0.099999964, y: 0.049504757, z: 0}
|
|
||||||
- {x: 0.099999964, y: 2.5495048, z: 1}
|
|
||||||
- {x: 0.099999964, y: 2.5495048, z: 0}
|
|
||||||
- {x: 0.099999964, y: 0.049504757, z: 0}
|
|
||||||
- {x: -0.000000059604645, y: 0.049504757, z: 0}
|
|
||||||
- {x: 0.099999964, y: 2.5495048, z: 0}
|
|
||||||
- {x: -0.000000059604645, y: 2.5495048, z: 0}
|
|
||||||
- {x: -0.000000059604645, y: 0.049504757, z: 0}
|
|
||||||
- {x: -0.000000059604645, y: 0.049504757, z: 1}
|
|
||||||
- {x: -0.000000059604645, y: 2.5495048, z: 0}
|
|
||||||
- {x: -0.000000059604645, y: 2.5495048, z: 1}
|
|
||||||
- {x: -0.000000059604645, y: 2.5495048, z: 1}
|
|
||||||
- {x: 0.099999964, y: 2.5495048, z: 1}
|
|
||||||
- {x: -0.000000059604645, y: 2.5495048, z: 0}
|
|
||||||
- {x: 0.099999964, y: 2.5495048, z: 0}
|
|
||||||
- {x: -0.000000059604645, y: 0.049504757, z: 0}
|
|
||||||
- {x: 0.099999964, y: 0.049504757, z: 0}
|
|
||||||
- {x: -0.000000059604645, y: 0.049504757, z: 1}
|
|
||||||
- {x: 0.099999964, y: 0.049504757, z: 1}
|
|
||||||
m_Textures0:
|
|
||||||
- {x: 0.000000059604645, y: 0.049504757}
|
|
||||||
- {x: -0.099999964, y: 0.049504757}
|
|
||||||
- {x: 0.000000059604645, y: 2.5495048}
|
|
||||||
- {x: -0.099999964, y: 2.5495048}
|
|
||||||
- {x: 1, y: 0.049504757}
|
|
||||||
- {x: 0, y: 0.049504757}
|
|
||||||
- {x: 1, y: 2.5495048}
|
|
||||||
- {x: 0, y: 2.5495048}
|
|
||||||
- {x: 0.099999964, y: 0.049504757}
|
|
||||||
- {x: -0.000000059604645, y: 0.049504757}
|
|
||||||
- {x: 0.099999964, y: 2.5495048}
|
|
||||||
- {x: -0.000000059604645, y: 2.5495048}
|
|
||||||
- {x: 0, y: 0.049504757}
|
|
||||||
- {x: -1, y: 0.049504757}
|
|
||||||
- {x: 0, y: 2.5495048}
|
|
||||||
- {x: -1, y: 2.5495048}
|
|
||||||
- {x: -0.000000059604645, y: 1}
|
|
||||||
- {x: 0.099999964, y: 1}
|
|
||||||
- {x: -0.000000059604645, y: 0}
|
|
||||||
- {x: 0.099999964, y: 0}
|
|
||||||
- {x: 0.000000059604645, y: 0}
|
|
||||||
- {x: -0.099999964, y: 0}
|
|
||||||
- {x: 0.000000059604645, y: 1}
|
|
||||||
- {x: -0.099999964, y: 1}
|
|
||||||
m_Textures2: []
|
|
||||||
m_Textures3: []
|
|
||||||
m_Tangents:
|
|
||||||
- {x: -1, y: 0, z: 0, w: -1}
|
|
||||||
- {x: -1, y: 0, z: 0, w: -1}
|
|
||||||
- {x: -1, y: 0, z: 0, w: -1}
|
|
||||||
- {x: -1, y: 0, z: 0, w: -1}
|
|
||||||
- {x: 0, y: 0, z: 1, w: -1}
|
|
||||||
- {x: 0, y: 0, z: 1, w: -1}
|
|
||||||
- {x: 0, y: 0, z: 1, w: -1}
|
|
||||||
- {x: 0, y: 0, z: 1, w: -1}
|
|
||||||
- {x: 1, y: 0, z: 0, w: -1}
|
|
||||||
- {x: 1, y: 0, z: 0, w: -1}
|
|
||||||
- {x: 1, y: 0, z: 0, w: -1}
|
|
||||||
- {x: 1, y: 0, z: 0, w: -1}
|
|
||||||
- {x: 0, y: 0, z: -1, w: -1}
|
|
||||||
- {x: 0, y: 0, z: -1, w: -1}
|
|
||||||
- {x: 0, y: 0, z: -1, w: -1}
|
|
||||||
- {x: 0, y: 0, z: -1, w: -1}
|
|
||||||
- {x: 1, y: 0, z: 0, w: -1}
|
|
||||||
- {x: 1, y: 0, z: 0, w: -1}
|
|
||||||
- {x: 1, y: 0, z: 0, w: -1}
|
|
||||||
- {x: 1, y: 0, z: 0, w: -1}
|
|
||||||
- {x: -1, y: 0, z: 0, w: -1}
|
|
||||||
- {x: -1, y: 0, z: 0, w: -1}
|
|
||||||
- {x: -1, y: 0, z: 0, w: -1}
|
|
||||||
- {x: -1, y: 0, z: 0, w: -1}
|
|
||||||
m_Colors: []
|
|
||||||
m_UnwrapParameters:
|
|
||||||
m_HardAngle: 88
|
|
||||||
m_PackMargin: 20
|
|
||||||
m_AngleError: 8
|
|
||||||
m_AreaError: 15
|
|
||||||
m_PreserveMeshAssetOnDestroy: 0
|
|
||||||
assetGuid:
|
|
||||||
m_Mesh: {fileID: 0}
|
|
||||||
m_VersionIndex: 2064
|
|
||||||
m_IsSelectable: 1
|
|
||||||
m_SelectedFaces:
|
|
||||||
m_SelectedEdges: []
|
|
||||||
m_SelectedVertices:
|
|
||||||
--- !u!114 &6524694759401631761
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 8399722317111019355}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 1ca002da428252441b92f28d83c8a65f, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
m_Shape:
|
|
||||||
rid: 5572245130708779022
|
|
||||||
m_Size: {x: 0.100000024, y: 2.5, z: 1}
|
|
||||||
m_Rotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_PivotLocation: 1
|
|
||||||
m_PivotPosition: {x: 0, y: 0, z: 0}
|
|
||||||
m_UnmodifiedMeshVersion: 2064
|
|
||||||
m_ShapeBox:
|
|
||||||
m_Center: {x: 0.049999952, y: 1.2995048, z: 0.5}
|
|
||||||
m_Extent: {x: 0.050000012, y: 1.25, z: 0.5}
|
|
||||||
references:
|
|
||||||
version: 2
|
|
||||||
RefIds:
|
|
||||||
- rid: 5572245130708779022
|
|
||||||
type: {class: Cube, ns: UnityEngine.ProBuilder.Shapes, asm: Unity.ProBuilder}
|
|
||||||
--- !u!23 &5034232006488667909
|
|
||||||
MeshRenderer:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 8399722317111019355}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_CastShadows: 1
|
|
||||||
m_ReceiveShadows: 1
|
|
||||||
m_DynamicOccludee: 1
|
|
||||||
m_StaticShadowCaster: 0
|
|
||||||
m_MotionVectors: 1
|
|
||||||
m_LightProbeUsage: 1
|
|
||||||
m_ReflectionProbeUsage: 1
|
|
||||||
m_RayTracingMode: 2
|
|
||||||
m_RayTraceProcedural: 0
|
|
||||||
m_RenderingLayerMask: 1
|
|
||||||
m_RendererPriority: 0
|
|
||||||
m_Materials:
|
|
||||||
- {fileID: 2100000, guid: c22777d6e868e4f2fb421913386b154e, type: 2}
|
|
||||||
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: 2
|
|
||||||
m_MinimumChartSize: 4
|
|
||||||
m_AutoUVMaxDistance: 0.5
|
|
||||||
m_AutoUVMaxAngle: 89
|
|
||||||
m_LightmapParameters: {fileID: 0}
|
|
||||||
m_SortingLayerID: 0
|
|
||||||
m_SortingLayer: 0
|
|
||||||
m_SortingOrder: 0
|
|
||||||
m_AdditionalVertexStreams: {fileID: 0}
|
|
||||||
--- !u!33 &7486695069966556586
|
|
||||||
MeshFilter:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 8399722317111019355}
|
|
||||||
m_Mesh: {fileID: 0}
|
|
||||||
--- !u!64 &6272804010592829304
|
|
||||||
MeshCollider:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 8399722317111019355}
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_IncludeLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 0
|
|
||||||
m_ExcludeLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 0
|
|
||||||
m_LayerOverridePriority: 0
|
|
||||||
m_IsTrigger: 0
|
|
||||||
m_ProvidesContacts: 0
|
|
||||||
m_Enabled: 1
|
|
||||||
serializedVersion: 5
|
|
||||||
m_Convex: 0
|
|
||||||
m_CookingOptions: 30
|
|
||||||
m_Mesh: {fileID: 0}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 1c605345aec331b4a97ead2a4d92e573
|
|
||||||
PrefabImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
+436
-989
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class OnSelectedObjectChangedEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public Transform SelectedObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OnMovementTargetSelectedEventArgs:EventArgs
|
||||||
|
{
|
||||||
|
public Vector3 PointToMove;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4add4f03070ea3f46a3e4aea1fc71585
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
|
public class MouseInputManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField]
|
||||||
|
private LayerMask _selectableLayerMask;
|
||||||
|
[SerializeField]
|
||||||
|
private LayerMask _walkableLayerMask;
|
||||||
|
[SerializeField]
|
||||||
|
private Camera _camera;
|
||||||
|
|
||||||
|
private RaycastHit _raycastHit;
|
||||||
|
|
||||||
|
public event EventHandler<OnSelectedObjectChangedEventArgs> OnSelectedObjectChanged;
|
||||||
|
public event EventHandler<OnMovementTargetSelectedEventArgs> OnMovementTargetSelected;
|
||||||
|
|
||||||
|
public static MouseInputManager Instance { get; private set; }
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
if (Instance != null)
|
||||||
|
{
|
||||||
|
Debug.Log("There's more than one player instance");
|
||||||
|
}
|
||||||
|
Instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||||
|
if (!EventSystem.current.IsPointerOverGameObject() && Physics.Raycast(ray, out _raycastHit, 100f, _selectableLayerMask))
|
||||||
|
{
|
||||||
|
OnSelectedObjectChanged?.Invoke(this, new OnSelectedObjectChangedEventArgs() { SelectedObject = _raycastHit.transform });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnSelectedObjectChanged?.Invoke(this, new OnSelectedObjectChangedEventArgs() { SelectedObject = null });
|
||||||
|
}
|
||||||
|
if (Input.GetMouseButton(0))
|
||||||
|
{
|
||||||
|
if (Physics.Raycast(_camera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, 100f, _walkableLayerMask))
|
||||||
|
{
|
||||||
|
var pointToMove = hit.point;
|
||||||
|
OnMovementTargetSelected?.Invoke(this, new OnMovementTargetSelectedEventArgs() { PointToMove = pointToMove });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
using System;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.EventSystems;
|
|
||||||
|
|
||||||
public class MouseSelection : MonoBehaviour
|
|
||||||
{
|
|
||||||
[SerializeField]
|
|
||||||
private LayerMask _selectableLayerMask;
|
|
||||||
private Transform _selection;
|
|
||||||
private RaycastHit _raycastHit;
|
|
||||||
public event EventHandler<OnSelectedObjectChangedEventArgs> OnSelectedObjectChanged;
|
|
||||||
public class OnSelectedObjectChangedEventArgs : EventArgs
|
|
||||||
{
|
|
||||||
public Transform SelectedObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MouseSelection Instance { get; private set; }
|
|
||||||
|
|
||||||
private void Awake()
|
|
||||||
{
|
|
||||||
if (Instance != null)
|
|
||||||
{
|
|
||||||
Debug.Log("There's more than one player instance");
|
|
||||||
}
|
|
||||||
Instance = this;
|
|
||||||
}
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
||||||
if (!EventSystem.current.IsPointerOverGameObject() && Physics.Raycast(ray, out _raycastHit, 100f, _selectableLayerMask))
|
|
||||||
{
|
|
||||||
OnSelectedObjectChanged?.Invoke(this, new OnSelectedObjectChangedEventArgs() { SelectedObject = _raycastHit.transform });
|
|
||||||
// _hightlight = _raycastHit.transform;
|
|
||||||
// if (_hightlight.CompareTag("Selectable") && _hightlight != _selection)
|
|
||||||
// {
|
|
||||||
// if (_hightlight.gameObject.GetComponent<Outline>() != null)
|
|
||||||
// {
|
|
||||||
// _hightlight.gameObject.GetComponent<Outline>().enabled = true;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// var outline = _hightlight.gameObject.AddComponent<Outline>();
|
|
||||||
// outline.enabled = true;
|
|
||||||
// _hightlight.gameObject.GetComponent<Outline>().OutlineColor = Color.yellow;
|
|
||||||
// _hightlight.gameObject.GetComponent<Outline>().OutlineWidth = 7f;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// _hightlight = null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
OnSelectedObjectChanged?.Invoke(this, new OnSelectedObjectChangedEventArgs() { SelectedObject = null });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,20 +3,20 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.AI;
|
using UnityEngine.AI;
|
||||||
using static GameManager;
|
using static GameManager;
|
||||||
|
using static UnityEditor.PlayerSettings;
|
||||||
|
|
||||||
public class PlayerManager : MonoBehaviour
|
public class PlayerManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
private enum States { Idle, Walking, Sleeping };
|
private enum States { Idle, Walking, Sleeping };
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
public LayerMask _walkableLayer;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
public NavMeshAgent _navAgent;
|
public NavMeshAgent _navAgent;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
public Animator _animator;
|
public Animator _animator;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private Camera _camera;
|
private Camera _camera;
|
||||||
[SerializeField]
|
|
||||||
public ParticleSystem _targetDest;
|
|
||||||
|
|
||||||
public bool allowMovement = true;
|
public bool allowMovement = true;
|
||||||
private States _state;
|
private States _state;
|
||||||
@@ -24,43 +24,37 @@ public class PlayerManager : MonoBehaviour
|
|||||||
|
|
||||||
public Dictionary<StatsId, Stat> PlayerStats;
|
public Dictionary<StatsId, Stat> PlayerStats;
|
||||||
public IWorkPlace WorkPlace { get; set; }
|
public IWorkPlace WorkPlace { get; set; }
|
||||||
|
private Vector3 _pointToMove;
|
||||||
|
private bool _movePointReceived=false;
|
||||||
|
|
||||||
private void OnEnable()
|
private void Start()
|
||||||
{
|
{
|
||||||
TimeManager.OnMinuteChanged += UpdatePlayerState;
|
TimeManager.OnMinuteChanged += UpdatePlayerState;
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDisable()
|
|
||||||
{
|
|
||||||
TimeManager.OnMinuteChanged -= UpdatePlayerState;
|
|
||||||
}
|
|
||||||
// Start is called before the first frame update
|
|
||||||
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
allowMovement = true;
|
allowMovement = true;
|
||||||
_navAgent.updatePosition = false;
|
_navAgent.updatePosition = false;
|
||||||
PlayerStats = GameManager.Instance.PlayerStats;
|
PlayerStats = GameManager.Instance.PlayerStats;
|
||||||
|
MouseInputManager.Instance.OnMovementTargetSelected += Mouse_OnMovementTargetSelected;
|
||||||
}
|
}
|
||||||
// Update is called once per frame
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
if (allowMovement)
|
|
||||||
{
|
|
||||||
if (Input.GetMouseButton(0))
|
|
||||||
{
|
|
||||||
_targetDest.Stop();
|
|
||||||
if (Physics.Raycast(_camera.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, 100))
|
|
||||||
{
|
|
||||||
var pos = hit.point;
|
|
||||||
pos.y += 0.2f;
|
|
||||||
_targetDest.transform.position = pos;
|
|
||||||
_navAgent.SetDestination(pos);
|
|
||||||
_targetDest.Play();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private void Mouse_OnMovementTargetSelected(object sender, OnMovementTargetSelectedEventArgs e)
|
||||||
|
{
|
||||||
|
_pointToMove= e.PointToMove;
|
||||||
|
_movePointReceived = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
TimeManager.OnMinuteChanged -= UpdatePlayerState;
|
||||||
|
MouseInputManager.Instance.OnMovementTargetSelected -= Mouse_OnMovementTargetSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if (allowMovement && _movePointReceived)
|
||||||
|
{
|
||||||
|
_movePointReceived = false;
|
||||||
|
_navAgent.SetDestination(_pointToMove);
|
||||||
|
}
|
||||||
|
|
||||||
var worldDeltaPosition = _navAgent.nextPosition - transform.position;
|
var worldDeltaPosition = _navAgent.nextPosition - transform.position;
|
||||||
_groundDeltaPosition.x = Vector3.Dot(transform.right, worldDeltaPosition);
|
_groundDeltaPosition.x = Vector3.Dot(transform.right, worldDeltaPosition);
|
||||||
|
|||||||
@@ -8,15 +8,15 @@ public class SelectedVisual : MonoBehaviour
|
|||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
MouseSelection.Instance.OnSelectedObjectChanged += Mouse_OnSelectedObjectChanged;
|
MouseInputManager.Instance.OnSelectedObjectChanged += Mouse_OnSelectedObjectChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
MouseSelection.Instance.OnSelectedObjectChanged -= Mouse_OnSelectedObjectChanged;
|
MouseInputManager.Instance.OnSelectedObjectChanged -= Mouse_OnSelectedObjectChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Mouse_OnSelectedObjectChanged(object sender, MouseSelection.OnSelectedObjectChangedEventArgs e)
|
private void Mouse_OnSelectedObjectChanged(object sender, OnSelectedObjectChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.SelectedObject == _selectedObject)
|
if (e.SelectedObject == _selectedObject)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class WaypointVisual : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField]
|
||||||
|
private ParticleSystem _particleSystem;
|
||||||
|
[SerializeField]
|
||||||
|
private Transform _wayPoint;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
MouseInputManager.Instance.OnMovementTargetSelected += Mouse_OnMovementTargetSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Mouse_OnMovementTargetSelected(object sender, OnMovementTargetSelectedEventArgs e)
|
||||||
|
{
|
||||||
|
_wayPoint.position = e.PointToMove;
|
||||||
|
_particleSystem.Play();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
MouseInputManager.Instance.OnMovementTargetSelected -= Mouse_OnMovementTargetSelected;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ae5ecbfd9a3637247b4cd539f9a57316
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -9,11 +9,11 @@ TagManager:
|
|||||||
- Default
|
- Default
|
||||||
- TransparentFX
|
- TransparentFX
|
||||||
- Ignore Raycast
|
- Ignore Raycast
|
||||||
- MouseColiderLayer
|
-
|
||||||
- Water
|
- Water
|
||||||
- UI
|
- UI
|
||||||
- Furniture
|
- SelectableObjects
|
||||||
-
|
- Ground
|
||||||
-
|
-
|
||||||
-
|
-
|
||||||
-
|
-
|
||||||
|
|||||||
Reference in New Issue
Block a user