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
f64ef01f
Commit
f64ef01f
authored
Jan 29, 2020
by
15박보승
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implementing character selection.
parent
314dae63
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
2541 additions
and
469 deletions
+2541
-469
Minimap.renderTexture
Assets/Minimap.renderTexture
+37
-0
Minimap.renderTexture.meta
Assets/Minimap.renderTexture.meta
+8
-0
Ingame.unity
Assets/Scenes/Ingame.unity
+2237
-427
Actor.cs
Assets/Scripts/Actors/Actor.cs
+5
-1
Enemy.cs
Assets/Scripts/Actors/Enemy.cs
+5
-0
PlayableCharacter.cs
Assets/Scripts/Actors/PlayableCharacter.cs
+16
-0
ring.png
Assets/Scripts/Actors/ring.png
+0
-0
ring.png.meta
Assets/Scripts/Actors/ring.png.meta
+91
-0
CameraController.cs
Assets/Scripts/CameraController.cs
+16
-0
IngameUIManager.cs
Assets/Scripts/IngameUIManager.cs
+5
-2
NodalPathfinding2DAgent.cs
Assets/Scripts/NodalPathfinding/NodalPathfinding2DAgent.cs
+1
-31
PlayerController.cs
Assets/Scripts/PlayerController.cs
+100
-8
Weapon.cs
Assets/Scripts/Weapon.cs
+9
-0
Weapon.cs.meta
Assets/Scripts/Weapon.cs.meta
+11
-0
No files found.
Assets/Minimap.renderTexture
0 → 100644
View file @
f64ef01f
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!84
&8400000
RenderTexture
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_Name
:
Minimap
m_ImageContentsHash
:
serializedVersion
:
2
Hash
:
00000000000000000000000000000000
m_ForcedFallbackFormat
:
4
m_DownscaleFallback
:
0
serializedVersion
:
3
m_Width
:
256
m_Height
:
256
m_AntiAliasing
:
1
m_MipCount
:
-1
m_DepthFormat
:
2
m_ColorFormat
:
8
m_MipMap
:
0
m_GenerateMips
:
1
m_SRGB
:
0
m_UseDynamicScale
:
0
m_BindMS
:
0
m_EnableCompatibleFormat
:
1
m_TextureSettings
:
serializedVersion
:
2
m_FilterMode
:
1
m_Aniso
:
0
m_MipBias
:
0
m_WrapU
:
1
m_WrapV
:
1
m_WrapW
:
1
m_Dimension
:
2
m_VolumeDepth
:
1
Assets/Minimap.renderTexture.meta
0 → 100644
View file @
f64ef01f
fileFormatVersion: 2
guid: 19bd072629084084a9019290f79799c2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
Assets/Scenes/Ingame.unity
View file @
f64ef01f
This diff is collapsed.
Click to expand it.
Assets/Scripts/Actors/Actor.cs
View file @
f64ef01f
...
...
@@ -6,6 +6,9 @@ using BS;
public
abstract
class
Actor
:
MonoBehaviour
{
protected
NodalPathfinding2DAgent
agent
=
null
;
[
SerializeField
]
protected
GameObject
selectRing
;
[
SerializeField
]
private
int
_maxHealth
;
...
...
@@ -41,10 +44,11 @@ public abstract class Actor : MonoBehaviour
agent
=
GetComponent
<
NodalPathfinding2DAgent
>();
}
public
void
MoveTo
(
Vector2
destination
)
public
v
irtual
v
oid
MoveTo
(
Vector2
destination
)
{
agent
.
MoveTo
(
destination
);
}
public
abstract
void
OnSelected
();
public
abstract
void
OnUnselected
();
}
Assets/Scripts/Actors/Enemy.cs
View file @
f64ef01f
...
...
@@ -98,4 +98,9 @@ public class Enemy : Actor
{
throw
new
System
.
NotImplementedException
();
}
public
override
void
OnUnselected
()
{
throw
new
System
.
NotImplementedException
();
}
}
Assets/Scripts/Actors/PlayableCharacter.cs
View file @
f64ef01f
...
...
@@ -26,6 +26,7 @@ public abstract class PlayableCharacter : Actor
{
base
.
Start
();
lr
=
GetComponent
<
LineRenderer
>();
selectRing
=
transform
.
Find
(
"SelectRing"
).
gameObject
;
}
protected
virtual
void
Update
()
...
...
@@ -54,9 +55,24 @@ public abstract class PlayableCharacter : Actor
public
override
void
OnSelected
()
{
isSelected
=
true
;
lr
.
enabled
=
true
;
selectRing
?.
SetActive
(
true
);
r
=
0
;
}
public
override
void
OnUnselected
()
{
isSelected
=
false
;
lr
.
enabled
=
false
;
selectRing
?.
SetActive
(
false
);
}
public
override
void
MoveTo
(
Vector2
destination
)
{
if
(
isSelected
)
agent
.
MoveTo
(
destination
);
}
protected
abstract
void
DefaultControl
();
protected
abstract
void
AimingControl
();
}
Assets/Scripts/Actors/ring.png
0 → 100644
View file @
f64ef01f
30 KB
Assets/Scripts/Actors/ring.png.meta
0 → 100644
View file @
f64ef01f
fileFormatVersion: 2
guid: 6172d55cc79fd0e48a86179d9692b34e
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: 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
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
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/CameraController.cs
View file @
f64ef01f
...
...
@@ -7,6 +7,11 @@ public class CameraController : MonoBehaviour
public
GameObject
target
=
null
;
public
bool
isLocked
=
false
;
[
SerializeField
]
private
Vector3
offset
=
new
Vector3
(
0
,
0
,
-
10
);
private
Vector3
focusPoint
;
// Update is called once per frame
void
Update
()
{
...
...
@@ -14,5 +19,16 @@ public class CameraController : MonoBehaviour
{
}
transform
.
position
=
Vector3
.
Lerp
(
transform
.
position
,
focusPoint
+
offset
,
0.4f
);
}
public
void
SetFocusPoint
(
Vector2
focusPoint
)
{
this
.
focusPoint
=
focusPoint
;
}
public
void
MoveFocusPoint
(
Vector2
moveDelta
)
{
this
.
focusPoint
+=
new
Vector3
(
moveDelta
.
x
,
moveDelta
.
y
);
}
}
Assets/Scripts/IngameUIManager.cs
View file @
f64ef01f
...
...
@@ -37,8 +37,6 @@ public class IngameUIManager : SingletonBehaviour<IngameUIManager>
startPoint
=
Camera
.
main
.
WorldToViewportPoint
(
startPoint
);
endPoint
=
Camera
.
main
.
WorldToViewportPoint
(
endPoint
);
Debug
.
Log
(
"Start : "
+
startPoint
+
", End : "
+
endPoint
);
dragUI
.
anchorMin
=
dragUI
.
anchorMax
=
(
startPoint
+
endPoint
)
/
2
;
Vector2
size
=
endPoint
-
startPoint
;
...
...
@@ -48,4 +46,9 @@ public class IngameUIManager : SingletonBehaviour<IngameUIManager>
size
.
y
=
Mathf
.
Abs
(
rect
.
sizeDelta
.
y
*
size
.
y
);
dragUI
.
sizeDelta
=
size
;
}
public
void
OnCharacterButtonClicked
(
int
index
)
{
PlayerController
.
inst
.
SelectCharacter
(
index
);
}
}
Assets/Scripts/NodalPathfinding/NodalPathfinding2DAgent.cs
View file @
f64ef01f
...
...
@@ -41,37 +41,7 @@ namespace BS {
rb
=
GetComponent
<
Rigidbody2D
>();
}
private
void
Update
()
{
/*
t -= Time.deltaTime;
if (t < 0)
{
MoveTo(new Vector2(Random.Range(pathFinder.bounds.min.x, pathFinder.bounds.max.x), Random.Range(pathFinder.bounds.min.y, pathFinder.bounds.max.y)));
t = 0.5f;
}
*/
/*
if (pathFinder.isBaked)
{
MoveTo(new Vector2(Random.Range(pathFinder.bounds.min.x, pathFinder.bounds.max.x), Random.Range(pathFinder.bounds.min.y, pathFinder.bounds.max.y)));
}
*/
if
(
Input
.
GetKeyDown
(
KeyCode
.
Space
))
{
transform
.
position
=
new
Vector2
(
Random
.
Range
(
pathFinder
.
bounds
.
min
.
x
,
pathFinder
.
bounds
.
max
.
x
),
Random
.
Range
(
pathFinder
.
bounds
.
min
.
y
,
pathFinder
.
bounds
.
max
.
y
));
}
if
(
Input
.
GetMouseButtonDown
(
1
))
{
Vector3
destination
=
Camera
.
main
.
ScreenToWorldPoint
(
Input
.
mousePosition
);
destination
.
z
=
0
;
MoveTo
(
destination
);
}
//path = pathFinder.GetPathGreedy(transform.position, destination);
}
public
void
MoveTo
(
Vector3
destination
)
public
void
MoveTo
(
Vector3
destination
)
{
this
.
destination
=
destination
;
//path = pathFinder.GetPathGreedy(transform.position, destination);
...
...
Assets/Scripts/PlayerController.cs
View file @
f64ef01f
...
...
@@ -2,23 +2,52 @@
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
PlayerController
:
MonoBehaviour
public
class
PlayerController
:
SingletonBehaviour
<
PlayerController
>
{
[
SerializeField
]
private
new
Camera
camera
;
public
float
moveSpeed
=
5.0f
;
public
float
zoomSpeed
=
20.0f
;
private
Vector3
clickPos
;
private
Vector3
dragPos
;
private
Vector3
releasePos
;
[
SerializeField
]
private
List
<
PlayableCharacter
>
characters
=
new
List
<
PlayableCharacter
>();
private
Vector3
lastMousePos
;
[
SerializeField
]
private
CameraController
cc
;
private
void
Awake
()
{
}
private
void
Update
()
{
CameraControl
();
MouseControl
();
KeyboardControl
();
}
public
void
KeyboardControl
()
{
for
(
int
i
=
0
;
i
<
characters
.
Count
;
i
++)
{
if
(
Input
.
GetKeyDown
(
KeyCode
.
Alpha1
+
i
))
{
if
(!
Input
.
GetKey
(
KeyCode
.
LeftControl
))
{
for
(
int
j
=
0
;
j
<
characters
.
Count
;
j
++)
{
characters
[
j
].
OnUnselected
();
}
}
characters
[
i
].
OnSelected
();
}
}
}
public
void
MouseControl
()
...
...
@@ -40,19 +69,66 @@ public class PlayerController : MonoBehaviour
Vector2
size
=
clickPos
-
releasePos
;
size
=
size
.
Abs
();
foreach
(
var
cast
in
Physics2D
.
OverlapBoxAll
((
clickPos
+
releasePos
)
/
2
,
size
,
0
))
List
<
PlayableCharacter
>
selectedCharacters
=
new
List
<
PlayableCharacter
>();
List
<
Enemy
>
selectedEnemies
=
new
List
<
Enemy
>();
foreach
(
var
cast
in
Physics2D
.
OverlapBoxAll
((
clickPos
+
releasePos
)
/
2
,
size
,
0
))
{
Actor
actor
=
cast
.
GetComponent
<
Actor
>();
if
(
actor
!=
null
)
{
actor
.
OnSelected
();
if
(
actor
is
PlayableCharacter
)
{
selectedCharacters
.
Add
((
PlayableCharacter
)
actor
);
}
else
if
(
actor
is
Enemy
)
{
selectedEnemies
.
Add
((
Enemy
)
actor
);
}
}
}
if
(
selectedCharacters
.
Count
>
0
)
{
if
(!
Input
.
GetKey
(
KeyCode
.
LeftControl
))
{
foreach
(
var
character
in
characters
)
{
character
.
OnUnselected
();
}
}
foreach
(
var
character
in
selectedCharacters
)
{
character
.
OnSelected
();
}
}
else
if
(
selectedEnemies
.
Count
<
1
)
{
foreach
(
var
character
in
characters
)
{
character
.
OnUnselected
();
}
}
else
{
foreach
(
var
enemy
in
selectedEnemies
)
{
enemy
.
OnSelected
();
}
}
}
if
(
Input
.
GetMouseButton
(
1
))
{
foreach
(
var
character
in
characters
)
{
character
.
MoveTo
(
Camera
.
main
.
ScreenToWorldPoint
(
Input
.
mousePosition
));
}
}
}
public
void
CameraControl
()
{
/*
float horizontal = 0;
float vertical = 0;
Vector2 mousePosition = Input.mousePosition;
...
...
@@ -75,14 +151,30 @@ public class PlayerController : MonoBehaviour
vertical = -1;
}
camera
.
transform
.
position
+=
new
Vector3
(
horizontal
,
vertical
)
*
moveSpeed
*
Time
.
deltaTime
;
cc.MoveFocusPoint(new Vector3(horizontal, vertical) * moveSpeed * Time.deltaTime);
*/
if
(
Input
.
GetMouseButton
(
2
))
{
Vector3
mouseMoveDelta
=
Camera
.
main
.
ScreenToWorldPoint
(
Input
.
mousePosition
)
-
camera
.
ScreenToWorldPoint
(
lastMousePos
);
cc
.
MoveFocusPoint
(-
mouseMoveDelta
*
moveSpeed
);
}
lastMousePos
=
Input
.
mousePosition
;
//camera.transform.position += new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0) * moveSpeed
* Time.deltaTime;
camera
.
orthographicSize
-=
zoomSpeed
*
Input
.
mouseScrollDelta
.
y
*
Time
.
deltaTime
;
}
public
void
OnMove
(
Vector2
direction
)
public
void
SelectCharacter
(
int
index
)
{
Debug
.
Log
(
"A"
);
transform
.
position
+=
new
Vector3
(
direction
.
x
,
0
,
direction
.
y
).
normalized
*
moveSpeed
*
Time
.
deltaTime
;
characters
[
index
].
OnSelected
();
if
(!
Input
.
GetKey
(
KeyCode
.
LeftControl
))
{
for
(
int
i
=
0
;
i
<
characters
.
Count
;
i
++)
{
if
(
i
==
index
)
continue
;
characters
[
i
].
OnUnselected
();
}
}
}
}
Assets/Scripts/Weapon.cs
0 → 100644
View file @
f64ef01f
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
Weapon
:
ScriptableObject
{
public
float
shotRange
;
public
float
damage
;
}
Assets/Scripts/Weapon.cs.meta
0 → 100644
View file @
f64ef01f
fileFormatVersion: 2
guid: 52bdbdbe9f689834e9dc0f4baaf52895
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 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