random stuff i forgot to commit
This commit is contained in:
parent
274af1e5a1
commit
b0625ae834
59 changed files with 7806 additions and 664 deletions
69
Assets/Scripts/Entities/Enemy.cs
Normal file
69
Assets/Scripts/Entities/Enemy.cs
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class Enemy : Entity
|
||||
{
|
||||
public SpriteRenderer sprite;
|
||||
private float currentState = 1;
|
||||
public float colorChangeSpeed;
|
||||
[Header("Movement")]
|
||||
private float currentMovement;
|
||||
public float moveSpeed;
|
||||
public float moveSpeedDelta;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
moveSpeed += Random.Range(-moveSpeedDelta, moveSpeedDelta);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!isStalled)
|
||||
{
|
||||
foreach (Ability ability in abilities)
|
||||
{
|
||||
ability.direction = WaveManager.instance.GetRandomPlayerPoint();
|
||||
bool success = ability.TryAbility();
|
||||
if (!success && ability.currentCooldown <= 0.5f && currentState >= 1f)
|
||||
{
|
||||
currentState = 0f;
|
||||
StartCoroutine(ImminentAttackAnim());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDeath()
|
||||
{
|
||||
base.OnDeath();
|
||||
Destroy(gameObject);
|
||||
WaveManager.instance.enemiesInPlay.Remove(this);
|
||||
WaveManager.instance.UpdateKills();
|
||||
}
|
||||
|
||||
private IEnumerator ImminentAttackAnim()
|
||||
{
|
||||
while (currentState < 1)
|
||||
{
|
||||
currentState += Time.deltaTime * colorChangeSpeed;
|
||||
sprite.color = Color.Lerp(Color.red, Color.white, currentState);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator MoveToPosition(Vector3 moveDirection)
|
||||
{
|
||||
while (currentMovement < 1)
|
||||
{
|
||||
currentMovement += Time.deltaTime * moveSpeed;
|
||||
if (currentMovement >= 1)
|
||||
{
|
||||
isStalled = false;
|
||||
}
|
||||
transform.position = Vector3.Lerp(WaveManager.instance.enemySpawnPoint.position, moveDirection, currentMovement);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Entities/Enemy.cs.meta
Normal file
2
Assets/Scripts/Entities/Enemy.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3585d9ceba9f440838b5b13d75bef210
|
||||
35
Assets/Scripts/Entities/Entity.cs
Normal file
35
Assets/Scripts/Entities/Entity.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Entity : MonoBehaviour
|
||||
{
|
||||
[Header("Health")]
|
||||
public int health; //using int instead of float because it's a simpler game lol
|
||||
public int maxHealth;
|
||||
|
||||
[Header("State")]
|
||||
public bool isStalled;
|
||||
[Header("Abilities")]
|
||||
public List<Ability> abilities = new();
|
||||
|
||||
public virtual void TakeDamage(int damage)
|
||||
{
|
||||
health -= damage;
|
||||
if (health <= 0)
|
||||
{
|
||||
OnDeath();
|
||||
}
|
||||
}
|
||||
|
||||
public void Heal(int healing)
|
||||
{
|
||||
health += healing;
|
||||
health = Math.Clamp(health, 0, maxHealth);
|
||||
}
|
||||
|
||||
protected virtual void OnDeath()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Entities/Entity.cs.meta
Normal file
2
Assets/Scripts/Entities/Entity.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 44ffe7b27489437e0ba113f43de5ad8c
|
||||
30
Assets/Scripts/Entities/Player.cs
Normal file
30
Assets/Scripts/Entities/Player.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class Player : Entity
|
||||
{
|
||||
[Header("UI")]
|
||||
[SerializeField] private TextMeshProUGUI livesText;
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
abilities[0].TryAbility();
|
||||
}
|
||||
if (Input.GetMouseButtonDown(1)) //this way kinda sucks but i'll fix it when i feel like it
|
||||
{
|
||||
abilities[1].TryAbility();
|
||||
}
|
||||
}
|
||||
|
||||
public override void TakeDamage(int damage)
|
||||
{
|
||||
base.TakeDamage(damage);
|
||||
UpdateLivesUI();
|
||||
}
|
||||
private void UpdateLivesUI()
|
||||
{
|
||||
livesText.text = $"Lives: {health}/{maxHealth}";
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Entities/Player.cs.meta
Normal file
2
Assets/Scripts/Entities/Player.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 89103b88932a2bbaf865c8848bdb31e6
|
||||
Loading…
Add table
Add a link
Reference in a new issue