Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ColdShot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
15박보승
ColdShot
Commits
d7bdc6ba
Commit
d7bdc6ba
authored
Jan 31, 2020
by
15박보승
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drawing agent's path with LineRenderer. Implementing Enemy Editor for editing roamingPath easily.
parent
4547eb1c
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
610 additions
and
17 deletions
+610
-17
Ingame.unity
Assets/Scenes/Ingame.unity
+402
-7
Enemy.cs
Assets/Scripts/Actors/Enemy.cs
+22
-0
PlayableCharacter.cs
Assets/Scripts/Actors/PlayableCharacter.cs
+19
-6
EnemyEditor.cs
Assets/Scripts/Editors/EnemyEditor.cs
+33
-0
EnemyEditor.cs.meta
Assets/Scripts/Editors/EnemyEditor.cs.meta
+11
-0
NodalPathfinding2DAgent.cs
Assets/Scripts/NodalPathfinding/NodalPathfinding2DAgent.cs
+20
-4
drag.png
Assets/Textures/drag.png
+0
-0
drag.png.meta
Assets/Textures/drag.png.meta
+103
-0
No files found.
Assets/Scenes/Ingame.unity
View file @
d7bdc6ba
This diff is collapsed.
Click to expand it.
Assets/Scripts/Actors/Enemy.cs
View file @
d7bdc6ba
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEditor
;
public
class
Enemy
:
Actor
{
...
...
@@ -13,11 +14,30 @@ public class Enemy : Actor
[
SerializeField
]
private
List
<
Vector3
>
roamingPath
;
public
List
<
Vector3
>
RoamingPath
{
get
{
return
roamingPath
;
}
}
[
SerializeField
]
private
LayerMask
blockEyesightMask
;
#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
()
{
if
(
roamingPath
.
Count
<
1
)
...
...
@@ -29,6 +49,8 @@ public class Enemy : Actor
{
Gizmos
.
DrawLine
(
roamingPath
[
i
],
roamingPath
[(
i
+
1
)
%
roamingPath
.
Count
]);
}
}
#endif
...
...
Assets/Scripts/Actors/PlayableCharacter.cs
View file @
d7bdc6ba
...
...
@@ -16,17 +16,25 @@ public abstract class PlayableCharacter : Actor
public
float
shotRange
=
5.0f
;
public
LayerMask
shotBlockMask
;
protected
LineRenderer
lr
;
protected
LineRenderer
shotRangeRenderer
;
[
SerializeField
]
protected
LineRenderer
pathRenderer
;
private
float
r
=
0.0f
;
public
bool
isSelected
=
false
;
private
Transform
target
;
protected
override
void
Start
()
{
base
.
Start
();
lr
=
GetComponent
<
LineRenderer
>();
selectRing
=
transform
.
Find
(
"SelectRing"
).
gameObject
;
if
(
shotRangeRenderer
==
null
)
shotRangeRenderer
=
GetComponent
<
LineRenderer
>();
if
(
pathRenderer
==
null
)
pathRenderer
=
GetComponentInChildren
<
LineRenderer
>();
if
(
selectRing
==
null
)
selectRing
=
transform
.
Find
(
"SelectRing"
).
gameObject
;
}
protected
virtual
void
Update
()
...
...
@@ -47,7 +55,7 @@ public abstract class PlayableCharacter : Actor
}
vertices
[
360
]
=
vertices
[
0
];
l
r
.
SetPositions
(
vertices
);
shotRangeRendere
r
.
SetPositions
(
vertices
);
}
}
...
...
@@ -55,7 +63,7 @@ public abstract class PlayableCharacter : Actor
public
override
void
OnSelected
()
{
isSelected
=
true
;
l
r
.
enabled
=
true
;
shotRangeRendere
r
.
enabled
=
true
;
selectRing
?.
SetActive
(
true
);
r
=
0
;
}
...
...
@@ -63,7 +71,7 @@ public abstract class PlayableCharacter : Actor
public
override
void
OnUnselected
()
{
isSelected
=
false
;
l
r
.
enabled
=
false
;
shotRangeRendere
r
.
enabled
=
false
;
selectRing
?.
SetActive
(
false
);
}
...
...
@@ -73,6 +81,11 @@ public abstract class PlayableCharacter : Actor
agent
.
MoveTo
(
destination
);
}
public
void
DrawPath
()
{
}
protected
abstract
void
DefaultControl
();
protected
abstract
void
AimingControl
();
}
Assets/Scripts/Editors/EnemyEditor.cs
0 → 100644
View file @
d7bdc6ba
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
Assets/Scripts/Editors/EnemyEditor.cs.meta
0 → 100644
View file @
d7bdc6ba
fileFormatVersion: 2
guid: 25eb5da6a91d1dc4fbc8c47c1e18cc83
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/NodalPathfinding/NodalPathfinding2DAgent.cs
View file @
d7bdc6ba
...
...
@@ -17,7 +17,12 @@ namespace BS {
private
Rigidbody2D
rb
;
public
bool
isGizmos
=
true
;
public
bool
isDrawingPath
=
false
;
[
SerializeField
]
private
LineRenderer
pathRenderer
;
public
bool
isGizmos
=
true
;
private
void
OnDrawGizmos
()
{
...
...
@@ -45,7 +50,13 @@ namespace BS {
rb
=
GetComponent
<
Rigidbody2D
>();
}
public
void
MoveTo
(
Vector3
destination
)
private
void
Update
()
{
if
(
isDrawingPath
)
DrawPath
();
}
public
void
MoveTo
(
Vector3
destination
)
{
this
.
destination
=
destination
;
//path = pathFinder.GetPathGreedy(transform.position, destination);
...
...
@@ -69,9 +80,14 @@ namespace BS {
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
()
...
...
Assets/Textures/drag.png
0 → 100644
View file @
d7bdc6ba
106 Bytes
Assets/Textures/drag.png.meta
0 → 100644
View file @
d7bdc6ba
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:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment