private void Awake() { unitRigidBody2D = ((Unit_)owner).rigidbody2D_; stats_ = (UnitStats_)((Unit_)owner).mechanics_.stats_; unitAnimator = GetUnitAnimator(); inventory_ = (UnitInventory_)((Unit_)owner).inventory_; target = owner.transform.position; }
public virtual void Hit(Unit_ unit) { UnitStats_ unitStats = (UnitStats_)unit.mechanics_.stats_; unitStats.hp -= stats_.GetHitDamage() / 2; unit.graphics_.inGame_.animator.SetFloat("hp", unitStats.hp); ((UnitBehaviour_)unit.mechanics_.behaviour_).GetEquippedItemAnimators().ForEach(t => t.SetFloat("hp", unitStats.hp)); if (unit.GetType() == typeof(Player_)) { PlayerBottomUiMiddleContainer_ playerBottomUiMiddleContainer_ = (PlayerBottomUiMiddleContainer_)unit.graphics_.ui.bottomUI.GetComponent <PlayerBottomUi_>().playerBottomUiMiddleContainer_; playerBottomUiMiddleContainer_.healthBarContainer.slider.value = unitStats.hp; } else if (unit.GetType() == typeof(Npc_)) { NpcBottomUiLeftContainer_ npcBottomUiLeftContainer_ = (NpcBottomUiLeftContainer_)unit.graphics_.ui.bottomUI.GetComponent <NpcBottomUi_>().leftContainer_; npcBottomUiLeftContainer_.barContainers.hpBar.value = unitStats.hp; } }