Commit d7bdc6ba authored by 15박보승's avatar 15박보승

Drawing agent's path with LineRenderer. Implementing Enemy Editor for editing roamingPath easily.

parent 4547eb1c
...@@ -153,7 +153,7 @@ MonoBehaviour: ...@@ -153,7 +153,7 @@ MonoBehaviour:
bounds: bounds:
m_Center: {x: 1.5, y: 1.5, z: 0} m_Center: {x: 1.5, y: 1.5, z: 0}
m_Extent: {x: 15, y: 15, z: 0} m_Extent: {x: 15, y: 15, z: 0}
pointInterval: 0.25 pointInterval: 0.2
agentRadius: 0.1 agentRadius: 0.1
blockMask: blockMask:
serializedVersion: 2 serializedVersion: 2
...@@ -604,6 +604,134 @@ CanvasRenderer: ...@@ -604,6 +604,134 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 396431086} m_GameObject: {fileID: 396431086}
m_CullTransparentMesh: 0 m_CullTransparentMesh: 0
--- !u!1 &422370197
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 422370198}
- component: {fileID: 422370199}
m_Layer: 0
m_Name: PathLineRenderer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &422370198
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 422370197}
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_Children: []
m_Father: {fileID: 2053488665}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!120 &422370199
LineRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 422370197}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 0
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
m_RayTracingMode: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10306, 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: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Positions:
- {x: 0, y: 0, z: 0}
- {x: 0, y: 0, z: 1}
m_Parameters:
serializedVersion: 3
widthMultiplier: 0.01
widthCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
colorGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
key1: {r: 1, g: 1, b: 1, a: 1}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime4: 0
atime5: 0
atime6: 0
atime7: 0
m_Mode: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
numCornerVertices: 0
numCapVertices: 0
alignment: 0
textureMode: 0
shadowBias: 0.5
generateLightingData: 0
m_UseWorldSpace: 1
m_Loop: 0
--- !u!1 &440116051 --- !u!1 &440116051
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -2220,9 +2348,9 @@ MonoBehaviour: ...@@ -2220,9 +2348,9 @@ MonoBehaviour:
eyesightDegree: 89 eyesightDegree: 89
roamingPath: roamingPath:
- {x: 10.5, y: 9.5, z: 0} - {x: 10.5, y: 9.5, z: 0}
- {x: 10.5, y: 11.5, z: 0} - {x: 10.500001, y: 11.897926, z: 0}
- {x: -7.5, y: 11.5, z: 0} - {x: -8.3300295, y: 11.8671, z: 0}
- {x: -7.5, y: 9.5, z: 0} - {x: -8.3300295, y: 9.36129, z: 0}
blockEyesightMask: blockEyesightMask:
serializedVersion: 2 serializedVersion: 2
m_Bits: 256 m_Bits: 256
...@@ -2242,7 +2370,9 @@ MonoBehaviour: ...@@ -2242,7 +2370,9 @@ MonoBehaviour:
destination: {x: 0, y: 0, z: 0} destination: {x: 0, y: 0, z: 0}
path: [] path: []
moveSpeed: 0.5 moveSpeed: 0.5
isGizmos: 1 isDrawingPath: 0
pathRenderer: {fileID: 1875923608}
isGizmos: 0
--- !u!212 &970109856 --- !u!212 &970109856
SpriteRenderer: SpriteRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -2305,9 +2435,138 @@ Transform: ...@@ -2305,9 +2435,138 @@ Transform:
m_LocalScale: {x: 2, y: 2, z: 0} m_LocalScale: {x: 2, y: 2, z: 0}
m_Children: m_Children:
- {fileID: 1701434670} - {fileID: 1701434670}
- {fileID: 1875923609}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -60} m_LocalEulerAnglesHint: {x: 0, y: 0, z: -60}
--- !u!1 &1010092400
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1010092402}
- component: {fileID: 1010092401}
m_Layer: 0
m_Name: PathLineRenderer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!120 &1010092401
LineRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1010092400}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 0
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
m_RayTracingMode: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10306, 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: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Positions:
- {x: 0, y: 0, z: 0}
- {x: 0, y: 0, z: 1}
m_Parameters:
serializedVersion: 3
widthMultiplier: 0.01
widthCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
colorGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
key1: {r: 1, g: 1, b: 1, a: 1}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime4: 0
atime5: 0
atime6: 0
atime7: 0
m_Mode: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
numCornerVertices: 0
numCapVertices: 0
alignment: 0
textureMode: 0
shadowBias: 0.5
generateLightingData: 0
m_UseWorldSpace: 1
m_Loop: 0
--- !u!4 &1010092402
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1010092400}
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_Children: []
m_Father: {fileID: 1702893731}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1018320458 --- !u!1 &1018320458
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -17360,6 +17619,7 @@ MonoBehaviour: ...@@ -17360,6 +17619,7 @@ MonoBehaviour:
shotBlockMask: shotBlockMask:
serializedVersion: 2 serializedVersion: 2
m_Bits: 256 m_Bits: 256
pathRenderer: {fileID: 1010092401}
isSelected: 0 isSelected: 0
--- !u!120 &1702893727 --- !u!120 &1702893727
LineRenderer: LineRenderer:
...@@ -17833,7 +18093,9 @@ MonoBehaviour: ...@@ -17833,7 +18093,9 @@ MonoBehaviour:
destination: {x: 0, y: 0, z: 0} destination: {x: 0, y: 0, z: 0}
path: [] path: []
moveSpeed: 2 moveSpeed: 2
isGizmos: 1 isDrawingPath: 0
pathRenderer: {fileID: 1010092401}
isGizmos: 0
--- !u!58 &1702893729 --- !u!58 &1702893729
CircleCollider2D: CircleCollider2D:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -17883,6 +18145,7 @@ Transform: ...@@ -17883,6 +18145,7 @@ Transform:
m_LocalScale: {x: 2, y: 2, z: 1} m_LocalScale: {x: 2, y: 2, z: 1}
m_Children: m_Children:
- {fileID: 595766800} - {fileID: 595766800}
- {fileID: 1010092402}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 5 m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
...@@ -18152,6 +18415,134 @@ Transform: ...@@ -18152,6 +18415,134 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 6 m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1875923607
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1875923609}
- component: {fileID: 1875923608}
m_Layer: 0
m_Name: PathLineRenderer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!120 &1875923608
LineRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1875923607}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 0
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
m_RayTracingMode: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10306, 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: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Positions:
- {x: 0, y: 0, z: 0}
- {x: 0, y: 0, z: 1}
m_Parameters:
serializedVersion: 3
widthMultiplier: 0.01
widthCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
colorGradient:
serializedVersion: 2
key0: {r: 1, g: 1, b: 1, a: 1}
key1: {r: 1, g: 1, b: 1, a: 1}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime4: 0
atime5: 0
atime6: 0
atime7: 0
m_Mode: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
numCornerVertices: 0
numCapVertices: 0
alignment: 0
textureMode: 0
shadowBias: 0.5
generateLightingData: 0
m_UseWorldSpace: 1
m_Loop: 0
--- !u!4 &1875923609
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1875923607}
m_LocalRotation: {x: -0, y: -0, z: 0.5, w: 0.8660254}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 0}
m_Children: []
m_Father: {fileID: 970109857}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1993486580 --- !u!1 &1993486580
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -18344,6 +18735,7 @@ MonoBehaviour: ...@@ -18344,6 +18735,7 @@ MonoBehaviour:
shotBlockMask: shotBlockMask:
serializedVersion: 2 serializedVersion: 2
m_Bits: 256 m_Bits: 256
pathRenderer: {fileID: 422370199}
isSelected: 0 isSelected: 0
--- !u!120 &2053488661 --- !u!120 &2053488661
LineRenderer: LineRenderer:
...@@ -18817,7 +19209,9 @@ MonoBehaviour: ...@@ -18817,7 +19209,9 @@ MonoBehaviour:
destination: {x: 0, y: 0, z: 0} destination: {x: 0, y: 0, z: 0}
path: [] path: []
moveSpeed: 2 moveSpeed: 2
isGizmos: 1 isDrawingPath: 0
pathRenderer: {fileID: 422370199}
isGizmos: 0
--- !u!58 &2053488663 --- !u!58 &2053488663
CircleCollider2D: CircleCollider2D:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -18868,6 +19262,7 @@ Transform: ...@@ -18868,6 +19262,7 @@ Transform:
m_Children: m_Children:
- {fileID: 1185187205} - {fileID: 1185187205}
- {fileID: 1690205890} - {fileID: 1690205890}
- {fileID: 422370198}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 4 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEditor;
public class Enemy : Actor public class Enemy : Actor
{ {
...@@ -13,11 +14,30 @@ public class Enemy : Actor ...@@ -13,11 +14,30 @@ public class Enemy : Actor
[SerializeField] [SerializeField]
private List<Vector3> roamingPath; private List<Vector3> roamingPath;
public List<Vector3> RoamingPath { get { return roamingPath; } }
[SerializeField] [SerializeField]
private LayerMask blockEyesightMask; private LayerMask blockEyesightMask;
#if UNITY_EDITOR #if UNITY_EDITOR
void OnSceneGUI()
{
}
private void OnDrawGizmosSelected()
{
for (int i = 0; i < roamingPath.Count; i++)
{
EditorGUI.BeginChangeCheck();
Vector3 newPosition = Handles.FreeMoveHandle(roamingPath[i], Quaternion.identity, 1f, Vector3.one, Handles.CircleHandleCap);
if (EditorGUI.EndChangeCheck())
{
roamingPath[i] = newPosition;
}
}
}
private void OnDrawGizmos() private void OnDrawGizmos()
{ {
if (roamingPath.Count < 1) if (roamingPath.Count < 1)
...@@ -29,6 +49,8 @@ public class Enemy : Actor ...@@ -29,6 +49,8 @@ public class Enemy : Actor
{ {
Gizmos.DrawLine(roamingPath[i], roamingPath[(i + 1) % roamingPath.Count]); Gizmos.DrawLine(roamingPath[i], roamingPath[(i + 1) % roamingPath.Count]);
} }
} }
#endif #endif
......
...@@ -16,17 +16,25 @@ public abstract class PlayableCharacter : Actor ...@@ -16,17 +16,25 @@ public abstract class PlayableCharacter : Actor
public float shotRange = 5.0f; public float shotRange = 5.0f;
public LayerMask shotBlockMask; public LayerMask shotBlockMask;
protected LineRenderer lr; protected LineRenderer shotRangeRenderer;
[SerializeField]
protected LineRenderer pathRenderer;
private float r = 0.0f; private float r = 0.0f;
public bool isSelected = false; public bool isSelected = false;
private Transform target;
protected override void Start() protected override void Start()
{ {
base.Start(); base.Start();
lr = GetComponent<LineRenderer>(); if (shotRangeRenderer == null)
selectRing = transform.Find("SelectRing").gameObject; shotRangeRenderer = GetComponent<LineRenderer>();
if (pathRenderer == null)
pathRenderer = GetComponentInChildren<LineRenderer>();
if (selectRing == null)
selectRing = transform.Find("SelectRing").gameObject;
} }
protected virtual void Update() protected virtual void Update()
...@@ -47,7 +55,7 @@ public abstract class PlayableCharacter : Actor ...@@ -47,7 +55,7 @@ public abstract class PlayableCharacter : Actor
} }
vertices[360] = vertices[0]; vertices[360] = vertices[0];
lr.SetPositions(vertices); shotRangeRenderer.SetPositions(vertices);
} }
} }
...@@ -55,7 +63,7 @@ public abstract class PlayableCharacter : Actor ...@@ -55,7 +63,7 @@ public abstract class PlayableCharacter : Actor
public override void OnSelected() public override void OnSelected()
{ {
isSelected = true; isSelected = true;
lr.enabled = true; shotRangeRenderer.enabled = true;
selectRing?.SetActive(true); selectRing?.SetActive(true);
r = 0; r = 0;
} }
...@@ -63,7 +71,7 @@ public abstract class PlayableCharacter : Actor ...@@ -63,7 +71,7 @@ public abstract class PlayableCharacter : Actor
public override void OnUnselected() public override void OnUnselected()
{ {
isSelected = false; isSelected = false;
lr.enabled = false; shotRangeRenderer.enabled = false;
selectRing?.SetActive(false); selectRing?.SetActive(false);
} }
...@@ -73,6 +81,11 @@ public abstract class PlayableCharacter : Actor ...@@ -73,6 +81,11 @@ public abstract class PlayableCharacter : Actor
agent.MoveTo(destination); agent.MoveTo(destination);
} }
public void DrawPath()
{
}
protected abstract void DefaultControl(); protected abstract void DefaultControl();
protected abstract void AimingControl(); protected abstract void AimingControl();
} }
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
#if UNITY_EDITOR
[CustomEditor(typeof(Enemy))]
public class EnemyEditor : Editor
{
private Enemy enemy;
private void OnEnable()
{
enemy = (Enemy)target;
}
private void OnSceneGUI()
{
for (int i = 0; i < enemy.RoamingPath.Count; i++)
{
EditorGUI.BeginChangeCheck();
Vector3 newPosition = Handles.FreeMoveHandle(enemy.RoamingPath[i], Quaternion.identity, 1f, Vector3.one, Handles.CircleHandleCap);
if (EditorGUI.EndChangeCheck())
{
enemy.RoamingPath[i] = newPosition;
}
}
SceneView.RepaintAll();
}
}
#endif
\ No newline at end of file
fileFormatVersion: 2
guid: 25eb5da6a91d1dc4fbc8c47c1e18cc83
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -17,7 +17,12 @@ namespace BS { ...@@ -17,7 +17,12 @@ namespace BS {
private Rigidbody2D rb; private Rigidbody2D rb;
public bool isGizmos = true; public bool isDrawingPath = false;
[SerializeField]
private LineRenderer pathRenderer;
public bool isGizmos = true;
private void OnDrawGizmos() private void OnDrawGizmos()
{ {
...@@ -45,7 +50,13 @@ namespace BS { ...@@ -45,7 +50,13 @@ namespace BS {
rb = GetComponent<Rigidbody2D>(); rb = GetComponent<Rigidbody2D>();
} }
public void MoveTo(Vector3 destination) private void Update()
{
if (isDrawingPath)
DrawPath();
}
public void MoveTo(Vector3 destination)
{ {
this.destination = destination; this.destination = destination;
//path = pathFinder.GetPathGreedy(transform.position, destination); //path = pathFinder.GetPathGreedy(transform.position, destination);
...@@ -69,9 +80,14 @@ namespace BS { ...@@ -69,9 +80,14 @@ namespace BS {
this.path = newPath; this.path = newPath;
} }
public void Move(Vector2 direction) public void DrawPath()
{ {
pathRenderer.positionCount = path.Count + 1;
pathRenderer.SetPosition(0, transform.position);
for (int i = 0; i < path.Count; i++)
{
pathRenderer.SetPosition(i + 1, path[i]);
}
} }
private void FixedUpdate() private void FixedUpdate()
......
fileFormatVersion: 2
guid: f3c97a168612e5440b8969d67cd6d58d
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 10
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
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: 1
spriteExtrude: 1
spriteMeshType: 0
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 1, y: 1, z: 1, w: 1}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 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: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment