Beispiel #1
0
    private void drawWeaponL(string viewWeaponLeft)
    {
        //     Debug.Log("viewWeaponLeft");
        if (viewWeaponL)
        {
            Destroy(viewWeaponL);
        }
        String weaponStr = viewWeaponLeft;

        if (weaponStr == "")
        {
            weaponStr = "Empty";
        }
        var            vPanel = wLwftPanel.GetChild(0);
        SettingsWeapon wSetL  = null;

        if (weaponStr != "Empty")
        {
            wSetL = _sett.viewWeaponLeft.GetComponent <SettingsWeapon>();

            viewWeaponL = Instantiate(wSetL.Icon);
        }
        else
        {
            viewWeaponL = Instantiate(Resources.Load <GameObject>("Hero/UiWeapons/" + weaponStr));
        }

        viewWeaponL.transform.SetParent(vPanel);
        viewWeaponL.transform.position = wLwftPanel.position;

        if (weaponStr != "Empty" && wSetL)
        {
            wLwftPanel.transform.Find("name").GetComponent <Text>().text = viewWeaponLeft;
            wLwftPanel.transform.Find("od").GetComponent <Text>().text   = "од " + wSetL.od;
            wLwftPanel.transform.Find("shop").GetComponent <Text>().text = "" + wSetL.shop + "/" + wSetL.shopFull;
            if (wSetL.shop < wSetL.shopFull)
            {
                bttnResetL.SetActive(true);
            }
            else
            {
                bttnResetL.SetActive(false);
            }
        }
        else
        {
            wLwftPanel.transform.Find("name").GetComponent <Text>().text = "нет анимации";
            wLwftPanel.transform.Find("od").GetComponent <Text>().text   = "";
            wLwftPanel.transform.Find("shop").GetComponent <Text>().text = "";
            bttnResetL.SetActive(false);
        }
        if (_sett.weaponActive == 0)
        {
            wLwftPanel.GetComponent <Image>().color = Color.green;
        }
        else
        {
            wLwftPanel.GetComponent <Image>().color = Color.white;
        }
    }
Beispiel #2
0
    public void resetWR()
    {
        //  Debug.Log("Reset left");
        // var weapo = viewWeaponL.GetComponent<SettingsWeapon>();
        SettingsWeapon wSetR = _sett.viewWeaponRight.GetComponent <SettingsWeapon>();

        if (wSetR.shop < wSetR.shopFull)
        {
            int full = _sett.coountOnInventar(wSetR.cartridge);
            if (full > 0)
            {
                int need = wSetR.shopFull - wSetR.shop;
                // if(full >= need)
                //{
                int add = _sett.dellItemInventar(wSetR.cartridge, need);
                wSetR.shop += add;
                drawWeaponR(_sett.nameWeaponRight);
                // }
            }
        }
    }
Beispiel #3
0
    public void LoadWeapons(int type = 0) //0 - full, 1-left, // 2 - righgt
    {
        String nameWeapon = nameWeaponLeft;

        if (type == 0 || type == 1)
        {
            if (nameWeapon == nameWeaponLeft && (nameWeaponLeft == null || nameWeaponLeft.Length == 0 || !parentWeapon))
            {
            }
            else
            {
                if (viewWeaponLeft)
                {
                    Destroy(viewWeaponLeft);
                }
                viewWeaponLeft = Instantiate(Resources.Load <GameObject>("Weapon/" + nameWeapon));
                viewWeaponLeft.transform.SetParent(player.transform);
                viewWeaponLeft.transform.position = player.transform.position;
                viewWeaponLeft.name = string.Format(nameWeapon);
                if (weaponActive == 0)
                {
                    LoadWeapon();
                }

                SettingsWeapon wSetL = viewWeaponLeft.GetComponent <SettingsWeapon>();
                if (wSetL.shop < wSetL.shopFull)
                {
                    int full = coountOnInventar(wSetL.cartridge);
                    if (full > 0)
                    {
                        int need = wSetL.shopFull - wSetL.shop;
                        // if(full >= need)
                        //{
                        int add = dellItemInventar(wSetL.cartridge, need);
                        wSetL.shop = add;
                        //  drawWeaponL(_sett.nameWeaponLeft);
                        // }
                    }
                }
            }
        }

        nameWeapon = nameWeaponRight;
        if (type == 0 || type == 1)
        {
            if (nameWeapon == nameWeaponRight && (nameWeaponRight == null || nameWeaponRight.Length == 0 || !parentWeapon))
            {
            }
            else
            {
                if (viewWeaponRight)
                {
                    Destroy(viewWeaponRight);
                }
                viewWeaponRight = Instantiate(Resources.Load <GameObject>("Weapon/" + nameWeapon));
                viewWeaponRight.transform.SetParent(player.transform);
                viewWeaponRight.transform.position = player.transform.position;
                viewWeaponRight.name = string.Format(nameWeapon);
                if (weaponActive == 0)
                {
                    LoadWeapon();
                }

                SettingsWeapon wSetR = viewWeaponRight.GetComponent <SettingsWeapon>();
                if (wSetR.shop < wSetR.shopFull)
                {
                    int full = coountOnInventar(wSetR.cartridge);
                    if (full > 0)
                    {
                        int need = wSetR.shopFull - wSetR.shop;
                        // if(full >= need)
                        //{
                        int add = dellItemInventar(wSetR.cartridge, need);
                        wSetR.shop = add;
                        // drawWeaponR(_sett.nameWeaponRight);
                        // }
                    }
                }
            }
        }
    }
Beispiel #4
0
    protected override void OnUpdate()
    {
        Vector3 mp = Input.mousePosition;

        //  RaycastHit hit;
        if (Boot.PVP)
        {
            if (PVPBattle.instance)
            {
                if (!PVPBattle.instance.isStep())
                {
                    cursorTxt.GetComponent <Text>().text = "";
                    MainCursor("UI");
                    return;
                }
            }
        }
        Ray ray = Camera.main.ScreenPointToRay(mp);

        cursorTxt.transform.position         = new Vector2(mp.x + 55f, mp.y - 40f);
        cursorTxt.GetComponent <Text>().text = "";


        for (int j = 0; j < cursor.Length; j++)
        {
            if (Physics.Raycast(ray, out hit))
            {
                Transform objectHit = hit.transform;

                if (EventSystem.current.IsPointerOverGameObject())
                {
                    gs.cursor = gs.cursorNormal;
                    return;
                }
                if (player.Length == 1)
                {
                    var tr   = player.tr[j];
                    var set  = player.sett[j];
                    var data = player.data[j];
                    // Debug.Log(objectHit.tag);
                    MainCursor(objectHit.tag);
                    if (objectHit.tag == "Tower" || objectHit.tag == "Player_Friend")
                    {
                        LifeComponent life = objectHit.gameObject.GetComponent <LifeComponent>();
                        cursorTxt.GetComponent <Text>().text = "life:" + life.life;
                    }
                    if (objectHit.tag == "Map")
                    {
                        if (Boot.batle || Boot.PVP)
                        {
                            if (ground.GetComponent <Collider>().Raycast(ray, out hit, Mathf.Infinity))
                            {
                                cursorTxt.GetComponent <Text>().color = Color.black;
                                int dist = (int)Vector3.Distance(hit.point, tr.position) + 1;
                                str = dist.ToString();
                                if (dist > set.od)                        // сначала систему батле и начисление ОД
                                {
                                    cursorTxt.GetComponent <Text>().color = Color.red;
                                    str = "X";
                                }
                                cursorTxt.GetComponent <Text>().text = str;
                            }
                        }
                    }
                    if (objectHit.tag == "Player_Enemy" && tr.transform != objectHit.transform)
                    {
                        SettingsWeapon _ws;
                        if (set.weaponActive == 0 && set.viewWeaponLeft)
                        {
                            _ws = set.viewWeaponLeft.GetComponent <SettingsWeapon>();
                        }
                        else if (set.weaponActive == 1 && set.viewWeaponRight)
                        {
                            _ws = set.viewWeaponRight.GetComponent <SettingsWeapon>();
                        }
                        else
                        {
                            _ws           = new SettingsWeapon();
                            _ws.shop      = 0;
                            _ws.od        = 0;
                            _ws.shopFull  = 0;
                            _ws.cart_step = 0;
                        }
                        if (ground.GetComponent <Collider>().Raycast(ray, out hit, Mathf.Infinity))
                        {
                            cursorTxt.GetComponent <Text>().color = Color.black;
                            int dist = (int)Vector3.Distance(objectHit.position, tr.position);
                            int shop = _ws.shop;
                            if (set.weaponActive == 1)
                            {
                                shop = _ws.shop;
                            }
                            //  LifeComponent life = objectHit.gameObject.GetComponent<LifeComponent>();
                            //  LifeComponent life = objectHit.GetComponent<LifeComponent>();
                            if (set.od >= _ws.od && shop <= _ws.shopFull && shop >= _ws.cart_step)
                            {
                                if (_ws.radius < dist)
                                {
                                    cursorTxt.GetComponent <Text>().color = Color.red;
                                    str = "X";
                                }
                                int pr = set.procentKillPlayer(objectHit.gameObject);
                                cursorTxt.GetComponent <Text>().text = pr + "%";
                                //    cursorTxt.GetComponent<Text>().text = pr + "% \n life:" + life.life;
                            }
                            else
                            {
                                cursorTxt.GetComponent <Text>().color = Color.red;
                                str = "R";
                                cursorTxt.GetComponent <Text>().text = str = "R";
                                // cursorTxt.GetComponent<Text>().text = str + "\n life:" + life.life;
                            }
                        }
                    }
                    else

                    if (objectHit.tag == "Enemy")
                    {
                        SettingsWeapon _ws;
                        if (set.weaponActive == 0 && set.viewWeaponLeft)
                        {
                            _ws = set.viewWeaponLeft.GetComponent <SettingsWeapon>();
                        }
                        else if (set.weaponActive == 1 && set.viewWeaponRight)
                        {
                            _ws = set.viewWeaponRight.GetComponent <SettingsWeapon>();
                        }
                        else
                        {
                            _ws           = new SettingsWeapon();
                            _ws.shop      = 0;
                            _ws.od        = 0;
                            _ws.shopFull  = 0;
                            _ws.cart_step = 0;
                        }
                        if (ground.GetComponent <Collider>().Raycast(ray, out hit, Mathf.Infinity))
                        {
                            cursorTxt.GetComponent <Text>().color = Color.black;
                            int dist = (int)Vector3.Distance(objectHit.position, tr.position);
                            int shop = _ws.shop;
                            if (set.weaponActive == 1)
                            {
                                shop = _ws.shop;
                            }
                            if (set.od >= _ws.od && shop <= _ws.shopFull && shop >= _ws.cart_step)
                            {
                                if (_ws.radius < dist)
                                {
                                    cursorTxt.GetComponent <Text>().color = Color.red;
                                    str = "X";
                                }
                                int pr = set.procentKillEnemy(objectHit.gameObject);

                                cursorTxt.GetComponent <Text>().text = "pr: " + pr + "%";
                                if (Boot.PVP)
                                {
                                    LifeComponent life = objectHit.gameObject.GetComponent <LifeComponent>();
                                    cursorTxt.GetComponent <Text>().text = "pr: " + pr + "% \n life:" + life.life;
                                }
                            }
                            else
                            {
                                cursorTxt.GetComponent <Text>().color = Color.red;
                                str = "R";
                                cursorTxt.GetComponent <Text>().text = str = "R";
                            }
                        }
                    }
                }
                else
                {
                    MainCursor("UI");
                }
            }
        }
    }
Beispiel #5
0
    private void drawWeaponR(string viewWeaponRight)
    {
        //Debug.Log(viewWeaponRight);
        if (viewWeaponR)
        {
            Destroy(viewWeaponR);
        }

        String weaponStr = viewWeaponRight;

        if (weaponStr == "")
        {
            weaponStr = "Empty";
        }
        var            vPanel = wRightPanel.GetChild(0);
        SettingsWeapon wSet   = null;

        if (weaponStr != "Empty")
        {
            /* GameObject weaponGo = Resources.Load<GameObject>("Weapon/" + weaponStr);
             * wSet = weaponGo.GetComponent<SettingsWeapon>();
             * viewWeaponR = Instantiate(wSet.Icon);*/
            wSet = _sett.viewWeaponRight.GetComponent <SettingsWeapon>();

            viewWeaponR = Instantiate(wSet.Icon);
        }
        else
        {
            viewWeaponR = Instantiate(Resources.Load <GameObject>("Hero/UiWeapons/" + weaponStr));
        }


        viewWeaponR.transform.SetParent(vPanel);
        viewWeaponR.transform.position = wRightPanel.position;
        if (weaponStr != "Empti" && wSet)
        {
            wRightPanel.transform.Find("name").GetComponent <Text>().text = viewWeaponRight;
            wRightPanel.transform.Find("od").GetComponent <Text>().text   = "од " + wSet.od;
            wRightPanel.transform.Find("shop").GetComponent <Text>().text = "" + wSet.shop + "/" + wSet.shopFull;
            if (wSet.shop < wSet.shopFull)
            {
                bttnResetR.SetActive(true);
            }
            else
            {
                bttnResetR.SetActive(false);
            }
        }
        else
        {
            wRightPanel.transform.Find("name").GetComponent <Text>().text = "нет анимации";
            wRightPanel.transform.Find("od").GetComponent <Text>().text   = "";
            wRightPanel.transform.Find("shop").GetComponent <Text>().text = "";
            bttnResetR.SetActive(false);
        }

        if (_sett.weaponActive == 1)
        {
            wRightPanel.GetComponent <Image>().color = Color.green;
        }
        else
        {
            wRightPanel.GetComponent <Image>().color = Color.white;
        }
    }