alot of stuff i forgot to commit
This commit is contained in:
parent
fc2329a873
commit
b8d516e734
60 changed files with 7397 additions and 64 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
public class AutoControlledEntity : Entity
|
||||
|
|
@ -20,4 +21,15 @@ public class AutoControlledEntity : Entity
|
|||
}
|
||||
return false;
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (closestEntity && !stats.abilitiesDisabled && !stats.isStalled)
|
||||
{
|
||||
stats.attackOriginCenter.Lookat2D(closestEntity.transform.position);
|
||||
foreach (Ability ability in stats.abilities)
|
||||
{
|
||||
ability.TryAbility();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,19 +6,7 @@ public class AutomatedPlayer : AutoControlledEntity
|
|||
{
|
||||
public Player player;
|
||||
public float playerMinDistance;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (closestEntity)
|
||||
{
|
||||
stats.attackOriginCenter.Lookat2D(closestEntity.transform.position);
|
||||
foreach (Ability ability in stats.abilities)
|
||||
{
|
||||
ability.TryAbility();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (!stats.isStalled)
|
||||
|
|
|
|||
|
|
@ -3,11 +3,12 @@ using UnityEngine;
|
|||
|
||||
public class Enemy : AutoControlledEntity
|
||||
{
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
Vector2 direction = new Vector2(0, stats.rb.linearVelocityY);
|
||||
if (!stats.isStalled)
|
||||
{
|
||||
Vector2 direction = new Vector2(0, stats.rb.linearVelocityY);
|
||||
if (closestEntity && Vector3.Distance(closestEntity.transform.position, transform.position) < maxTargettingRange)
|
||||
{
|
||||
direction.x = (closestEntity.transform.position - transform.position).normalized.x * stats.speed;
|
||||
|
|
@ -17,8 +18,12 @@ public class Enemy : AutoControlledEntity
|
|||
}
|
||||
}
|
||||
FlipSprite(direction);
|
||||
stats.rb.linearVelocity = direction;
|
||||
}
|
||||
else
|
||||
{
|
||||
direction.x = 0;
|
||||
}
|
||||
stats.rb.linearVelocity = direction;
|
||||
}
|
||||
|
||||
public override void OnDeath()
|
||||
|
|
|
|||
|
|
@ -1,19 +1,28 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DamageNumbersPro;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
public class EntityStats : MonoBehaviour
|
||||
{
|
||||
[Header("Identification")]
|
||||
public string name;
|
||||
public Sprite icon; //only if applicable...
|
||||
public Entity thisEntity;
|
||||
[Header("Health")]
|
||||
public float health;
|
||||
public float maxHealth;
|
||||
public DamageNumber damageNumbers;
|
||||
[Header("Health UI")]
|
||||
public Transform healthBar;
|
||||
[Header("Stats")]
|
||||
public float speed;
|
||||
public float jumpPower;
|
||||
[Header("State")]
|
||||
public bool isStalled;
|
||||
public bool abilitiesDisabled;
|
||||
[Header("Ground Detection")]
|
||||
[SerializeField] private Transform groundCheck;
|
||||
[SerializeField] private LayerMask groundLayer;
|
||||
|
|
@ -38,6 +47,14 @@ public class EntityStats : MonoBehaviour
|
|||
{
|
||||
health -= damage;
|
||||
StartCoroutine(DamageVisual());
|
||||
if (damageNumbers)
|
||||
{
|
||||
damageNumbers.Spawn(transform.position, damage.ToString());
|
||||
}
|
||||
if (healthBar)
|
||||
{
|
||||
UpdateHealthBar();
|
||||
}
|
||||
if (health <= 0)
|
||||
{
|
||||
thisEntity.OnDeath();
|
||||
|
|
@ -64,4 +81,9 @@ public class EntityStats : MonoBehaviour
|
|||
{
|
||||
return Physics2D.OverlapCircle(groundCheck.position, 0.05f, groundLayer);
|
||||
}
|
||||
|
||||
public void UpdateHealthBar()
|
||||
{
|
||||
healthBar.transform.localScale = new Vector3(math.clamp(health / maxHealth, 0f, 1f), 1f, 1f);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,20 @@ public class Player : Entity
|
|||
private void Update()
|
||||
{
|
||||
stats.attackOriginCenter.Lookat2D(cam.ScreenToWorldPoint(Input.mousePosition));
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
if (!stats.abilitiesDisabled)
|
||||
{
|
||||
stats.abilities[0].TryAbility();
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
stats.abilities[0].TryAbility();
|
||||
}
|
||||
else if (Input.GetMouseButtonDown(1))
|
||||
{
|
||||
stats.abilities[1].TryAbility(); //the ability system needs to be fixed
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Q) && stats.abilities[2])
|
||||
{
|
||||
stats.abilities[2].TryAbility();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue