start work on implementing gameplay
This commit is contained in:
parent
94f5a5e209
commit
274af1e5a1
42 changed files with 3054 additions and 371 deletions
39
Assets/Scripts/Ability.cs
Normal file
39
Assets/Scripts/Ability.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class Ability : MonoBehaviour
|
||||
{
|
||||
[Header("Cooldown")]
|
||||
public float currentCooldown;
|
||||
public float cooldown;
|
||||
[Header("Stats")]
|
||||
public int power;
|
||||
|
||||
[Header("Targetting")]
|
||||
public Transform origin;
|
||||
public Vector3 direction;
|
||||
|
||||
public bool TryAbility()
|
||||
{
|
||||
if (currentCooldown <= 0)
|
||||
{
|
||||
currentCooldown = cooldown;
|
||||
AbilityEffects();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual void AbilityEffects()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (currentCooldown >= 0)
|
||||
{
|
||||
currentCooldown -= Time.deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Ability.cs.meta
Normal file
2
Assets/Scripts/Ability.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 44b9d09afb8c9b825bf024d2c59ac4bc
|
||||
19
Assets/Scripts/Enemy.cs
Normal file
19
Assets/Scripts/Enemy.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class Enemy : Entity
|
||||
{
|
||||
private void Update()
|
||||
{
|
||||
foreach (Ability ability in abilities)
|
||||
{
|
||||
ability.TryAbility();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDeath()
|
||||
{
|
||||
base.OnDeath();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Enemy.cs.meta
Normal file
2
Assets/Scripts/Enemy.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3585d9ceba9f440838b5b13d75bef210
|
||||
11
Assets/Scripts/EnemyAbility.cs
Normal file
11
Assets/Scripts/EnemyAbility.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class EnemyAbility : Ability
|
||||
{
|
||||
[SerializeField] private float cooldownDelta;
|
||||
void Start()
|
||||
{
|
||||
cooldown += Random.Range(-cooldownDelta, cooldownDelta);
|
||||
currentCooldown = Random.Range(0, cooldown);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/EnemyAbility.cs.meta
Normal file
2
Assets/Scripts/EnemyAbility.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9f66fd8bb75c08a0e92e682f4cca0fab
|
||||
19
Assets/Scripts/EnemyShootBasic.cs
Normal file
19
Assets/Scripts/EnemyShootBasic.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class EnemyShootBasic : EnemyAbility
|
||||
{
|
||||
// i think this will just be a debug script since a regular singular bullet attack is kinda boring lol
|
||||
//or atleast i'd need to figure out cool bullet patterns
|
||||
[SerializeField] private Projectile projectile;
|
||||
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
Projectile newProjectile = Instantiate(projectile, origin.position, Quaternion.identity);
|
||||
newProjectile.transform.Lookat2D(direction);
|
||||
newProjectile.damage = power;
|
||||
newProjectile.tag = tag;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/EnemyShootBasic.cs.meta
Normal file
2
Assets/Scripts/EnemyShootBasic.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c2d01df850251ebc4adc091f0274b225
|
||||
35
Assets/Scripts/Entity.cs
Normal file
35
Assets/Scripts/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 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/Entity.cs.meta
Normal file
2
Assets/Scripts/Entity.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 44ffe7b27489437e0ba113f43de5ad8c
|
||||
17
Assets/Scripts/Player.cs
Normal file
17
Assets/Scripts/Player.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Player : Entity
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Player.cs.meta
Normal file
2
Assets/Scripts/Player.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 89103b88932a2bbaf865c8848bdb31e6
|
||||
31
Assets/Scripts/Projectile.cs
Normal file
31
Assets/Scripts/Projectile.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class Projectile : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Rigidbody2D rb;
|
||||
public int damage;
|
||||
public float speed;
|
||||
public float lifetime;
|
||||
public Vector2 direction;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Destroy(gameObject, lifetime);
|
||||
direction = transform.right;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
rb.linearVelocity = direction * speed;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(tag) && other.TryGetComponent(out Entity isEntity))
|
||||
{
|
||||
isEntity.TakeDamage(damage);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Projectile.cs.meta
Normal file
2
Assets/Scripts/Projectile.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6cb8b1c6e38733b8a846a00e4b0ad87b
|
||||
17
Assets/Scripts/ReisenShoot.cs
Normal file
17
Assets/Scripts/ReisenShoot.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
public class ReisenShoot : Ability
|
||||
{
|
||||
[SerializeField] private Projectile projectile;
|
||||
[SerializeField] private Camera cam;
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
direction = cam.ScreenToWorldPoint(Input.mousePosition);
|
||||
Projectile newProjectile = Instantiate(projectile, origin.position, Quaternion.identity);
|
||||
newProjectile.transform.Lookat2D(direction);
|
||||
newProjectile.damage = power;
|
||||
newProjectile.tag = tag;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/ReisenShoot.cs.meta
Normal file
2
Assets/Scripts/ReisenShoot.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a3b3ef6bc0f1a1f78b2e8af72f1186c1
|
||||
35
Assets/Scripts/YoumuDeflect.cs
Normal file
35
Assets/Scripts/YoumuDeflect.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class YoumuDeflect : Ability
|
||||
{
|
||||
private List<Projectile> projectilesInRange = new();
|
||||
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
base.AbilityEffects();
|
||||
foreach (Projectile projectile in projectilesInRange)
|
||||
{
|
||||
projectile.transform.eulerAngles = new Vector3(0, 0, 180);
|
||||
projectile.direction = -transform.right;
|
||||
projectile.tag = tag;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(tag) && other.TryGetComponent(out Projectile isProjectile))
|
||||
{
|
||||
projectilesInRange.Add(isProjectile);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(tag) && other.TryGetComponent(out Projectile isProjectile) && projectilesInRange.Contains(isProjectile))
|
||||
{
|
||||
projectilesInRange.Add(isProjectile);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/YoumuDeflect.cs.meta
Normal file
2
Assets/Scripts/YoumuDeflect.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0fd254066289aba4a8779f6678e0c515
|
||||
Loading…
Add table
Add a link
Reference in a new issue