Commit 333dc944 authored by Isa's avatar Isa

Versuch 2

parents f2576c7d f7f57ba8
......@@ -13,8 +13,8 @@ GameObject:
- component: {fileID: 70840632841850180}
- component: {fileID: 212152556601460820}
- component: {fileID: 5567333940966867164}
m_Layer: 0
m_Name: Pre_PlayerFireAttack
m_Layer: 12
m_Name: FireAttack
m_TagString: Fire
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
......
......@@ -142,3 +142,4 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
destroyTime: 3
pushFactor: 5
......@@ -258,7 +258,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
cooldown: 1
massIncrease: 30
massIncrease: 5
isStomping: 0
--- !u!114 &352228605
MonoBehaviour:
......
......@@ -778,7 +778,7 @@ BoxCollider2D:
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 2, y: 2}
oldSize: {x: 8, y: 8}
newSize: {x: 2, y: 2}
adaptiveTilingThreshold: 0.5
drawMode: 0
......@@ -10561,7 +10561,7 @@ GameObject:
type: 3}
m_PrefabInstance: {fileID: 1738372363}
m_PrefabAsset: {fileID: 0}
--- !u!114 &847607783
--- !u!114 &847607772
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
......@@ -23755,7 +23755,7 @@ BoxCollider2D:
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 2, y: 2}
oldSize: {x: 8, y: 8}
newSize: {x: 2, y: 2}
adaptiveTilingThreshold: 0.5
drawMode: 0
......
......@@ -55,7 +55,7 @@ public class AI_WindAttack : WeightedAction
public void Fire(Vector3 attackdir)
{
GameObject projectile = Instantiate(windAttack, transform.position + attackdir*2, Quaternion.AngleAxis(Mathf.Atan2(-attackdir.y, -attackdir.x) * Mathf.Rad2Deg + 180, Vector3.forward));
GameObject projectile = Instantiate(windAttack, transform.position + attackdir*2, Quaternion.AngleAxis(0, Vector3.forward));
projectile.GetComponent<AI_WindProjectile>().setValues(damage, destroyTime, thrust);
body = projectile.GetComponent<Rigidbody2D>();
......
......@@ -14,6 +14,10 @@ public class AI_WindProjectile : MonoBehaviour
private void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("EnemyShot"))
{
return;
}
if (other.CompareTag("Player"))
{
Vector2 dir = other.GetComponentInParent<Transform>().position - transform.position;
......
......@@ -12,7 +12,7 @@ public class AI_FireProjectile : MonoBehaviour
private void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Fire"))
if (other.CompareTag("Fire") || other.CompareTag("EnemyShot"))
{
return;
}
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SliderObject : MonoBehaviour
namespace _Game.Scripts.Level_Hazards
{
private Rigidbody2D rb;
public float force;
/*private void OnTriggerEnter2D(Collider2D collision)
public class SliderObject : MonoBehaviour
{
if (!GetComponent<Rigidbody2D>())
{
rb = GetComponent<Rigidbody2D>();
}
else
private Vector2 _position;
private Rigidbody2D _rigidbody2D;
private void Start()
{
Debug.Log("Kein Rigidbody");
_rigidbody2D = this.GetComponentInParent<Rigidbody2D>();
}
if (collision.gameObject.CompareTag("Water"))
private void OnCollisionEnter2D(Collision2D other)
{
if(collision.transform.position.x > GetComponent<Transform>().position.x)
{
rb.AddForce(new Vector2(-force, 0));
}else if (collision.transform.position.x < GetComponent<Transform>().position.x)
if (other.gameObject.layer == LayerMask.NameToLayer("Player") || other.gameObject.layer == LayerMask.NameToLayer("Enemy") ||
other.gameObject.CompareTag("Fire"))
{
rb.AddForce(new Vector2(force, 0));
_rigidbody2D.velocity = Vector2.zero;
_rigidbody2D.bodyType = RigidbodyType2D.Static;
}
}
}*/
private void OnCollisionEnter2D(Collision2D other)
{
if (other.transform.gameObject.tag.Equals("Water"))
{
gameObject.GetComponent<Rigidbody2D>().velocity = other.gameObject.GetComponent<Rigidbody2D>().velocity;
}
}
private void OnCollisionExit2D(Collision2D other)
{
if (other.transform.gameObject.tag.Equals("Water"))
private void OnCollisionExit2D(Collision2D other)
{
gameObject.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
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;
}
}
}
}
......@@ -34,9 +34,13 @@ public class Life : MonoBehaviour {
}
public void Death(){
//Reset
gameObject.SetActive(false);
Debug.Log("Death");
if (gameObject.CompareTag("Player"))
{
gameObject.SetActive(false);
Debug.Log("Death");
return;
}
Destroy(gameObject);
}
public int getCurrentLife()
......
......@@ -5,6 +5,7 @@ namespace _Game.Scripts.Player.PlayerAttacks.Water
public class PlayerWaterProjectile : MonoBehaviour
{
public float destroyTime = 2.0f;
public float pushFactor = 1.0f;
private float _startTime;
private float _deltaTime;
private float _newScaleFactor;
......@@ -18,7 +19,6 @@ namespace _Game.Scripts.Player.PlayerAttacks.Water
_startTime = Time.time;
_startingScale = this.gameObject.transform.localScale;
_rigidbody2D = GetComponent<Rigidbody2D>();
_startingVelocity = _rigidbody2D.velocity;
}
private void Update()
......@@ -38,6 +38,24 @@ namespace _Game.Scripts.Player.PlayerAttacks.Water
this.gameObject.transform.localScale = _newScaleVector;
}
public void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.layer != LayerMask.NameToLayer("Ground"))
{
if (other.gameObject.layer == LayerMask.NameToLayer("MovableObject"))
{
if (Mathf.Abs(_rigidbody2D.velocity.x) > 0.0001f)
{
var projectileVelocityX = _rigidbody2D.velocity.x / Mathf.Abs(_rigidbody2D.velocity.x);
print(projectileVelocityX);
other.gameObject.GetComponent<Rigidbody2D>().velocity = new Vector3(projectileVelocityX * pushFactor, 0.0f, 0.0f);
}
}
Destroy();
}
}
private void OnEnable()
{
Invoke(nameof(Destroy), destroyTime);
......
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