// Update is called once per frame
        void LateUpdate()
        {
            if (unit == null)
            {
                if (thisObj.activeInHierarchy)
                {
                    thisObj.SetActive(false);
                }
                return;
            }


            if (unit.IsDestroyed() || (unit.HP >= unit.GetFullHP() && unit.shield >= unit.GetFullShield()))
            {
                UIUnitOverlayManager.RemoveUnit(unit);
                unit = null;
                thisObj.SetActive(false);
                return;
            }


            if (!thisObj.activeInHierarchy)
            {
                return;
            }

            Vector3 screenPos = Camera.main.WorldToScreenPoint(unit.thisT.position + new Vector3(0, 1, 0));

            screenPos.z         = 0;
            rectT.localPosition = screenPos * UIMainControl.GetScaleFactor();

            sliderHP.value     = (unit.HP / unit.GetFullHP());
            sliderShield.value = (unit.shield / unit.GetFullShield());
        }
        //stats processing for attack from fps-weapon
        public void Process_SrcWeapon()
        {
            if (srcWeapon.GetInstantKill().IsApplicable(tgtUnit.HP, tgtUnit.GetFullHP()))
            {
                damage      = tgtUnit.HP;
                damageHP    = tgtUnit.HP;
                instantKill = true;
                destroy     = true;
                return;
            }

            damage  = Random.Range(srcWeapon.GetDamageMin(), srcWeapon.GetDamageMax());
            damage /= (float)srcWeapon.GetShootPointCount();            //divide the damage by number of shootPoint

            float critChance = srcWeapon.GetCritChance();

            if (tgtUnit.immuneToCrit)
            {
                critChance = -1f;
            }
            if (Random.Range(0f, 1f) < critChance)
            {
                critical = true;
                damage  *= srcWeapon.GetCritMultiplier();
                //new TextOverlay(impactPoint, "Critical", new Color(1f, .6f, 0f, 1f));
            }

            float dmgModifier = DamageTable.GetModifier(tgtUnit.armorType, srcWeapon.damageType);

            damage *= dmgModifier;

            if (damage >= tgtUnit.shield)
            {
                damageShield = tgtUnit.shield;
                damageHP     = damage - tgtUnit.shield;
            }
            else
            {
                damageShield = damage;
                damageHP     = 0;
            }


            if (Random.Range(0f, 1f) < srcWeapon.GetShieldPierce() && damageShield > 0)
            {
                damageHP    += damageShield;
                damageShield = 0;
                pierceShield = true;
                //new TextOverlay(impactPoint,"Shield Pierced", new Color(0f, 1f, 1f, 1f));
            }
            if (srcWeapon.DamageShieldOnly())
            {
                damageHP = 0;
            }

            if (damageHP >= tgtUnit.HP)
            {
                destroy = true;
                return;
            }

            if (Random.Range(0f, 1f) < srcWeapon.GetShieldBreak() && tgtUnit.defaultShield > 0)
            {
                breakShield = true;
            }

            stunned = srcWeapon.GetStun().IsApplicable();
            if (tgtUnit.immuneToStun)
            {
                stunned = false;
            }

            slowed = srcWeapon.GetSlow().IsValid();
            if (tgtUnit.immuneToSlow)
            {
                slowed = false;
            }

            if (srcWeapon.GetDot().GetTotalDamage() > 0)
            {
                dotted = true;
            }


            if (stunned)
            {
                stun = srcWeapon.GetStun().Clone();
            }
            if (slowed)
            {
                slow = srcWeapon.GetSlow().Clone();
            }
            if (dotted)
            {
                dot = srcWeapon.GetDot().Clone();
            }
        }