Commit 65a1baf3 authored by Sebastian Frey's avatar Sebastian Frey

Schaden für Wasser-Attacken hinzugefügt

parent 333dc944
...@@ -27,8 +27,8 @@ namespace _Game.Scripts.Level_Hazards ...@@ -27,8 +27,8 @@ namespace _Game.Scripts.Level_Hazards
if (other.gameObject.layer == LayerMask.NameToLayer("Player") || other.gameObject.layer == LayerMask.NameToLayer("Enemy") || if (other.gameObject.layer == LayerMask.NameToLayer("Player") || other.gameObject.layer == LayerMask.NameToLayer("Enemy") ||
other.gameObject.CompareTag("Fire")) other.gameObject.CompareTag("Fire"))
{ {
_rigidbody2D.velocity = Vector2.zero;
_rigidbody2D.bodyType = RigidbodyType2D.Dynamic; _rigidbody2D.bodyType = RigidbodyType2D.Dynamic;
_rigidbody2D.velocity = Vector2.zero;
} }
} }
} }
......
...@@ -6,6 +6,7 @@ namespace _Game.Scripts.Player.PlayerAttacks.Water ...@@ -6,6 +6,7 @@ namespace _Game.Scripts.Player.PlayerAttacks.Water
{ {
public float destroyTime = 2.0f; public float destroyTime = 2.0f;
public float pushFactor = 1.0f; public float pushFactor = 1.0f;
public float pushEnemyFactor = 1.0f;
private float _startTime; private float _startTime;
private float _deltaTime; private float _deltaTime;
private float _newScaleFactor; private float _newScaleFactor;
...@@ -44,15 +45,43 @@ namespace _Game.Scripts.Player.PlayerAttacks.Water ...@@ -44,15 +45,43 @@ namespace _Game.Scripts.Player.PlayerAttacks.Water
{ {
if (other.gameObject.layer == LayerMask.NameToLayer("MovableObject")) if (other.gameObject.layer == LayerMask.NameToLayer("MovableObject"))
{ {
if (Mathf.Abs(_rigidbody2D.velocity.x) > 0.0001f) if (Mathf.Abs(_rigidbody2D.velocity.x) > 0.0f)
{ {
var projectileVelocityX = _rigidbody2D.velocity.x / Mathf.Abs(_rigidbody2D.velocity.x); var velocity = _rigidbody2D.velocity;
print(projectileVelocityX); var projectileVelocityX = velocity.x / Mathf.Abs(velocity.x);
other.gameObject.GetComponent<Rigidbody2D>().velocity = new Vector3(projectileVelocityX * pushFactor, 0.0f, 0.0f); 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();
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment