basically the whole game
This commit is contained in:
parent
949135cecb
commit
96dcfa9064
315 changed files with 34386 additions and 396 deletions
98
Assets/Scripts/Abilities/EnemyBulletPattern.cs
Normal file
98
Assets/Scripts/Abilities/EnemyBulletPattern.cs
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class EnemyBulletPattern : EnemyAbility
|
||||
{
|
||||
[Serializable]
|
||||
public class ProjectileDirection
|
||||
{
|
||||
public Projectile projectile;
|
||||
public Transform direction;
|
||||
public float timing;
|
||||
public int amount;
|
||||
public float burstTiming;
|
||||
public float projectileSpeed;
|
||||
public bool aimedShot;
|
||||
}
|
||||
|
||||
[SerializeField] protected ProjectileDirection[] projectileDirections;
|
||||
[SerializeField] private bool randomAim;
|
||||
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
base.AbilityEffects();
|
||||
transform.Lookat2D(direction);
|
||||
if (randomAim)
|
||||
{
|
||||
transform.eulerAngles = new Vector3(0, 0, Random.Range(0, 360f));
|
||||
}
|
||||
foreach (ProjectileDirection projectileDirection in projectileDirections)
|
||||
{
|
||||
if (projectileDirection.timing <= 0 && projectileDirection.amount <= 1)
|
||||
{
|
||||
ShootProjectile(projectileDirection.projectile, projectileDirection.direction.position, projectileDirection.projectileSpeed, projectileDirection.aimedShot);
|
||||
}
|
||||
else if (projectileDirection.amount > 1)
|
||||
{
|
||||
StartCoroutine(BurstFire(projectileDirection, projectileDirection.amount,
|
||||
projectileDirection.burstTiming));
|
||||
}
|
||||
else
|
||||
{
|
||||
StartCoroutine(DelayedShot(projectileDirection, projectileDirection.timing));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ShootProjectile(Projectile projectile, Vector3 location, float speed, bool aimed)
|
||||
{
|
||||
Projectile newProjectile = Instantiate(projectile, origin.position, Quaternion.identity);
|
||||
Vector3 projectileDirection = location;
|
||||
if (aimed)
|
||||
{
|
||||
projectileDirection = WaveManager.instance.GetRandomPlayerPoint();
|
||||
}
|
||||
newProjectile.transform.Lookat2D(projectileDirection);
|
||||
newProjectile.damage = power;
|
||||
newProjectile.tag = tag;
|
||||
if (speed > 0f)
|
||||
{
|
||||
newProjectile.speed = speed;
|
||||
}
|
||||
}
|
||||
private IEnumerator BurstFire(ProjectileDirection projectile, int burstCount, float burstDelay)
|
||||
{
|
||||
int currentCount = 0;
|
||||
while (currentCount < burstCount)
|
||||
{
|
||||
ShootProjectile(projectile.projectile, projectile.direction.position, projectile.projectileSpeed, projectile.aimedShot);
|
||||
currentCount++;
|
||||
yield return new WaitForSeconds(burstDelay);
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
private IEnumerator DelayedShot(ProjectileDirection projectile, float delay)
|
||||
{
|
||||
float currentDelayTiming = 0f;
|
||||
while (currentDelayTiming < delay)
|
||||
{
|
||||
currentDelayTiming += Time.deltaTime;
|
||||
if (currentDelayTiming > delay)
|
||||
{
|
||||
if (projectile.amount > 1)
|
||||
{
|
||||
StartCoroutine(BurstFire(projectile, projectile.amount, projectile.burstTiming));
|
||||
}
|
||||
else
|
||||
{
|
||||
ShootProjectile(projectile.projectile, projectile.direction.position, projectile.projectileSpeed, projectile.aimedShot);
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue