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
4393e73e
Commit
4393e73e
authored
Feb 03, 2020
by
15박보승
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implementing skill system. Debug a bug related with ScriptableObject assets. Minor changes.
parent
ff9eca1b
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
7725 additions
and
531 deletions
+7725
-531
HeadShot.asset
Assets/Resources/Skills/HeadShot.asset
+4
-2
Ingame.unity
Assets/Scenes/Ingame.unity
+7591
-511
Enemy.cs
Assets/Scripts/Actors/Enemy.cs
+1
-1
PlayableCharacter.cs
Assets/Scripts/Actors/PlayableCharacter.cs
+36
-2
EnemyEditor.cs
Assets/Scripts/Editors/EnemyEditor.cs
+1
-0
IngameUIManager.cs
Assets/Scripts/IngameUIManager.cs
+24
-1
PlayerController.cs
Assets/Scripts/PlayerController.cs
+21
-2
BouncingShot.cs
Assets/Scripts/Skills/BouncingShot.cs
+2
-2
HeadShot.cs
Assets/Scripts/Skills/HeadShot.cs
+7
-6
Skill.cs
Assets/Scripts/Skills/Skill.cs
+26
-3
WeaponBehaviour.cs
Assets/Scripts/Weapons/WeaponBehaviour.cs
+12
-1
No files found.
Assets/Resources/Skills/HeadShot.asset
View file @
4393e73e
...
...
@@ -12,6 +12,8 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
1cfb2ac990cea404494c0e55af055d62
,
type
:
3
}
m_Name
:
HeadShot
m_EditorClassIdentifier
:
tier
:
0
index
:
0
m_tier
:
0
m_index
:
0
m_skillImage
:
{
fileID
:
21300000
,
guid
:
4c85b737d44119f4f828910c3bd26659
,
type
:
3
}
cooltime
:
0
damageTimes
:
2
Assets/Scenes/Ingame.unity
View file @
4393e73e
This diff is collapsed.
Click to expand it.
Assets/Scripts/Actors/Enemy.cs
View file @
4393e73e
...
...
@@ -118,7 +118,7 @@ public class Enemy : Actor
public
override
void
OnSelected
()
{
throw
new
System
.
NotImplementedException
();
//
throw new System.NotImplementedException();
}
public
override
void
OnUnselected
()
...
...
Assets/Scripts/Actors/PlayableCharacter.cs
View file @
4393e73e
...
...
@@ -16,12 +16,23 @@ public abstract class PlayableCharacter : Actor
{
[
SerializeField
]
private
WeaponBehaviour
weaponBehaviour
=
null
;
public
bool
isSelected
=
false
;
#
region
Character
Status
Booleans
private
bool
isOnlySelected
=
false
;
private
bool
isSelected
=
false
;
#
endregion
public
Enemy
Target
{
private
get
;
set
;
}
public
bool
isAutoTargeting
=
false
;
public
LayerMask
enemyMask
;
[
SerializeField
]
private
Skill
[]
m_skills
=
new
Skill
[
4
];
public
Skill
[]
Skills
{
get
{
return
m_skills
;
}
}
protected
override
void
Start
()
{
base
.
Start
();
...
...
@@ -29,6 +40,11 @@ public abstract class PlayableCharacter : Actor
weaponBehaviour
=
GetComponent
<
WeaponBehaviour
>();
if
(
selectRing
==
null
)
selectRing
=
transform
.
Find
(
"SelectRing"
).
gameObject
;
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
m_skills
[
i
]
=
Instantiate
(
m_skills
[
i
]);
m_skills
[
i
].
Init
(
this
);
}
}
protected
virtual
void
Update
()
...
...
@@ -60,7 +76,19 @@ public abstract class PlayableCharacter : Actor
{
isSelected
=
false
;
selectRing
?.
SetActive
(
false
);
weaponBehaviour
.
OnDeselected
();
weaponBehaviour
.
OnUnselected
();
if
(
isOnlySelected
)
{
IngameUIManager
.
inst
.
DisableCharacterStatusUI
();
isOnlySelected
=
false
;
}
}
public
void
OnOnlySelected
()
{
OnSelected
();
isOnlySelected
=
true
;
IngameUIManager
.
inst
.
EnableCharacterStatusUI
(
this
);
}
public
override
void
MoveTo
(
Vector2
destination
)
...
...
@@ -109,6 +137,12 @@ public abstract class PlayableCharacter : Actor
transform
.
rotation
=
Quaternion
.
Euler
(
0
,
0
,
Vector2
.
SignedAngle
(
Vector2
.
up
,
target
.
position
-
transform
.
position
));
}
public
void
UseSkill
(
int
index
)
{
if
(
isOnlySelected
&&
m_skills
[
index
].
IsReady
)
m_skills
[
index
].
Aiming
();
}
protected
abstract
void
DefaultControl
();
protected
abstract
void
AimingControl
();
}
Assets/Scripts/Editors/EnemyEditor.cs
View file @
4393e73e
...
...
@@ -22,6 +22,7 @@ public class EnemyEditor : Editor
Vector3
newPosition
=
Handles
.
FreeMoveHandle
(
enemy
.
RoamingPath
[
i
],
Quaternion
.
identity
,
1f
,
Vector3
.
one
,
Handles
.
CircleHandleCap
);
if
(
EditorGUI
.
EndChangeCheck
())
{
Undo
.
RecordObject
(
enemy
,
"Prev Roaming"
);
enemy
.
RoamingPath
[
i
]
=
newPosition
;
}
}
...
...
Assets/Scripts/IngameUIManager.cs
View file @
4393e73e
...
...
@@ -7,7 +7,8 @@ public class IngameUIManager : SingletonBehaviour<IngameUIManager>
{
public
RectTransform
dragUI
;
public
GameObject
characterStatusUI
;
public
Image
[]
skillUIs
=
new
Image
[
4
];
// Start is called before the first frame update
void
Start
()
...
...
@@ -51,4 +52,26 @@ public class IngameUIManager : SingletonBehaviour<IngameUIManager>
{
PlayerController
.
inst
.
SelectCharacter
(
index
);
}
public
void
EnableCharacterStatusUI
(
PlayableCharacter
character
)
{
characterStatusUI
.
SetActive
(
true
);
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
skillUIs
[
i
].
sprite
=
character
.
Skills
[
i
].
SkillImage
;
UpdateSkillUI
(
character
.
Skills
[
i
]);
}
}
public
void
DisableCharacterStatusUI
()
{
characterStatusUI
.
SetActive
(
false
);
}
public
void
UpdateSkillUI
(
Skill
skill
)
{
Image
skillUI
=
skillUIs
[
skill
.
Tier
];
skillUI
.
GetComponentInChildren
<
Text
>().
text
=
skill
.
RemainedCooltime
.
ToString
(
"F1"
);
skillUI
.
fillAmount
=
skill
.
CooltimeRatio
;
}
}
Assets/Scripts/PlayerController.cs
View file @
4393e73e
...
...
@@ -17,6 +17,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
[
SerializeField
]
private
List
<
PlayableCharacter
>
characters
=
new
List
<
PlayableCharacter
>();
private
Vector3
lastMousePos
;
[
SerializeField
]
...
...
@@ -50,6 +51,14 @@ public class PlayerController : SingletonBehaviour<PlayerController>
characters
[
i
].
OnSelected
();
}
}
if
(
Input
.
GetKeyDown
(
KeyCode
.
Q
))
{
foreach
(
var
character
in
characters
)
{
character
.
UseSkill
(
0
);
}
}
}
public
void
MouseControl
()
...
...
@@ -96,12 +105,22 @@ public class PlayerController : SingletonBehaviour<PlayerController>
{
foreach
(
var
character
in
characters
)
{
if
(
selectedCharacters
.
Contains
(
character
))
continue
;
character
.
OnUnselected
();
}
}
foreach
(
var
character
in
selectedCharacters
)
if
(
selectedCharacters
.
Count
==
1
)
{
selectedCharacters
[
0
].
OnOnlySelected
();
}
else
{
character
.
OnSelected
();
foreach
(
var
character
in
selectedCharacters
)
{
character
.
OnSelected
();
}
}
}
else
if
(
selectedEnemies
.
Count
<
1
)
...
...
Assets/Scripts/Skills/BouncingShot.cs
View file @
4393e73e
...
...
@@ -2,7 +2,7 @@
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
BouncingShot
:
Skill
public
sealed
class
BouncingShot
:
Skill
{
public
GameObject
bouncyBulletPrefab
;
public
int
bounceCount
=
3
;
...
...
@@ -26,7 +26,7 @@ public class BouncingShot : Skill
}
}
p
ublic
override
void
Use
()
p
rotected
override
void
Use
()
{
}
...
...
Assets/Scripts/Skills/HeadShot.cs
View file @
4393e73e
...
...
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using
UnityEngine
;
using
UnityEditor
;
public
class
HeadShot
:
Skill
public
sealed
class
HeadShot
:
Skill
{
public
float
damageTimes
;
private
Collider2D
target
;
...
...
@@ -19,28 +19,29 @@ public class HeadShot : Skill
public
override
void
Aiming
()
{
throw
new
System
.
NotImplementedException
(
);
weaponBehaviour
.
StartCoroutine
(
AimingRoutine
()
);
}
private
IEnumerator
AimingRoutine
()
{
while
(
true
)
{
if
(
Input
.
GetMouseButtonDown
(
0
))
Vector3
mouseWorldPosition
=
Camera
.
main
.
ScreenToWorldPoint
(
Input
.
mousePosition
);
target
=
Physics2D
.
OverlapPoint
(
mouseWorldPosition
,
1
<<
LayerMask
.
NameToLayer
(
"Enemy"
));
if
(
Input
.
GetMouseButtonDown
(
0
))
{
Use
();
break
;
}
Vector3
mouseWorldPosition
=
Camera
.
main
.
ScreenToWorldPoint
(
Input
.
mousePosition
);
target
=
Physics2D
.
OverlapPoint
(
mouseWorldPosition
,
LayerMask
.
NameToLayer
(
"Enemy"
));
yield
return
null
;
}
}
p
ublic
override
void
Use
()
p
rotected
override
void
Use
()
{
if
(!
target
)
return
;
Debug
.
Log
(
"A"
);
target
.
GetComponent
<
Enemy
>().
Health
-=
Mathf
.
CeilToInt
(
weaponBehaviour
.
weapon
.
damage
*
damageTimes
);
}
}
Assets/Scripts/Skills/Skill.cs
View file @
4393e73e
...
...
@@ -7,8 +7,31 @@ public abstract class Skill : ScriptableObject
protected
PlayableCharacter
character
;
protected
WeaponBehaviour
weaponBehaviour
;
public
int
tier
;
public
int
index
;
[
SerializeField
]
private
int
m_tier
;
public
int
Tier
{
get
{
return
m_tier
;
}
}
[
SerializeField
]
private
int
m_index
;
public
int
Index
{
get
{
return
m_index
;
}
}
[
SerializeField
]
private
Sprite
m_skillImage
;
public
Sprite
SkillImage
{
get
{
return
m_skillImage
;
}
}
[
SerializeField
]
private
float
cooltime
;
protected
float
m_remainedCooltime
=
0
;
public
float
RemainedCooltime
{
get
{
return
m_remainedCooltime
;
}
}
public
bool
IsReady
{
get
{
return
m_remainedCooltime
<=
0
;
}
}
public
float
CooltimeRatio
{
get
{
return
m_remainedCooltime
/
cooltime
;
}
}
public
virtual
void
UpdateSkill
(
float
deltaTime
)
{
m_remainedCooltime
=
Mathf
.
Max
(
0
,
m_remainedCooltime
-
deltaTime
);
IngameUIManager
.
inst
.
UpdateSkillUI
(
this
);
}
public
virtual
void
Init
(
PlayableCharacter
character
)
{
...
...
@@ -17,5 +40,5 @@ public abstract class Skill : ScriptableObject
}
public
abstract
void
Aiming
();
p
ublic
abstract
void
Use
();
p
rotected
abstract
void
Use
();
}
Assets/Scripts/Weapons/WeaponBehaviour.cs
View file @
4393e73e
...
...
@@ -2,6 +2,7 @@
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine.Experimental.Rendering.Universal
;
public
sealed
class
WeaponBehaviour
:
MonoBehaviour
{
...
...
@@ -23,14 +24,23 @@ public sealed class WeaponBehaviour : MonoBehaviour
private
float
shotRadius
=
0
;
[
SerializeField
]
private
Light2D
gunFireLight
;
private
void
Start
()
{
for
(
int
i
=
0
;
i
<
weapons
.
Count
;
i
++)
{
weapons
[
i
]
=
Instantiate
(
weapons
[
i
]);
}
ChangeWeapon
(
weaponIndex
);
}
private
void
Update
()
{
weapon
.
UpdateWeapon
(
Time
.
deltaTime
);
gunFireLight
.
intensity
=
Mathf
.
Max
(
0
,
gunFireLight
.
intensity
-
50
*
Time
.
deltaTime
);
}
public
void
Init
(
Weapon
weapon
)
...
...
@@ -52,6 +62,7 @@ public sealed class WeaponBehaviour : MonoBehaviour
public
void
EmitBulletParticle
()
{
bulletParticle
.
Emit
(
1
);
gunFireLight
.
intensity
=
3
;
}
public
void
DrawWeaponRange
()
...
...
@@ -79,7 +90,7 @@ public sealed class WeaponBehaviour : MonoBehaviour
shotRangeRenderer
.
enabled
=
true
;
}
public
void
On
De
selected
()
public
void
On
Un
selected
()
{
shotRangeRenderer
.
enabled
=
false
;
}
...
...
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