public override void CreateSlots()
        {
            for (int i = 0; i < inventory.GetSlots.Length; i++)
            {
                var      slot     = Instantiate(equipmentSlotPrefab, contentPanel);
                var      text     = Utilities.RecursiveFindChild(slot.transform, "SlotName");
                GearSlot gearSlot = inventory.GetSlots[i].AllowedGearTypes.ElementAt(0);
                text.GetComponent <TextMeshProUGUI>().text = gearSlot.ToString();
            }

            // After inventory buttons have been made, initialize each slot with the allowed gear for that slot
            InventorySlotButton[] buttons = GetComponentsInChildren <InventorySlotButton>();
            for (int i = 0; i < buttons.Length; i++)
            {
                LinkButtonToInventorySlot(buttons[i], inventory.GetSlots[i]);

                // Add Drag and drop functionality to buttons by adding events to the game object
                var buttonGameObject = buttons[i].gameObject;
                Utilities.AddEvent(buttonGameObject, EventTriggerType.PointerEnter, delegate { OnEnter(buttonGameObject); });
                Utilities.AddEvent(buttonGameObject, EventTriggerType.PointerExit, delegate { OnExit(buttonGameObject); });
                Utilities.AddEvent(buttonGameObject, EventTriggerType.BeginDrag, delegate { OnDragStart(buttonGameObject); });
                Utilities.AddEvent(buttonGameObject, EventTriggerType.EndDrag, delegate { OnDragEnd(buttonGameObject); });
                Utilities.AddEvent(buttonGameObject, EventTriggerType.Drag, delegate { OnDrag(buttonGameObject); });
            }
        }
Beispiel #2
0
 public void SetGearSpinDirection(GearSlot gearSlot, Gear gear)
 {
     if (gear.GearSpinner == this)
     {
         _gearAnimator.SetBool("IsClockwise", gearSlot.TurnsClockwise);
     }
 }
Beispiel #3
0
 public Gear(GearSlot slot, int powerLevel, AffinityType affinity, string description)
 {
     Slot        = slot;
     PowerLevel  = powerLevel;
     Description = description;
     Affinity    = affinity;
 }
Beispiel #4
0
    private void OnClickUp()
    {
        if (!isDragging)
        {
            return;
        }
        GearSlot _gearSlot = AllRaycasts("Slot");

        if (_gearSlot == null)       //se não achar nada devolve a engrenagem
        {
            lastSlot.GearEnter(gearColor.Color);
        }
        else if (!_gearSlot.isActive) //se achar slot vazio, coloca a engrenagem
        {
            _gearSlot.GearEnter(gearColor.Color);
        }
        else                         //se acahr slot com engrenagem, troca as engrenagens
        {
            lastSlot.GearEnter(_gearSlot.GearExit());
            _gearSlot.GearEnter(gearColor.Color);
        }

        //desliga a engrenagem arrastavel
        gearTransparency.alpha = 0f;
        isDragging             = false;
    }
    public void BuyItem(int id)
    {
        if (currentWares != null && id >= 0 && id < currentWares.ownedGear.Count)
        {
            GearSlot gearSlot = currentWares.ownedGear[id];

            InventoryObject.TradeItem(gearSlot, playerInventory, currentWares);

            //Update UI:
            EmptySlot(id);
            GenerateIcons();

            /*
             * //Exchange money
             * InventoryObject.ExchangeMainCurrency(currentWares.ownedGear[id].gear.BuyPrice, playerInventory, currentWares);
             *
             * //Give item to player:
             * playerInventory.AddGear(currentWares.ownedGear[id].gear);
             * Debug.Log("You bought item of id: " + id);
             * Debug.Log(currentWares.ownedGear[id].gear);
             *
             * //Remove item from current wares:
             * currentWares.RemoveGear(id);
             */
        }
        else
        {
            Debug.Log("It's an empty slot dumbass...");
        }
        //GenerateIcons();
    }
    public void itemClicked()
    {
        if (item != null)
        {
            WardrobePreviewPanelUpdater wppu = GameObject.Find("Wardrobe").GetComponent <WardrobePreviewPanelUpdater>();
            Toggle toggle = GetComponentInChildren <Toggle>();

            GearSlot slot = item.allowedSlots.First();
            if (!mainPaperdoll.slotSet(slot))
            {
                mainPaperdoll.setGearSlotKey(slot, item.key);
                wppu.toggle(this, true);
            }
            else
            {
                long oldKey = mainPaperdoll.getGearSlot(slot);
                if (oldKey == item.key)
                {
                    mainPaperdoll.clearGearSlot(slot);
                    wppu.toggle(this, false);
                }
                else
                {
                    mainPaperdoll.setGearSlotKey(slot, item.key);
                    wppu.toggle(this, true);
                }
            }
        }
    }
Beispiel #7
0
        private GameObject loadNIFForSlot(GearSlot slot, GameObject skeleton, GameObject meshHolder, string nifFile, string geo)
        {
            //Debug.Log("load nif[" + nifFile + "] for slot " + slot, this.gameObject);
            // First move all the meshes across to the skeleton
            GameObject meshes = new GameObject(slot.ToString());

            //Debug.Log("create new gameobh:" + meshes.name);
            try
            {
                NIFFile    file       = NIFLoader.getNIF(nifFile);
                GameObject newNifRoot = NIFLoader.loadNIF(file, nifFile, true);

                meshes.transform.parent = meshHolder.transform;

                //Debug.Log("Move components from loaded nif to our new gameobj");
                foreach (SkinnedMeshRenderer r in newNifRoot.GetComponentsInChildren <SkinnedMeshRenderer>(true))
                {
                    //  Debug.Log("Move renderer " + r.gameObject.name);
                    r.transform.parent = meshes.transform;
                }

                /** I'm not quite sure how bows are supposed to work yet. The quiver, bow and prop all appear to be a single mesh, so they must be moved around using bones or something..
                 * At the moment they don't even show propertly because the ROOT bone assigned while loading is not copied over and is destroyed causing the SKinnedMeshRender to behave poorly
                 * More research required.
                 */

                // weapons are a bit different
                if (!WardrobeStuff.isWeapon(slot))
                {
                    // process the NiSkinningMeshModifier
                    NIFLoader.linkBonesToMesh(file, skeleton);
                }
                else
                {
                    //Debug.Log("Treating slot (" + slot + ") as weapon and attach it to AP_r_hand on skeleton");
                    Transform t = skeleton.transform.FindDeepChild("AP_r_hand");

                    meshes.transform.parent        = t;
                    meshes.transform.localPosition = new Vector3(0, 0, 0);
                }

                this.animationNif.clearBoneMap();

                // disable the proxy geo
                enableDisableGeo(nifFile, skeleton, false);
                // special case to ensure boots are disabled as well
                if (nifFile.Contains("foot"))
                {
                    enableDisableGeo("boots", skeleton, false);
                }

                GameObject.DestroyObject(newNifRoot);
            }
            catch (Exception ex)
            {
                Debug.Log("Exception trying to load nif[" + nifFile + "]" + ex);
            }
            return(meshes);
        }
 public ItemSO GetItemFromSlot(GearSlot slot)
 {
     if (this._gear.ContainsKey(slot))
     {
         return(this._gear[slot]);
     }
     return(null);
 }
Beispiel #9
0
 public void clearGearSlot(GearSlot slot)
 {
     gearSlotKeys.Remove(slot);
     if (state == ClassState.IDLE)
     {
         state = ClassState.UPDATE;
     }
 }
Beispiel #10
0
 private void ChangeAppearanceToPlayzone(GearSlot gearSlot, Gear gear)
 {
     if (gear.GearAppearance == this)
     {
         _gearImage.sprite             = _PZGearSprite;
         _gearRectTransform.localScale = new Vector3(1.5f, 1.5f, 1);
     }
 }
Beispiel #11
0
        private string GenerateGearDescription(GearSlot slot, AffinityType affinityType, int powerLevel)
        {
            string adjective   = GenerateAdjective(powerLevel);
            string synonym     = GenerateSynonym(slot);
            string associasion = GenerateAssociasion(affinityType);
            string spacing     = adjective.Length > 0 ? " " : "";

            return(adjective + spacing + synonym + " of " + associasion);
        }
Beispiel #12
0
        public Gear Generate()
        {
            GearSlot     slot         = GenerateGearSlot();
            AffinityType affinityType = GenerateAffinityType();
            int          powerLevel   = GeneratePowerLevel();

            string description = GenerateGearDescription(slot, affinityType, powerLevel);

            return(new Gear(slot, powerLevel, affinityType, description));
        }
    public static void ExchangeItemForCurrency(GearSlot gearSlot, InventoryObject sellerInv, CurrencyObject mainCurrency)
    {
        EquipmentObject eq        = gearSlot.gear;
        int             itemPrice = eq.SellPrice;

        mainCurrency.IncreaseAmount(itemPrice);
        sellerInv.RemoveGear(gearSlot);

        Debug.Log("Item sold");
    }
Beispiel #14
0
 private void DropInGearSlot(GearSlot gearSlot, Gear gear)
 {
     if (gear.GearDragDrop == this)
     {
         _currentSlot       = gearSlot;
         _wasDragSuccessful = true;
         _gearRectTransform.SetParent(gearSlot.GetComponent <RectTransform>());
         _gearRectTransform.anchoredPosition = new Vector2(0, 0);
     }
 }
Beispiel #15
0
 bool shouldShow(GearSlot slot, ClothingItem c)
 {
     if (c.allowedSlots.Contains(slot))
     {
         if (filter != null && filter.Length > 0)
         {
             return(c.name.ToLower().Contains(filter));
         }
         return(true);
     }
     return(false);
 }
Beispiel #16
0
        public void setGearSlotKey(GearSlot slot, long key)
        {
            if (gearSlotKeys.ContainsKey(slot) && gearSlotKeys[slot] == key)
            {
                return;
            }
            Debug.Log("set gear slot[" + slot + "] to  key " + key, gameObject);

            clearOtherWeapons(slot);

            gearSlotKeys[slot] = key;
            if (state == ClassState.IDLE)
            {
                state = ClassState.UPDATE;
            }
        }
Beispiel #17
0
    public static void TradeItem(GearSlot gearSlot, InventoryObject buyerInv, InventoryObject sellerInv)
    {
        EquipmentObject eq        = gearSlot.gear;
        int             itemPrice = eq.BuyPrice;

        if (ExchangeMainCurrency(itemPrice, buyerInv, sellerInv))
        {
            buyerInv.AddGear(eq);
            Debug.Log("You acquired an item: " + eq);
            sellerInv.RemoveGear(gearSlot);
        }
        else
        {
            Debug.Log("Trade failed.");
        }
    }
Beispiel #18
0
    public void changeSlot()
    {
        DOption  option = (DOption)slotChangeDropdown.options[slotChangeDropdown.value];
        GearSlot slot   = (GearSlot)option.userObject;

        if (originals == null)
        {
            originals = db.getClothing().ToArray();
        }
        clothingItems           = originals.Where(c => shouldShow(slot, c)).ToArray();
        panelUpdater.panelItems = clothingItems.Count();

        previewIndex = 0;
        updatePageText();
        updatePreviews();
    }
Beispiel #19
0
    /// <summary>
    /// Check the world collision, returns true if on top of a slot
    /// </summary>
    /// <returns></returns>
    private bool CheckWorldCollision()
    {
        Vector2      mousePosition = mainCamera.ScreenToWorldPoint(Input.mousePosition);
        RaycastHit2D mouseHit      = Physics2D.Raycast(mousePosition, Vector2.zero, float.PositiveInfinity, layerMask);

        if (mouseHit.collider != null)
        {
            if (mouseHit.collider.CompareTag("GearWorldSlot"))
            {
                currentGearSlot = mouseHit.collider.GetComponent <GearSlot>();
                return(true);
            }
        }

        currentGearSlot = null;
        return(false);
    }
Beispiel #20
0
 public void clearOtherWeapons(GearSlot slot)
 {
     if (slot == GearSlot.TWO_HAND)
     {
         clearGearSlot(GearSlot.MAIN_HAND);
         clearGearSlot(GearSlot.OFF_HAND);
         clearGearSlot(GearSlot.RANGED);
     }
     else if (slot == GearSlot.RANGED)
     {
         clearGearSlot(GearSlot.MAIN_HAND);
         clearGearSlot(GearSlot.OFF_HAND);
         clearGearSlot(GearSlot.TWO_HAND);
     }
     else
     {
         clearGearSlot(GearSlot.RANGED);
         clearGearSlot(GearSlot.TWO_HAND);
     }
 }
    public void BuyItem(int id)
    {
        if (currentWares != null && id >= 0 && id < currentWares.ownedGear.Count)
        {
            GearSlot gearSlot = currentWares.ownedGear[id];

            InventoryObject.TradeItem(gearSlot, playerInventory, currentWares);

            //Update UI:
            EmptySlot(id);
            GenerateIcons();

            if (this.name == "ShopMenu")
            {
                Debug.Log("UI updated: " + this.name);
            }
        }
        else
        {
            //Debug.Log("It's an empty slot...");
        }
    }
Beispiel #22
0
    private void OnClickDown()
    {
        GearSlot _gearSlot = AllRaycasts("Slot");

        if (_gearSlot == null)
        {
            return;
        }
        if (!_gearSlot.isActive)
        {
            return;
        }

        lastSlot = _gearSlot;

        //prepara a  engrenagem arrastavel pra seguir
        gearTransform.position = Input.mousePosition;
        gearColor.Color        = _gearSlot.GearExit();
        gearTransparency.alpha = 0.7f;

        //liga o arrastamento
        isDragging = true;
    }
    public void SellItem(int id)
    {
        if (currentWares != null && id >= 0 && id < currentWares.ownedGear.Count)
        {
            GearSlot gearSlot = currentWares.ownedGear[id];
            gearSlot.isEquipped = false;

            InventoryObject.ExchangeItemForCurrency(gearSlot, currentWares, currentWares.mainCurrency);

            //Update UI:
            EmptySlot(id);
            GenerateIcons();

            if (this.name == "ShopMenu")
            {
                Debug.Log("UI updated: " + this.name);
            }
        }
        else
        {
            //Debug.Log("It's an empty slot...");
        }
    }
Beispiel #24
0
        private void updateGearSlotObject(GearSlot slot)
        {
            //Debug.Log("update gear slot [" + slot + "]", this.gameObject);
            if (state != ClassState.UPDATE)
            {
                Debug.LogError("Cannot update gear slot[" + slot + "] without being update mode");
                return;
            }

            // destroy any existing gear slot
            //Debug.Log("try destroy update gear slot object");
            if (gearSlotObjects.ContainsKey(slot))
            {
                GameObject.Destroy(gearSlotObjects[slot]);
            }

            //Debug.Log("try create update gear slot object if key for slot: " + gearSlotKeys.ContainsKey(slot), this.gameObject);
            if (gearSlotKeys.ContainsKey(slot))
            {
                int          race = WardrobeStuff.raceMap[raceString];
                int          sex  = WardrobeStuff.genderMap[genderString];
                long         key  = gearSlotKeys[slot];
                string       nif  = "";
                ClothingItem item = new ClothingItem(DBInst.inst, key);
                if (item.nifRef != null)
                {
                    nif = item.nifRef.getNif(race, sex);
                }
                else
                {
                    nif = new NIFReference(DBInst.inst, key).getNif(race, sex);
                }

                //Debug.Log("load nif[" + nif + "] for slot:" + slot, this.gameObject);
                gearSlotObjects[slot] = loadNIFForSlot(slot, refModel, costumeParts, Path.GetFileName(nif), "");
            }
        }
 private void OnGUI()
 {
     this._itemName = EditorGUILayout.TextField("Item name", this._itemName);
     this._gearSlot = (GearSlot)EditorGUILayout.EnumPopup("Slot", this._gearSlot);
     string[] optionsArray = optionsDic.Keys.ToArray();
     this._behaviorSelectedIndex = EditorGUILayout.Popup("Behaviors", this._behaviorSelectedIndex, optionsArray);
     if (GUILayout.Button("Update options"))
     {
         UpdateItemOptions();
     }
     GUILayout.BeginHorizontal();
     if (GUILayout.Button("Add Behavior"))
     {
         this.AddBehaviorIfNotExists(optionsArray[this._behaviorSelectedIndex]);
     }
     if (GUILayout.Button("Remove behavior"))
     {
         this._selectedItemBehaviors.RemoveAll(x => x == optionsDic[optionsArray[this._behaviorSelectedIndex]]);
     }
     if (GUILayout.Button("Clear behaviors"))
     {
         this._selectedItemBehaviors.RemoveAll(x => x);
     }
     GUILayout.EndHorizontal();
     GUILayout.Space(20);
     foreach (ItemBehavior ib in this._selectedItemBehaviors)
     {
         GUILayout.Label(ib.name);
     }
     GUILayout.Space(10);
     EditorGUI.BeginDisabledGroup(String.IsNullOrWhiteSpace(this._itemName));
     if (GUILayout.Button("Create item asset"))
     {
         CreateAsset(optionsArray[this._behaviorSelectedIndex]);
     }
     EditorGUI.EndDisabledGroup();
 }
Beispiel #26
0
 public Gear(GearObject gearObject) : base(gearObject)
 {
     buffs    = GetBuffs(gearObject.rarity);
     gearSlot = gearObject.gearSlot;
     rarity   = gearObject.rarity;
 }
Beispiel #27
0
 public Gear() : base()
 {
     gearSlot = GearSlot.Default;
     buffs    = new GearBuff[0];
     rarity   = Rarity.Artefact;
 }
Beispiel #28
0
 /// <summary>
 /// Selects the best-in-slot Gear object for the Hero, for the given Affinity.
 /// </summary>
 public Gear BestGearInSlot(GearSlot slot, AffinityType affinity)
 {
     return(BestGearInSlot(slot, g => g.Affinity == affinity));
 }
Beispiel #29
0
 /// <summary>
 /// Selects the best-in-slot Gear object for the Hero, without restrictions.
 /// </summary>
 public Gear BestGearInSlot(GearSlot slot)
 {
     return(BestGearInSlot(slot, g => true));
 }
Beispiel #30
0
 /// <summary>
 /// Selects the best-in-slot Gear object for the Hero, subjected to the
 /// selection criterion provided by the selector parameter.
 /// </summary>
 public Gear BestGearInSlot(GearSlot slot, Func <Gear, bool> selector)
 {
     return(!_gearOwned.ContainsKey(slot) ? null : _gearOwned[slot].Where(selector).Max());
 }