i am looking respectfully
This commit is contained in:
parent
3160bff7a3
commit
084aada510
29 changed files with 2891 additions and 482 deletions
8
Assets/Scripts/AbilityUpgrade.cs
Normal file
8
Assets/Scripts/AbilityUpgrade.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class AbilityUpgrade : MonoBehaviour
|
||||
{
|
||||
[Header("Identification")]
|
||||
public string upgradeName;
|
||||
public PlayerAbility thisPlayerAbility;
|
||||
}
|
||||
2
Assets/Scripts/AbilityUpgrade.cs.meta
Normal file
2
Assets/Scripts/AbilityUpgrade.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1d4bef84914cd439da6e7fa4a07ae966
|
||||
54
Assets/Scripts/Enemy.cs
Normal file
54
Assets/Scripts/Enemy.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
public class Enemy : Entity
|
||||
{
|
||||
[Header("Targetting")]
|
||||
public Entity closestTarget;
|
||||
[Header("Direction")]
|
||||
public float acceleration;
|
||||
public Transform[] possibleDirections;
|
||||
public float forwardPercent;
|
||||
public float strafePercent;
|
||||
private float xSign = -1f;
|
||||
private float ySign = 1f;
|
||||
private void Start()
|
||||
{
|
||||
if (Random.Range(0f, 2f) > 1f)
|
||||
{
|
||||
xSign = -xSign;
|
||||
ySign = -ySign;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void FixedUpdate()
|
||||
{
|
||||
if (stalled || !closestTarget)
|
||||
{
|
||||
rb.VelocityTowards(Vector2.zero.ScaleToMagnitude(speed), acceleration);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 directionToTarget = (closestTarget.transform.position - transform.position).normalized;
|
||||
Vector2 directionToMove = directionToTarget;
|
||||
float currentHighestScore = float.NegativeInfinity;
|
||||
Vector2 strafeDirection = new Vector3(directionToTarget.y * ySign, directionToTarget.x * xSign);
|
||||
foreach (Transform direction in possibleDirections)
|
||||
{
|
||||
Vector3 directionToPoint = (direction.position - transform.position).normalized;
|
||||
float forwardScore = Vector3.Dot(directionToPoint, directionToTarget);
|
||||
float strafeScore = Vector3.Dot(directionToPoint, strafeDirection);
|
||||
float finalScore = (forwardScore * forwardPercent) + (strafeScore * strafePercent);
|
||||
//Debug.Log($"Forward: {forwardScore} Strafe: {strafeScore} Final: {finalScore}");
|
||||
if (finalScore > currentHighestScore)
|
||||
{
|
||||
//Debug.Log($"{finalScore} is higher than current score: {currentHighestScore}");
|
||||
currentHighestScore = finalScore;
|
||||
directionToMove = directionToPoint;
|
||||
}
|
||||
}
|
||||
rb.VelocityTowards(directionToMove.ScaleToMagnitude(speed), acceleration);
|
||||
FlipSprite(directionToMove);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Enemy.cs.meta
Normal file
2
Assets/Scripts/Enemy.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d2f63beb11592bee5a56b820466a852d
|
||||
59
Assets/Scripts/Entity.cs
Normal file
59
Assets/Scripts/Entity.cs
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class Entity : MonoBehaviour
|
||||
{
|
||||
[Header("Identification")]
|
||||
public string entityName;
|
||||
public SpriteRenderer sprite;
|
||||
[Header("Flags")]
|
||||
public bool stalled;
|
||||
public bool invincible;
|
||||
[Header("Stats")]
|
||||
public float health;
|
||||
public float maxHealth;
|
||||
[Header("Movement")]
|
||||
[SerializeField] private bool isFacingRight;
|
||||
[SerializeField] protected Rigidbody2D rb;
|
||||
protected Vector2 moveDirection;
|
||||
public float speed;
|
||||
|
||||
protected void FlipSprite(Vector2 lookDirection)
|
||||
{
|
||||
if (lookDirection.x < 0f && isFacingRight)
|
||||
{
|
||||
sprite.flipX = true;
|
||||
isFacingRight = !isFacingRight;
|
||||
}
|
||||
else if (lookDirection.x > 0f && !isFacingRight)
|
||||
{
|
||||
sprite.flipX = false;
|
||||
isFacingRight = !isFacingRight;
|
||||
}
|
||||
}
|
||||
protected virtual void FixedUpdate()
|
||||
{
|
||||
if (!stalled)
|
||||
{
|
||||
rb.linearVelocity = moveDirection * speed;
|
||||
}
|
||||
}
|
||||
public void TakeDamage(float damage)
|
||||
{
|
||||
health -= damage;
|
||||
health = Mathf.Clamp(health, 0, maxHealth);
|
||||
if (health < 0)
|
||||
{
|
||||
OnKillEffects();
|
||||
}
|
||||
}
|
||||
public void Heal(float healingAmount)
|
||||
{
|
||||
health += healingAmount;
|
||||
health = Mathf.Clamp(health, 0, maxHealth);
|
||||
}
|
||||
|
||||
protected virtual void OnKillEffects()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Entity.cs.meta
Normal file
2
Assets/Scripts/Entity.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 74fafccf721a0a5d2b3580fb7042d4f8
|
||||
11
Assets/Scripts/Marisa.cs
Normal file
11
Assets/Scripts/Marisa.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class Marisa : Entity
|
||||
{
|
||||
protected override void FixedUpdate()
|
||||
{
|
||||
moveDirection = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
|
||||
base.FixedUpdate();
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Marisa.cs.meta
Normal file
2
Assets/Scripts/Marisa.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 52bda12b42435d197a10a340f8608249
|
||||
6
Assets/Scripts/MarisaAbilityHandler.cs
Normal file
6
Assets/Scripts/MarisaAbilityHandler.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class MarisaAbilityHandler : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
2
Assets/Scripts/MarisaAbilityHandler.cs.meta
Normal file
2
Assets/Scripts/MarisaAbilityHandler.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e4cb2f99b870cbec6b3f8e40a997b596
|
||||
32
Assets/Scripts/PlayerAbility.cs
Normal file
32
Assets/Scripts/PlayerAbility.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerAbility : MonoBehaviour
|
||||
{
|
||||
[Header("Identification")]
|
||||
public string abilityName;
|
||||
[Header("Cooldown")]
|
||||
public float cooldown;
|
||||
private float currentCooldown;
|
||||
|
||||
public void TryAbility()
|
||||
{
|
||||
if (currentCooldown <= 0)
|
||||
{
|
||||
currentCooldown = cooldown;
|
||||
AbilityEffects();
|
||||
}
|
||||
}
|
||||
|
||||
protected void AbilityEffects()
|
||||
{
|
||||
|
||||
}
|
||||
protected virtual void Update()
|
||||
{
|
||||
if (currentCooldown > 0)
|
||||
{
|
||||
currentCooldown -= Time.deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/PlayerAbility.cs.meta
Normal file
2
Assets/Scripts/PlayerAbility.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f5c5f92fbdbe28abb8404bf5c5d1977b
|
||||
41
Assets/Scripts/Projectile.cs
Normal file
41
Assets/Scripts/Projectile.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
public class Projectile : MonoBehaviour
|
||||
{
|
||||
public float damage;
|
||||
public float speed;
|
||||
private int currentPierced;
|
||||
public int pierceAmount;
|
||||
public float lifetime;
|
||||
[SerializeField] private Rigidbody2D rb;
|
||||
|
||||
public void RotateToTarget(Vector3 target)
|
||||
{
|
||||
transform.Lookat2D(target);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Destroy(gameObject, lifetime);
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
rb.linearVelocity = transform.right * speed;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(tag) && other.TryGetComponent(out Entity isEntity))
|
||||
{
|
||||
isEntity.TakeDamage(damage);
|
||||
currentPierced++;
|
||||
if (currentPierced > pierceAmount)
|
||||
{
|
||||
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: e66b3403d93ec8803822e3a85537224b
|
||||
Loading…
Add table
Add a link
Reference in a new issue