Esempio n. 1
0
 public static void GenerateCustomIcons()
 {
     if (MenuShop.generated)
     {
         return;
     }
     MenuShop.generated = true;
     for (int i = 512; i < 1024; i++)
     {
         if (MenuShop.shopdata[i] != null)
         {
             string[] array = MenuShop.shopdata[i].iconname.Split(new char[]
             {
                 '_'
             });
             if (array.Length == 3)
             {
                 GameObject gameObject = ItemPreview.Create("w_" + array[0]);
                 if (gameObject == null)
                 {
                     MonoBehaviour.print("error create preview: w_" + array[0]);
                 }
                 else
                 {
                     ItemPreview.SetSkin(gameObject, MenuShop.shopdata[i].iconname);
                     MenuShop.shopdata[i].icon = ItemPreview.Get();
                     UnityEngine.Object.DestroyImmediate(gameObject);
                 }
             }
         }
     }
 }
 private void Awake()
 {
     btn           = GetComponent <Button>();
     img           = GetComponent <Image>();
     rectTransform = GetComponent <RectTransform>();
     itemPreview   = GetComponentInChildren <ItemPreview>();
     textLabel     = GetComponentInChildren <Text>();
 }
Esempio n. 3
0
        private async void ResetItemPreviewRotationToDefault()
        {
            await AsyncManager.WaitForFrame(1);

            ItemPreview.ResetRotation();
            ResetCameraPositionAndRotation();
            RenderCamera();
        }
Esempio n. 4
0
    public static void Preview(MenuShop.CShopData item)
    {
        if (MenuPreview.go != null)
        {
            MenuPreview.go.name = string.Concat(new object[]
            {
                "item_",
                Time.time,
                " ",
                UnityEngine.Random.Range(0, 1000)
            });
            UnityEngine.Object.Destroy(MenuPreview.go);
        }
        MenuPreview.currData = item;
        if (MenuPreview.currData == null)
        {
            return;
        }
        string[] array = MenuPreview.currData.iconname.Split(new char[]
        {
            '_'
        });
        if (array.Length != 3)
        {
            return;
        }
        MenuPreview.go = ItemPreview.Create("w_" + array[0]);
        if (MenuPreview.go == null)
        {
            MonoBehaviour.print("error create preview w_" + array[0]);
            return;
        }
        ItemPreview.SetSkin(MenuPreview.go, MenuPreview.currData.iconname);
        Transform[] componentsInChildren = MenuPreview.go.GetComponentsInChildren <Transform>();
        Transform[] array2 = componentsInChildren;
        for (int i = 0; i < array2.Length; i++)
        {
            Transform transform = array2[i];
            transform.gameObject.layer = 0;
        }
        RotateModel rotateModel = MenuPreview.go.AddComponent <RotateModel>();

        rotateModel.fullrotate = true;
    }
        public static async Task <ItemPreview> GetLatestCreated(HttpClient httpClient, TypeOfItems typeOfItems)
        {
            HttpResponseMessage responseMessage = null;

            try
            {
                responseMessage = await httpClient.GetAsync($"api/{typeOfItems}s?lastCreated=true");
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            if (responseMessage.IsSuccessStatusCode)
            {
                ItemPreview item = await responseMessage.Content.ReadAsAsync <ItemPreview>();

                return(item);
            }
            return(null);
        }
Esempio n. 6
0
        private void InventoryOnItemUsed(InventoryItemBase item, ItemType type)
        {
            if (item == null || type == ItemType.Resource)
            {
                return;
            }
            int?eventArgument;

            if (System.Type.op_Equality(item.GetType(), typeof(FoodInventoryItem)))
            {
                FoodInventoryItem foodInventoryItem = (FoodInventoryItem)item;
                PlayerInventory.PlayerPed.get_Task().PlayAnimation(foodInventoryItem.AnimationDict, foodInventoryItem.AnimationName, 8f, foodInventoryItem.AnimationDuration, foodInventoryItem.AnimationFlags);
                // ISSUE: reference to a compiler-generated field
                PlayerInventory.OnUsedFoodEvent foodUsed = PlayerInventory.FoodUsed;
                if (foodUsed != null)
                {
                    foodUsed(foodInventoryItem, foodInventoryItem.FoodType);
                }
            }
            else if (System.Type.op_Equality(item.GetType(), typeof(WeaponInventoryItem)))
            {
                WeaponInventoryItem weapon = (WeaponInventoryItem)item;
                PlayerInventory.PlayerPed.get_Weapons().Give(weapon.Hash, weapon.Ammo, true, true);
                // ISSUE: reference to a compiler-generated field
                PlayerInventory.OnUsedWeaponEvent weaponUsed = PlayerInventory.WeaponUsed;
                if (weaponUsed != null)
                {
                    weaponUsed(weapon);
                }
            }
            else if (System.Type.op_Equality(item.GetType(), typeof(BuildableInventoryItem)) || System.Type.op_Equality(item.GetType(), typeof(WeaponStorageInventoryItem)))
            {
                if (PlayerInventory.PlayerPed.IsInVehicle())
                {
                    UI.Notify("You can't build while in a vehicle!");
                    return;
                }
                BuildableInventoryItem buildableInventoryItem = (BuildableInventoryItem)item;
                ItemPreview            itemPreview            = new ItemPreview();
                itemPreview.StartPreview(buildableInventoryItem.PropName, buildableInventoryItem.GroundOffset, buildableInventoryItem.IsDoor);
                while (!itemPreview.PreviewComplete)
                {
                    Script.Yield();
                }
                Prop result = itemPreview.GetResult();
                if (Entity.op_Equality((Entity)result, (Entity)null))
                {
                    return;
                }
                PlayerInventory.AddBlipToProp((IProp)buildableInventoryItem, buildableInventoryItem.Id, (Entity)result);
                // ISSUE: reference to a compiler-generated field
                PlayerInventory.OnUsedBuildableEvent buildableUsed = PlayerInventory.BuildableUsed;
                if (buildableUsed != null)
                {
                    buildableUsed(buildableInventoryItem, result);
                }
            }
            else if (System.Type.op_Equality(item.GetType(), typeof(UsableInventoryItem)))
            {
                foreach (UsableItemEvent itemEvent in ((UsableInventoryItem)item).ItemEvents)
                {
                    switch (itemEvent.Event)
                    {
                    case ItemEvent.GiveArmor:
                        eventArgument = itemEvent.EventArgument as int?;
                        int num1       = eventArgument ?? 0;
                        Ped playerPed1 = PlayerInventory.PlayerPed;
                        ((Entity)playerPed1).set_Health(((Entity)playerPed1).get_Health() + num1);
                        break;

                    case ItemEvent.GiveHealth:
                        eventArgument = itemEvent.EventArgument as int?;
                        int num2       = eventArgument ?? 0;
                        Ped playerPed2 = PlayerInventory.PlayerPed;
                        playerPed2.set_Armor(playerPed2.get_Armor() + num2);
                        break;
                    }
                }
            }
            else if (System.Type.op_Equality(item.GetType(), typeof(CraftableInventoryItem)) && !((CraftableInventoryItem)item).Validation.Invoke())
            {
                return;
            }
            this._inventory.AddItem(item, -1, type);
        }
Esempio n. 7
0
        private void InventoryOnItemUsed(InventoryItemBase item, ItemType type)
        {
            if (item != null && type != 0)
            {
                if (item.GetType() == typeof(FoodInventoryItem))
                {
                    FoodInventoryItem foodItem = (FoodInventoryItem)item;
                    PlayerPed.Task.PlayAnimation(foodItem.AnimationDict, foodItem.AnimationName, 8f, foodItem.AnimationDuration, foodItem.AnimationFlags);
                    PlayerInventory.FoodUsed?.Invoke(foodItem, foodItem.FoodType);
                }
                else if (item.GetType() == typeof(WeaponInventoryItem))
                {
                    WeaponInventoryItem weaponItem = (WeaponInventoryItem)item;
                    PlayerPed.Weapons.Give(weaponItem.Hash, weaponItem.Ammo, true, true);
                    PlayerInventory.WeaponUsed?.Invoke(weaponItem);
                }
                else if (item.GetType() == typeof(BuildableInventoryItem) || item.GetType() == typeof(WeaponStorageInventoryItem))
                {
                    if (PlayerPed.IsInVehicle())
                    {
                        UI.Notify("You can't build while in a vehicle!");
                        return;
                    }
                    BuildableInventoryItem buildableItem = (BuildableInventoryItem)item;
                    ItemPreview            preview       = new ItemPreview();
                    preview.StartPreview(buildableItem.PropName, buildableItem.GroundOffset, buildableItem.IsDoor);
                    while (!preview.PreviewComplete)
                    {
                        Script.Yield();
                    }
                    Prop result = preview.GetResult();
                    if (result == null)
                    {
                        return;
                    }
                    AddBlipToProp(buildableItem, buildableItem.Id, result);
                    PlayerInventory.BuildableUsed?.Invoke(buildableItem, result);
                }
                else if (item.GetType() == typeof(UsableInventoryItem))
                {
                    UsableInventoryItem usableItem = (UsableInventoryItem)item;
                    UsableItemEvent[]   events     = usableItem.ItemEvents;
                    UsableItemEvent[]   array      = events;
                    foreach (UsableItemEvent @event in array)
                    {
                        switch (@event.Event)
                        {
                        case ItemEvent.GiveArmor:
                        {
                            int arg        = (@event.EventArgument as int?) ?? 0;
                            Ped playerPed2 = new Ped(PlayerPed.Handle);
                            playerPed2.Health = playerPed2.Health + arg;
                            break;
                        }

                        case ItemEvent.GiveHealth:
                        {
                            int arg2      = (@event.EventArgument as int?) ?? 0;
                            Ped playerPed = new Ped(PlayerPed.Handle);
                            playerPed.Armor = playerPed.Armor + arg2;
                            break;
                        }
                        }
                    }
                }
                else if (item.GetType() == typeof(CraftableInventoryItem))
                {
                    CraftableInventoryItem craftableItem = (CraftableInventoryItem)item;
                    if (!craftableItem.Validation())
                    {
                        return;
                    }
                }
                _inventory.AddItem(item, -1, type);
            }
        }
Esempio n. 8
0
 public UpdateModel(TypeOfUpdates updateType, ItemPreview item)
 {
     UpdateType  = updateType;
     ItemPreview = item;
 }
Esempio n. 9
0
 public ModifyCallStatus(bool isSuccess, bool itemChanged, ItemPreview item)
 {
     IsCallSucces       = isSuccess;
     ItemPreviewChanged = itemChanged;
     ItemPreview        = item;
 }