コード例 #1
0
        public override void PlayerInteract(HolderObject interactObject, GameManager gameManager, Vector3?hitPosition = null)
        {
            base.PlayerInteract(interactObject, gameManager, hitPosition);

            CurrentHp -= interactObject.Item.Damage;
            if (CurrentHp > 0)
            {
                GameManager.Player.MainHud.ShowHudText("[" + CurrentHp + "/" + Hp + "]", HudTextColor.Yellow);
            }
            if (CurrentHp <= 0)
            {
                CurrentHp = 0;

                if (ItemModel != null)
                {
                    if (ItemModel.AddDestroyReward)
                    {
                        foreach (var holderObject in ItemModel.CraftRecipe)
                        {
                            var placeObject = HolderObjectFactory.GetItem(holderObject.Item.GetType(), holderObject.Amount / 2);
                            GameManager.PlacementItemsController.DropItemToGround(GameManager, placeObject);
                        }
                    }
                }

                GameManager.PlacementItemsController.RemovePlacedItem(MainObject);
                MainObject.SetActive(false);
                SoundManager.PlaySFX(WorldConsts.AudioConsts.Destroy);
            }
        }
コード例 #2
0
        private void RefreshCooking()
        {
            _firedWoods++;
            foreach (var holderObject in _sourceinventory.Slots)
            {
                if (holderObject != null && holderObject.Item != null && holderObject.Item is WoodResource)
                {
                    _destinationInventory.AddItem(HolderObjectFactory.GetItem(holderObject.Item.CookingResult.Key.GetType(), holderObject.Item.CookingResult.Value));
                    holderObject.ChangeAmount(1);
                }
                else if (holderObject != null &&
                         holderObject.Amount > 0 &&
                         holderObject.Item.CookingResult.Key != null &&
                         holderObject.Item.Converters.Contains(TypeConverter))
                {
                    if (_firedWoods % holderObject.Item.NeedWoodToCook == 0)
                    {
                        _destinationInventory.AddItem(HolderObjectFactory.GetItem(holderObject.Item.CookingResult.Key.GetType(), holderObject.Item.CookingResult.Value));
                        holderObject.ChangeAmount(1);
                    }
                }
            }

            if (_panel != null)
            {
                _panel.UpdateView(_sourceinventory, _destinationInventory);
            }

            if (!HasWood())
            {
                SnuffOut();
            }
        }
コード例 #3
0
        private void PlantItem()
        {
            if (_currentItem == null)
            {
                StartCoroutine(TweenPinPong(DescriptionLabel.gameObject, 0.5f, 1.1f));
                return;
            }

            if (_currentItem.Amount < _maxSeeds)
            {
                StartCoroutine(TweenPinPong(RequarementAmountLabel.gameObject, 0.5f, 1.1f));
                return;
            }

            var itemType = _currentItem.Item.GetType();

            if (_currentItem.Amount <= _maxSeeds)
            {
                GameManager.PlayerModel.Inventory.RemoveItem(_currentItem);
            }
            else
            {
                _currentItem.ChangeAmount(_maxSeeds);
            }

            _currentItem = HolderObjectFactory.GetItem(itemType, _maxSeeds);

            CurrentState = GardenBedState.InProgress;
            UpdateView();

            if (_onPlantAction != null)
            {
                _onPlantAction(_currentItem);
            }
        }
コード例 #4
0
        public override HolderObject GetResource()
        {
            var amount = UnityEngine.Random.Range(MinMiningAmount, MaxMiningAmount);

            InitialAmount -= amount;
            return(HolderObjectFactory.GetItem(typeof(Meat), amount));
        }
コード例 #5
0
        private void AddFish()
        {
            var holder = HolderObjectFactory.GetItem(typeof(Fish), 1);

            _gameManager.PlayerModel.Inventory.AddItem(holder);
            _gameManager.Player.MainHud.GettingResourceView.ShowItem(holder.Item.IconName, holder.Amount, holder.Item.LocalizationName);
        }
コード例 #6
0
        public override HolderObject GetResource()
        {
            var amount = GetMiningAmount();

            InitialAmount -= amount;
            return(HolderObjectFactory.GetItem(typeof(FiberResource), amount));
        }
コード例 #7
0
    private void GetItem(GameManager gameManager = null)
    {
        if (_gameManager == null)
        {
            _gameManager = GameObject.FindWithTag("GameManager").GetComponent <GameManager>();
        }

        if (_gameManager == null)
        {
            return;
        }

        var playerDistance = (transform.localPosition - _gameManager.Player.transform.localPosition).sqrMagnitude;

        if (playerDistance > CanGetDistance)
        {
            return;
        }

        var item = HolderObjectFactory.GetItem(_typeItem, Amount, _currentDurability);

        if (_gameManager.PlayerModel.Inventory.AddItem(item))
        {
            _gameManager.Player.MainHud.ShowAddedResource(item.Item.IconName, item.Amount, item.Item.LocalizationName);
            _gameManager.PlacementItemsController.RemovePlacedItem(gameObject);
            gameObject.SetActive(false);
            SoundManager.PlaySFX(_soundName);
        }
        else
        {
            _gameManager.Player.MainHud.ShowHudText(Localization.Get("no_place_in_inventory"), HudTextColor.Red);
        }
    }
コード例 #8
0
        public void OnInventorySlotClick(UiSlot uiSlot)
        {
            RefreshPrevSelectedSlot();

            if (_prevSelectedSlot == uiSlot)
            {
                if (uiSlot.ItemModel.Item is ConsumableItem)
                {
                    if (uiSlot.ItemModel.Amount == 1)
                    {
                        uiSlot.SetActiveSlot(false);
                    }

                    UseItem(uiSlot.ItemModel);
                }
                else
                {
                    uiSlot.SetActiveSlot(false);
                }
            }
            else if (_prevSelectedSlot == null)
            {
                if (uiSlot.ItemModel != null)
                {
                    uiSlot.SetActiveSlot(true);
                }
            }
            else
            {
                if (uiSlot.ItemModel == null || uiSlot.ItemModel.Item == null)
                {
                    if (_prevSelectedSlot.ItemModel.Amount == 1)
                    {
                        _prevSelectedSlot.SetActiveSlot(false);
                    }

                    uiSlot.SetData(_gameManager, HolderObjectFactory.GetItem(_prevSelectedSlot.ItemModel.Item.GetType(), 1));
                    _prevSelectedSlot.ChangeAmount(1);
                }
                else if (uiSlot.ItemModel.Item.GetType() == _prevSelectedSlot.ItemModel.Item.GetType() &&
                         (uiSlot.ItemModel.Item.Durability == null || !uiSlot.ItemModel.Item.ShowDurability))
                {
                    if (_prevSelectedSlot.ItemModel.Amount == 1)
                    {
                        _prevSelectedSlot.SetActiveSlot(false);
                    }

                    _gameManager.PlayerModel.ChangeItemAmount(uiSlot, -1);
                    _gameManager.PlayerModel.ChangeItemAmount(_prevSelectedSlot, 1);
                }
                else
                {
                    var curModel = uiSlot.ItemModel;
                    uiSlot.SetData(_gameManager, _prevSelectedSlot.ItemModel);
                    _prevSelectedSlot.SetData(_gameManager, curModel);
                    _prevSelectedSlot.SetActiveSlot(false);
                }
            }
        }
コード例 #9
0
        public Cobblestone()
        {
            LocalizationName = "cobblestone";
            Description      = "cobblestone_descr";
            IconName         = "cobblestone_icon";

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(StoneResource), 3));
        }
コード例 #10
0
        public WoodPlank()
        {
            LocalizationName = "wood_plank";
            Description      = "wood_plank_descr";
            IconName         = "wood_plank_icon";

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(WoodResource), 3));
        }
コード例 #11
0
        public MediumBackpack()
        {
            LocalizationName = "medium_backpack";
            Description      = "medium_backpack_descr";
            IconName         = "backpack_icon";

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Leather), 8));
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Rope), 4));
        }
コード例 #12
0
        public WoodenFence()
        {
            LocalizationName = "fence";
            IconName         = "fence";

            PrefabTemplatePath = "Prefabs/Constructions/WoodenFence/WoodenFenceTemplate";
            PrefabPath         = "Prefabs/Constructions/WoodenFence/WoodenFence";

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(WoodResource), 30));
        }
コード例 #13
0
        public SmallBackpack()
        {
            LocalizationName = "small_backpack";
            Description      = "small_backpack_descr";
            IconName         = "backpack_icon";

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Fur), 5));
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Leather), 3));
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Rope), 5));
        }
コード例 #14
0
        public Medkit()
        {
            LocalizationName = "medkit";
            Description      = "medkit_descr";
            IconName         = "medkit_icon";

            HealthEffect = 50f;

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Bandage), 5));
        }
コード例 #15
0
        public Rope()
        {
            LocalizationName = "rope";
            Description      = "rope_descr";
            IconName         = "rope_icon";
            CanBuy           = true;
            ShopPrice        = 20;

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(FiberResource), 3));
        }
コード例 #16
0
        public AntiRadiationPills()
        {
            LocalizationName = "anti_radiation_pills";
            Description      = "anti_radiation_pills_descr";
            IconName         = "anti_radiation_pills_icon";

            HealthEffect = 25f;

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Bandage), 3));
        }
コード例 #17
0
        public Torch()
        {
            LocalizationName = "torch";
            Description      = "torch_descr";
            IconName         = "torch_icon";
            Durability       = 300;

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(WoodResource), 10));
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Rope), 1));
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Fat), 3));
        }
コード例 #18
0
        public Mace()
        {
            WeaponType        = WeaponType.Melee;
            WeaponInventoryId = 4;
            LocalizationName  = "mace";
            IconName          = "mace_icon";
            Durability        = 200;
            Damage            = 80;

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Metal), 100));
        }
コード例 #19
0
        public Crowbar()
        {
            WeaponType        = WeaponType.Melee;
            WeaponInventoryId = 9;
            LocalizationName  = "crowbar";
            IconName          = "crowbar_icon";
            Durability        = 300;
            Damage            = 30;

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Metal), 60));
        }
コード例 #20
0
        public Gunpowder()
        {
            LocalizationName = "gunpowder";
            Description      = "gunpowder_descr";
            IconName         = "gunpowder";
            CanBuy           = true;
            ShopPrice        = 30;

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Sulfur), 4));
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Charcoal), 4));
        }
コード例 #21
0
        public KitchenTable()
        {
            LocalizationName = "kitchen_table";
            IconName         = "kitchen_table_icon";
            IsStackable      = false;

            PrefabTemplatePath = "Prefabs/Items/PlacedItems/Decor/KitchenTable/KitchenTableTemplate";
            PrefabPath         = "Prefabs/Items/PlacedItems/Decor/KitchenTable/KitchenTable";

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(WoodResource), 40));
        }
コード例 #22
0
        public Bandage()
        {
            LocalizationName = "bandage";
            Description      = "bandage_descr";
            IconName         = "bandage_icon";

            HealthEffect = 10f;

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Leather), 2));
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(MedicinalPlant), 1));
        }
コード例 #23
0
        public LeatherShirt()
        {
            LocalizationName = "leather_shirt";
            IconName         = "leather_shirt_icon";
            CraftAmount      = 1;
            Durability       = 20000;
            Effect           = ItemEffectType.Damage;
            EffectAmount     = 8;

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Leather), 10));
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Rope), 4));
        }
コード例 #24
0
        public LeatherCap()
        {
            LocalizationName = "leather_cap";
            IconName         = "leather_cap_icon";
            CraftAmount      = 1;
            Durability       = 15000;
            Effect           = ItemEffectType.Damage;
            EffectAmount     = 5;

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Leather), 5));
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Rope), 2));
        }
コード例 #25
0
        public Arrow()
        {
            LocalizationName = "arrow";
            Description      = "arrow_descr";
            IconName         = "arrow_icon";
            CraftAmount      = 5;

            Damage = 80;

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(WoodResource), 20));
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(StoneResource), 10));
        }
コード例 #26
0
        public Chest()
        {
            LocalizationName = "chest";
            Description      = "chest_descr";
            IconName         = "chest_cion";
            IsStackable      = false;

            PrefabTemplatePath = "Prefabs/Items/PlacedItems/Chest/ChestTemplate";
            PrefabPath         = "Prefabs/Items/PlacedItems/Chest/Chest";

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(WoodResource), 60));
        }
コード例 #27
0
        public FurPants()
        {
            LocalizationName = "fur_pants";
            IconName         = "fur_pants_icon";
            CraftAmount      = 1;
            Durability       = 18000;
            Effect           = ItemEffectType.Damage;
            EffectAmount     = 8;

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Fur), 8));
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Rope), 4));
        }
コード例 #28
0
        public Cupboard_Closed()
        {
            LocalizationName = "item-cupboard_closed";
            IconName         = "cupboard_closed_icon";
            IsStackable      = false;

            PrefabTemplatePath = "Prefabs/Items/PlacedItems/Decor/Cupboard_Closed/Cupboard_ClosedTemplate";
            PrefabPath         = "Prefabs/Items/PlacedItems/Decor/Cupboard_Closed/Cupboard_Closed";

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(WoodResource), 50));
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(Metal), 10));
        }
コード例 #29
0
        public InventoryBox()
        {
            LocalizationName = "inventory_box";
            Description      = "inventory_box_descr";
            IconName         = "inventory_box_icon";
            IsStackable      = false;

            PrefabTemplatePath = "Prefabs/Items/PlacedItems/InventoryBox/InventoryBoxTemplate";
            PrefabPath         = "Prefabs/Items/PlacedItems/InventoryBox/InventoryBox";

            CraftRecipe = new List <HolderObject>();
            CraftRecipe.Add(HolderObjectFactory.GetItem(typeof(WoodResource), 50));
        }
コード例 #30
0
        public List <InventoryBase> GetInventoryList()
        {
            if (_currentItem != null)
            {
                _inventory.AddItem(HolderObjectFactory.GetItem(_currentItem.Item.GetType(), _currentItem.Amount, _currentItem.CurrentDurability));
            }

            var list = new List <InventoryBase> {
                _inventory
            };

            return(list);
        }