Commit 8f9b2c62 authored by Sebastian Frey's avatar Sebastian Frey
Browse files

PlayerInteract aktiviert nun die AttackScripts

parent df19a7d2
fileFormatVersion: 2
guid: 9c6ef63eae6936f47aec65ad78f4a39c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
namespace _Game.Scripts.Player.PlayerAttacks.Air
{
public class PlayerAirAttack : WeightedAction
{
GameObject nearestPlayer;
AI_Core myAI;
private float restCooldown;
private Rigidbody2D body;
public GameObject windAttack;
public float Cooldown;
public float attackRange;
public float firePower;
// Use this for initialization
void Start()
{
myAI = GetComponent<AI_Core>();
}
void CheckConditions()
{
nearestPlayer = myAI.findNearestPlayer();
float dist = Vector2.Distance(transform.position, nearestPlayer.transform.position);
if (dist > attackRange)
{
return;
}
Vector2 dir = Vector2.zero;
direction = dir;
myAI.desiredAction.Add(this);
}
public override void performAction()
{
Vector3 attackdir = nearestPlayer.transform.position - transform.position;
attackdir.Normalize();
if (restCooldown <= 0)
{
Fire(attackdir);
restCooldown = Cooldown;
}
else
{
restCooldown -= Time.deltaTime;
}
}
public void Fire(Vector3 attackdir)
{
GameObject projectile = Instantiate(windAttack, transform.position + attackdir, Quaternion.AngleAxis(Mathf.Atan2(-attackdir.y, -attackdir.x) * Mathf.Rad2Deg + 180, Vector3.forward));
body = projectile.GetComponent<Rigidbody2D>();
Vector3 rotatedVector = Quaternion.AngleAxis(0, Vector3.forward) * attackdir;
body.velocity = new Vector2(rotatedVector.x * firePower, rotatedVector.y * firePower);
}
private void OnDrawGizmosSelected()
{
Gizmos.color = Color.red;
}
public void Enable()
{
this.enabled = true;
}
public void Disable()
{
this.enabled = false;
}
}
}
using UnityEngine;
public class Player_WindProjectile : MonoBehaviour
public class PlayerAirProjectile : MonoBehaviour
{
public float destroyTime = 1f;
......
fileFormatVersion: 2
guid: 4211579f44945ad4783012a0b1cee572
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
namespace _Game.Scripts.Player.PlayerAttacks.Earth
{
public class PlayerEarthAttack : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void Enable()
{
this.enabled = true;
}
public void Disable()
{
this.enabled = false;
}
}
}
fileFormatVersion: 2
guid: ad90db0185377664288543ce4696c6b8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerEarthProjectile : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
fileFormatVersion: 2
guid: 2007383666d03dc4da582cfeb693f08a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: dbedadf8e6fd4b0439b9012d9525d6cf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using UnityEngine;
namespace _Game.Scripts.Player.PlayerAttacks.Fire
{
public class PlayerFireAttack : MonoBehaviour
{
private float _nextFire;
public float cooldown;
public int volleySize;
public float launchPower;
public float attackSpeed;
public Transform shotSpawn;
public GameObject elementalAttack;
private Rigidbody2D _body;
private void Start()
{
_nextFire = 0;
}
private void Update()
{
if (!Input.GetButtonDown("Fire1") || !(Time.time > _nextFire)) return;
Debug.Log("pla");
_nextFire = _nextFire + cooldown;
StartCoroutine(Fire());
}
private IEnumerator Fire()
{
for (var i = 0; i < volleySize; i++)
{
var position = shotSpawn.position;
var projectile = Instantiate(elementalAttack, position, shotSpawn.rotation);
var direction = position - transform.position;
projectile.GetComponent<Rigidbody2D>().velocity = direction * launchPower;
yield return new WaitForSeconds(attackSpeed);
}
}
public void Enable()
{
this.enabled = true;
}
public void Disable()
{
this.enabled = false;
}
}
}
using UnityEngine;
namespace _Game.Scripts.Player.PlayerAttacks.Fire
{
public class PlayerFireProjectile : MonoBehaviour
{
public double damage;
public GameObject nearestPlayer;
/// <summary>
/// Bisher werden die Shots nach einer Sekunde auf inactive gesetzt
/// hier muss noch was mit Collidern eingefügt werden um
/// auf Zusammenstöße reagieren zu können, damit der Shot dann
/// auf inactive gesetzt wird
/// </summary>
public float destroyTime = 1f;
/// <summary>
/// Wenn das Geschoss auf active gesetzt wird, wird nach 2 Sekunden
/// die Destroy Methode aufgerufen
/// </summary>
private void OnEnable()
{
Invoke("Destroy", destroyTime);
}
/// <summary>
/// Setzt das Geschoss auf 'inactive'
/// </summary>
private void Destroy()
{
Destroy(gameObject);
}
/// <summary>
/// Beim Zusammenstoß mit einem anderen GameObject
/// </summary>
/// <param name="collision"></param>
private void OnTriggerEnter2D(Collider2D target)
{
//if (target.CompareTag("Enemy"))
//{
// return;
//}
//Destroy();
}
}
}
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
public class Player_FireAttack : MonoBehaviour
{
private float nextFire;
public float Cooldown;
public int volleySize;
public float launchPower;
public float attackSpeed;
public Transform shotSpawn;
public GameObject fireBall;
private Rigidbody2D body;
private void Start()
{
nextFire = 0;
}
private void Update()
{
if (Input.GetButtonDown("Fire1") && Time.time > nextFire)
{
Debug.Log("pla");
nextFire = nextFire + Cooldown;
StartCoroutine(fire());
}
}
IEnumerator fire()
{
for (int i = 0; i < volleySize; i++)
{
GameObject projectile = Instantiate(fireBall, shotSpawn.position, shotSpawn.rotation);
Vector3 direction = shotSpawn.position - transform.position;
projectile.GetComponent<Rigidbody2D>().velocity = direction * launchPower;
yield return new WaitForSeconds(attackSpeed);
}
}
}
using UnityEngine;
public class Player_FireProjectile : MonoBehaviour
{
public double damage;
public GameObject nearestPlayer;
/// <summary>
/// Bisher werden die Shots nach einer Sekunde auf inactive gesetzt
/// hier muss noch was mit Collidern eingefügt werden um
/// auf Zusammenstöße reagieren zu können, damit der Shot dann
/// auf inactive gesetzt wird
/// </summary>
public float destroyTime = 1f;
/// <summary>
/// Wenn das Geschoss auf active gesetzt wird, wird nach 2 Sekunden
/// die Destroy Methode aufgerufen
/// </summary>
void OnEnable()
{
Invoke("Destroy", destroyTime);
}
/// <summary>
/// Setzt das Geschoss auf 'inactive'
/// </summary>
void Destroy()
{
Destroy(gameObject);
}
/// <summary>
/// Beim Zusammenstoß mit einem anderen GameObject
/// </summary>
/// <param name="collision"></param>
private void OnTriggerEnter2D(Collider2D target)
{
//if (target.CompareTag("Enemy"))
//{
// return;
//}
//Destroy();
}
}
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
public class Player_WindAttack : WeightedAction
{
GameObject nearestPlayer;
AI_Core myAI;
private float restCooldown;
private Rigidbody2D body;
public GameObject windAttack;
public float Cooldown;
public float attackRange;
public float firePower;
// Use this for initialization
void Start()
{
myAI = GetComponent<AI_Core>();
}
void CheckConditions()
{
nearestPlayer = myAI.findNearestPlayer();
float dist = Vector2.Distance(transform.position, nearestPlayer.transform.position);
if (dist > attackRange)
{
return;
}
Vector2 dir = Vector2.zero;
direction = dir;
myAI.desiredAction.Add(this);
}
public override void performAction()
{
Vector3 attackdir = nearestPlayer.transform.position - transform.position;
attackdir.Normalize();
if (restCooldown <= 0)
{
Fire(attackdir);
restCooldown = Cooldown;
}
else
{
restCooldown -= Time.deltaTime;
}
}
public void Fire(Vector3 attackdir)
{
GameObject projectile = Instantiate(windAttack, transform.position + attackdir, Quaternion.AngleAxis(Mathf.Atan2(-attackdir.y, -attackdir.x) * Mathf.Rad2Deg + 180, Vector3.forward));
body = projectile.GetComponent<Rigidbody2D>();
Vector3 rotatedVector = Quaternion.AngleAxis(0, Vector3.forward) * attackdir;
body.velocity = new Vector2(rotatedVector.x * firePower, rotatedVector.y * firePower);
}
private void OnDrawGizmosSelected()
{
Gizmos.color = Color.red;
}
}
fileFormatVersion: 2
guid: 5c21eee9f2f1edf43905a0d493589508
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using UnityEngine;
namespace _Game.Scripts.Player.PlayerAttacks.Water
{
public class PlayerWaterAttack : MonoBehaviour
{
private float _nextFire;
private Rigidbody2D _body;
public float cooldown;
public int volleySize;
public float launchPower;
public float attackSpeed;
public Transform shotSpawn;
public GameObject elementalAttack;
private void Start()
{
_nextFire = 0.0f;
}
private void Update()
{
if (!Input.GetButtonDown("Fire1") || !(Time.time > _nextFire)) return;
Debug.Log("Water_Attack");
_nextFire = _nextFire + cooldown;
StartCoroutine(Fire());
}
private IEnumerator Fire()
{
for (var i = 0; i < volleySize; i++)
{
var position = shotSpawn.position;
var projectile = Instantiate(elementalAttack, position, shotSpawn.rotation);
var direction = position - transform.position;
projectile.GetComponent<Rigidbody2D>().velocity = direction * launchPower;
yield return new WaitForSeconds(attackSpeed);
}
}
public void Enable()
{
this.enabled = true;
}
public void Disable()
{
this.enabled = false;
}
}
}
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