public void HoverSet(string name, int dmg, int spd, WeaponDraggable w)
    {
        wep         = w;
        nameT       = transform.GetChild(0).GetComponent <Text> ();
        damage      = transform.GetChild(1).GetComponent <Text> ();
        firerate    = transform.GetChild(2).GetComponent <Text> ();
        extra       = transform.GetChild(3).GetComponent <Image> ();
        extraActual = transform.GetChild(3).GetChild(0).GetComponent <Image>();
        image       = GetComponent <Image> ();
        nameT.text  = wep.nameUI;
        //damage.text = "Damage: " + wep.damageUI.ToString();
        //firerate.text = "Firerate: " + wep.firerateUI.ToString ();
        for (int i = 0; i < 10; i++)
        {
            damage.transform.GetChild(i).GetComponent <Image> ().color   = new Color(100f / 255f, 100f / 255f, 100f / 255f);
            firerate.transform.GetChild(i).GetComponent <Image> ().color = new Color(100f / 255f, 100f / 255f, 100f / 255f);
        }
        for (int i = 0; i < (int)wep.damageUI && i < 10; i++)
        {
            damage.transform.GetChild(i).GetComponent <Image> ().color = new Color(1f, 1f, 1f);
        }
        for (int i = 0; i < (int)wep.firerateUI && i < 10; i++)
        {
            firerate.transform.GetChild(i).GetComponent <Image> ().color = new Color(1f, 1f, 1f);
        }
        extra.color = TierColor(wep.getWeaponId());
        image.color = TierColor(wep.getWeaponId());
        Sprite a = GetExtra(wep.getWeaponId());

        if (a != null)
        {
            extraActual.sprite = a;
        }
    }
Exemple #2
0
 // Update is called once per frame
 void Update()
 {
     wep = transform.GetChild(4).GetComponent <WeaponDraggable> ();
     //if(wep != null && nameT.text != wep.nameUI){
     if (wep != null && (wep.nameUI != nameT.text || image.color != TierColor(wep.getWeaponId())))
     {
         nameT.text = wep.nameUI;
         //damage.text = "Damage: " + wep.damageUI.ToString();
         //firerate.text = "Firerate: " + wep.firerateUI.ToString ();
         for (int i = 0; i < 10; i++)
         {
             damage.transform.GetChild(i).GetComponent <Image> ().color   = new Color(100f / 255f, 100f / 255f, 100f / 255f);
             firerate.transform.GetChild(i).GetComponent <Image> ().color = new Color(100f / 255f, 100f / 255f, 100f / 255f);
         }
         for (int i = 0; i < (int)wep.damageUI && i < 10; i++)
         {
             damage.transform.GetChild(i).GetComponent <Image> ().color = new Color(1f, 1f, 1f);
         }
         for (int i = 0; i < (int)wep.firerateUI && i < 10; i++)
         {
             firerate.transform.GetChild(i).GetComponent <Image> ().color = new Color(1f, 1f, 1f);
         }
         extra.color = TierColor(wep.getWeaponId());
         image.color = TierColor(wep.getWeaponId());
         Sprite a = GetExtra(wep.getWeaponId());
         if (a != null)
         {
             extraActual.sprite = a;
         }
     }
 }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            moduleToDrag = GetDraggableTransformUnderMouse();
            if (moduleToDrag != null)
            {
                dragging = true;
                moduleToDrag.SetAsLastSibling();
                //originalPosition = moduleToDrag.position;
                originalPosition  = moduleToDrag.localPosition;
                moduleToDragImage = moduleToDrag.GetComponent <Image> ();
                moduleToDragImage.raycastTarget = false;
            }
        }

        if (dragging)
        {
            moduleToDrag.position = Input.mousePosition;
        }

        if (Input.GetMouseButtonUp(0))
        {
            if (moduleToDrag != null)
            {
                Transform moduleToReplace = GetDraggableTransformUnderMouse();
                if (moduleToReplace != null)
                {
                    //moduleToDrag.position = moduleToReplace.position;
                    //moduleToReplace.position = originalPosition;
                    //Vector2 dragPos = moduleToDrag.localPosition;
                    Vector2 replacePos = moduleToReplace.localPosition;
                    //moduleToDrag.localPosition = moduleToReplace.InverseTransformPoint(moduleToReplace.position);
                    //moduleToReplace.localPosition = moduleToDrag.InverseTransformPoint(originalPosition);

                    WeaponDraggable Drag    = moduleToDrag.gameObject.GetComponent <WeaponDraggable> ();
                    WeaponDraggable Replace = moduleToReplace.gameObject.GetComponent <WeaponDraggable> ();
                    if (Replace.equipped && !Drag.equipped)
                    {
                        Drag.equipped    = true;
                        Replace.equipped = false;
                        Drag.slot        = Replace.slot;
                        Replace.slot     = -1;
                        Transform panel = moduleToDrag.parent;
                        moduleToDrag.parent    = moduleToReplace.parent;
                        moduleToReplace.parent = panel;
                        ip.RemoveEquipped(Replace.getWeaponId());
                        ip.AddEquipped(Drag.getWeaponId());
                        ip.RemoveWeapon(Drag.getWeaponId());
                        ip.AddWeapon(Replace.getWeaponId());
                    }
                    else if (!Replace.equipped && Drag.equipped)
                    {
                        Drag.equipped    = false;
                        Replace.equipped = true;
                        Replace.slot     = Drag.slot;
                        Drag.slot        = -1;
                        Transform panel = moduleToDrag.parent;
                        moduleToDrag.parent    = moduleToReplace.parent;
                        moduleToReplace.parent = panel;
                        ip.RemoveEquipped(Drag.getWeaponId());
                        ip.AddEquipped(Replace.getWeaponId());
                        ip.RemoveWeapon(Replace.getWeaponId());
                        ip.AddWeapon(Drag.getWeaponId());
                    }
                    else if (Replace.equipped && Drag.equipped)
                    {
                        int dragSlot = Drag.slot;
                        Drag.slot    = Replace.slot;
                        Replace.slot = dragSlot;
                    }
                    else if (!Replace.equipped && !Drag.equipped)
                    {
                        Transform panel = moduleToDrag.parent;
                        moduleToDrag.parent    = moduleToReplace.parent;
                        moduleToReplace.parent = panel;
                    }
                    moduleToDrag.localPosition    = replacePos;
                    moduleToReplace.localPosition = originalPosition;
                }
                else
                {
                    moduleToDrag.localPosition = originalPosition;
                }

                moduleToDragImage.raycastTarget = true;
                moduleToDrag = null;
            }
            dragging = false;
        }
    }