this idiot forgot to commit an entire month's worth of code
This commit is contained in:
parent
c67146ea1a
commit
a3321d361c
51 changed files with 3644 additions and 84 deletions
|
|
@ -5,7 +5,7 @@ using UnityEngine.EventSystems;
|
|||
|
||||
public class AbilityHotbarIcon : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
[SerializeField] private Transform cooldownBar;
|
||||
public Transform cooldownBar;
|
||||
[SerializeField] private TextMeshProUGUI text;
|
||||
private bool onCooldown;
|
||||
private PlayerAbility thisAbility;
|
||||
|
|
@ -34,6 +34,7 @@ public class AbilityHotbarIcon : MonoBehaviour, IPointerEnterHandler, IPointerEx
|
|||
public void UpdateAbility(PlayerAbility ability)
|
||||
{
|
||||
thisAbility = ability;
|
||||
ability.thisHotbarIcon = this;
|
||||
text.text = thisAbility.abilityName;
|
||||
}
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ public class AbilityManager : MonoBehaviour
|
|||
return;
|
||||
}
|
||||
instance = this;
|
||||
DontDestroyOnLoad(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -26,12 +27,23 @@ public class AbilityManager : MonoBehaviour
|
|||
public Button upgradeButton;
|
||||
[Header("Upgrades")]
|
||||
public AbilityUpgrade[] allUpgrades;
|
||||
public PlayerAbility[] allAbilities;
|
||||
[SerializeField] private PlayerAbility[] allAbilities;
|
||||
public Dictionary<String, PlayerAbility> abilityLookup = new();
|
||||
public Dictionary<String, AbilityUpgrade> upgradeLookup = new();
|
||||
public Dictionary<AbilityUpgrade, int> upgradesInventory = new();
|
||||
private void Start()
|
||||
{
|
||||
// upgradeButton.onClick.AddListener((() => AddUpgrade(upgradeToAdd, player.mainAttackInstance)));
|
||||
StoreUpgrade(upgradeToAdd);
|
||||
foreach (PlayerAbility ability in allAbilities)
|
||||
{
|
||||
abilityLookup[ability.abilityName] = ability;
|
||||
}
|
||||
|
||||
foreach (AbilityUpgrade upgrade in allUpgrades)
|
||||
{
|
||||
upgradeLookup[upgrade.upgradeName] = upgrade;
|
||||
}
|
||||
}
|
||||
|
||||
public void StoreUpgrade(AbilityUpgrade upgradeToStore)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ public class EnemyAbility : ScriptableObject
|
|||
{
|
||||
public float cooldown;
|
||||
public float power;
|
||||
public float range;
|
||||
public float maxRange;
|
||||
public float minRange; //usually zero but might be needed in some cases
|
||||
public virtual void UseAbility(Entity target, Enemy owner)
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ public class PlayerAbility : MonoBehaviour
|
|||
public string abilityName;
|
||||
public Sprite abilityIcon;
|
||||
public Marisa thisPlayer;
|
||||
public AbilityHotbarIcon thisHotbarIcon;
|
||||
[Header("Cooldown")]
|
||||
public bool canCooldown = true;
|
||||
public float baseCooldown;
|
||||
|
|
@ -16,6 +17,7 @@ public class PlayerAbility : MonoBehaviour
|
|||
[Header("Stats")]
|
||||
public float basePower;
|
||||
public float power;
|
||||
public float powerMultiplier; // you need to figure out power.
|
||||
public int baseProjectileCount;
|
||||
public int projectileCount;
|
||||
public Dictionary<AbilityUpgrade, int> attachedUpgrades = new();
|
||||
|
|
|
|||
|
|
@ -5,15 +5,17 @@ public class AbilityUpgrade : ScriptableObject
|
|||
[Header("Identification")]
|
||||
public string upgradeName;
|
||||
public Sprite upgradeIcon;
|
||||
public int rarity; //higher is rarer
|
||||
public int cost;
|
||||
[Header("Stats")]
|
||||
[SerializeField] private string hi; //never use this lol it's just for the header
|
||||
|
||||
public void ApplyUpgrade(PlayerAbility abilityToUpgrade)
|
||||
public void ApplyUpgrade(PlayerAbility abilityToUpgrade, float optionalInput = 0)
|
||||
{
|
||||
UpgradeEffects(abilityToUpgrade);
|
||||
UpgradeEffects(abilityToUpgrade, optionalInput);
|
||||
}
|
||||
|
||||
protected virtual void UpgradeEffects(PlayerAbility abilityToUpgrade)
|
||||
protected virtual void UpgradeEffects(PlayerAbility abilityToUpgrade, float optionalInput)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ public class CooldownUpgrade : AbilityUpgrade
|
|||
{
|
||||
[SerializeField] private float cooldownDifference;
|
||||
|
||||
protected override void UpgradeEffects(PlayerAbility abilityToUpgrade)
|
||||
protected override void UpgradeEffects(PlayerAbility abilityToUpgrade, float optionalInput)
|
||||
{
|
||||
abilityToUpgrade.cooldown = abilityToUpgrade.baseCooldown * ((float)Math.Pow(cooldownDifference, abilityToUpgrade.attachedUpgrades[this])); //almost forgot my math there...
|
||||
}
|
||||
|
|
|
|||
19
Assets/Scripts/Abilities/Upgrades/Enemy Count Upgrade.asset
Normal file
19
Assets/Scripts/Abilities/Upgrades/Enemy Count Upgrade.asset
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ce6ef1d1ae7df5849b3fdee8fc8fcbba, type: 3}
|
||||
m_Name: Enemy Count Upgrade
|
||||
m_EditorClassIdentifier:
|
||||
upgradeName: A name
|
||||
upgradeIcon: {fileID: 0}
|
||||
hi:
|
||||
damageIncreasePercentage: 0.15
|
||||
runtimeObject: {fileID: 7716994186307467207, guid: 6d10c59bff13032f287e544b4c3c19cf, type: 3}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f8b8bce9dd3b28a8fa56648bcb036480
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
48
Assets/Scripts/Abilities/Upgrades/EnemyCountInstance.prefab
Normal file
48
Assets/Scripts/Abilities/Upgrades/EnemyCountInstance.prefab
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &6018690837818724447
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2133486229549973065}
|
||||
- component: {fileID: 7716994186307467207}
|
||||
m_Layer: 0
|
||||
m_Name: EnemyCountInstance
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &2133486229549973065
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6018690837818724447}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &7716994186307467207
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6018690837818724447}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 54d7053b10fbdd0329fb509aa84129fb, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
baseSO: {fileID: 0}
|
||||
thisAbility: {fileID: 0}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6d10c59bff13032f287e544b4c3c19cf
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Scripts/Abilities/Upgrades/EnemyCountPowerup.cs
Normal file
16
Assets/Scripts/Abilities/Upgrades/EnemyCountPowerup.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(fileName = "Enemy Count Upgrade", menuName = "AbilityUpgrades/EnemyCountUpgrade")]
|
||||
public class EnemyCountPowerup : AbilityUpgrade
|
||||
{
|
||||
public float damageIncreasePercentage;
|
||||
[SerializeField] private EnemyCountRuntime runtimeObject;
|
||||
protected override void UpgradeEffects(PlayerAbility abilityToUpgrade, float optionalInput)
|
||||
{
|
||||
EnemyCountRuntime newRuntimeObject = Instantiate(runtimeObject, abilityToUpgrade.transform);
|
||||
newRuntimeObject.baseSO = this;
|
||||
newRuntimeObject.thisAbility = abilityToUpgrade;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ce6ef1d1ae7df5849b3fdee8fc8fcbba
|
||||
26
Assets/Scripts/Abilities/Upgrades/EnemyCountRuntime.cs
Normal file
26
Assets/Scripts/Abilities/Upgrades/EnemyCountRuntime.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EnemyCountRuntime : MonoBehaviour
|
||||
{
|
||||
private List<Collider2D> enemiesInRange = new(); //was supposed to be entity list but trygetcomponent isn't needed because we aren't using the actual entity values
|
||||
public EnemyCountPowerup baseSO;
|
||||
public PlayerAbility thisAbility;
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(tag))
|
||||
{
|
||||
enemiesInRange.Add(other);
|
||||
}
|
||||
thisAbility.powerMultiplier = 1 + baseSO.damageIncreasePercentage * enemiesInRange.Count; //does not stack with other multipliers and must be fixed
|
||||
}
|
||||
|
||||
private void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(tag) && enemiesInRange.Contains(other))
|
||||
{
|
||||
enemiesInRange.Remove(other);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 54d7053b10fbdd0329fb509aa84129fb
|
||||
18
Assets/Scripts/Abilities/Upgrades/KillCooldown.cs
Normal file
18
Assets/Scripts/Abilities/Upgrades/KillCooldown.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class KillCooldown : AbilityUpgrade
|
||||
{
|
||||
public float damageIncrease;
|
||||
public float cooldownChange;
|
||||
[SerializeField] private KillCooldownRuntimeObject runtimeObject;
|
||||
|
||||
protected override void UpgradeEffects(PlayerAbility abilityToUpgrade, float optionalInput)
|
||||
{
|
||||
base.UpgradeEffects(abilityToUpgrade, optionalInput);
|
||||
abilityToUpgrade.canCooldown = false;
|
||||
abilityToUpgrade.cooldown = abilityToUpgrade.baseCooldown * cooldownChange;
|
||||
KillCooldownRuntimeObject newRuntimeObject = Instantiate(runtimeObject, abilityToUpgrade.transform);
|
||||
newRuntimeObject.ability = abilityToUpgrade;
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Abilities/Upgrades/KillCooldown.cs.meta
Normal file
2
Assets/Scripts/Abilities/Upgrades/KillCooldown.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 70c8f2392635dc77da8d3f4bf9d656c7
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class KillCooldownRuntimeObject : MonoBehaviour
|
||||
{
|
||||
public PlayerAbility ability;
|
||||
private void Start()
|
||||
{
|
||||
Enemy.OnKill += UpdateKills;
|
||||
}
|
||||
|
||||
public void UpdateKills()
|
||||
{
|
||||
ability.currentCooldown -= 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c4e5e6da9766bf54d8c2aa3b49966213
|
||||
|
|
@ -3,7 +3,7 @@ using UnityEngine;
|
|||
[CreateAssetMenu(fileName = "Projectile Count Upgrade", menuName = "AbilityUpgrades/ProjectileCountUpgrade")]
|
||||
public class ProjectileCountUpgrade : AbilityUpgrade
|
||||
{
|
||||
protected override void UpgradeEffects(PlayerAbility abilityToUpgrade)
|
||||
protected override void UpgradeEffects(PlayerAbility abilityToUpgrade, float optionalInput)
|
||||
{
|
||||
abilityToUpgrade.projectileCount =
|
||||
abilityToUpgrade.baseProjectileCount + abilityToUpgrade.attachedUpgrades[this];
|
||||
|
|
|
|||
|
|
@ -68,16 +68,7 @@ public class AbilitySceneTransfer : MonoBehaviour
|
|||
abilityHandler.abilities.Clear();
|
||||
foreach (SavedAbility savedAbility in savedAbilities)
|
||||
{
|
||||
PlayerAbility foundAbility = null;
|
||||
foreach (PlayerAbility ability in AbilityManager.instance.allAbilities)
|
||||
{
|
||||
if (savedAbility.abilityName == ability.abilityName) //shit code
|
||||
{
|
||||
foundAbility = ability;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerAbility foundAbility = AbilityManager.instance.abilityLookup[savedAbility.abilityName];
|
||||
if (!foundAbility)
|
||||
{
|
||||
Debug.LogWarning($"{savedAbility.abilityName} was not found.");
|
||||
|
|
@ -85,20 +76,13 @@ public class AbilitySceneTransfer : MonoBehaviour
|
|||
abilityHandler.abilities.Add(foundAbility);
|
||||
}
|
||||
abilityHandler.SetupAbilities();
|
||||
foreach (PlayerAbility abilityInstance in abilityHandler.abilityInstances)
|
||||
foreach (SavedAbility savedAbility in savedAbilities)
|
||||
{
|
||||
foreach (SavedAbility savedAbility in savedAbilities)
|
||||
foreach (KeyValuePair<string, int> equippedUpgrade in savedAbility.equippedUpgrades)
|
||||
{
|
||||
if (savedAbility.abilityName == abilityInstance.abilityName) //shit code
|
||||
if (AbilityManager.instance.upgradeLookup[equippedUpgrade.Key] != null)
|
||||
{
|
||||
foreach (AbilityUpgrade upgrade in AbilityManager.instance.allUpgrades)
|
||||
{
|
||||
if (savedAbility.equippedUpgrades[upgrade.upgradeName] > 0)
|
||||
{
|
||||
abilityInstance.AddUpgrade(upgrade, savedAbility.equippedUpgrades[upgrade.upgradeName]);
|
||||
}
|
||||
} //this is REALLY BAD.
|
||||
break;
|
||||
abilityHandler.instantiatedAbilityLookup[savedAbility.abilityName].AddUpgrade(AbilityManager.instance.upgradeLookup[equippedUpgrade.Key], equippedUpgrade.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ public class Effect : ScriptableObject
|
|||
{
|
||||
EffectInstance newEffectInstance = Instantiate(effectInstanceObject, affectedEntity.transform);
|
||||
newEffectInstance.affectedEntity = affectedEntity;
|
||||
|
||||
newEffectInstance.thisEffect = this;
|
||||
|
||||
}
|
||||
|
||||
public virtual void EffectTick(Entity affectedEntity)
|
||||
|
|
|
|||
16
Assets/Scripts/Effects/SpeedEffect.cs
Normal file
16
Assets/Scripts/Effects/SpeedEffect.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(fileName = "New Speed Effect", menuName = "Effects/Speed")]
|
||||
public class SpeedEffect : Effect
|
||||
{
|
||||
[SerializeField] private float speedAmount;
|
||||
public override void ApplyEffect(Entity affectedEntity)
|
||||
{
|
||||
base.ApplyEffect(affectedEntity);
|
||||
affectedEntity.speedMultiplier += speedAmount;
|
||||
}
|
||||
public override void RemoveEffect(Entity affectedEntity)
|
||||
{
|
||||
affectedEntity.speedMultiplier = 1f; //supposed to be -= speedAmount but it's fucked.
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Effects/SpeedEffect.cs.meta
Normal file
2
Assets/Scripts/Effects/SpeedEffect.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c42a268529acb9c14b00a019f63603b8
|
||||
|
|
@ -13,6 +13,7 @@ public class Enemy : Entity
|
|||
public float currentCooldown;
|
||||
}
|
||||
public static event Action OnDamaged;
|
||||
public static event Action OnKill;
|
||||
[Header("Targetting")]
|
||||
public Entity closestTarget;
|
||||
public float engagementRange;
|
||||
|
|
@ -22,8 +23,8 @@ public class Enemy : Entity
|
|||
public Transform[] possibleDirections;
|
||||
public float forwardPercent;
|
||||
public float strafePercent;
|
||||
private float xSign = -1f;
|
||||
private float ySign = 1f;
|
||||
protected float xSign = -1f;
|
||||
protected float ySign = 1f;
|
||||
|
||||
[System.Serializable]
|
||||
public class UpgradeDrop
|
||||
|
|
@ -37,6 +38,11 @@ public class Enemy : Entity
|
|||
|
||||
[Header("Abilities")]
|
||||
[SerializeField] private Ability[] allAbilities;
|
||||
|
||||
[Header("Levels")]
|
||||
[SerializeField] private float levelHealthBuff;
|
||||
[SerializeField] private float levelPowerBuff;
|
||||
public float powerBuffAmount;
|
||||
private void Start()
|
||||
{
|
||||
if (Random.Range(0f, 2f) > 1f)
|
||||
|
|
@ -44,16 +50,21 @@ public class Enemy : Entity
|
|||
xSign = -xSign;
|
||||
ySign = -ySign;
|
||||
}
|
||||
//set hp and dmg values
|
||||
maxHealth = baseMaxHealth * (EnemySpawner.instance.enemyLevel * levelHealthBuff);
|
||||
health = maxHealth;
|
||||
powerBuffAmount = EnemySpawner.instance.enemyLevel * levelPowerBuff;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
protected virtual void Update()
|
||||
{
|
||||
if (detectedPlayer)
|
||||
{
|
||||
Ability foundAbility = null;
|
||||
foreach (Ability availableAbility in allAbilities)
|
||||
{
|
||||
if (foundAbility == null && availableAbility.currentCooldown <= 0 && availableAbility.ability.range < Vector3.Distance(closestTarget.transform.position, transform.position))
|
||||
float targetDistance = Vector3.Distance(closestTarget.transform.position, transform.position);
|
||||
if (foundAbility == null && availableAbility.currentCooldown <= 0 && availableAbility.ability.maxRange > targetDistance && availableAbility.ability.minRange < targetDistance)
|
||||
{
|
||||
foundAbility = availableAbility;
|
||||
}
|
||||
|
|
@ -100,7 +111,7 @@ public class Enemy : Entity
|
|||
directionToMove = directionToPoint;
|
||||
}
|
||||
}
|
||||
rb.VelocityTowards(directionToMove.ScaleToMagnitude(speed), acceleration);
|
||||
rb.VelocityTowards(directionToMove.ScaleToMagnitude(speed * speedMultiplier), acceleration);
|
||||
FlipSprite(directionToMove);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class EnemyFireBullet : EnemyAbility
|
|||
|
||||
newProjectile.owner = owner;
|
||||
newProjectile.pierceAmount = pierceAmount;
|
||||
newProjectile.damage = power;
|
||||
newProjectile.damage = power * owner.powerBuffAmount;
|
||||
newProjectile.speed = projectileSpeed;
|
||||
newProjectile.lifetime = bulletLifetime;
|
||||
newProjectile.transform.Rotate(0, 0, Random.Range(-accuracy, accuracy));
|
||||
|
|
|
|||
17
Assets/Scripts/Entities/Enemy/EnemyRushAbility.cs
Normal file
17
Assets/Scripts/Entities/Enemy/EnemyRushAbility.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(fileName = "New Enemy Rush Ability", menuName = "EnemyAbilities/Rush")]
|
||||
public class EnemyRushAbility : EnemyAbility
|
||||
{
|
||||
[SerializeField] private Effect speedEffect;
|
||||
public override void UseAbility(Entity target, Enemy owner)
|
||||
{
|
||||
Debug.Log("ability activated");
|
||||
if (owner.speedMultiplier < 1.10f)
|
||||
{
|
||||
Debug.Log("affect applied");
|
||||
speedEffect.ApplyEffect(owner);
|
||||
}
|
||||
//owner.closestTarget =
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Entities/Enemy/EnemyRushAbility.cs.meta
Normal file
2
Assets/Scripts/Entities/Enemy/EnemyRushAbility.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 489701e947dc0bf818f370f0fa7734aa
|
||||
|
|
@ -36,9 +36,12 @@ public class EnemySpawner : MonoBehaviour
|
|||
[SerializeField] private Transform bossHealthBar;
|
||||
[SerializeField] private TextMeshProUGUI bossHealthText;
|
||||
[SerializeField] private TextMeshProUGUI bossNameText;
|
||||
[Header("Difficulty Scaling")]
|
||||
public float levelUpIntervals;
|
||||
public int enemyLevel;
|
||||
[Header("Cache")]
|
||||
[SerializeField] private Transform enemyFolder;
|
||||
[SerializeField] private Marisa player;
|
||||
public Marisa player;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
|
@ -51,13 +54,14 @@ public class EnemySpawner : MonoBehaviour
|
|||
SpawnEnemy(enemiesToSpawn[Random.Range(0, enemiesToSpawn.Length)], spawnPoints[Random.Range(0, spawnPoints.Count)].position);
|
||||
}
|
||||
}
|
||||
else if (!canSpawn && bossEnemy)
|
||||
else if (!canSpawn && bossEnemy.health < 0)
|
||||
{
|
||||
if (Input.GetKey(KeyCode.E))
|
||||
{
|
||||
LevelSwitcher.instance.LoadShop();
|
||||
}
|
||||
}
|
||||
enemyLevel = (int)(Time.time / levelUpIntervals); //figure out the time.time thing because that's not gonna work here
|
||||
}
|
||||
|
||||
public Enemy SpawnEnemy(Enemy enemy, Vector3 location)
|
||||
|
|
|
|||
58
Assets/Scripts/Entities/Enemy/RusherEnemy.cs
Normal file
58
Assets/Scripts/Entities/Enemy/RusherEnemy.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
public class RusherEnemy : Enemy
|
||||
{
|
||||
private bool isRushing;
|
||||
public Vector2 lastTargetLocation;
|
||||
public Vector2 lastTargetDirection;
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (speedMultiplier <= 1.10f && closestTarget)
|
||||
{
|
||||
lastTargetLocation = closestTarget.transform.position;
|
||||
lastTargetDirection = (lastTargetLocation - (Vector2)transform.position).normalized;
|
||||
}
|
||||
|
||||
}
|
||||
protected override void FixedUpdate() //this is really bad.
|
||||
{
|
||||
if (!detectedPlayer && Vector3.Distance(transform.position, lastTargetLocation) < engagementRange)
|
||||
{
|
||||
detectedPlayer = true;
|
||||
}
|
||||
if (stalled || !closestTarget || !detectedPlayer)
|
||||
{
|
||||
rb.VelocityTowards(Vector2.zero.ScaleToMagnitude(speed), acceleration);
|
||||
}
|
||||
else if (speed > 1.10f && closestTarget)
|
||||
{
|
||||
rb.VelocityTowards(lastTargetDirection.ScaleToMagnitude(speed * speedMultiplier), acceleration);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 directionToTarget = (lastTargetLocation - (Vector2)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 * speedMultiplier), acceleration);
|
||||
FlipSprite(directionToMove);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Entities/Enemy/RusherEnemy.cs.meta
Normal file
2
Assets/Scripts/Entities/Enemy/RusherEnemy.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8f7666f7f9e3cad958069b3b00bd6879
|
||||
|
|
@ -11,6 +11,7 @@ public class Entity : MonoBehaviour
|
|||
public bool invincible;
|
||||
[Header("Stats")]
|
||||
public float health;
|
||||
public float baseMaxHealth; //for enemies, mostly.
|
||||
public float maxHealth;
|
||||
|
||||
[Header("Movement")]
|
||||
|
|
@ -18,6 +19,7 @@ public class Entity : MonoBehaviour
|
|||
[SerializeField] protected Rigidbody2D rb;
|
||||
protected Vector2 moveDirection;
|
||||
public float speed;
|
||||
public float speedMultiplier = 1f;
|
||||
|
||||
protected void FlipSprite(Vector2 lookDirection)
|
||||
{
|
||||
|
|
@ -36,7 +38,7 @@ public class Entity : MonoBehaviour
|
|||
{
|
||||
if (!stalled)
|
||||
{
|
||||
rb.linearVelocity = moveDirection * speed;
|
||||
rb.linearVelocity = moveDirection * (speed * speedMultiplier);
|
||||
FlipSprite(moveDirection);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class MarisaAbilityHandler : MonoBehaviour
|
|||
|
||||
[Header("Ability Instances")]
|
||||
public List<PlayerAbility> abilityInstances = new();
|
||||
|
||||
public Dictionary<String, PlayerAbility> instantiatedAbilityLookup = new();
|
||||
[Header("UI")]
|
||||
public AbilityHotbarIcon[] hotbarIcons;
|
||||
//this is getting ridiculous
|
||||
|
|
@ -23,6 +23,15 @@ public class MarisaAbilityHandler : MonoBehaviour
|
|||
SetupAbilities();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
hotbarIcons = FindObjectsByType<AbilityHotbarIcon>(FindObjectsSortMode.InstanceID);
|
||||
if (AbilitySceneTransfer.instance.savedAbilities.Count > 0)
|
||||
{
|
||||
LevelSwitcher.instance.SetupScene();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetupAbilities()
|
||||
{
|
||||
foreach (PlayerAbility oldAbility in abilityInstances)
|
||||
|
|
@ -37,6 +46,7 @@ public class MarisaAbilityHandler : MonoBehaviour
|
|||
abilityInstances.Add(newAbility);
|
||||
newAbility.thisPlayer = thisPlayer;
|
||||
hotbarIcons[currentAbilityCount].UpdateAbility(newAbility);
|
||||
instantiatedAbilityLookup[ability.abilityName] = ability;
|
||||
currentAbilityCount++;
|
||||
Debug.Log(ability.abilityName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ public class LevelSwitcher : MonoBehaviour
|
|||
AbilitySceneTransfer.instance.SaveAllAbilities();
|
||||
SceneManager.LoadScene(shopStage);
|
||||
SceneManager.LoadScene(uiStage, LoadSceneMode.Additive);
|
||||
SetupScene();
|
||||
}
|
||||
public void ChangeLevel()
|
||||
{
|
||||
|
|
@ -39,12 +38,13 @@ public class LevelSwitcher : MonoBehaviour
|
|||
AbilitySceneTransfer.instance.SaveAllAbilities();
|
||||
SceneManager.LoadScene(stages[currentStage]);
|
||||
SceneManager.LoadScene(uiStage, LoadSceneMode.Additive);
|
||||
SetupScene();
|
||||
}
|
||||
|
||||
public void SetupScene()
|
||||
{
|
||||
AbilitySceneTransfer.instance.abilityHandler = FindFirstObjectByType<MarisaAbilityHandler>();
|
||||
MarisaAbilityHandler abilityHandler = FindFirstObjectByType<MarisaAbilityHandler>();
|
||||
AbilityManager.instance.player = abilityHandler;
|
||||
AbilitySceneTransfer.instance.abilityHandler = abilityHandler;
|
||||
AbilitySceneTransfer.instance.LoadAbilities();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
Assets/Scripts/ShopKeeperInteractionRadius.cs
Normal file
27
Assets/Scripts/ShopKeeperInteractionRadius.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class ShopKeeperInteractionRadius : MonoBehaviour
|
||||
{
|
||||
private bool playerNearby;
|
||||
[SerializeField] private GameObject interactionIcon;
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
playerNearby = true;
|
||||
interactionIcon.SetActive(true);
|
||||
}
|
||||
|
||||
private void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
playerNearby = false;
|
||||
interactionIcon.SetActive(false);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (playerNearby && Input.GetKeyDown(KeyCode.E))
|
||||
{
|
||||
ShopManager.instance.OpenShopUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/ShopKeeperInteractionRadius.cs.meta
Normal file
2
Assets/Scripts/ShopKeeperInteractionRadius.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0bdd5df04b73a1d49895790a09b14f5d
|
||||
58
Assets/Scripts/ShopManager.cs
Normal file
58
Assets/Scripts/ShopManager.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ShopManager : MonoBehaviour
|
||||
{
|
||||
#region Statication
|
||||
|
||||
public static ShopManager instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (instance != null && instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
instance = this;
|
||||
DontDestroyOnLoad(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
public List<AbilityUpgrade> buyableUpgrades;
|
||||
public int currency; //uh. we need to figure out this one lol
|
||||
public GameObject shopUIObject;
|
||||
[SerializeField] private Marisa player;
|
||||
public void GenerateUpgradeList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void BuyUpgrade(AbilityUpgrade abilityToBuy)
|
||||
{
|
||||
if (currency >= abilityToBuy.cost)
|
||||
{
|
||||
AbilityManager.instance.upgradesInventory[abilityToBuy]++;
|
||||
currency -= abilityToBuy.cost;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void SellUpgrade(AbilityUpgrade abilityToSell)
|
||||
{
|
||||
AbilityManager.instance.upgradesInventory[abilityToSell]--;
|
||||
currency += abilityToSell.cost/2;
|
||||
}
|
||||
|
||||
public void OpenShopUI()
|
||||
{
|
||||
shopUIObject.SetActive(true);
|
||||
player.stalled = true;
|
||||
}
|
||||
|
||||
public void CloseShopUI()
|
||||
{
|
||||
shopUIObject.SetActive(false);
|
||||
player.stalled = false;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/ShopManager.cs.meta
Normal file
2
Assets/Scripts/ShopManager.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 608f31ca71d83048b93bab7cbc0d4d92
|
||||
Loading…
Add table
Add a link
Reference in a new issue