public void OpenMenu(List <UnitData> _unitList, List <WeaponData> _weaponList)
    {
        transform.GetChild(0).gameObject.SetActive(true);

        UnitsCanUse       = new UnitBehevior[_unitList.Count];
        WeaponCanUse      = new WeaponBehevior[_weaponList.Count];
        WeaponCanUseCount = new List <int> ();

        for (int i = 0; i < _unitList.Count; i++)
        {
            WeaponCanUse[i]      = Instantiate(_emptyPrefabOfWeapon, Vector3.one * 1000, Quaternion.identity, transform);
            WeaponCanUse[i].data = _weaponList[i];
            WeaponCanUse[i].ChekDataMetod();
            WeaponCanUseCount.Add(99);
        }

        for (int i = 0; i < _unitList.Count; i++)
        {
            UnitsCanUse[i]      = Instantiate(_emptyPrefabOfUnit, Vector3.one * 1000, Quaternion.identity, transform);
            UnitsCanUse[i].data = _unitList[i];
            UnitsCanUse[i].ChekDataMetod();
        }

        DontDestroyOnLoad(gameObject);
        UnitThis   = Instantiate(UnitsCanUse[UnitTurn], transform);
        WeaponThis = Instantiate(WeaponCanUse[WeaponTurn], transform);

        Refresh();
    }
    public void OpenMenu()
    {
        UnitsCanUse = G_UnitsCanUse;

        WeaponCanUse      = G_WeaponCanUse;
        WeaponCanUseCount = new List <int> ();
        for (int i = 0; i < WeaponCanUse.Length; i++)
        {
            WeaponCanUseCount.Add(Save.GetCoutInventory(WeaponCanUse[i].data.name, 1));
        }
        UnitsCanUse     = G_UnitsCanUse;
        UnitsCanUseCout = new List <int> ();
        for (int i = 0; i < UnitsCanUse.Length; i++)
        {
            UnitsCanUseCout.Add(Save.GetCoutInventory(UnitsCanUse[i].data.name, 2));
        }

        GameObject.DontDestroyOnLoad(this.gameObject);
        UnitThis = Instantiate(UnitsCanUse[UnitTurn], transform);
        UnitThis.transform.position = Vector3.one * 1000;

        WeaponThis = Instantiate(WeaponCanUse[WeaponTurn], transform);
        WeaponThis.transform.position = Vector3.one * 1000;
        Refresh();

        MissInit();
    }
    void SpellPerc(UnitBehevior Target)
    {
        switch (CAParm)
        {
        case 0:
            Target._effectOnUnit.MakeFired(PowerPerc, Duratin);
            break;


        case 1:
            Target._effectOnUnit.MakePoisend(PowerPerc, Duratin);
            break;


        case 2:
            Target._effectOnUnit.MakeStuned(Duratin);
            break;

        case 3:
            Target._effectOnUnit.MakeElectricShock(PowerPerc);
            break;

        case 4:
            Target._effectOnUnit.HealHuman(PowerPerc);
            break;
        }
    }
    bool IsTarget(UnitBehevior _testTarget)
    {
        switch (BAPram)
        {
        case 0:
            if (_testTarget == manager.CorrectUnit)
            {
                return(true);
            }
            break;

        case 1:
            if (_testTarget.Enemy != manager.CorrectUnit.Enemy)
            {
                return(true);
            }
            break;

        case 2:
            if (_testTarget.Enemy == manager.CorrectUnit.Enemy)
            {
                return(true);
            }
            break;
        }
        return(false);
    }
    void GetUnit()
    {
        UnitThis = Instantiate <UnitBehevior> (UnitsCanUse[UnitTurn], transform);
        UnitThis.transform.position = Vector3.one * 1000;

        UnitText.text    = UnitsCanUse[UnitTurn].name;
        UnitImage.sprite = UnitThis.transform.Find("Body").GetComponent <SpriteRenderer> ().sprite;
        AllText[0].text  = "Helty:" + UnitThis.data.Helty;
        AllText[1].text  = "Shild:" + UnitThis.data.Shild;
        AllText[2].text  = "Armor:" + UnitThis.data.Armor;
        AllText[3].text  = "Armor qulity:" + UnitThis.ArmorQulity;
        AllText[4].text  = "Skill for this weapon:" + UnitThis.Skills[WeaponThis.TypeWeapon];
        AllText[9].text  = "Unit Cost:" + UnitThis.WhatACost();

        AllText[10].text = "Unit and Weapon Cost:" + (UnitThis.WhatACost() + WeaponThis.WhatACost());
        AllText[13].text = UnitThis.data.PercOfUnit.Discription;
        AllText[14].text = "";
        for (int i = 0; i < 6; i++)
        {
            AllText[14].text += GetWeaponType(i) + " : " + UnitThis.Skills[i] + "\n";
        }
        AllText[15].text = UnitThis.data.Discription;
        AllText[16].text = UnitThis.data.PercOfUnit.name;
        AllText[17].text = "кол-во:" + UnitsCanUseCout[UnitTurn];
    }
    public void Shoot(UnitBehevior Target)
    {
        if (Target == null)
        {
            return;
        }

        GameObject    BulletObject;
        TrailRenderer BulletT;

        _audioSource.clip = WeaponSound;
        _audioSource.Play();

        BulletObject = Instantiate(BulletObjectStandart, transform.GetChild(0).position, Quaternion.identity);

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

        Load = Load - 1;
        _selfUnit.candosomething = false;
        StartCoroutine(FinalHitUnit(Target, DistanceTarget / 25f));
        StartCoroutine(Shooting(Target, Target.transform.position + Vector3.up * (Random.Range(-5, 11) / 20f), DistanceTarget, n, BulletObject));

        BulletT            = BulletObject.GetComponent <TrailRenderer> ();
        BulletT.startColor = BulletColor;
    }
    public void NextLevel()
    {
        if (WeaponCanUseCount[WeaponTurn] != 0)
        {
            if (UnitNumber > 3)
            {
                SetEnemy(untTest, wepTest);

                LoadManger.StartLoading(2);
            }
            else
            {
                WeaponCanUseCount[WeaponTurn] -= 1;
                UnitsCanUseCout[UnitTurn]     -= 1;

                UnitBehevior UnitVar = Instantiate(UnitThis, transform);
                UnitVar.transform.position = Vector3.one * 1000;
                WeaponBehevior WeaponVar = Instantiate(WeaponThis, UnitVar.transform);
                WeaponVar.name = WeaponVar.data.name.Remove(0, 2) + " : " + Random.Range(0, 1001);
                WeaponVar.transform.localPosition = Vector3.zero + Vector3.up * 0.091f;
                WeaponVar.transform.localScale    = Vector3.one;
                WeaponVar.transform.eulerAngles   = Vector3.zero;
                UnitVar.Weapon           = WeaponVar;
                UnitConfirmd[UnitNumber] = UnitVar.gameObject;
                UnitNumber = UnitNumber + 1;
                GetComponent <AudioSource> ().Play();
                UnitVar.Enemy = false;
                Refresh();
            }
        }
    }
Exemple #8
0
    private int TestPointOnShoot(int x, int y, out UnitBehevior Target)
    {
        var          mainPoint  = 0;
        var          localPoint = 0;
        UnitBehevior mainTarget = null;
        UnitBehevior localTarget;

        for (var d = 0; d < 4; d++)
        {
            for (var i = 1; i <= Weapon.MaxDistance; i++)
            {
                var nodes = GridManager.GridOfArena[x + i * MPAer(d, true), y + i * MPAer(d, false)];

                if (nodes._Bloc == NodeA.TypeOfNode.Wall)
                {
                    break;
                }
                else
                {
                    localPoint = GetPointCord(nodes.x1, nodes.y1, out localTarget);
                    if (localPoint > mainPoint)
                    {
                        mainPoint  = localPoint;
                        mainTarget = localTarget;
                    }
                    if (nodes.UnitOnNode != null && i >= 1)
                    {
                        break;
                    }
                }
            }
        }
        Target = mainTarget;
        return(mainPoint);
    }
Exemple #9
0
    public void MaxMovement(Vector3 UnitPosition, int MaxUnitMove, UnitBehevior Unit)  //показывает возможно движение
    {
        CleatGrid();

        int x = 0, y = 0;

        NodeCoordinat(UnitPosition, out x, out y);
        for (var d = 0; d < 4; d++)
        {
            for (var i = 0; i <= MaxUnitMove; i++)
            {
                var nodes = GridOfArena[x + i * MPAer(d, true), y + i * MPAer(d, false)];
                if (nodes._Bloc == 0 &&
                    nodes.UnitOnNode == null)
                {
                    WalkableArea.Add(nodes);
                    MoveMentList.Add(new Vector2(nodes.x1, nodes.y1));
                }
                if (nodes._Bloc == NodeA.TypeOfNode.Wall)
                {
                    break;
                }
            }
        }
        CreateNodeShow(Color.green);
    }
    void LoadDataFromRes()
    {
        AllUnitsCanUse = new UnitBehevior[Resources.LoadAll <UnitData> ("UnitData").Length];

        int i = 0;

        foreach (UnitData n in Resources.LoadAll <UnitData> ("UnitData"))
        {
            AllUnitsCanUse[i]      = Instantiate(_emptyPrefabOfUnit, Vector3.one * 1000, Quaternion.identity, transform);
            AllUnitsCanUse[i].data = n;
            AllUnitsCanUse[i].ChekDataMetod();
            AllUnitsCanUse[i].name = AllUnitsCanUse[i].data.name.Remove(0, 2);
            i += 1;
        }

        AllWeaponCanUse = new WeaponBehevior[Resources.LoadAll <WeaponData> ("WeaponData").Length];

        i = 0;
        foreach (WeaponData n in Resources.LoadAll <WeaponData> ("WeaponData"))
        {
            AllWeaponCanUse[i]      = Instantiate(_emptyPrefabOfWeapon, Vector3.one * 1000, Quaternion.identity, transform);
            AllWeaponCanUse[i].data = n;
            AllWeaponCanUse[i].ChekDataMetod();
            AllWeaponCanUse[i].name = AllWeaponCanUse[i].data.name.Remove(0, 2);
            i += 1;
        }
    }
    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();
        }
    }
Exemple #12
0
    public void EndTurn()
    {
        CorrectUnit.TimeToReusePerc = CorrectUnit.TimeToReusePerc - 1;
        AttackControl = false;
        MoveControl   = false;
        PercUse       = false;
        CorrectUnit.candosomething = true;

        Turn++;
        if (Turn >= ListOfGo.Count)
        {
            Turn = 0;
        }

        CorrectUnit = ListOfGo[Turn];
        NewPointedUnit(CorrectUnit);

        AmmoText.text = (CorrectUnit.Weapon.Load + "/" + CorrectUnit.Weapon.MaxLoad);
        PercText.text = ((CorrectUnit.TimeToReusePerc < 1) ? "Redy !" : ("Wait " + CorrectUnit.TimeToReusePerc));

        CameraFollow.transform.position = new Vector3(CorrectUnit.transform.position.x + Camera.main.transform.position.y / 1.5f, 0, CorrectUnit.transform.position.z - Camera.main.transform.position.y / 1.5f) + new Vector3(0, Camera.main.transform.position.y, 0);

        unitShowCorrectUnit.SetActive(true);
        unitShowCorrectUnit.transform.position = GridABSManager.NodeFromWorldPoint(CorrectUnit.transform.position).Position;

        CleanJunk();
        GridABSManager.CleatGrid();

        CorrectUnit.AmbushZone = false;

        if (Turn + 1 < ListOfGo.Count)
        {
            NextTurnBackImage.color             = (!ListOfGo[Turn + 1].Enemy) ? new Color(0, 244 / 255f, 1) : new Color(1, 30 / 255f, 0);
            NextTurnIcon.sprite                 = ListOfGo[Turn + 1].data.IconBodyFace;
            NextTurnText.text                   = "Next turn :" + "\n" + ListOfGo[Turn + 1].data.name.Remove(0, 2);
            unitShowNextTurn.transform.position = ListOfGo[Turn + 1].transform.position;
        }
        else
        {
            NextTurnBackImage.color             = (!ListOfGo[0].Enemy) ? new Color(0, 244 / 255f, 1) : new Color(1, 30 / 255f, 0);
            NextTurnIcon.sprite                 = ListOfGo[0].data.IconBodyFace;
            NextTurnText.text                   = "Next turn :" + "\n" + ListOfGo[0].data.name.Remove(0, 2);
            unitShowNextTurn.transform.position = ListOfGo[0].transform.position;
        }

        if (CorrectUnit.Enemy && !CorrectUnit._effectOnUnit.HaveEffect(2))
        {
            CorrectUnit.GetComponent <UnitAI> ().ChooseTactic();
        }
        if (CorrectUnit._effectOnUnit.HaveEffect(2))
        {
            RetarderCall(1f);
        }
        CorrectUnit.candosomething = true;
        CorrectUnit._effectOnUnit.CheckEffects();
    }
    void Start()
    {
        BulletObjectStandart = FindObjectOfType <ManagerMovment> ().transform.GetChild(0).gameObject;
        _selfUnit            = GetComponentInParent <UnitBehevior> ();

        _audioSource            = GetComponent <AudioSource> ();
        Load                    = MaxLoad;
        SpriteRendererValue     = GetComponent <SpriteRenderer> ();
        transform.localPosition = _selfUnit.data.WeaponPosVector * Vector3.up;
    }
    public void UsePerc(bool _Enemy, UnitBehevior _Target)
    {
        switch (AParm)
        {
        case 0:
            ChengParams(_Target);

            break;



        case 1:
            SpellPerc(_Target);
            break;

        case 2:
            vectorsOfGrande = GetMatrix();


            Vector3 vector = GridManager.NodeFromWorldPoint(_Target.transform.position).Position;
            Vector3 dir    = vector - transform.position;
            for (int i = 0; i < vectorsOfGrande.Length; i++)
            {
                vectorsOfGrande[i] += new Vector2(vector.x, vector.z);
            }


            var granadeLineFx = Instantiate(manager.OnTurnEffectFX[8].GetComponent <ParticleSystem>(), transform.position, Quaternion.identity);
            granadeLineFx.Stop();
            var fxvel = granadeLineFx.velocityOverLifetime;

            fxvel.x = new ParticleSystem.MinMaxCurve(dir.x);
            fxvel.z = new ParticleSystem.MinMaxCurve(dir.z);

            granadeLineFx.gameObject.SetActive(true);
            granadeLineFx.Play();

            point = vector;
            Invoke("MakeBoom", 1);
            break;
        }
    }
    public IEnumerator Shooting(UnitBehevior Target, Vector3 TargetVector, float Distance, float RandomN, GameObject BulletObject)
    {
        if (!_testSound)
        {
            BulletObject.transform.position = transform.GetChild(0).position;
            yield return(new WaitForSeconds(range));
        }
        _testSound = true;

        while (Target != null && Vector3.Distance(BulletObject.transform.position, Target.transform.position) > 0.3f)
        {
            BulletObject.transform.position = Vector3.MoveTowards(BulletObject.transform.position, TargetVector, Distance / 5);

            yield return(new WaitForFixedUpdate());
        }

        Destroy(BulletObject);

        _testSound = false;
    }
Exemple #16
0
    public void NewPointedUnit(UnitBehevior _UnitPointed)
    {
        HeltyBar.transform.localScale = new Vector3(_UnitPointed.Helty / _UnitPointed.MaxHelty, 1, 1);
        if (_UnitPointed.Shild > 0)
        {
            ShildBar.transform.localScale = new Vector3(_UnitPointed.Shild / _UnitPointed.MaxShild, 1, 1);
        }
        if (_UnitPointed.Armor > 0)
        {
            ArmorBar.transform.localScale = new Vector3(_UnitPointed.Armor / _UnitPointed.MaxArmor, 1, 1);
        }
        NameText.text = _UnitPointed.data.name.Remove(0, 2);

        HeltyBText.text = ((int)_UnitPointed.Helty).ToString();
        ShildBText.text = ((int)_UnitPointed.Shild).ToString();
        ArmorBText.text = ((int)_UnitPointed.Armor).ToString();

        PercText.text = ((_UnitPointed.TimeToReusePerc < 1) ? "Redy !" : ("Wait " + _UnitPointed.TimeToReusePerc));
        string _statsunit = "";

        _statsunit += "- Навык владения оружеем  -" + "\n" + "\n";

        int num = 0;

        foreach (int n in _UnitPointed.Skills)
        {
            _statsunit += UIManager.GetWeaponType(num) + " : " + n + "\n";
            num++;
        }

        _statsunit += "\n" + "\n" + "- Сопротивление -" + "\n" + "\n";

        num = 0;
        foreach (int n in _UnitPointed.Resistans)
        {
            _statsunit += UIManager.GetResistanceName(num) + " : " + n + "\n";
            num++;
        }

        StatsOfUnit.text = _statsunit;
    }
Exemple #17
0
    public IEnumerator ShootByUnit(UnitBehevior unitShooter, UnitBehevior unitTarget)
    {
        unitShooter = this;
        if (unitTarget.transform.position.x - unitShooter.transform.position.x > 1)
        {
            Weapon.SpriteRendererValue.sortingOrder = 1;
            Weapon.SpriteRendererValue.flipX        = false;

            HandRenderer.sortingOrder = 1;
            HandRenderer.flipX        = false;

            BodyRenderer.sprite = data.IconBodyFace;
        }

        if (unitTarget.transform.position.x - unitShooter.transform.position.x < -1 && false)
        {
            Weapon.SpriteRendererValue.sortingOrder = -2;
            Weapon.SpriteRendererValue.flipX        = true;

            HandRenderer.sortingOrder = -2;
            HandRenderer.flipX        = true;

            BodyRenderer.sprite = data.IconBodyBack;
        }
        Weapon.SetAmmoCountCheck();

        for (var i = 0; i < Weapon.BulletPerShoot; i++)
        {
            if (Weapon.Load > 0 && unitShooter != null)
            {
                Weapon.Shoot(unitTarget);
                yield return(new WaitForSeconds(Weapon.SecondPerShoot));
            }
        }
        if (manager.CorrectUnit == unitShooter)
        {
            manager.RetarderCall(Vector3.Distance(unitShooter.transform.position, unitTarget.transform.position) / 5f +
                                 Weapon.SecondPerShoot * Weapon.BulletPerShoot);
        }
        yield return(new WaitForEndOfFrame());
    }
Exemple #18
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);
    }
    void ChengParams(UnitBehevior Target)
    {
        switch (CAParm)
        {
        case 0:
            Target.Helty -= PowerPerc;
            Target.GetHit(0, 0);
            break;


        case 1:
            Target.Shild -= PowerPerc;
            Target.GetHit(0, 0);
            break;


        case 2:
            Target.Armor -= PowerPerc;
            Target.GetHit(0, 0);
            break;
        }
    }
Exemple #20
0
    public void CreateLIst()
    {
        ListOfGo   = new List <UnitBehevior> ();
        AllUnits   = FindObjectsOfType <UnitBehevior> ();
        FriendList = new List <UnitBehevior> ();
        EnemyList  = new List <UnitBehevior> ();

        for (int i = 0; i < AllUnits.Length; i++)
        {
            if (!AllUnits[i].Enemy)
            {
                FriendList.Add(AllUnits[i]);
            }
            else
            {
                EnemyList.Add(AllUnits[i]);
            }
        }
        int F = 0, E = 0;

        while (ListOfGo.Count <= AllUnits.Length - 1)
        {
            if (F < FriendList.Count)
            {
                ListOfGo.Add(FriendList[F]);

                F = F + 1;
            }
            if (E < EnemyList.Count)
            {
                ListOfGo.Add(EnemyList[E]);

                E = E + 1;
            }
        }
        CorrectUnit = ListOfGo[0];
    }
    public void SetEnemy(List <UnitData> unitlist, List <WeaponData> weaponlist)
    {
        for (int i = 0; i < unitlist.Count; i++)
        {
            UnitBehevior UnitVar = Instantiate(UnitThis, transform);
            UnitVar.transform.position = Vector3.one * 1000;
            WeaponBehevior WeaponVar = Instantiate(WeaponThis, UnitVar.transform);
            WeaponVar.name = WeaponVar.data.name.Remove(0, 2) + " : " + Random.Range(0, 1001);
            WeaponVar.transform.localPosition = Vector3.zero + Vector3.up * 0.091f;
            WeaponVar.transform.localScale    = Vector3.one;
            WeaponVar.transform.eulerAngles   = Vector3.zero;
            UnitVar.Weapon = WeaponVar;

            UnitVar.data = unitlist[i];
            UnitVar.ChekDataMetod();

            WeaponVar.data = weaponlist[i];
            WeaponVar.ChekDataMetod();

            UnitVar.Enemy            = true;
            UnitConfirmd[UnitNumber] = UnitVar.gameObject;
            UnitNumber = UnitNumber + 1;
        }
    }
Exemple #22
0
 public void ClearNode(Vector3 _Position, UnitBehevior _unit)
 {
     GridOfArena[NodeFromWorldPoint(_Position).x1, NodeFromWorldPoint(_Position).y1].UnitOnNode = _unit;
 }
Exemple #23
0
    private int TestPercUsable(out UnitBehevior target)
    {
        target = null;
        if (TimeToReusePerc > 0)
        {
            return(0);
        }
        int maxPoint = 0;

        switch (PercBehevior.AParm)
        {
        case 1:
            if (PercBehevior.BAPram == 1)
            {
                foreach (UnitBehevior unit in manager.FriendList)
                {
                    if (Vector3.Distance(transform.position, unit.transform.position) > PercBehevior.Radious)
                    {
                        continue;
                    }

                    if (maxPoint < PercBehevior.PowerPerc * (1 + PercBehevior.Duratin) * unit.GetHeltyTarget() &&
                        !unit._effectOnUnit.HaveEffect(PercBehevior.CAParm) || PercBehevior.CAParm == 2)
                    {
                        maxPoint = PercBehevior.CAParm != 2
                                  ? (int)(PercBehevior.PowerPerc * (1 + PercBehevior.Duratin) * unit.GetHeltyTarget() *
                                          (1 - unit.Resistans[PercBehevior.CAParm] / 100f)) : 1000;
                        target = unit;
                    }
                }
                return(maxPoint);
            }
            break;

        case 2:
            int localPoint = 0, countInBoom = 0;
            int allUnitCount = manager.FriendList.Count;
            for (int i = 0; i < allUnitCount; i++)
            {
                if (Vector3.Distance(manager.FriendList[i].transform.position, transform.position)
                    < PercBehevior.Radious)
                {
                    UnitBehevior unit = manager.FriendList[i];
                    localPoint += PercBehevior.PowerPerc;
                    countInBoom++;
                    for (int j = 0; j < allUnitCount; j++)
                    {
                        if (Vector3.Distance(manager.FriendList[j].transform.position, unit.transform.position) < PercBehevior.Duratin &&
                            unit != manager.FriendList[j])
                        {
                            countInBoom++;
                            if (PercBehevior.CAParm != 1)
                            {
                                localPoint += PercBehevior.PowerPerc;
                            }
                            else
                            {
                                localPoint *= PercBehevior.PowerPerc;
                            }
                        }
                    }
                    if (localPoint > maxPoint && countInBoom > 1)
                    {
                        maxPoint = localPoint;
                        target   = unit;
                    }
                    countInBoom = 0;
                }
            }
            return(maxPoint);
        }


        return(0);
    }
    void MakeBoom()
    {
        for (int i = 0; i < vectorsOfGrande.Length; i++)
        {
            Vector2      n          = vectorsOfGrande[i];
            UnitBehevior unitTarget = GridManager.NodeFromWorldPoint(new Vector3(n.x, 0, n.y)).UnitOnNode;
            if (unitTarget != null)
            {
                switch (CAParm)
                {
                case 0:
                    unitTarget.GetHit(PowerPerc, 434);
                    break;

                case 1:
                    Vector3 poitionToChek = unitTarget.transform.position + (unitTarget.transform.position - point).normalized * PowerPerc;    //Check

                    if (GridManager.NodeFromWorldPoint(poitionToChek)._Bloc == NodeA.TypeOfNode.Walkable &&
                        GridManager.NodeFromWorldPoint(poitionToChek).UnitOnNode == null)
                    {
                        GridManager.ClearNode(unitTarget.transform.position);
                        StartCoroutine(unitTarget.LerpMove(GridManager.NodeFromWorldPoint(poitionToChek).Position +
                                                           Vector3.forward * 0.12f + Vector3.up * 0.34f));
                        unitTarget.transform.eulerAngles = new Vector3(20, -45, 0);
                        GridManager.ClearNode(
                            GridManager.NodeFromWorldPoint(poitionToChek).Position + Vector3.forward * 0.12f +
                            Vector3.up * 0.34f, unitTarget);

                        unitTarget.GetHit(PowerPerc * 4, 434);
                    }
                    else
                    {
                        unitTarget.GetHit(PowerPerc * 12, 434);
                    }
                    break;

                case 2:
                    unitTarget._effectOnUnit.MakeStuned(1);
                    break;

                case 3:
                    unitTarget._effectOnUnit.MakeFired(PowerPerc, 2);
                    break;

                case 4:
                    unitTarget._effectOnUnit.MakeElectricShock(PowerPerc);
                    break;
                }
            }
            foreach (Shelter sh in GridManager.CurrentShelterList)
            {
                if (Vector3.Distance(sh.transform.position, new Vector3(n.x, 0, n.y)) < 1)
                {
                    Instantiate(sh.FX, sh.transform.position, Quaternion.identity);

                    sh.ShelterLevl -= PowerPerc * 3;
                    if (sh.ShelterLevl < 1)
                    {
                        Destroy(sh.gameObject);
                    }
                }
            }
        }


        Instantiate(manager.OnTurnEffectFX[CAParm + 2], point + Vector3.up * 0.75f, Quaternion.identity);
        manager.PlaySpecific(manager.Expl);
    }
    void Update()
    {
        if (manager.CorrectUnit == ThisUnit && manager.PercUse)
        {
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            Physics.Raycast(ray, out hit, Mathf.Infinity);



            if (AParm == 1 && hit.rigidbody != null)
            {
                Debug.Log(hit.rigidbody.name);
                UnitBehevior PointedTarget = hit.rigidbody.GetComponent <UnitBehevior>();

                if (ThisUnit.TimeToReusePerc <= 0 && manager.PercUse && Input.GetKeyDown(KeyCode.Mouse0) && IsTarget(PointedTarget) && Vector3.Distance(transform.position, PointedTarget.transform.position) < Radious)
                {
                    GridManager.CleatGrid();
                    manager.CleanJunk();


                    UnitBehevior unitTarget = manager.CorrectUnit;



                    if (unitTarget.transform.position.x - manager.CorrectUnit.transform.position.x > 1)
                    {
                        unitTarget.Weapon.SpriteRendererValue.sortingOrder = 1;
                        unitTarget.Weapon.SpriteRendererValue.flipX        = false;

                        unitTarget.HandRenderer.sortingOrder = 1;
                        unitTarget.HandRenderer.flipX        = false;

                        unitTarget.BodyRenderer.sprite = unitTarget.data.IconBodyFace;
                    }

                    if (unitTarget.transform.position.x - manager.CorrectUnit.transform.position.x < -1)
                    {
                        unitTarget.Weapon.SpriteRendererValue.sortingOrder = -2;
                        unitTarget.Weapon.SpriteRendererValue.flipX        = true;

                        unitTarget.HandRenderer.sortingOrder = -2;
                        unitTarget.HandRenderer.flipX        = true;

                        unitTarget.BodyRenderer.sprite = unitTarget.data.IconBodyBack;
                    }



                    manager.CorrectUnit.PercBehevior.UsePerc(manager.CorrectUnit.Enemy, PointedTarget);
                    manager.PercUse = false;
                    Destroy(Show);
                    manager.CorrectUnit.TimeToReusePerc = data.TimeToReuse;
                    manager.EndTurn();
                }
            }


            if (AParm == 2 && ThisUnit.TimeToReusePerc < 1)
            {
                if (!VisualEffect.gameObject.activeInHierarchy)
                {
                    VisualEffect.gameObject.SetActive(true);
                }

                GridManager.CleatGrid();
                point           = GridManager.NodeFromWorldPoint(ray.GetPoint(15)).Position;
                vectorsOfGrande = GetMatrix();
                VisualEffect.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);


                var     vel = VisualEffect.velocityOverLifetime;
                Vector3 dir = (point - transform.position).normalized;


                float dist = Vector3.Distance(point, transform.position);
                if (dist > Radious)
                {
                    dist = Radious;
                }
                vel.x = new ParticleSystem.MinMaxCurve(dir.x * dist);
                vel.z = new ParticleSystem.MinMaxCurve(dir.z * dist);


                VisualEffect.Play();

                Vector3 vector = GridManager.NodeFromWorldPoint(transform.position + dist * dir).Position;
                for (int i = 0; i < vectorsOfGrande.Length; i++)
                {
                    vectorsOfGrande[i] += new Vector2(vector.x, vector.z);
                    GridManager.CreateNodeShow(Color.cyan, new Vector3(vectorsOfGrande[i].x, 0, vectorsOfGrande[i].y));
                }


                if (Input.GetKeyDown(KeyCode.Mouse0) && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
                {
                    var granadeLineFx = Instantiate(manager.OnTurnEffectFX[8].GetComponent <ParticleSystem>(), transform.position, Quaternion.identity);
                    granadeLineFx.Stop();
                    var fxvel = granadeLineFx.velocityOverLifetime;

                    fxvel.x = new ParticleSystem.MinMaxCurve(dir.x * dist);
                    fxvel.z = new ParticleSystem.MinMaxCurve(dir.z * dist);

                    granadeLineFx.gameObject.SetActive(true);
                    granadeLineFx.Play();

                    VisualEffect.gameObject.SetActive(false);

                    point = vector;
                    Invoke("MakeBoom", 1);



                    ThisUnit.TimeToReusePerc = data.TimeToReuse;
                    manager.RetarderCall(1.5f);
                }
            }

            if (AParm == 3 && ThisUnit.TimeToReusePerc < 1)
            {
                NodeA node = new NodeA(Vector3.right * 1000, 1111, 1111, NodeA.TypeOfNode.Wall);

                if (Vector3.Distance(point, ray.GetPoint(15)) > 0.1f)
                {
                    if (!VisualEffect.gameObject.activeInHierarchy)
                    {
                        VisualEffect.gameObject.SetActive(true);
                    }

                    VisualEffect.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
                    var vel = VisualEffect.velocityOverLifetime;

                    GridManager.CleatGrid();
                    point = GridManager.NodeFromWorldPoint(ray.GetPoint(15)).Position;
                    Vector3 dir = (point - transform.position).normalized;

                    float dist = Vector3.Distance(point, transform.position);
                    if (dist > Radious)
                    {
                        dist = Radious;
                    }
                    vel.x = new ParticleSystem.MinMaxCurve(dir.x * dist);
                    vel.z = new ParticleSystem.MinMaxCurve(dir.z * dist);


                    VisualEffect.Play();

                    node = GridManager.NodeFromWorldPoint(transform.position + dir * dist);

                    if (node._Bloc == NodeA.TypeOfNode.Walkable && node.UnitOnNode == null)
                    {
                        GridManager.CreateNodeShow(manager.ColorOfIfo[1], node.Position);
                    }
                }
                if (Input.GetKeyDown(KeyCode.Mouse0) && node._Bloc == NodeA.TypeOfNode.Walkable && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
                {
                    GameObject fx = Instantiate(manager.OnTurnEffectFX[10 + CAParm], node.Position, Quaternion.identity);
                    fx.transform.eulerAngles = new Vector3(0, -87.69f, 0);
                    VisualEffect.gameObject.SetActive(false);
                    ThisUnit.TimeToReusePerc = data.TimeToReuse;
                    manager.RetarderCall(1f);
                }
            }
        }
        else if (VisualEffect != null && VisualEffect.gameObject.activeInHierarchy)
        {
            VisualEffect.gameObject.SetActive(false);
        }
    }