コード例 #1
0
ファイル: ConsumableObject.cs プロジェクト: RachadQ/Game
 public ConsumableObject(ConsumableObject obj)
 {
     Id          = obj.Id;
     Name        = obj.Name;
     Description = obj.Description;
     Icon        = obj.Icon;
     IsStackable = obj.IsStackable;
 }
コード例 #2
0
    // Callback whenever we enter a "trigger", which is a collder on an object with "isTrigger" checked.
    private void OnCollisionEnter2D(Collision2D collision)
    {
        ConsumableObject consumable = collision.collider.GetComponent <ConsumableObject>();

        if (consumable)
        {
            consumable.TryBeConsumedBy(this);
        }
    }
コード例 #3
0
    public void EatOther(ConsumableObject obj, Action onAnimationComplete)
    {
        PauseTouchInput();
        var letter = obj as ConsumableLetter;

        if (letter != null)
        {
            ModifyProficiency(letter.Letter, -1);
        }

        Destroy(obj.gameObject);
        Animator.ReactNegatively(onComplete: ResumeTouchAfterAnimation(onAnimationComplete));
    }
コード例 #4
0
    public void UseItem0(ConsumableObject item)
    {
        GameMaster.PartyStats0.GetStat <Stat_Vital>(Base_Stat_Type.HP).StatCurrentValue += item.restoreHealthValue;
        GameMaster.PartyStats0.GetStat <Stat_Vital>(Base_Stat_Type.MP).StatCurrentValue += item.restoreSkillValue;

        _system.Inventory.RemoveItem(_system.selectedOption, 1);
        _system.itemsDisplayed[_system.Inventory.Container.Items[_system.selectedOption]].GetComponentInChildren <TextMeshProUGUI>().text = _system.Inventory.GetAmount(_system.selectedOption).ToString("n0");

        _system.miniStats1.UpdateStats();

        _system.IP_Cursor.transform.position = new Vector2(-1000, 0);
        Debug.Log(item + " was used");
    }
コード例 #5
0
        void ConsumeObject(ConsumableObject consumedObject)
        {
            _objectsInActivity.Remove(consumedObject);

            var letter = consumedObject as ConsumableLetter;

            if (letter != null && _requestedLetter.Letter == letter.Letter)
            {
                HandleCorrectLetter(letter);
            }
            else
            {
                HandleWrongLetter(consumedObject);
            }
        }
コード例 #6
0
    void ConsumeObject(ConsumableObject consumedObject)
    {
        var letter = consumedObject as ConsumableLetter;

        if (IsRealLetter(letter))
        {
            _remainingRealLetters--;
            _realLettersEaten++;

            Ressi.EatLetter(letter, TryCompleteActivity);
        }
        else
        {
            _nonLettersEaten++;
            Ressi.EatOther(consumedObject, TryCompleteActivity);
        }
    }
コード例 #7
0
    // Spotřebuje předmět ve slotu
    private void ConsumeItemInSlot(InventorySlot inventorySlot)
    {
        bool consumed = false;

        if (inventorySlot.ItemObject.type == ItemType.Consumable) // ADD more categories
        {
            ConsumableObject consumable = (ConsumableObject)inventorySlot.ItemObject;

            consumed = _player.RestoreHealth(consumable.healthRegen);
        }

        if (consumed)
        {
            GameObject slot = _slotHolder.transform.GetChild(inventorySlot.SlotHolderChildPosition).gameObject;

            if (_playerInventoryContainer.RemoveItem(inventorySlot.ItemObject.itemID))
            {
                slot.SetActive(false);

                if (_playerInventoryContainer.Slots.Count > 0)
                {
                    DisplayInfo(_playerInventoryContainer.Slots[0].ItemObject.itemID);
                }
            }
            else
            {
                if (inventorySlot.Amount > 1)
                {
                    slot.GetComponentInChildren <TextMeshProUGUI>().enabled = true;
                    slot.GetComponentInChildren <TextMeshProUGUI>().text    = inventorySlot.Amount.ToString();
                }
                else
                {
                    slot.GetComponentInChildren <TextMeshProUGUI>().enabled = false;
                }
            }
        }
    }
コード例 #8
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        ExitPortal portal = collider.GetComponent <ExitPortal>();

        if (portal)
        {
            AudioController.instance.PlayPortalSound();
            GameController.instance.PortalToScene(portal.sceneToLoad);
        }

        BurnableObject burnable = collider.GetComponent <BurnableObject>();

        if (burnable)
        {
            burnable.TryBeBurnedBy(this);
        }
        ConsumableObject consumable = collider.GetComponent <ConsumableObject>();

        if (consumable)
        {
            consumable.TryBeConsumedBy(this);
        }
    }
コード例 #9
0
 void HandleWrongLetter(ConsumableObject consumedObject)
 {
     Ressi.EatOther(consumedObject, onAnimationComplete: PrintRequestedLetter);
 }