public IEnumerator FinalHitUnit(UnitBehevior Target, float second)
    {
        float ambushValue = 1;

        if (_selfUnit.manager.CorrectUnit != _selfUnit)
        {
            ambushValue = 0.80f;
        }
        yield return(new WaitForSeconds(second));

        if (Target == null)
        {
            if (_selfUnit.manager.CorrectUnit = _selfUnit)
            {
                _selfUnit.manager.EndTurn();
            }
            yield break;
        }
        float   n = Random.Range(0, 100);
        Shelter _shelter;

        float DistanceTarget = Vector3.Distance(_selfUnit.transform.position, Target.transform.position + Vector3.up * (Random.Range(-5, 11) / 20f));

        float Range = NormalDistance / DistanceTarget;

        if (Range > 1)
        {
            Range = 1;
        }
        if (n < Range * 100f * ambushValue + _selfUnit.Skills[TypeWeapon] - Target.GetShelterLevel())
        {
            Target.GetHit(Damage, TypeWeapon);
        }
        else
        {
            if (Random.Range(0, 101) > Target.GetShelterLevel() * 0.75f)
            {
                Target.GetShelterLevel(out _shelter);

                if (_shelter != null)
                {
                    Instantiate(_shelter.FX, _shelter.transform.position, Quaternion.identity);

                    _shelter.ShelterLevl -= Damage * 3;
                    if (_shelter.ShelterLevl < 1)
                    {
                        Destroy(_shelter.gameObject);
                    }
                }
            }
            Target.GetHit(0, 999);
        }
        if (_prevAmmoCount == _lastAmmoCount)
        {
            _selfUnit.manager.EndTurn();
        }
    }
Example #2
0
    private int GetPointCord(int x, int y, out UnitBehevior target)
    {
        target = null;
        try
        {
            target = GridManager.GridOfArena[x, y].UnitOnNode;
        }
        catch { }

        if (target != null && !target.Enemy)
        {
            WeaponData wp     = Weapon.data;
            int        result = (int)
                                (wp.Damage * wp.BulletPerShoot                                                                        // Урон вчистом виде
                                 * Mathf.Clamp01((wp.NormalDistance / Vector3.Distance(target.transform.position, transform.position) // Учет дистанции
                                                  + Skills[wp.TypeWeapon] - target.GetShelterLevel())                                 // Учет навыков и защищщенности цели
                                                 * target.GetHeltyTarget()));                                                         // Учет процента жизней
            return(result);
        }
        return(0);
    }