using System.Collections.Generic; using UnityEngine; public class PlayerEntity : Entity { [Header("Player Flags")] public bool hasMoved = false; public bool hasAttacked = false; [Header("Weaponry")] [SerializeField] private Weapon[] weapons; private List weaponInstances = new(); public Weapon currentWeapon; [Header("UI")] [SerializeField] private Transform hpBar; void Start() { foreach (Weapon weapon in weapons) { Weapon newWeapon = Instantiate(weapon, transform); newWeapon.thisEntity = this; newWeapon.tag = tag; weaponInstances.Add(newWeapon); } currentWeapon = weaponInstances[0]; } // Update is called once per frame void Update() { } public override void TakeDamage(float amount) { base.TakeDamage(amount); UpdateHealthUI(); } public void UpdateHealthUI() { hpBar.localScale = new Vector3(health/maxHealth, 1f, 1f); } public void SkipTurn() { hasMoved = true; hasAttacked = true; TurnHandler.instance.UpdateTurns(); } public void Attack() { currentWeapon.TryAttack(); } public void SwitchWeapon() { } protected override void FinishedMovement() { base.FinishedMovement(); TurnHandler.instance.UpdateTurns(); if (!ActionUIHandler.instance.opened) { ActionUIHandler.instance.ShowUI(this); } } private void OnMouseDown() { if ((!hasMoved || !hasAttacked) && !PlayerEntityMovement.instance.isMoving) { ActionUIHandler.instance.ShowUI(this); } } }