Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
GameDevWeek
Wintersemester 2018-2019
Unity
Suck It
Commits
65a1baf3
Commit
65a1baf3
authored
Mar 29, 2019
by
Sebastian Frey
Browse files
Schaden für Wasser-Attacken hinzugefügt
parent
333dc944
Changes
2
Hide whitespace changes
Inline
Side-by-side
Assets/_Game/Scripts/Level Hazards/SliderObject.cs
View file @
65a1baf3
...
...
@@ -27,8 +27,8 @@ namespace _Game.Scripts.Level_Hazards
if
(
other
.
gameObject
.
layer
==
LayerMask
.
NameToLayer
(
"Player"
)
||
other
.
gameObject
.
layer
==
LayerMask
.
NameToLayer
(
"Enemy"
)
||
other
.
gameObject
.
CompareTag
(
"Fire"
))
{
_rigidbody2D
.
velocity
=
Vector2
.
zero
;
_rigidbody2D
.
bodyType
=
RigidbodyType2D
.
Dynamic
;
_rigidbody2D
.
velocity
=
Vector2
.
zero
;
}
}
}
...
...
Assets/_Game/Scripts/Player/PlayerAttacks/Water/PlayerWaterProjectile.cs
View file @
65a1baf3
...
...
@@ -6,6 +6,7 @@ namespace _Game.Scripts.Player.PlayerAttacks.Water
{
public
float
destroyTime
=
2.0f
;
public
float
pushFactor
=
1.0f
;
public
float
pushEnemyFactor
=
1.0f
;
private
float
_startTime
;
private
float
_deltaTime
;
private
float
_newScaleFactor
;
...
...
@@ -44,15 +45,43 @@ namespace _Game.Scripts.Player.PlayerAttacks.Water
{
if
(
other
.
gameObject
.
layer
==
LayerMask
.
NameToLayer
(
"MovableObject"
))
{
if
(
Mathf
.
Abs
(
_rigidbody2D
.
velocity
.
x
)
>
0.0
001
f
)
if
(
Mathf
.
Abs
(
_rigidbody2D
.
velocity
.
x
)
>
0.0f
)
{
var
projectileVelocityX
=
_rigidbody2D
.
velocity
.
x
/
Mathf
.
Abs
(
_rigidbody2D
.
velocity
.
x
)
;
print
(
projectileVelocityX
);
var
velocity
=
_rigidbody2D
.
velocity
;
var
projectileVelocityX
=
velocity
.
x
/
Mathf
.
Abs
(
velocity
.
x
);
other
.
gameObject
.
GetComponent
<
Rigidbody2D
>().
velocity
=
new
Vector3
(
projectileVelocityX
*
pushFactor
,
0.0f
,
0.0f
);
Destroy
();
}
}
Destroy
();
else
if
(
other
.
gameObject
.
layer
==
LayerMask
.
NameToLayer
(
"Enemy"
))
{
if
(
other
.
gameObject
.
CompareTag
(
"Fire"
))
{
other
.
gameObject
.
GetComponent
<
Life
>().
Damage
(
1
);
if
(
Mathf
.
Abs
(
_rigidbody2D
.
velocity
.
x
)
>
0.0f
)
{
var
velocity
=
_rigidbody2D
.
velocity
;
var
projectileVelocityX
=
velocity
.
x
/
Mathf
.
Abs
(
velocity
.
x
);
other
.
gameObject
.
GetComponent
<
Rigidbody2D
>().
AddForce
(
new
Vector2
(
projectileVelocityX
*
pushEnemyFactor
,
0.0f
));
}
Destroy
();
}
else
{
if
(
Mathf
.
Abs
(
_rigidbody2D
.
velocity
.
x
)
>
0.0f
)
{
var
velocity
=
_rigidbody2D
.
velocity
;
var
projectileVelocityX
=
velocity
.
x
/
Mathf
.
Abs
(
velocity
.
x
);
other
.
gameObject
.
GetComponent
<
Rigidbody2D
>().
AddForce
(
new
Vector2
(
projectileVelocityX
*
pushEnemyFactor
,
0.0f
));
}
Destroy
();
}
}
else
if
(
other
.
gameObject
.
CompareTag
(
"DestroyableByFire"
))
{
Destroy
();
}
}
}
...
...
Write
Preview
Supports
Markdown
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