Esempio n. 1
0
        private void On_InputHolderUpdated(ItemHolder holder)
        {
            ItemProperty.Value durabilityProperty = null;

            if (holder.HasItem && holder.CurrentItem.HasProperty("Durability"))
            {
                durabilityProperty = holder.CurrentItem.GetPropertyValue("Durability");
            }

            if (durabilityProperty != null && holder.CurrentItem.ItemData.IsCraftable && durabilityProperty.Float.Ratio != 1f)
            {
                if (holder.CurrentItem.ItemData.IsCraftable)
                {
                    InputItem.Recipe             = holder.CurrentItem.ItemData.Recipe;
                    InputItem.DurabilityProperty = durabilityProperty;
                    CalculateRequiredItems(InputItem.Recipe, InputItem.DurabilityProperty.Float.Ratio);

                    InputItemReadyForRepair.SetAndForceUpdate(true);

                    return;
                }
            }

            // If we're here it means the item in the input slot cannot be repaired, or it doesn't exist.
            //InputItem.DurabilityProperty = null;
            //InputItem.Recipe = null;

            InputItemReadyForRepair.SetAndForceUpdate(false);

            if (Repairing.Active)
            {
                Repairing.ForceStop();
            }
        }
Esempio n. 2
0
        private void On_EquipmentChanged(ItemHolder holder)
        {
            int defense = 0;

            // Calculate the total defense now.
            foreach (var h in m_EquipmentHolders)
            {
                if (h.HasItem && h.CurrentItem.HasProperty("Defense"))
                {
                    defense += h.CurrentItem.GetPropertyValue("Defense").Int.Current;
                }
            }

            Player.Defense.Set(defense);
        }
Esempio n. 3
0
        private void Start()
        {
            FuelSlot  = new ItemHolder();
            InputSlot = new ItemHolder();
            FuelSlot.Updated.AddListener(On_HolderUpdated);
            InputSlot.Updated.AddListener(On_HolderUpdated);

            // Initialize the loot container (create the empty slots).
            LootSlots = new List <ItemHolder>();

            for (int i = 0; i < m_LootContainerSize; i++)
            {
                LootSlots.Add(new ItemHolder());
            }

            IsBurning.AddChangeListener(OnChanged_IsBurning);
            IsBurning.SetAndForceUpdate(false);
        }
Esempio n. 4
0
        private void Start()
        {
            InputItem    = new ItemToRepair();
            InputHolder  = new ItemHolder();
            ResultHolder = new ItemHolder();

            InputHolder.Updated.AddListener(On_InputHolderUpdated);

            // TODO: We shouldn't have access to GUI functions here.
            m_Inventory = GUIController.Instance.GetContainer("Inventory");
            m_Inventory.Slot_Refreshed.AddListener(On_InventorySlotRefreshed);

            Repairing.AddStartTryer(TryStart_Repairing);
            Repairing.AddStopListener(OnStop_Repairing);
            RepairFinished.AddListener(On_RepairFinished);

            m_UpdateInterval = new WaitForSeconds(UPDATE_INTERVAL);
        }
Esempio n. 5
0
        private void HandleUnderwear(ItemHolder holder)
        {
            if (!m_Underwear || m_Underwear.activeSelf)
            {
                return;
            }

            bool showUnderwear = true;

            foreach (var piece in m_EquipmentPieces)
            {
                if (piece.CorrespondingHolder && piece.CorrespondingHolder.HasItem && piece.CorrespondingHolder.CurrentItem.HasProperty("Disable Underwear"))
                {
                    showUnderwear = false;
                }
            }

            if (showUnderwear)
            {
                m_Underwear.SetActive(true);
            }
        }
Esempio n. 6
0
        private void On_EquipmentChanged(ItemHolder holder)
        {
            foreach (var piece in m_EquipmentPieces)
            {
                if (holder.HasItem && piece.ItemName == holder.CurrentItem.ItemData.Name)
                {
                    piece.CorrespondingHolder = holder.HasItem ? holder : null;
                    piece.Object.SetActive(holder.HasItem);

                    if (holder.HasItem && m_Underwear && holder.CurrentItem.HasProperty("Disable Underwear"))
                    {
                        m_Underwear.SetActive(false);
                    }
                }
                else if (piece.CorrespondingHolder == holder)
                {
                    piece.CorrespondingHolder = null;
                    piece.Object.SetActive(false);
                }
            }

            HandleUnderwear(holder);
        }
Esempio n. 7
0
        private void On_HolderUpdated(ItemHolder holder)
        {
            bool shouldStopBurning = false;

            if (FuelSlot.HasItem && InputSlot.HasItem)
            {
                // The items have the correct properties, and the burn process can begin.
                if (FuelSlot.CurrentItem.HasProperty("Fuel Time") && InputSlot.CurrentItem.HasProperty("Burn Time") && InputSlot.CurrentItem.HasProperty("Burn Result"))
                {
                    if (IsBurning.Is(false))
                    {
                        m_FuelTimeProperty = FuelSlot.CurrentItem.GetPropertyValue("Fuel Time");
                        m_BurnTimeProperty = InputSlot.CurrentItem.GetPropertyValue("Burn Time");
                        m_ItemResult       = InputSlot.CurrentItem.GetPropertyValue("Burn Result").String;

                        IsBurning.Set(true);
                        m_BurningHandler = StartCoroutine(C_Burn());

                        return;
                    }
                }
                else
                {
                    shouldStopBurning = true;
                }
            }
            else
            {
                shouldStopBurning = true;
            }

            if (IsBurning.Is(true) && shouldStopBurning)
            {
                StopBurning();
            }
        }