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
3f2a02af
Commit
3f2a02af
authored
Jun 04, 2015
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make traps respawn after some time
parent
69c3571b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
Trap.cs
Assets/Scripts/Trap.cs
+13
-1
No files found.
Assets/Scripts/Trap.cs
View file @
3f2a02af
...
@@ -4,18 +4,30 @@ using System.Collections;
...
@@ -4,18 +4,30 @@ using System.Collections;
public
class
Trap
:
MonoBehaviour
{
public
class
Trap
:
MonoBehaviour
{
public
int
damagePoints
=
10
;
public
int
damagePoints
=
10
;
public
float
respawnTime
=
5.0f
;
// used to store the position while the trap is deactivated
private
Vector2
realPosition
;
void
OnTriggerEnter2D
(
Collider2D
other
)
void
OnTriggerEnter2D
(
Collider2D
other
)
{
{
if
(
other
.
tag
==
"Player"
)
if
(
other
.
tag
==
"Player"
)
{
{
other
.
GetComponent
<
PlayerHealth
>().
changeHealthBy
(-
damagePoints
);
other
.
GetComponent
<
PlayerHealth
>().
changeHealthBy
(-
damagePoints
);
transform
.
position
=
new
Vector2
(
50
,
50
);
//TODO setze auf 1000 oder so, zur sicherheit.
destroyTrap
();
}
}
}
}
public
void
destroyTrap
()
public
void
destroyTrap
()
{
{
realPosition
=
transform
.
position
;
transform
.
position
=
new
Vector2
(
100
,
100
);
transform
.
position
=
new
Vector2
(
100
,
100
);
Invoke
(
"Activate"
,
respawnTime
);
}
void
Activate
()
{
transform
.
position
=
realPosition
;
}
}
}
}
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