public void ReceiveIncidentalDamage(int damage, MagicElemancy element)
    {
        DamageInfo damageInfo = ResolveDamageUnitAGivesUnitB(this.Properties, this.Properties, damage);
        int        dmg        = (int)damageInfo.TotalDamage;

        this.Properties.ChangeHealth(-dmg);
        this.SpawnDamageParticles(element);

        CoreUIManager.Instance.SpawnText(dmg.ToString(), this.gameObject, CoreUIManager.Instance.PlayerTakeDamageColor, 1.6f);
    }
    public void SpawnDamageParticles(MagicElemancy element)
    {
        if (ParticleSpawnPoint == null)
        {
            return;
        }

        var muzzleVFX = Instantiate(CoreUIManager.Instance.ParticleMuzzle, ParticleSpawnPoint.transform.position, Quaternion.identity);

        switch (element)
        {
        case MagicElemancy.None:
            Instantiate(CoreUIManager.Instance.ParticleBounce, ParticleSpawnPoint.transform.position, Quaternion.identity);
            break;

        case MagicElemancy.Fire:
            Instantiate(CoreUIManager.Instance.ParticleFire, ParticleSpawnPoint.transform.position, Quaternion.identity);
            break;

        case MagicElemancy.Water:
            break;

        case MagicElemancy.Lighting:
            break;

        case MagicElemancy.Blizzard:
            break;

        default:
            break;
        }

        var muzzleParticle = muzzleVFX.GetComponent <ParticleSystem>();

        if (muzzleParticle != null)
        {
            Destroy(muzzleVFX, muzzleParticle.main.duration);
        }
    }
    public void DoDamageAttack(int damage, MagicElemancy element, GameObject target, float fontIncrement = 0, bool isSpecialDamage = false)
    {
        if (isPlayer)
        {
            ChainBarDisplayController.Instance.AddToChainBar(1.5f);
        }

        RPGActor targetActor = target.GetComponent <RPGActor>();

        //If target is not engaged, engage it with this actor
        if (targetActor.State == ActorState.Idle)
        {
            if (target.tag == "Player" /* && GameManager.Instance.CurrentState == GameManager.Instance.StateIdle */)
            {
                targetActor.SetSoftTarget(this.gameObject);
                GameManager.Instance.Log("Attacked target is a player who was idle, now entering battle state and showing UI");
            }

            this.TargetObject = target; //Set current target to this enemy
            targetActor.SetTarget(this.gameObject);
            targetActor.EngageTarget(); //notify the enemy.
        }
        else if (targetActor.State == ActorState.Engaged)
        {
            AddToEngaged(target); //When target is already in battle, add to engaged but don't set the current target
        }

        //
        var playerShoot = GetComponent <PlayerShoot>();

        if (playerShoot != null && target != null)
        {
            //playerShoot.TargetObject = target;
            playerShoot.ShootBullet(target);
        }

        DamageInfo damageInfo = ResolveDamageUnitAGivesUnitB(this.Properties, targetActor.Properties, damage);
        int        dmg        = (int)damageInfo.TotalDamage;

        targetActor.Properties.ChangeHealth(-dmg);
        targetActor.SpawnDamageParticles(element);

        if (fontIncrement == 0)
        {
            fontIncrement = damageInfo.CritMultiplier * 1.3f;

            //for auto attack size variation
            if (damage == 1)
            {
                fontIncrement *= 0.6f;
            }
            if (damage == 2)
            {
                fontIncrement *= 0.9f;
            }
            if (damage == 3)
            {
                fontIncrement *= 1.1f;
            }

            if (damage > 5)
            {
                fontIncrement *= 1.6f;
            }
        }

        Color playerDMG  = CoreUIManager.Instance.PlayerTakeDamageColor;
        Color enemyDMG   = CoreUIManager.Instance.EnemyTakeDamageColor;
        Color specialDMG = CoreUIManager.Instance.SpecialDamageColor;

        if (isSpecialDamage)
        {
            CoreUIManager.Instance.SpawnText(dmg.ToString(), target, specialDMG, 2.6f);
        }
        else if (this.tag == "Enemy")
        {
            CoreUIManager.Instance.SpawnText(dmg.ToString(), target, playerDMG, fontIncrement);
        }
        else
        {
            CoreUIManager.Instance.SpawnText(dmg.ToString(), target, enemyDMG, fontIncrement);
        }
    }
 public void DoDamageAttackOnCurrentTarget(int skillDamage, MagicElemancy element, float fontIncrement = 0)
 {
     DoDamageAttack(skillDamage, element, TargetObject);
 }