Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dyingIsMainstream
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gamejam-gpn15
dyingIsMainstream
Commits
3df54979
Commit
3df54979
authored
Jun 06, 2015
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix shields oscilating between players
parent
9fa623ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
ShieldScript.cs
Assets/Scripts/ShieldScript.cs
+10
-1
No files found.
Assets/Scripts/ShieldScript.cs
View file @
3df54979
...
...
@@ -13,6 +13,8 @@ public class ShieldScript : MonoBehaviour
// used to store the position while the trap is deactivated
private
Vector2
spawnPosition
;
public
float
relayDelay
=
0.25f
;
private
bool
canRelay
=
true
;
// Use this for initialization
void
Start
()
...
...
@@ -23,7 +25,7 @@ public class ShieldScript : MonoBehaviour
void
OnTriggerEnter2D
(
Collider2D
other
)
{
PlayerHealth
oldHealth
=
parentHealth
;
if
(
other
.
tag
==
"Player"
)
if
(
canRelay
&&
other
.
tag
==
"Player"
)
{
Invoke
(
"stopShielding"
,
shieldingTime
);
parentHealth
=
other
.
GetComponent
<
PlayerHealth
>();
...
...
@@ -31,11 +33,18 @@ public class ShieldScript : MonoBehaviour
transform
.
parent
=
other
.
transform
;
Debug
.
Log
(
"Set shield from shield"
);
parentHealth
.
setShield
(
true
);
canRelay
=
false
;
Invoke
(
"enableRelay"
,
relayDelay
);
}
if
(
oldHealth
!=
null
&&
oldHealth
!=
parentHealth
)
oldHealth
.
setShield
(
false
);
}
void
enableRelay
()
{
canRelay
=
true
;
}
void
stopShielding
()
{
CancelInvoke
(
"stopShielding"
);
...
...
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