예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("AccessoryTypeId,AccessoryType")] AccessoryTypes accessoryTypes)
        {
            if (id != accessoryTypes.AccessoryTypeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(accessoryTypes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccessoryTypesExists(accessoryTypes.AccessoryTypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(accessoryTypes));
        }
예제 #2
0
        /// <summary>
        /// Sets the Value of selected slot to null.
        /// </summary>
        /// <param name="type">Type of the Accessoir to DeEquip</param>
        /// <param name="slot"></param>
        /// <returns>Previous value of changed Slot</returns>
        public Accessoir DeEquip(AccessoryTypes type, int slot = 0)
        {
            Accessoir oldAccessoir = null;

            switch (type)
            {
            case AccessoryTypes.Finger:
                if (slot > 7 || slot < 0)
                {
                    Debug.LogError("Slot of DeEquip(Fingers) out of range");
                }
                else if (this.Fingers[slot] == null)
                {
                    Debug.LogWarning("Can't DeEquip(Fingers) slot with null");
                }
                else
                {
                    oldAccessoir       = this.Fingers[slot];
                    this.Fingers[slot] = null;
                } break;

            case AccessoryTypes.Handwrist:
                if (slot > 5 || slot < 0)
                {
                    Debug.LogError("Slot of DeEquip(Handwrist) out of range");
                }
                else if (this.Fingers[slot] == null)
                {
                    Debug.LogWarning("Can't DeEquip(Handwrist) slot with null");
                }
                else
                {
                    oldAccessoir         = this.HandWrist[slot];
                    this.HandWrist[slot] = null;
                } break;

            case AccessoryTypes.Neck:
                if (slot > 1 || slot < 0)
                {
                    Debug.LogError("Slot of DeEquip(Neck) out of range");
                }
                else if (this.Fingers[slot] == null)
                {
                    Debug.LogWarning("Can't DeEquip slot(Neck) with null");
                }
                else
                {
                    oldAccessoir    = this.Neck[slot];
                    this.Neck[slot] = null;
                }
                break;
            }


            return(oldAccessoir);
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("AccessoryTypeId,AccessoryType")] AccessoryTypes accessoryTypes)
        {
            if (ModelState.IsValid)
            {
                _context.Add(accessoryTypes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(accessoryTypes));
        }
예제 #4
0
    public void ShowCategory(AccessoryTypes type)
    {
        baseTween.Hide();
        gridTween.Show();
        int itemCount = 0;

        // Reset accessory list
        accessoryEntryList = new List <AccessoryStoreItemController>();

        // Populate the entries with loaded data
        List <Item> accessoryList = ItemManager.Instance.AccessoryList;

        foreach (AccessoryItem accessoryData in accessoryList)
        {
            if (accessoryData.AccessoryType == type)
            {
                // Change the title of the category
                switch (accessoryData.AccessoryType)
                {
                case AccessoryTypes.Hat:
                    categoryBanner.key = "ACCESSORIES_TYPE_HAT";
                    break;

                case AccessoryTypes.Glasses:
                    categoryBanner.key = "ACCESSORIES_TYPE_GLASSES";
                    break;

                default:
                    Debug.LogError("Invalid accessory type");
                    break;
                }
                categoryBanner.Localize();                    // Force relocalize

                GameObject accessoryEntry = GameObjectUtils.AddChild(gridParent.gameObject, accessoryEntryPrefab);
                AccessoryStoreItemController entryController = accessoryEntry.GetComponent <AccessoryStoreItemController>();
                entryController.Init(accessoryData);
                accessoryEntryList.Add(entryController);
                itemCount++;
            }
        }

        // Adjust the grid height based on the height of the cell and spacing
        float gridHeight = itemCount * (gridParent.cellSize.y + gridParent.spacing.y);

        gridParent.GetComponent <RectTransform>().sizeDelta = new Vector2(gridParent.cellSize.x, gridHeight);
    }
예제 #5
0
    public AccessoryItem(string id, ItemType type, Hashtable hashItemData) : base(id, type, hashItemData)
    {
        // Get the type of this decoration
        string strType = XMLUtils.GetString(hashItemData["AccessoryType"] as IXMLNode);

        eType = (AccessoryTypes)System.Enum.Parse(typeof(AccessoryTypes), strType);

        if (hashItemData.Contains("PrefabName"))
        {
            prefabName = XMLUtils.GetString(hashItemData["PrefabName"] as IXMLNode);
        }

        if (hashItemData.Contains("InSeason"))
        {
            inSeason = XMLUtils.GetBool(hashItemData["InSeason"] as IXMLNode);
        }
    }
 public bool Exclusive(AccessoryTypes accessoryType)
 {
     if ((this.AccessoryType == AccessoryTypes.Head ||
          this.AccessoryType == AccessoryTypes.Back ||
          this.AccessoryType == AccessoryTypes.Sides) &&
         accessoryType == AccessoryTypes.Suit)
     {
         return(true);//如果我是头/背/两侧,你是套装,互斥
     }
     else if ((accessoryType == AccessoryTypes.Head ||
               accessoryType == AccessoryTypes.Back ||
               accessoryType == AccessoryTypes.Sides) &&
              this.AccessoryType == AccessoryTypes.Suit)
     {
         return(true);//如果你是头/背/两侧,我是套装,互斥
     }
     else
     {
         return(false);//否则,暂时不互斥
     }
 }
예제 #7
0
 public Accessoir(string name, float weight, ItemQuality quality, AccessoryTypes type) : base(name, weight, quality)
 {
     this.Type = type;
 }
예제 #8
0
        private int DeterminBestAccessoirSlot(AccessoryTypes type)
        {
            int   slot        = 0;
            float lowestValue = 23456.789f;

            switch (type)
            {
            case AccessoryTypes.Finger:
                for (int i = 0; i < this.Fingers.Length; i++)
                {
                    if (this.Fingers[i] != null)
                    {
                        if (lowestValue == 23456.789f)
                        {
                            lowestValue = this.Fingers[i].Worth;
                        }
                        else if (this.Fingers[i].Worth > lowestValue)
                        {
                            lowestValue = this.Fingers[i].Worth;
                            slot        = i;
                        }
                    }
                    else
                    {
                        slot = i;
                        break;
                    }
                }
                break;

            case AccessoryTypes.Handwrist:
                for (int i = 0; i < this.HandWrist.Length; i++)
                {
                    if (this.HandWrist[i] != null)
                    {
                        if (lowestValue == 23456.789f)
                        {
                            lowestValue = this.HandWrist[i].Worth;
                        }
                        else if (this.HandWrist[i].Worth > lowestValue)
                        {
                            lowestValue = this.HandWrist[i].Worth;
                            slot        = i;
                        }
                    }
                    else
                    {
                        slot = i;
                        break;
                    }
                }
                break;

            case AccessoryTypes.Neck:
                if (this.Neck[0] == null)
                {
                    slot = 0; break;
                }
                if (this.Neck[1] == null)
                {
                    slot = 1; break;
                }
                if (this.Neck[0].Worth >= this.Neck[1].Worth)
                {
                    slot = 1;
                }
                else
                {
                    slot = 0;
                }

                break;
            }
            return(slot);
        }