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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gard Aleksander Furre
Mr BigSock
Merge requests
!15
Fixing knockback & movement.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Fixing knockback & movement.
master
into
main
Overview
0
Commits
7
Pipelines
0
Changes
21
Merged
Robin Halseth Sandvik
requested to merge
master
into
main
2 years ago
Overview
0
Commits
7
Pipelines
0
Changes
21
Expand
Adjusting the knockback to be reasonable level.
Rewrite movement code to use acceleration.
Adjusted speed, mass, and linear drag of the prefabs.
Moved TryMove() down to Character.
Made character death remove the object from the world by default.
Created some starting code for the ability system (Not working yet, please don't touch)
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
be5c6323
7 commits,
2 years ago
21 files
+
367
−
57
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
21
Search (e.g. *.vue) (Ctrl+P)
MrBigsock/Assets/Code/Core/Abilities/Base/BaseAbility.cs
0 → 100644
+
95
−
0
Options
using
System.Collections
;
using
System
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine.InputSystem
;
namespace
BigSock
{
/*
Base class for abilities.
*/
public
abstract
class
BaseAbility
:
IAbility
{
/*
The cooldown of the ability in seconds.
*/
public
TimeSpan
Cooldown
{
get
;
set
;
}
=
new
TimeSpan
(
0
,
0
,
0
,
0
,
250
);
// 1/4 seconds.
/*
The name of the ability.
*/
public
string
Name
{
get
;
set
;
}
/*
The description of the ability.
*/
public
string
Description
{
get
;
set
;
}
/*
The id of the ability.
*/
public
ulong
Id
{
get
;
set
;
}
/*
The next time the ability has cooled down.
*/
public
DateTime
NextTimeCanUse
{
get
;
set
;
}
=
DateTime
.
Now
;
/*
Whether the ability is ready.
*/
public
bool
Ready
=>
NextTimeCanUse
<=
DateTime
.
Now
;
/*
Try to use the ability.
Handles cooldown and ability cost here.
Returns true if the ability was successfully used.
*/
public
bool
Use
(
Character
actor
,
Vector2
target
)
{
// Check that the ability is cooled down.
if
(
Ready
)
{
//> Handle checking costs here.
// Activate the ability.
var
res
=
Activate
(
actor
,
target
);
// If it succeeded, update cooldown and pay ability cost.
if
(
res
)
{
NextTimeCanUse
=
DateTime
.
Now
+
Cooldown
;
//> Handle paying the cost (HP, mana, stamina) here.
}
return
res
;
}
return
false
;
}
/*
Activates the ability.
Returns true if the ability was successfully activated.
- Even if nothing was hit, used to indicate that cooldowns should be updated.
This should be overridden in sub-classes for the actual abilities.
*/
protected
abstract
bool
Activate
(
Character
actor
,
Vector2
target
);
}
/*
Notes:
- Subclasses should override Activate() to implement their actual functionality.
- Use() should not be overridden unless absolutely neccesary.
- Activate() can be used to hold special conditions, if it returns false, no cooldowns or costs will be enforced.
+ An ability that can only be activated if there is a valid target, Activate() can return false if no targets found.
- Planning to expand code later:
- Allow passing a target character instead of a position.
- Return a result object instead of just bool to allow for more fine grained controll, like resetting cooldown without mana cost.
- Adding cost management, use count limits (pr lvl or in total)
*/
}
\ No newline at end of file
Loading