too many if statements
This commit is contained in:
parent
533f137c48
commit
17b1a1e367
7 changed files with 55 additions and 20 deletions
|
|
@ -182,6 +182,9 @@ MonoBehaviour:
|
|||
moveAnimSpeed: 10
|
||||
canMove: 1
|
||||
invincible: 0
|
||||
spriteRenderers:
|
||||
- {fileID: 6433073964262250546}
|
||||
damageColorChangeSpeed: 4
|
||||
turnSpeed: 1
|
||||
minimumAttackRange: 1.5
|
||||
damage: 10
|
||||
|
|
|
|||
|
|
@ -436,6 +436,9 @@ MonoBehaviour:
|
|||
moveAnimSpeed: 10
|
||||
canMove: 1
|
||||
invincible: 0
|
||||
spriteRenderers:
|
||||
- {fileID: 3017941309338641158}
|
||||
damageColorChangeSpeed: 4
|
||||
hasMoved: 0
|
||||
hasAttacked: 0
|
||||
weapons:
|
||||
|
|
|
|||
|
|
@ -48,36 +48,36 @@ public class ActionUIHandler : MonoBehaviour
|
|||
}
|
||||
|
||||
public void UpdateUI()
|
||||
{
|
||||
if (!selectedEntity.hasAttacked)
|
||||
{
|
||||
if (selectedEntity.currentWeapon.TryGetComponent(out RangedWeapon isRanged))
|
||||
{
|
||||
possibleRanged = isRanged;
|
||||
}
|
||||
if (!isRanged || !isRanged.fired)
|
||||
if ((!isRanged || !isRanged.fired) && !selectedEntity.hasAttacked)
|
||||
{
|
||||
attackButton.gameObject.SetActive(true);
|
||||
reloadButton.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
attackButton.gameObject.SetActive(false);
|
||||
}
|
||||
if (isRanged && isRanged.fired)
|
||||
{
|
||||
if (selectedEntity.hasMoved || selectedEntity.hasAttacked)
|
||||
{
|
||||
reloadButton.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
attackButton.gameObject.SetActive(false);
|
||||
reloadButton.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!selectedEntity.hasMoved || !selectedEntity.hasAttacked)
|
||||
{
|
||||
moveButton.gameObject.SetActive(true);
|
||||
switchButton.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
reloadButton.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
if (selectedEntity.hasAttacked && selectedEntity.hasMoved)
|
||||
{
|
||||
HideUI();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using UnityEngine;
|
|||
|
||||
public class Enemy : Entity
|
||||
{
|
||||
[Header("Enemy Stats")]
|
||||
public int turnSpeed;
|
||||
public float minimumAttackRange;
|
||||
private PlayerEntity closestPlayer;
|
||||
|
|
|
|||
|
|
@ -11,15 +11,20 @@ public class Entity : MonoBehaviour
|
|||
[Header("Movement")]
|
||||
public int maxMovement;
|
||||
public TileObject currentTile;
|
||||
public float moveAnimSpeed;
|
||||
[SerializeField] private float moveAnimSpeed;
|
||||
|
||||
[Header("Flags")]
|
||||
public bool canMove = true;
|
||||
public bool invincible;
|
||||
|
||||
[Header("Animation")]
|
||||
[SerializeField] private SpriteRenderer[] spriteRenderers;
|
||||
[SerializeField] private float damageColorChangeSpeed;
|
||||
|
||||
public virtual void TakeDamage(float damage)
|
||||
{
|
||||
health -= damage;
|
||||
StartCoroutine(DamageAnimation());
|
||||
if (health <= 0)
|
||||
{
|
||||
OnKillEffects();
|
||||
|
|
@ -61,4 +66,20 @@ public class Entity : MonoBehaviour
|
|||
}
|
||||
FinishedMovement();
|
||||
}
|
||||
private IEnumerator DamageAnimation()
|
||||
{
|
||||
float currentState = 0;
|
||||
while (currentState < 1)
|
||||
{
|
||||
currentState += Time.deltaTime * damageColorChangeSpeed;
|
||||
foreach (SpriteRenderer spritepart in spriteRenderers)
|
||||
{
|
||||
if (spritepart)
|
||||
{
|
||||
spritepart.color = Color.Lerp(Color.gray, Color.white, currentState);
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ public class RangedWeapon : Weapon
|
|||
{
|
||||
private Camera cam;
|
||||
private Vector3 mousePos;
|
||||
[Header("Ranged Weapon Specifics")]
|
||||
public bool fired;
|
||||
public bool isAiming;
|
||||
[SerializeField] private Projectile projectile;
|
||||
private void Start()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,8 +2,15 @@ using UnityEngine;
|
|||
|
||||
public class Weapon : MonoBehaviour
|
||||
{
|
||||
[Header("Identification")]
|
||||
public string weaponName;
|
||||
[Header("Cache")]
|
||||
public bool isAiming;
|
||||
public PlayerEntity thisEntity;
|
||||
|
||||
[Header("Stats")]
|
||||
public float damage;
|
||||
|
||||
public virtual void TryAttack()
|
||||
{
|
||||
AttackEffects();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue