using System.Collections.Generic; using UnityEngine; public class PlayerEntity : Entity { [Header("Player Flags")] public int actions = 2; public int maxActions = 2; [Header("Weaponry")] [SerializeField] private Weapon[] weapons; [HideInInspector] public 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() { actions = 0; TurnHandler.instance.UpdateTurns(); } public void Attack() { currentWeapon.TryAttack(); } public void SwitchWeapon(Weapon requestedWeapon) { currentWeapon = requestedWeapon; } protected override void FinishedMovement() { base.FinishedMovement(); TurnHandler.instance.UpdateTurns(); if (!ActionUIHandler.instance.opened) { ActionUIHandler.instance.ShowUI(this); } } private void OnMouseDown() { if (actions > 0 && !PlayerEntityMovement.instance.isMoving) { ActionUIHandler.instance.ShowUI(this); } } }