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
Commits
bc266f3e
Commit
bc266f3e
authored
2 years ago
by
Robin Halseth Sandvik
Browse files
Options
Downloads
Patches
Plain Diff
Added support for invisibility status.
parent
a4450dde
No related branches found
Branches containing commit
No related tags found
1 merge request
!34
Dodge
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
MrBigsock/Assets/Code/Character.cs
+72
-11
72 additions, 11 deletions
MrBigsock/Assets/Code/Character.cs
with
72 additions
and
11 deletions
MrBigsock/Assets/Code/Character.cs
+
72
−
11
View file @
bc266f3e
...
...
@@ -180,7 +180,7 @@ namespace BigSock {
return
false
;
// Start new IFrames
Set
IFrames
(
IFrameDuration
);
Add
IFrames
(
IFrameDuration
);
// Trigger the event for taking damage.
OnTakeDamage
?.
Invoke
(
this
,
attack
.
Actor
,
attack
);
...
...
@@ -456,13 +456,36 @@ namespace BigSock {
public
partial
class
Character
{
/*
Indicates whether or not the characer is a
live.
Indicates whether or not the characer is alive.
*/
public
bool
Alive
{
get
;
private
set
;
}
=
true
;
/*
How long between each time the character can take damage.
*/
public
TimeSpan
IFrameDuration
{
get
=>
_iFrameDuration
;
private
set
=>
_iFrameDuration
=
value
;
}
public
TimeSpan
_iFrameDuration
=
new
TimeSpan
(
0
,
0
,
0
,
0
,
333
);
/*
Is the character visible.
*/
public
bool
IsInvisible
=>
NextTimeVisible
>
DateTime
.
Now
;
/*
Stores the next time the character can recieve damage.
*/
public
DateTime
NextTimeVisible
{
get
;
private
set
;
}
=
DateTime
.
Now
;
/*
I
ndicates whether or not
the characer i
s a liv
e.
I
s
the charac
t
er i
nvincibl
e.
*/
public
bool
HasIFrames
=>
NextTimeCanTakeDamage
>
DateTime
.
Now
;
...
...
@@ -471,21 +494,60 @@ namespace BigSock {
*/
public
DateTime
NextTimeCanTakeDamage
{
get
;
private
set
;
}
=
DateTime
.
Now
;
/*
How long between each time the character can take damage
.
Adds a status effect to the character
.
*/
public
TimeSpan
IFrameDuration
{
get
=>
_iFrameDuration
;
private
set
=>
_iFrameDuration
=
value
;
public
bool
AddStatusEffect
(
StatusEffectType
statusType
,
TimeSpan
amount
)
{
switch
(
statusType
)
{
case
StatusEffectType
.
Invincible
:
return
AddIFrames
(
amount
);
case
StatusEffectType
.
Invisible
:
return
AddInvisibility
(
amount
);
default
:
return
false
;
}
}
/*
Adds invisibility for the character.
*/
public
bool
AddInvisibility
(
TimeSpan
amount
)
{
// Get when the status effect would expire.
var
wouldExpire
=
DateTime
.
Now
+
IFrameDuration
;
// Only if that's later than current.
if
(
wouldExpire
>
NextTimeVisible
)
{
// If character currently doesn't have the status effect.
if
(
NextTimeVisible
<
DateTime
.
Now
)
{
ApplyInvisibility
();
}
// Set new time.
NextTimeVisible
=
wouldExpire
;
return
true
;
}
return
false
;
}
/*
Appies invisibility to the character.
*/
private
void
ApplyInvisibility
()
{
}
/*
Removes invisibility for the character.
*/
private
void
RemoveInvisibility
()
{
}
public
TimeSpan
_iFrameDuration
=
new
TimeSpan
(
0
,
0
,
0
,
0
,
333
);
/*
Set
s IFrames for the character.
Add
s IFrames for the character.
*/
public
bool
Set
IFrames
(
TimeSpan
amount
)
{
public
bool
Add
IFrames
(
TimeSpan
amount
)
{
// Get when the IFrames would expire.
var
nextCanTakeDamage
=
DateTime
.
Now
+
IFrameDuration
;
...
...
@@ -502,7 +564,6 @@ namespace BigSock {
}
return
false
;
}
/*
Appies IFrames to the character.
*/
...
...
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
register
or
sign in
to comment