Exemple #1
0
        private SymbolsImage GetWorldImage(ItemMaterial material, ArmorType type)
        {
            var imageName = GetWorldImageName(type);
            var imageInit = imagesStorage.GetImage(imageName);

            return(ItemRecolorHelper.RecolorItemImage(imageInit, material));
        }
Exemple #2
0
        private SymbolsImage GetArmorImage(IArmorPieceConfiguration config, ItemMaterial material)
        {
            var imageName = RandomHelper.GetRandomElement(config.Images);
            var imageInit = imagesStorage.GetImage(imageName);

            return(ItemRecolorHelper.RecolorItemImage(imageInit, material));
        }
Exemple #3
0
        //	triangle
        private static Mesh createTriangleMesh(float width, float height, ItemMaterial itemMaterial)
        {
            Vector3[] vertices =
            {
                new Vector3(-width / 2, -height / 2, 0),
                new Vector3(-width / 2, height / 2,  0),
                new Vector3(width / 2,  -height / 2, 0),
            };
            int[]     triangles = { 0, 1, 2 };
            Vector2[] uvs       = new Vector2[3];

            Texture2D texture = itemTextures[(int)itemMaterial];

            IntVector2 TextureXYCenter = new IntVector2(
                (int)Math.Round((texture.width / 2) / itemMaterials[(int)itemMaterial].mainTextureScale.x),
                (int)Math.Round((texture.height / 2) / itemMaterials[(int)itemMaterial].mainTextureScale.y));

            uvs[0] = TextureXY2UV2(texture, TextureXYCenter.x + (int)(-width / 2 * PixelsPerUnit), TextureXYCenter.y + (int)(-height / 2 * PixelsPerUnit));
            uvs[1] = TextureXY2UV2(texture, TextureXYCenter.x + (int)(-width / 2 * PixelsPerUnit), TextureXYCenter.y + (int)(height / 2 * PixelsPerUnit));
            uvs[2] = TextureXY2UV2(texture, TextureXYCenter.x + (int)(width / 2 * PixelsPerUnit), TextureXYCenter.y - (int)(height / 2 * PixelsPerUnit));

            Mesh mesh = new Mesh();

            mesh.vertices  = vertices;
            mesh.triangles = triangles;
            mesh.uv        = uvs;

            return(mesh);
        }
Exemple #4
0
 public ItemStack(ItemMaterial type, int amount)
     : base(0, 0, 64, 64)
 {
     _Type   = type;
     _Amount = amount;
     _Image  = (Image) new Bitmap(PVResources.ItemImageMap[_Type], Width, Height);
 }
        public static string GetMaterialPrefix(ItemMaterial material)
        {
            switch (material)
            {
            case ItemMaterial.Wood:
                return("Wooden");

            case ItemMaterial.Leather:
                return("Leather");

            case ItemMaterial.Iron:
                return("Iron");

            case ItemMaterial.Steel:
                return("Steel");

            case ItemMaterial.Silver:
                return("Silver");

            case ItemMaterial.ElvesMetal:
                return("Elven");

            case ItemMaterial.DwarfsMetal:
                return("Dwarf");

            case ItemMaterial.Mythril:
                return("Mythril");

            default:
                throw new ArgumentException($"Unknown material: {material}");
            }
        }
Exemple #6
0
        public IMaterial SetRequiredTool(ItemType type, ItemMaterial material = ItemMaterial.Any)
        {
            _requiredTool     = type;
            _requiredMaterial = material;

            return(this);
        }
Exemple #7
0
    public void SetData(int id, string name, ItemQuality quality, ItemType type, string description, int amount, int capacity, int buyprice, int sellprice)
    {
        ItemMaterial dataTmp = new ItemMaterial();

        dataTmp.SetData(id, name, quality, type, description, amount, capacity, buyprice, sellprice);
        data = dataTmp;
    }
Exemple #8
0
        public bool CanUseTool(ItemType type, ItemMaterial material)
        {
            bool hasRequiredType     = _requiredTool == type || _requiredTool.HasFlag(type);
            bool hasRequiredMaterial = _requiredMaterial == material || _requiredMaterial.HasFlag(material) ||
                                       (material > _requiredMaterial);

            return(hasRequiredType && hasRequiredMaterial);
        }
Exemple #9
0
        private string GetMaterialDescription(ItemMaterial material)
        {
            var textConfig = configuration.DescriptionConfiguration.MaterialDescription.FirstOrDefault(config => config.Material == material);
            if (textConfig == null)
                throw new ApplicationException($"Text configuration not found for shield material: {material}");

            return RandomHelper.GetRandomElement(textConfig.Text);
        }
Exemple #10
0
 private SymbolsImage GenerateInventoryImage(IShieldConfiguration config, ItemMaterial material)
 {
     var parts = config.Images.Sprites.OrderBy(sprite => sprite.Index)
         .Select(sprite => imagesStorage.GetImage(RandomHelper.GetRandomElement(sprite.Images)))
         .Select(image => ItemRecolorHelper.RecolorItemImage(image, material))
         .ToArray();
     return MergeImages(parts);
 }
Exemple #11
0
        public static ItemInstance MakeNaturalWeapon(int wielderSize)
        {
            ItemMaterial itemMaterial = MaterialHandler.GetMaterial("Flesh");
            BaseItemType baseItem     = new BaseItemType("Weapon", "A claw, fist or psuedopod.", "A claw, fist or psuedopod.", "Natural Weapon", "Natural Weapon", "Hand1",
                                                         wielderSize * 40.0f, itemMaterial, "Weapon", "Martial Arts", "strikes", null, 0, 0);

            return(new ItemInstance(baseItem, new Vector2Int(-1, -1), true));
        }
Exemple #12
0
 private string[] GenerateDescription(ItemRareness rareness, ItemMaterial material)
 {
     return(new[]
     {
         GetMaterialDescription(material),
         GetRarenessDescription(rareness)
     });
 }
    internal GameObject Get(ItemType type, ItemMaterial material, string maleModelId)
    {
        var itemMaterial = (gameManager ? gameManager.Items : itemManager).GetMaterial((int)material - 1);

        if (!int.TryParse(maleModelId, out var itemIndex))
        {
            return(null);
        }
        var output = new GameObject(type + "_" + material);

        switch (type)
        {
        case ItemType.Boots:
            ActivateAndInstantiate(maleLegsLeft[itemIndex], output.transform);
            ActivateAndInstantiate(maleLegsRight[itemIndex], output.transform);
            break;

        case ItemType.Chest:
            ActivateAndInstantiate(maleTorso[itemIndex], output.transform);
            ActivateAndInstantiate(maleArmUpperLeft[13], output.transform);
            ActivateAndInstantiate(maleArmUpperRight[13], output.transform);
            ActivateAndInstantiate(shoulderPadsLeft[20], output.transform);
            ActivateAndInstantiate(shoulderPadsRight[20], output.transform);
            break;

        case ItemType.Gloves:
            ActivateAndInstantiate(maleHandsLeft[itemIndex], output.transform);
            ActivateAndInstantiate(maleHandsRight[itemIndex], output.transform);
            ActivateAndInstantiate(maleArmLowerLeft[5], output.transform);
            ActivateAndInstantiate(maleArmLowerRight[5], output.transform);
            break;

        case ItemType.LeftShoulder:
        case ItemType.RightShoulder:
            ActivateAndInstantiate(shoulderPadsLeft[itemIndex], output.transform);
            ActivateAndInstantiate(shoulderPadsRight[itemIndex], output.transform);
            break;

        case ItemType.Helm:
            ActivateAndInstantiate(maleHelmets[itemIndex], output.transform);
            break;

        case ItemType.Leggings:
            ActivateAndInstantiate(maleHips[itemIndex], output.transform);
            break;
        }

        if (itemMaterial)
        {
            foreach (var renderer in output.GetComponentsInChildren <SkinnedMeshRenderer>())
            {
                renderer.sharedMaterial = itemMaterial;
            }
        }

        return(output);
    }
Exemple #14
0
    public ItemController Create(RavenNest.Models.Item item, bool useMalePrefab)
    {
        definition = item;

        gameObject.name = item.Name;

        transform.localPosition = Vector3.zero;
        transform.localRotation = Quaternion.identity;

        Id    = item.Id;
        Name  = item.Name;
        Level = item.Level;

        WeaponAim   = item.WeaponAim;
        WeaponPower = item.WeaponPower;
        ArmorPower  = item.ArmorPower;

        RequiredAttackLevel  = item.RequiredAttackLevel;
        RequiredDefenseLevel = item.RequiredDefenseLevel;

        Category          = item.Category;
        Type              = item.Type;
        Material          = item.Material;
        FemaleModelID     = item.FemaleModelId;
        MaleModelID       = item.MaleModelId;
        GenericPrefabPath = item.GenericPrefab;
        MalePrefabPath    = item.MalePrefab;
        FemalePrefabPath  = item.FemalePrefab;
        IsGenericModel    = item.IsGenericModel.GetValueOrDefault();

        if (!prefab)
        {
            var path = IsGenericModel
                ? GenericPrefabPath
                : useMalePrefab
                    ? MalePrefabPath
                    : FemalePrefabPath;

            if (string.IsNullOrEmpty(path))
            {
                return(this);
            }

            prefab = Resources.Load <GameObject>(path);
            if (!prefab)
            {
                //Debug.LogError(this.name + " failed to load prefab: " + path);
                return(this);
            }

            model = Instantiate(prefab, transform) as GameObject;
        }

        return(this);
    }
Exemple #15
0
        private IWeightConfiguration GetWeightConfiguration(ItemMaterial material)
        {
            var result = configuration.Weight.FirstOrDefault(config => config.Material == material);

            if (result == null)
            {
                throw new ApplicationException($"No {baseName} weight configuration for material: {material}");
            }

            return(result);
        }
Exemple #16
0
    /// <summary>
    /// 解析材料
    /// </summary>
    private void ParseMaterial()
    {
        var jsonData = SerializeTool.JsonDeserialize(Contract.Instance.materialDataPath);

        for (int i = 0; i < jsonData.Count; i++)
        {
            var materialData = new ItemMaterial();
            materialData.SetData(jsonData[i]);
            allItems.Add(materialData.id, materialData);//向物品管理器中添加该数据
        }
    }
 public bool ContainsItem(ItemMaterial m)
 {
     for (int i = 0; i < _Items.Count; i++)
     {
         if (_Items[i].GetType() == m)
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #18
0
        private SymbolsImage GetEquippedImage(ItemMaterial material, IArmorPieceConfiguration config)
        {
            if (string.IsNullOrEmpty(config.EquippedImage))
            {
                return(null);
            }

            var image = imagesStorage.GetImage(config.EquippedImage);

            return(ItemRecolorHelper.RecolorItemImage(image, material));
        }
        public ActionResult Create(ItemMaterial itemmaterial)
        {
            if (ModelState.IsValid)
            {
                db.ItemMaterial.Add(itemmaterial);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.IdMaterial = new SelectList(db.Material, "IdMaterial", "Nombre", itemmaterial.IdMaterial);
            return View(itemmaterial);
        }
        //Meant for making things like magic blasts that will never actually appear in the world.
        public static ItemInstance Make(int number, int faces, string actionString, string skill)
        {
            int   division = 50;
            int   size     = number * division;
            float weight   = (float)faces / number;

            ItemMaterial material = new ItemMaterial("", 1, 0, weight);

            BaseItemType tempItem = new BaseItemType("", "", "", "Temporary weapon", "Temporary weapon", "None", size, material, "Weapon", skill, actionString, null, 0, 0, 0);

            return(new ItemInstance(tempItem, new Vector2Int(-1, -1), true));
        }
Exemple #21
0
    public void Create(RavenNest.Models.Item item, bool useMalePrefab)
    {
        this.definition = item;

        this.gameObject.name = item.Name;

        this.transform.localPosition = Vector3.zero;
        this.transform.localRotation = Quaternion.identity;

        this.Id    = item.Id;
        this.Name  = item.Name;
        this.Level = item.Level;

        this.WeaponAim   = item.WeaponAim;
        this.WeaponPower = item.WeaponPower;
        this.ArmorPower  = item.ArmorPower;

        this.RequiredAttackLevel  = item.RequiredAttackLevel;
        this.RequiredDefenseLevel = item.RequiredDefenseLevel;

        this.Category          = item.Category;
        this.Type              = item.Type;
        this.Material          = item.Material;
        this.FemaleModelID     = item.FemaleModelId;
        this.MaleModelID       = item.MaleModelId;
        this.GenericPrefabPath = item.GenericPrefab;
        this.MalePrefabPath    = item.MalePrefab;
        this.FemalePrefabPath  = item.FemalePrefab;
        this.IsGenericModel    = item.IsGenericModel.GetValueOrDefault();

        if (!prefab)
        {
            var path = IsGenericModel
                ? this.GenericPrefabPath
                : useMalePrefab
                    ? this.MalePrefabPath
                    : this.FemalePrefabPath;

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            this.prefab = Resources.Load <GameObject>(path);
            if (!prefab)
            {
                //Debug.LogError(this.name + " failed to load prefab: " + path);
                return;
            }

            this.model = Instantiate(prefab, this.transform) as GameObject;
        }
    }
Exemple #22
0
        /// <summary>
        /// Spawns an asteroid with random characteristics
        /// </summary>
        /// <returns>The asteroid that was spawned</returns>
        public GameObject SpawnAsteroid()
        {
            int     spriteIndex = Random.Range(0, asteroidSprites.Count);
            int     size        = Random.Range(0, 3);
            Vector2 velocity    = new Vector2(Random.Range(-10f, 10f), Random.Range(-10f, 10f));
            Vector3 position;

            do
            {
                position = new Vector3(
                    Random.Range(-(SceneConstants.BoundarySize.x - SceneConstants.BodySpawnPadding), SceneConstants.BoundarySize.x - SceneConstants.BodySpawnPadding),
                    Random.Range(-(SceneConstants.BoundarySize.y - SceneConstants.BodySpawnPadding), SceneConstants.BoundarySize.y - SceneConstants.BodySpawnPadding), 0);
            }while (position.x > -SceneConstants.PlayerSafeZone.x && position.x < SceneConstants.PlayerSafeZone.x ||
                    position.y > -SceneConstants.PlayerSafeZone.y && position.y < SceneConstants.PlayerSafeZone.y);

            ItemMaterial[] contents = new ItemMaterial[Random.Range(1, 11)];
            for (int i = 0; i < contents.Length; i++)
            {
                contents[i] = GenerateItemMaterial();
            }

            Material mat = null;

            switch (currTheme.import_Asteroids)
            {
            case (int)SpriteImportType.png:
                mat = matMgr.Mat_Raster;
                break;

            case (int)SpriteImportType.svggradient:
                mat = matMgr.Mat_VectorGradient;
                break;

            case (int)SpriteImportType.svg:
            default:
                mat = matMgr.Mat_Vector;
                break;
            }


            GameObject asteroid = Instantiate(asteroidPrefab);

            Asteroid behaviour = asteroid.GetComponent <Asteroid>();

            Color32[] uiColors = new Color32[]
            {
                currTheme.elem_objHealthValue,
                currTheme.elem_objHealthBkgd
            };
            behaviour.Setup(contents, (AsteroidSize)size, asteroidSprites[spriteIndex], mat, currTheme.spriteColor_asteroid, velocity, position, this, uiColors, currTheme.spriteColor_asteroidDamage);

            return(asteroid);
        }
    public void AddFuel(InventoryItemStack pItemStack)
    {
        ItemMaterial item = pItemStack.ContainedItem as ItemMaterial;

        MinutesLeft = Mathf.Clamp(MinutesLeft += item.BurnTime, 0, 10000f);
        FindObjectOfType <PlayerInventory>().RemoveFromStack(pItemStack, 1);

        if (WoodSprite != null)
        {
            WoodSprite.SetActive(true);
        }
    }
Exemple #24
0
        public ActionResult GetMaterial(int id = -1)
        {
            if (id == -1)
            {
                ItemMaterial model = new ItemMaterial()
                {
                    Id = -1
                };
                return(Json(model));
            }
            var entity = _itemMaterialService.Get(id);

            return(Json(entity));
        }
Exemple #25
0
    ItemSlot GetItemSlot(Item item)
    {
        foreach (ItemSlot iS in _items)
        {
            if (iS._item.name == item.name && iS._item.material == item.material)
            {
                return(iS);
            }
        }
        ItemMaterial itemMaterial = new ItemMaterial();
        ItemSlot     emptySlot    = new ItemSlot()
        {
            _item = item, _amount = 0
        };

        return(emptySlot);
    }
Exemple #26
0
        //	circle
        private static Mesh createCircleMesh(float radius, ItemMaterial itemMaterial)
        {
            Vector3[] vertices  = new Vector3[circleSegments + 1];
            int[]     triangles = new int[circleSegments * 3];
            Vector2[] uvs       = new Vector2[circleSegments + 1];

            vertices[0] = new Vector3(0, 0, 0);

            Texture2D texture = itemTextures[(int)itemMaterial];

            IntVector2 TextureXYCenter = new IntVector2(
                (int)Math.Round((texture.width / 2) / itemMaterials[(int)itemMaterial].mainTextureScale.x),
                (int)Math.Round((texture.height / 2) / itemMaterials[(int)itemMaterial].mainTextureScale.y));

            uvs[0] = TextureXY2UV2(texture, TextureXYCenter);

            double angle = 2 * Math.PI / circleSegments;

            for (int i = 0; i < circleSegments; i++)
            {
                vertices[i + 1] = new Vector3((float)(radius * Math.Cos(i * angle)), (float)(radius * Math.Sin(i * angle)), 0);

                uvs[i + 1] = TextureXY2UV2(texture, TextureXYCenter.x + (int)(radius * PixelsPerUnit * Math.Cos(i * angle)), TextureXYCenter.y + (int)(radius * PixelsPerUnit * Math.Sin(i * angle)));

                triangles[i * 3] = 0;

                if (i < circleSegments - 1)
                {
                    triangles[i * 3 + 1] = i + 2;
                }
                else
                {
                    triangles[i * 3 + 1] = 1;
                }

                triangles[i * 3 + 2] = i + 1;
            }

            Mesh mesh = new Mesh();

            mesh.vertices  = vertices;
            mesh.triangles = triangles;
            mesh.uv        = uvs;

            return(mesh);
        }
Exemple #27
0
		protected int GetSwordDamage(ItemMaterial itemMaterial)
		{
			switch (itemMaterial)
			{
				case ItemMaterial.Wood:
					return 5;
				case ItemMaterial.Gold:
					return 5;
				case ItemMaterial.Stone:
					return 6;
				case ItemMaterial.Iron:
					return 7;
				case ItemMaterial.Diamond:
					return 8;
				default:
					return 1;
			}
		}
Exemple #28
0
    void Start()
    {
        gui      = new GUIManager(this);
        skin     = Resources.Load("GUI Skins/Normal") as GUISkin;
        material = new ItemMaterial();
        AddToInventory(new Staff(this), 1);
        AddToInventory(new HeaterShield(this), 1);
        AddToInventory(new Shirt(this), 1);
        AddToInventory(new Cloak(this), 1);
        AddToInventory(new Shoes(this), 1);
        AddToInventory(new NormanSword(this), 1);
        AddToInventory(new PointedHat(this), 1);
        AddToInventory(new Pants(this), 1);

        AddToInventory(new MiningProbe(Tier.One, this), 1000);
        AddToInventory(new MiningTablet(Tier.One, this), 1);

        test = new Window(43, content.Mining, transform, new Rect(0, 0, 300, 300));
        //green = new Window (44, content.Green, transform, new Rect(300, 300, 300, 300));
    }
Exemple #29
0
        private string GenerateName(ItemMaterial material, string typeName, ArmorType type)
        {
            var materialPrefix = NameGenerationHelper.GetMaterialPrefix(material);
            var armorTypeName  = GetArmorTypeName(type);

            var builder = new List <string>();

            if (!string.IsNullOrEmpty(materialPrefix))
            {
                builder.Add(materialPrefix);
            }

            if (!string.IsNullOrEmpty(typeName))
            {
                builder.Add(typeName);
            }

            builder.Add(armorTypeName);

            return(string.Join(" ", builder));
        }
Exemple #30
0
        public static short GetIdealNumberOfUses(ItemMaterial material)
        {
            switch (material)
            {
            case ItemMaterial.Wood:
                return(60);

            case ItemMaterial.Stone:
                return(132);

            case ItemMaterial.Iron:
                return(251);

            case ItemMaterial.Gold:
                return(33);

            case ItemMaterial.Diamond:
                return(1562);
            }
            return(short.MaxValue);
        }
Exemple #31
0
    /// <summary>
    /// 根据id创建item 一定要返回新创建的item 否则引用数据备份会出现bug
    /// </summary>
    /// <param name="id"></param>
    private BaseItemData GetItemDataById(int id)
    {
        if (allItems.Count != 0)
        {
            BaseItemData baseItemData;
            allItems.TryGetValue(id, out baseItemData);
            switch (baseItemData.type)
            {
            case ItemType.Consumable:
                ItemConsumable itemConsumable = (ItemConsumable)baseItemData;
                ItemConsumable resultItem     = new ItemConsumable();
                resultItem.SetData(itemConsumable.hp, itemConsumable.mp, itemConsumable.itemEffect, baseItemData.id, baseItemData.name, baseItemData.quality, baseItemData.type, baseItemData.description, baseItemData.amount, baseItemData.capacity, baseItemData.buyprice, baseItemData.sellprice);
                return(resultItem);

            case ItemType.Equipment:
                ItemEquipment itemEquipment = (ItemEquipment)baseItemData;
                ItemEquipment resultItem1   = new ItemEquipment();
                resultItem1.SetData(itemEquipment.strength, itemEquipment.intellect, itemEquipment.agility, itemEquipment.stamina, itemEquipment.equipmentType, baseItemData.id, baseItemData.name, baseItemData.quality, baseItemData.type, baseItemData.description, baseItemData.amount, baseItemData.capacity, baseItemData.buyprice, baseItemData.sellprice);
                return(resultItem1);

            case ItemType.Material:
                ItemMaterial itemMaterial = (ItemMaterial)baseItemData;
                ItemMaterial resultItem2  = new ItemMaterial();
                resultItem2.SetData(baseItemData.id, baseItemData.name, baseItemData.quality, baseItemData.type, baseItemData.description, baseItemData.amount, baseItemData.capacity, baseItemData.buyprice, baseItemData.sellprice);
                return(resultItem2);

            case ItemType.Weapon:
                ItemWeapon itemWeapon  = (ItemWeapon)baseItemData;
                ItemWeapon resultItem3 = new ItemWeapon();
                resultItem3.SetData(itemWeapon.damage, itemWeapon.weaponType, itemWeapon.weaponEffects, baseItemData.id, baseItemData.name, baseItemData.quality, baseItemData.type, baseItemData.description, baseItemData.amount, baseItemData.capacity, baseItemData.buyprice, baseItemData.sellprice);
                return(resultItem3);
            }
        }
        else
        {
            Debug.LogError("物品列表中没有物品");
        }
        return(null);
    }
Exemple #32
0
        private static int GetDurability(ItemType itemType, ItemMaterial material)
        {
            int durability = 0;

            switch (material)
            {
            case ItemMaterial.Leather:
                break;

            case ItemMaterial.Chain:
                break;

            case ItemMaterial.None:
                break;

            case ItemMaterial.Wood:
                durability = 60;
                break;

            case ItemMaterial.Stone:
                durability = 132;
                break;

            case ItemMaterial.Gold:
                durability = 33;
                break;

            case ItemMaterial.Iron:
                durability = 351;
                break;

            case ItemMaterial.Diamond:
                durability = 1562;
                break;
            }

            return(durability);
        }
Exemple #33
0
		private int GetPickAxeDamage(ItemMaterial itemMaterial)
		{
			return GetSwordDamage(itemMaterial) - 2;
		}
Exemple #34
0
 public Weapon(ItemMaterial material, string name, float weight, byte id)
     : base(name, weight, id)
 {
 }
Exemple #35
0
 public PickaxeItem(string name, ItemMaterial material)
     : base(name, material, Craft.Net.Logic.ToolType.Pickaxe)
 {
 }
Exemple #36
0
		private int GetAxeDamage(ItemMaterial itemMaterial)
		{
			return GetSwordDamage(itemMaterial) - 1;
		}
Exemple #37
0
		private int GetShovelDamage(ItemMaterial itemMaterial)
		{
			return GetSwordDamage(itemMaterial) - 3;
		}
Exemple #38
0
    ItemParent AddItem(ItemInstance instance)
    {
        ItemParent item = null;
        LoggerHelper.Debug("AddItem:" + instance.bagType + ",index:" + instance.gridIndex);
        switch (instance.bagType)
        {
            case ITEM_TYPE_EQUIPMENT:
                if (ItemEquipmentData.dataMap.ContainsKey(instance.templeId))
                {
                    item = GetItemEquipmentByInstance(instance);
                }
                else
                {
                    ItemParentInstance toolInstance = new ItemParentInstance()
                    {
                        id = instance.id,
                        bagType = instance.bagType,
                        stack = instance.stack,
                        templeId = instance.templeId,
                        gridIndex = instance.gridIndex,
                    };
                    item = new ItemMaterial(toolInstance);
                }

                m_itemsInBag[ITEM_TYPE_EQUIPMENT][item.gridIndex] = item;
                break;

            case ITEM_TYPE_JEWEL:
                ItemJewelInstance jewelInstance = new ItemJewelInstance()
                {
                    id = instance.id,
                    bagType = instance.bagType,
                    bindingType = instance.bindingType,
                    stack = instance.stack,
                    templeId = instance.templeId,
                    gridIndex = instance.gridIndex,
                };
                item = new ItemJewel(jewelInstance);
                m_itemsInBag[ITEM_TYPE_JEWEL][item.gridIndex] = item;
                break;
            case ITEM_TYPE_ONEQUIP:
                item = GetItemEquipmentByInstance(instance);
                //Mogo.Util.LoggerHelper.Debug("item.gridIndex:" + item.gridIndex + "!!!!!!!!!!!");
                m_itemsOnEquip[item.gridIndex + 1] = (ItemEquipment)item;
                //Mogo.Util.LoggerHelper.Debug("inventroy equip:" + item.templateId);
                myself.Equip(item.templateId);
                break;
            case ITEM_TYPE_MATERIAL:
                ItemParentInstance materialInstance = new ItemParentInstance()
                {
                    id = instance.id,
                    bagType = instance.bagType,
                    stack = instance.stack,
                    templeId = instance.templeId,
                    gridIndex = instance.gridIndex,
                };
                item = new ItemMaterial(materialInstance);
                m_itemsInBag[ITEM_TYPE_MATERIAL][item.gridIndex] = item;
                break;

        }
        return item;
    }
 public ActionResult Edit(ItemMaterial itemmaterial)
 {
     if (ModelState.IsValid)
     {
         db.Entry(itemmaterial).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.IdMaterial = new SelectList(db.Material, "IdMaterial", "Nombre", itemmaterial.IdMaterial);
     return View(itemmaterial);
 }