The Greatest Game Dev To Have Ever Lived
This commit is contained in:
parent
fada3af715
commit
00e65ff31f
16 changed files with 398 additions and 37 deletions
|
|
@ -42,7 +42,8 @@ public class ActionUIHandler : MonoBehaviour
|
|||
[SerializeField] private Button attackButton;
|
||||
[SerializeField] private Button reloadButton;
|
||||
[SerializeField] private Button switchButton;
|
||||
[SerializeField] private Button officerAbilityButton;
|
||||
[SerializeField] private Button classAbilityButton;
|
||||
[SerializeField] private TextMeshProUGUI classAbilityLabel;
|
||||
|
||||
[Header("Weapon Switcher")]
|
||||
[SerializeField] private RectTransform weaponUIPanel;
|
||||
|
|
@ -89,10 +90,11 @@ public class ActionUIHandler : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
officerAbilityButton.gameObject.SetActive(false);
|
||||
if (selectedEntity.officerInstance)
|
||||
classAbilityButton.gameObject.SetActive(false);
|
||||
if (selectedEntity.abilityInstance)
|
||||
{
|
||||
officerAbilityButton.gameObject.SetActive(true);
|
||||
classAbilityButton.gameObject.SetActive(true);
|
||||
classAbilityLabel.text = selectedEntity.abilityInstance.abilityName;
|
||||
}
|
||||
moveButton.gameObject.SetActive(true);
|
||||
switchButton.gameObject.SetActive(true);
|
||||
|
|
@ -137,9 +139,9 @@ public class ActionUIHandler : MonoBehaviour
|
|||
HideUI();
|
||||
}
|
||||
|
||||
public void ActivateOfficer()
|
||||
public void ActivateClassAbility()
|
||||
{
|
||||
selectedEntity.officerInstance.ActivateAbility();
|
||||
selectedEntity.abilityInstance.TryAbility();
|
||||
}
|
||||
public void SkipTurn()
|
||||
{
|
||||
|
|
|
|||
16
Assets/Scripts/ClassAbility.cs
Normal file
16
Assets/Scripts/ClassAbility.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class ClassAbility : MonoBehaviour
|
||||
{
|
||||
public string abilityName;
|
||||
public PlayerEntity thisEntity;
|
||||
public virtual void TryAbility()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected virtual void AbilityEffects()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/ClassAbility.cs.meta
Normal file
2
Assets/Scripts/ClassAbility.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fc8d15189dbb82d06ab5b16e381ec83d
|
||||
15
Assets/Scripts/ConstructAbility.cs
Normal file
15
Assets/Scripts/ConstructAbility.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class ConstructAbility : ClassAbility
|
||||
{
|
||||
[SerializeField] private Construction building;
|
||||
public override void TryAbility()
|
||||
{
|
||||
AbilityEffects();
|
||||
}
|
||||
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
Instantiate(building, transform.position, Quaternion.identity);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/ConstructAbility.cs.meta
Normal file
2
Assets/Scripts/ConstructAbility.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 093bb0b035a9e08d6bc85b8b5b110027
|
||||
5
Assets/Scripts/Construction.cs
Normal file
5
Assets/Scripts/Construction.cs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class Construction : Entity
|
||||
{
|
||||
}
|
||||
2
Assets/Scripts/Construction.cs.meta
Normal file
2
Assets/Scripts/Construction.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6ae998986ae9a0893a2de369d0a943e6
|
||||
32
Assets/Scripts/HealAbility.cs
Normal file
32
Assets/Scripts/HealAbility.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class HealAbility : ClassAbility
|
||||
{
|
||||
private PlayerEntity thisPlayer;
|
||||
[SerializeField] private float healingAmount;
|
||||
[SerializeField] private int suppliesMax;
|
||||
public int currentSupplies;
|
||||
|
||||
public override void TryAbility()
|
||||
{
|
||||
if (currentSupplies > 0)
|
||||
{
|
||||
currentSupplies--;
|
||||
AbilityEffects();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void AbilityEffects()
|
||||
{
|
||||
HealPlayer();
|
||||
}
|
||||
|
||||
public void HealPlayer()
|
||||
{
|
||||
PlayerEntity closestPlayer = thisPlayer.GetAdjacentPlayers();
|
||||
if (closestPlayer)
|
||||
{
|
||||
closestPlayer.Heal(healingAmount); //insane code, i know.
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/HealAbility.cs.meta
Normal file
2
Assets/Scripts/HealAbility.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8ec3e66b2a18ee85c963a43c95b592d2
|
||||
|
|
@ -5,9 +5,10 @@ using UnityEngine;
|
|||
|
||||
public class MeleeWeapon : Weapon
|
||||
{
|
||||
public LayerMask entityLayer;
|
||||
[SerializeField] private Rigidbody2D rb;
|
||||
[SerializeField] private GameObject debugColliderHitbox;
|
||||
[SerializeField] private Vector2 colliderSize;
|
||||
[SerializeField] private List<Enemy> enemiesInRange = new();
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
|
@ -15,17 +16,14 @@ public class MeleeWeapon : Weapon
|
|||
{
|
||||
Vector2 mouseWorldPos = PlayerEntityMovement.instance.mouseWorldPos; //using this so i don't have to paste in and recalculate the variable on something i already have lol
|
||||
debugColliderHitbox.gameObject.SetActive(true);
|
||||
transform.Lookat2D(mouseWorldPos);
|
||||
Vector2 direction = mouseWorldPos - (Vector2)transform.position;
|
||||
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; //did you know i sucked at trig? because i don't understand this lol ;
|
||||
rb.rotation = angle;
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
RaycastHit2D[] enemyList = Physics2D.BoxCastAll(transform.position, colliderSize, Vector3.Angle(transform.position, mouseWorldPos),
|
||||
PlayerEntityMovement.instance.mouseWorldPos, 2, entityLayer);
|
||||
foreach (RaycastHit2D enemy in enemyList)
|
||||
foreach (Enemy enemy in enemiesInRange)
|
||||
{
|
||||
if (!enemy.transform.CompareTag(tag) && enemy.transform.TryGetComponent(out Entity isEntity))
|
||||
{
|
||||
isEntity.TakeDamage(damage, thisEntity);
|
||||
}
|
||||
enemy.TakeDamage(damage, thisEntity);
|
||||
}
|
||||
isAiming = false;
|
||||
thisEntity.actions--;
|
||||
|
|
@ -47,4 +45,20 @@ public class MeleeWeapon : Weapon
|
|||
{
|
||||
isAiming = true;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(tag) && other.TryGetComponent(out Enemy isEnemy))
|
||||
{
|
||||
enemiesInRange.Add(isEnemy);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(tag) && other.TryGetComponent(out Enemy isEnemy) && enemiesInRange.Contains(isEnemy))
|
||||
{
|
||||
enemiesInRange.Remove(isEnemy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class OfficerAbilities : MonoBehaviour
|
||||
public class OfficerAbilities : ClassAbility
|
||||
{
|
||||
public PlayerEntity thisEntity;
|
||||
[Header("Kills")]
|
||||
[SerializeField] private int killQuota;
|
||||
private int currentKills;
|
||||
|
|
@ -36,7 +35,7 @@ public class OfficerAbilities : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
public void ActivateAbility()
|
||||
public override void TryAbility()
|
||||
{
|
||||
if (currentKills >= killQuota)
|
||||
{
|
||||
|
|
@ -46,11 +45,6 @@ public class OfficerAbilities : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
protected virtual void AbilityEffects()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected virtual void DeactivateAbility()
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ public class PlayerEntity : Entity
|
|||
[SerializeField] private Weapon[] weapons;
|
||||
[HideInInspector] public List<Weapon> weaponInstances = new();
|
||||
public Weapon currentWeapon;
|
||||
[Header("OfficerAbilities")]
|
||||
[SerializeField] private OfficerAbilities officerAbility;
|
||||
[HideInInspector] public OfficerAbilities officerInstance;
|
||||
[Header("Class Abilities")]
|
||||
[SerializeField] private ClassAbility classAbility;
|
||||
[HideInInspector] public ClassAbility abilityInstance;
|
||||
[Header("UI")]
|
||||
[SerializeField] private Transform hpBar;
|
||||
public GameObject debugDoneObject;
|
||||
|
|
@ -30,8 +30,8 @@ public class PlayerEntity : Entity
|
|||
|
||||
if (selectedClass == PlayerClass.Officer)
|
||||
{
|
||||
officerInstance = Instantiate(officerAbility, transform);
|
||||
officerInstance.thisEntity = this;
|
||||
abilityInstance = Instantiate(classAbility, transform);
|
||||
abilityInstance.thisEntity = this;
|
||||
}
|
||||
currentWeapon = weaponInstances[0];
|
||||
}
|
||||
|
|
@ -84,4 +84,16 @@ public class PlayerEntity : Entity
|
|||
ActionUIHandler.instance.ShowUI(this);
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerEntity GetAdjacentPlayers()
|
||||
{
|
||||
foreach (TileObject neighbor in currentTile.neighbors)
|
||||
{
|
||||
if (neighbor.hasUnit && neighbor.hasUnit is PlayerEntity)
|
||||
{
|
||||
return neighbor.hasUnit as PlayerEntity; //i'll uh, make it return a list later this is just a quick way.
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue