Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mr BigSock
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gard Aleksander Furre
Mr BigSock
Commits
5cb1a947
Commit
5cb1a947
authored
Nov 1, 2022
by
Robin Halseth Sandvik
Browse files
Options
Downloads
Patches
Plain Diff
Changed ability code to handle fire types.
parent
10754bf0
No related branches found
No related tags found
1 merge request
!56
New ability fire rework. (Charging)
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
MrBigsock/Assets/Code/PlayerController.cs
+177
-138
177 additions, 138 deletions
MrBigsock/Assets/Code/PlayerController.cs
with
177 additions
and
138 deletions
MrBigsock/Assets/Code/PlayerController.cs
+
177
−
138
View file @
5cb1a947
...
@@ -119,13 +119,45 @@ namespace BigSock {
...
@@ -119,13 +119,45 @@ namespace BigSock {
}
}
// Dictionary that holds start times for charging abilities.
Dictionary
<
KeyCode
,
float
>
chargeStarts
=
new
Dictionary
<
KeyCode
,
float
>();
/*
Triggers an ability if it should be.
*/
private
void
CheckAbilityInput
(
KeyCode
key
,
IAbility
ability
)
{
var
par
=
GetAbilityParam
(
Camera
.
main
.
ScreenToWorldPoint
(
Input
.
mousePosition
));
switch
(
ability
.
FireType
)
{
// Standard: Press to fire.
case
FireType
.
Standard
:
if
(
Input
.
GetKeyDown
(
key
))
ability
.
Use
(
par
);
break
;
// FullAuto: Keep firing while key is down.
case
FireType
.
FullAuto
:
if
(
Input
.
GetKey
(
key
))
ability
.
Use
(
par
);
break
;
// Charge: Fire when let go.
case
FireType
.
Charge
:
// If pressed down: Store start time.
if
(
Input
.
GetKeyDown
(
key
))
chargeStarts
[
key
]
=
Time
.
time
;
// If let go: Activate
else
if
(
Input
.
GetKeyUp
(
key
))
{
par
.
ChargeTime
=
Time
.
time
-
chargeStarts
[
key
];
ability
.
Use
(
par
);
}
break
;
default
:
break
;
}
}
private
void
Update
()
{
private
void
Update
()
{
// Regenerate mana & stamina.
// Regenerate mana & stamina.
Regenerate
();
Regenerate
();
// Object w/ parameters for abilities.
// Object w/ parameters for abilities.
var
par
=
GetAbilityParam
(
Camera
.
main
.
ScreenToWorldPoint
(
Input
.
mousePosition
));
//var par = new AbilityParam{
//var par = new AbilityParam{
// Actor = this,
// Actor = this,
// TargetPos = Camera.main.ScreenToWorldPoint(Input.mousePosition),
// TargetPos = Camera.main.ScreenToWorldPoint(Input.mousePosition),
...
@@ -133,20 +165,27 @@ namespace BigSock {
...
@@ -133,20 +165,27 @@ namespace BigSock {
//};
//};
// If pressed Soace or LMB: Regular attack.
//
// If pressed Soace or LMB: Regular attack.
if
(
Input
.
GetKeyDown
(
KeyCode
.
Space
)
||
Input
.
GetMouseButton
(
0
))
{
//
if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButton(0)) {
_testAttack
.
Use
(
par
);
//
_testAttack.Use(par);
}
//
}
// If pressed Z: Big attack.
// Check ability 1.
if
(
Input
.
GetKey
(
KeyCode
.
Z
))
{
CheckAbilityInput
(
KeyCode
.
Space
,
_testAttack
);
_testAttack2
.
Use
(
par
);
// Check ability 2.
}
CheckAbilityInput
(
KeyCode
.
Z
,
_testAttack2
);
// Check ability 3.
CheckAbilityInput
(
KeyCode
.
X
,
_dodge
);
// If pressed X: dodge.
//// If pressed Z: Big attack.
if
(
Input
.
GetKey
(
KeyCode
.
X
))
{
//if(Input.GetKey(KeyCode.Z)) {
_dodge
.
Use
(
par
);
// _testAttack2.Use(par);
}
//}
//// If pressed X: dodge.
//if(Input.GetKey(KeyCode.X)) {
// _dodge.Use(par);
//}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment