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
|
|
@ -4,9 +4,9 @@ public class Ability : MonoBehaviour
|
|||
{
|
||||
[Header("Identification")]
|
||||
public string abilityName;
|
||||
public Entity thisEntity;
|
||||
public EntityStats thisEntity;
|
||||
[Header("Cooldown")]
|
||||
protected float currentCooldown;
|
||||
public float currentCooldown;
|
||||
public float cooldown;
|
||||
[Header("Stats")]
|
||||
public float power;
|
||||
|
|
@ -26,10 +26,10 @@ public class Ability : MonoBehaviour
|
|||
{
|
||||
AbilityEffects();
|
||||
currentCooldown = cooldown;
|
||||
Debug.Log($"Ability {abilityName} SUCCESS");
|
||||
//Debug.Log($"Ability {abilityName} SUCCESS");
|
||||
return true;
|
||||
}
|
||||
Debug.Log($"Ability {abilityName} ON COOLDOWN");
|
||||
//Debug.Log($"Ability {abilityName} ON COOLDOWN");
|
||||
return false;
|
||||
}
|
||||
protected virtual void AbilityEffects()
|
||||
|
|
|
|||
33
Assets/Scripts/Abilities/AbilitySelector.cs
Normal file
33
Assets/Scripts/Abilities/AbilitySelector.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AbilitySelector : MonoBehaviour
|
||||
{
|
||||
#region Statication
|
||||
|
||||
public static AbilitySelector instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (instance != null && instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
instance = this;
|
||||
DontDestroyOnLoad(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
[Header("INDEX 0 IS DEFAULT")]
|
||||
[SerializeField] private List<Ability> reisenPrimaries = new();
|
||||
[SerializeField] private List<Ability> reisenSecondaries = new();
|
||||
[SerializeField] private List<Ability> reisenSpecials = new();
|
||||
[SerializeField] private List<Ability> youmuPrimaries = new();
|
||||
[SerializeField] private List<Ability> youmuSecondaries = new();
|
||||
[SerializeField] private List<Ability> youmuSpecials = new();
|
||||
[Header("SelectedAbiltiies")]
|
||||
public List<Ability> reisenAbilities = new();
|
||||
public List<Ability> youmuAbilities = new(); //this will be a mess to work with...
|
||||
|
||||
}
|
||||
2
Assets/Scripts/Abilities/AbilitySelector.cs.meta
Normal file
2
Assets/Scripts/Abilities/AbilitySelector.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 647bb64098fc7ded8834dc44bfaf9fa8
|
||||
56
Assets/Scripts/Abilities/ChargedShot.cs
Normal file
56
Assets/Scripts/Abilities/ChargedShot.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
using System;
|
||||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
public class ChargedShot : Ability
|
||||
{
|
||||
[Header("Projectile Stats")]
|
||||
[SerializeField] private Projectile projectile;
|
||||
[SerializeField] private float projectileSpeed;
|
||||
[SerializeField] private float projectileLifetime;
|
||||
[SerializeField] private int pierceAmount;
|
||||
[Header("Charge")]
|
||||
private bool isCharging;
|
||||
private float currentChargeDuration;
|
||||
[SerializeField] private float maxChargeDuration;
|
||||
public float chargeModifier;
|
||||
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
base.AbilityEffects();
|
||||
isCharging = true;
|
||||
thisEntity.abilitiesDisabled = true;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (isCharging)
|
||||
{
|
||||
if (Input.GetMouseButton(1))
|
||||
{
|
||||
currentChargeDuration += Time.deltaTime;
|
||||
}
|
||||
else if (Input.GetMouseButtonUp(1))
|
||||
{
|
||||
currentChargeDuration = Math.Clamp(currentChargeDuration, 0f, maxChargeDuration);
|
||||
float calculatedChargeModifier = Map(currentChargeDuration, 0f, maxChargeDuration, 0f, chargeModifier);
|
||||
isCharging = false;
|
||||
thisEntity.abilitiesDisabled = false;
|
||||
Projectile newProjectile = Instantiate(projectile, thisEntity.transform.position, projectile.transform.rotation);
|
||||
//newProjectile.owner = thisEntity;
|
||||
newProjectile.tag = thisEntity.tag;
|
||||
newProjectile.speed = projectileSpeed;
|
||||
newProjectile.damage = power * 1f + calculatedChargeModifier;
|
||||
newProjectile.lifetime = projectileLifetime;
|
||||
newProjectile.pierceAmount = pierceAmount;
|
||||
newProjectile.transform.Lookat2D(thisEntity.attackOriginPoint.position); //targetLocation);
|
||||
newProjectile.transform.localScale = new Vector3(newProjectile.transform.localScale.x * (1f + calculatedChargeModifier), newProjectile.transform.localScale.y * (1f + calculatedChargeModifier), 1f);
|
||||
currentChargeDuration = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static float Map (float value, float from1, float to1, float from2, float to2) {
|
||||
return (value - from1) / (to1 - from1) * (to2 - from2) + from2;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Abilities/ChargedShot.cs.meta
Normal file
2
Assets/Scripts/Abilities/ChargedShot.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 78058c1d64b6076979b8185d531afd62
|
||||
56
Assets/Scripts/Abilities/LunaticRedEyes.cs
Normal file
56
Assets/Scripts/Abilities/LunaticRedEyes.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
public class LunaticRedEyes : Ability
|
||||
{
|
||||
private List<Entity> entitiesInRange = new();
|
||||
[SerializeField] private StunEffect stunEffect;
|
||||
[Header("Effect Chances")]
|
||||
[SerializeField] private float effectChance;
|
||||
[SerializeField] private float hypnotismChance;
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
transform.Lookat2D(thisEntity.attackOriginPoint.position);
|
||||
}
|
||||
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
base.AbilityEffects();
|
||||
foreach (Entity entity in entitiesInRange.ToList())
|
||||
{
|
||||
float rolledEffectChance = Random.Range(0, 100);
|
||||
if (rolledEffectChance > 100 - effectChance) //so if i made it 80 percent, it would need to be higher than 20
|
||||
{
|
||||
float rolledHypnotismChance = Random.Range(0, 100);
|
||||
if (rolledHypnotismChance > 100 - hypnotismChance)
|
||||
{
|
||||
entity.tag = thisEntity.tag;
|
||||
entity.entitiesInRange.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
stunEffect.ApplyEffect(entity.stats);
|
||||
}
|
||||
entitiesInRange.Remove(entity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(thisEntity.tag) && other.TryGetComponent(out Entity isEntity))
|
||||
{
|
||||
entitiesInRange.Add(isEntity);
|
||||
}
|
||||
}
|
||||
private void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(thisEntity.tag) && other.TryGetComponent(out Entity isEntity) && entitiesInRange.Contains(isEntity))
|
||||
{
|
||||
entitiesInRange.Remove(isEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Abilities/LunaticRedEyes.cs.meta
Normal file
2
Assets/Scripts/Abilities/LunaticRedEyes.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 956259a543e87a821b6850d96d435d33
|
||||
46
Assets/Scripts/Abilities/Parry.cs
Normal file
46
Assets/Scripts/Abilities/Parry.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
public class Parry : Ability
|
||||
{
|
||||
public List<Projectile> projectilesInRange = new();
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
transform.Lookat2D(thisEntity.attackOriginPoint.position);
|
||||
}
|
||||
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
base.AbilityEffects();
|
||||
foreach (Projectile projectile in projectilesInRange.ToList())
|
||||
{
|
||||
if (!projectile)
|
||||
{
|
||||
projectilesInRange.Remove(projectile);
|
||||
continue;
|
||||
}
|
||||
projectile.transform.eulerAngles = new Vector3(0, 0, 180);
|
||||
projectile.direction = -projectile.transform.right * projectile.speed;
|
||||
projectile.tag = thisEntity.tag;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(thisEntity.tag) && other.TryGetComponent(out Projectile isProjectile))
|
||||
{
|
||||
projectilesInRange.Add(isProjectile);
|
||||
}
|
||||
}
|
||||
private void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(thisEntity.tag) && other.TryGetComponent(out Projectile isProjectile) && projectilesInRange.Contains(isProjectile))
|
||||
{
|
||||
projectilesInRange.Remove(isProjectile);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Abilities/Parry.cs.meta
Normal file
2
Assets/Scripts/Abilities/Parry.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b12d958979cb9081693930dc212b4b5b
|
||||
|
|
@ -11,12 +11,12 @@ public class ShootBullet : Ability
|
|||
{
|
||||
base.AbilityEffects();
|
||||
Projectile newProjectile = Instantiate(projectile, thisEntity.transform.position, projectile.transform.rotation);
|
||||
newProjectile.owner = thisEntity;
|
||||
//newProjectile.owner = thisEntity;
|
||||
newProjectile.tag = thisEntity.tag;
|
||||
newProjectile.speed = projectileSpeed;
|
||||
newProjectile.damage = power;
|
||||
newProjectile.lifetime = projectileLifetime;
|
||||
newProjectile.pierceAmount = pierceAmount;
|
||||
newProjectile.transform.Lookat2D(thisEntity.stats.attackOriginPoint.position); //targetLocation);
|
||||
newProjectile.transform.Lookat2D(thisEntity.attackOriginPoint.position); //targetLocation);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public class SwordSlash : Ability
|
|||
protected override void AbilityEffects()
|
||||
{
|
||||
base.AbilityEffects();
|
||||
Collider2D[] entitiesFound = Physics2D.OverlapCircleAll(thisEntity.stats.attackOriginPoint.position, damageRadius, entityLayer);
|
||||
Collider2D[] entitiesFound = Physics2D.OverlapCircleAll(thisEntity.attackOriginPoint.position, damageRadius, entityLayer);
|
||||
foreach (Collider2D entityFound in entitiesFound)
|
||||
{
|
||||
if (!entityFound.CompareTag(thisEntity.tag))
|
||||
|
|
|
|||
8
Assets/Scripts/Effects.meta
Normal file
8
Assets/Scripts/Effects.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 28dd0266b1fe9cf7cba9b8a0e26f09ab
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
27
Assets/Scripts/Effects/Effect.cs
Normal file
27
Assets/Scripts/Effects/Effect.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class Effect : ScriptableObject
|
||||
{
|
||||
[SerializeField] private EffectInstance effectInstanceObject;
|
||||
[Header("Stats")]
|
||||
public float duration;
|
||||
public bool isConstant; //that means if it uses the tick function or not
|
||||
|
||||
public virtual void ApplyEffect(EntityStats affectedEntity)
|
||||
{
|
||||
EffectInstance newEffectInstance = Instantiate(effectInstanceObject, affectedEntity.transform);
|
||||
newEffectInstance.affectedEntity = affectedEntity;
|
||||
newEffectInstance.thisEffect = this;
|
||||
|
||||
}
|
||||
|
||||
public virtual void EffectTick(EntityStats affectedEntity)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void RemoveEffect(EntityStats affectedEntity)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Effects/Effect.cs.meta
Normal file
2
Assets/Scripts/Effects/Effect.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0b651e63407ba835ca32118ad1d595f6
|
||||
21
Assets/Scripts/Effects/EffectInstance.cs
Normal file
21
Assets/Scripts/Effects/EffectInstance.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class EffectInstance : MonoBehaviour
|
||||
{
|
||||
public Effect thisEffect;
|
||||
public EntityStats affectedEntity;
|
||||
public float timeElapsed;
|
||||
private void Update()
|
||||
{
|
||||
timeElapsed += Time.deltaTime;
|
||||
if (timeElapsed > thisEffect.duration)
|
||||
{
|
||||
thisEffect.RemoveEffect(affectedEntity);
|
||||
return;
|
||||
}
|
||||
if (thisEffect.isConstant)
|
||||
{
|
||||
thisEffect.EffectTick(affectedEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Effects/EffectInstance.cs.meta
Normal file
2
Assets/Scripts/Effects/EffectInstance.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a7159312b04c2231e8eee3bea5bc1362
|
||||
16
Assets/Scripts/Effects/HypnotismEffect.cs
Normal file
16
Assets/Scripts/Effects/HypnotismEffect.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class HypnotismEffect : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Effects/HypnotismEffect.cs.meta
Normal file
2
Assets/Scripts/Effects/HypnotismEffect.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a1b859b13dfbe89128d4f55176d16214
|
||||
18
Assets/Scripts/Effects/StunEffect.cs
Normal file
18
Assets/Scripts/Effects/StunEffect.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(fileName = "New Stun Effect", menuName = "Effects/Stun Effect")]
|
||||
public class StunEffect : Effect
|
||||
{
|
||||
public override void ApplyEffect(EntityStats affectedEntity)
|
||||
{
|
||||
base.ApplyEffect(affectedEntity);
|
||||
affectedEntity.isStalled = true;
|
||||
Debug.Log(affectedEntity.isStalled);
|
||||
}
|
||||
|
||||
public override void RemoveEffect(EntityStats affectedEntity)
|
||||
{
|
||||
base.RemoveEffect(affectedEntity);
|
||||
affectedEntity.isStalled = false;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Effects/StunEffect.cs.meta
Normal file
2
Assets/Scripts/Effects/StunEffect.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cb710f41706eebbd1a28eb04794a6aef
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,15 +11,17 @@ public class Projectile : MonoBehaviour
|
|||
|
||||
public float speed;
|
||||
[SerializeField] private Rigidbody2D rb;
|
||||
public Vector2 direction;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Destroy(gameObject, lifetime);
|
||||
direction = transform.right * speed;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
rb.linearVelocity = transform.right * speed;
|
||||
rb.linearVelocity = direction;
|
||||
}
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using TMPro;
|
||||
using Unity.Cinemachine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PlayerSwitcher : MonoBehaviour
|
||||
{
|
||||
|
|
@ -14,8 +16,14 @@ public class PlayerSwitcher : MonoBehaviour
|
|||
[Header("Switch Cooldowns")]
|
||||
[SerializeField] private float switchCooldown;
|
||||
private float currentSwitchCooldown;
|
||||
|
||||
|
||||
[Header("UI")]
|
||||
[SerializeField] private TextMeshProUGUI mainPlayerText;
|
||||
[SerializeField] private TextMeshProUGUI nonPlayerText;
|
||||
[SerializeField] private Image mainPlayerIcon;
|
||||
[SerializeField] private Image nonPlayerIcon;
|
||||
[SerializeField] private Transform mainPlayerHealthBar;
|
||||
[SerializeField] private Transform nonPlayerHealthbar;
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.E) && currentSwitchCooldown <= 0f)
|
||||
|
|
@ -42,13 +50,13 @@ public class PlayerSwitcher : MonoBehaviour
|
|||
player1AI = playerBAI;
|
||||
player2 = playerA;
|
||||
player2AI = playerAAI;
|
||||
foreach (Ability ability in playerA.stats.abilities)
|
||||
{
|
||||
ability.thisEntity = playerAAI;
|
||||
}
|
||||
foreach (Ability ability in playerBAI.stats.abilities)
|
||||
{
|
||||
ability.thisEntity = playerB;
|
||||
}
|
||||
mainPlayerText.text = playerB.name;
|
||||
nonPlayerText.text = playerA.name;
|
||||
mainPlayerIcon.sprite = playerB.stats.icon;
|
||||
nonPlayerIcon.sprite = playerA.stats.icon;
|
||||
playerA.stats.healthBar = nonPlayerHealthbar;
|
||||
playerA.stats.UpdateHealthBar();
|
||||
playerB.stats.healthBar = mainPlayerHealthBar;
|
||||
playerB.stats.UpdateHealthBar();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue