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
ae42e08e
Commit
ae42e08e
authored
Jun 05, 2015
by
Alisa Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
respawn for powerups, fire and shield.
TODO for Tim: Add Bullet prefabs to Player, Add Tag "Trap" to Trap prefab.
parent
765fd15d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
7 deletions
+49
-7
Bullet.cs
Assets/Scripts/Bullet.cs
+1
-1
FireScript.cs
Assets/Scripts/FireScript.cs
+13
-2
PlayerControl.cs
Assets/Scripts/PlayerControl.cs
+1
-1
PowerUpScript.cs
Assets/Scripts/PowerUpScript.cs
+17
-1
ShieldScript.cs
Assets/Scripts/ShieldScript.cs
+17
-2
No files found.
Assets/Scripts/Bullet.cs
View file @
ae42e08e
...
...
@@ -20,7 +20,6 @@ public class Bullet : MonoBehaviour
void
OnTriggerEnter2D
(
Collider2D
other
)
{
//Debug.Log("Bullet colide with " + other.name);
if
(
healingPoints
>
0
&&
other
.
tag
==
"Player"
)
{
other
.
GetComponent
<
PlayerHealth
>().
changeHealthBy
(
healingPoints
);
...
...
@@ -28,6 +27,7 @@ public class Bullet : MonoBehaviour
}
else
if
(
destroyTrap
&&
other
.
tag
==
"Trap"
)
{
//TODO für Tim: ACHTUNG Trap braucht Tag Trap.
other
.
GetComponent
<
Trap
>().
destroyTrap
();
Destroy
(
gameObject
);
}
...
...
Assets/Scripts/FireScript.cs
View file @
ae42e08e
...
...
@@ -12,10 +12,13 @@ public class FireScript : MonoBehaviour
private
Vector3
startScale
;
//fixes a bug: scale of fire was 0 when attached to the player.
private
Vector2
spawnPosition
;
public
float
respawnTime
=
5.0f
;
void
Start
()
{
startScale
=
transform
.
localScale
;
spawnPosition
=
transform
.
position
;
}
// Update is called once per frame
...
...
@@ -31,16 +34,24 @@ public class FireScript : MonoBehaviour
{
if
(
other
.
tag
==
"Player"
)
{
Invoke
(
"stopBurning"
,
burningTime
);
parentHealth
=
other
.
GetComponent
<
PlayerHealth
>();
transform
.
position
=
other
.
transform
.
position
;
//hier schon position setzen
transform
.
parent
=
other
.
transform
;
transform
.
localScale
=
startScale
;
Invoke
(
"stopBurning"
,
burningTime
);
}
}
void
stopBurning
()
{
Destroy
(
gameObject
);
CancelInvoke
(
"stopBurning"
);
parentHealth
=
null
;
transform
.
position
=
new
Vector2
(
100
,
100
);
Invoke
(
"Activate"
,
respawnTime
);
}
void
Activate
()
{
transform
.
position
=
spawnPosition
;
}
}
Assets/Scripts/PlayerControl.cs
View file @
ae42e08e
...
...
@@ -253,7 +253,7 @@ public class PlayerControl : MonoBehaviour
private
void
shoot
()
{
float
dir
=
Mathf
.
Sign
(
transform
.
localScale
.
x
);
float
dir
=
-
Mathf
.
Sign
(
transform
.
localScale
.
x
);
Vector2
pos
=
new
Vector2
(
transform
.
position
.
x
+
dir
*
spawnDistance
,
transform
.
position
.
y
);
switch
(
powerUpType
)
...
...
Assets/Scripts/PowerUpScript.cs
View file @
ae42e08e
...
...
@@ -12,12 +12,28 @@ public class PowerUpScript : MonoBehaviour
/// </summary>
public
int
type
;
public
float
respawnTime
=
5.0f
;
// used to store the position while the trap is deactivated
private
Vector2
realPosition
;
void
OnTriggerEnter2D
(
Collider2D
other
)
{
if
(
other
.
tag
==
"Player"
)
{
other
.
GetComponent
<
PlayerControl
>().
setPowerUpType
(
type
);
transform
.
position
=
new
Vector2
(
50
,
50
);
//TODO setze auf 1000 oder so, zur sicherheit.
destroyPowerUp
();
}
}
public
void
destroyPowerUp
()
{
realPosition
=
transform
.
position
;
transform
.
position
=
new
Vector2
(
100
,
100
);
//TODO setze auf 1000 oder so, zur sicherheit.
Invoke
(
"Activate"
,
respawnTime
);
}
void
Activate
()
{
transform
.
position
=
realPosition
;
}
}
Assets/Scripts/ShieldScript.cs
View file @
ae42e08e
...
...
@@ -8,10 +8,16 @@ public class ShieldScript : MonoBehaviour
public
float
shieldingTime
=
10
;
public
float
respawnTime
=
5.0f
;
// used to store the position while the trap is deactivated
private
Vector2
spawnPosition
;
// Use this for initialization
void
Start
()
{
Invoke
(
"stopShielding"
,
shieldingTime
)
;
spawnPosition
=
transform
.
position
;
}
void
OnTriggerEnter2D
(
Collider2D
other
)
...
...
@@ -19,6 +25,7 @@ public class ShieldScript : MonoBehaviour
PlayerHealth
oldHealth
=
parentHealth
;
if
(
other
.
tag
==
"Player"
)
{
Invoke
(
"stopShielding"
,
shieldingTime
);
parentHealth
=
other
.
GetComponent
<
PlayerHealth
>();
transform
.
position
=
other
.
transform
.
position
;
//hier schon position setzen
transform
.
parent
=
other
.
transform
;
...
...
@@ -31,7 +38,15 @@ public class ShieldScript : MonoBehaviour
void
stopShielding
()
{
CancelInvoke
(
"stopShielding"
);
if
(
parentHealth
!=
null
)
parentHealth
.
setShield
(
false
);
Destroy
(
gameObject
);
parentHealth
=
null
;
transform
.
position
=
new
Vector2
(
100
,
100
);
Invoke
(
"Activate"
,
respawnTime
);
}
void
Activate
()
{
transform
.
position
=
spawnPosition
;
}
}
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