Esempio n. 1
0
    public override void Use(ItemSlot playersItemSlot)
    {
        if (playersItemSlot.Item && !itemSlot.Item && playersItemSlot.Item.GetComponent <Item>() && playersItemSlot.Item.GetComponent <Item>().IsForged)
        {
            itemSlot.AddItemToSlot(playersItemSlot.Item);
            fillableCircle.transform.parent.gameObject.SetActive(true);
            fillableCircle.fillAmount = 0;
            playersItemSlot.RemoveItemFromSlot();

            itemSlot.Item.transform.GetChild(0).transform.Rotate(0, 180, 0);

            particles.Play();

            audioSource.clip = audioClips[0];
            audioSource.Play();
        }
        else if (playersItemSlot.Item && playersItemSlot.Item.GetComponent <Cup>())
        {
            Destroy(playersItemSlot.Item);
            playersItemSlot.RemoveItemFromSlot();

            AddWater();
        }
        else if (!playersItemSlot.Item && itemSlot.Item && itemSlot.Item.GetComponent <Item>() && itemSlot.Item.GetComponent <Item>().IsChilled)
        {
            playersItemSlot.AddItemToSlot(itemSlot.Item);
            fillableCircle.transform.parent.gameObject.SetActive(false);
            itemSlot.RemoveItemFromSlot();

            particles.Stop();
        }
    }
Esempio n. 2
0
    public override void Use(ItemSlot playersItemSlot)
    {
        GameObject itemInHand = null;

        if (!playersItemSlot.Item)
        {
            Debug.Log("No item in hands");
        }
        else
        {
            itemInHand = playersItemSlot.Item;
        }

        //if player doesn't have broom in hands give it to him
        if (itemInHand == null || (itemInHand != null && itemInHand.GetComponent <Broom>() == null))
        {
            if (itemInHand.GetComponent <Tray>())
            {
                playersItemSlot.HideTray();
            }

            playersItemSlot.AddItemToSlot(Instantiate(broomToTake));
        }
        //if player has broom take it from him
        else
        {
            playersItemSlot.RemoveItemFromSlot();

            playersItemSlot.ShowTray();
        }
    }
Esempio n. 3
0
    public void SwapHand()
    {
        GameObject currentObject = hands[currentIndex].handObject;

        if (currentIndex + 1 >= hands.Length)
        {
            currentIndex = 0;
        }
        else
        {
            currentIndex++;
        }

        if (currentObject.GetComponent <Tray>())
        {
            itemSlot?.HideTray();
        }
        else
        {
            itemSlot?.RemoveItemFromSlot();
        }

        if (hands[currentIndex].handObject.GetComponent <Tray>())
        {
            itemSlot?.ShowTray();
        }
        else
        {
            itemSlot.AddItemToSlot(Instantiate(hands[currentIndex].handObject));
        }

        audioSource.Play();
        ChangeHand(hands[currentIndex].type);
    }
Esempio n. 4
0
    public override void Use(ItemSlot playersItemSlot)
    {
        if (playersItemSlot.Item && !itemSlot.Item && playersItemSlot.Item.GetComponent <Item>() &&
            playersItemSlot.Item.GetComponent <Item>().IsChilled)
        {
            itemSlot.AddItemToSlot(playersItemSlot.Item);

            itemSlot.Item.transform.localScale = new Vector3(1, 1, 1);

            playersItemSlot.RemoveItemFromSlot();

            requiredWoods = itemSlot.Item.GetComponent <Item>().RequiredWoods;
        }
        else if (playersItemSlot.Item && playersItemSlot.Item.GetComponent <Wood>())
        {
            Destroy(playersItemSlot.Item);
            playersItemSlot.RemoveItemFromSlot();

            requiredWoods--;

            if (requiredWoods == 0)
            {
                StartMiniGame(playersItemSlot);
            }
        }
        else if (!playersItemSlot.Item && itemSlot.Item && itemSlot.Item.GetComponent <Item>() && itemSlot.Item.GetComponent <Item>().IsWoodEnchanted)
        {
            playersItemSlot.AddItemToSlot(itemSlot.Item);
            itemSlot.Item.GetComponentInChildren <ItemClock>().transform.GetChild(0).gameObject.SetActive(false);
            itemSlot.RemoveItemFromSlot();
        }
    }
Esempio n. 5
0
 private void ReturnItemToPreviousSlot()
 {
     if (_lastClickedSlot is EquipmentSlot)
     {
         _player.PlayerEquipmentController.EquipItem(_movingItem as Equipment);
     }
     else
     {
         _lastClickedSlot.AddItemToSlot(_movingItem);
         _lastClickedSlot.RightPointerClicked += OnItemUsed;
     }
 }
Esempio n. 6
0
    private void EndMove(bool tryToMove)
    {
        Item newItem = null;

        if (tryToMove)
        {
            if (_player.PlayerWindow.PointerOverWindow)
            {
                if (_newClickedSlot != null)
                {
                    EquipmentSlot equipmentSlot = _newClickedSlot as EquipmentSlot;
                    if (equipmentSlot != null)
                    {
                        if (_newClickedSlot.SlotInteractable)
                        {
                            newItem = equipmentSlot.SlotItem;
                            _player.PlayerEquipmentController.EquipItem(equipmentSlot.EquipmentSlotType, _movingItem as Equipment, false);
                        }
                    }
                    else
                    {
                        newItem = _newClickedSlot.SlotItem;
                        _newClickedSlot.RightPointerClicked += OnItemUsed;
                        _newClickedSlot.AddItemToSlot(_movingItem);
                    }
                }
                else
                {
                    return;
                }
                if (newItem != null)
                {
                    SetNewMovingItem(newItem);
                    return;
                }
            }
            else
            {
                Debug.Log("Drop");
            }
        }
        else
        {
            ReturnItemToPreviousSlot();
        }

        _lastClickedSlot = null;
        _newClickedSlot  = null;
        _movingItem      = null;
        _player.PlayerInventoryUI.MovingImage.color  = Color.clear;
        _player.PlayerInventoryUI.MovingImage.sprite = null;
    }
Esempio n. 7
0
 public override void Use(ItemSlot playersItemSlot)
 {
     //if player has ore in hands put it in container
     if (playersItemSlot.Item && playersItemSlot.Item.GetComponent <Cup>())
     {
         Destroy(playersItemSlot.Item);
         playersItemSlot.RemoveItemFromSlot();
     }
     //if player has empty hands give him ore
     else if (!playersItemSlot.Item)
     {
         playersItemSlot.AddItemToSlot(Instantiate(water, transform.position, Quaternion.identity));
     }
 }
Esempio n. 8
0
    public override void Use(ItemSlot playersItemSlot)
    {
        if (playersItemSlot.Item && !itemSlot.Item)
        {
            itemSlot.AddItemToSlot(playersItemSlot.Item);

            playersItemSlot.RemoveItemFromSlot();
        }
        else if (!playersItemSlot.Item && itemSlot.Item)
        {
            playersItemSlot.AddItemToSlot(itemSlot.Item);

            itemSlot.RemoveItemFromSlot();
        }
    }
Esempio n. 9
0
 void Update()
 {
     if (itemSlot.Item == null && time < timeToNewOrder)
     {
         time += Time.deltaTime;
     }
     else if (itemSlot.Item == null)
     {
         GameObject order = Instantiate(newOrder[Random.Range(0, newOrder.Count)]);
         order.transform.parent = itemSlot.transform;
         //order.transform.GetChild(0).transform.localScale = new Vector3(1, 1, 1);
         order.transform.Rotate(0, -90, 0);
         itemSlot.AddItemToSlot(order);
         time = 0;
     }
 }
Esempio n. 10
0
    public override void Use(ItemSlot playersItemSlot)
    {
        if (miniGameActive)
        {
            CheckMiniGameStatus();
        }
        else if (playersItemSlot.Item && !itemSlot.Item && playersItemSlot.Item.GetComponent <Item>() &&
                 playersItemSlot.Item.GetComponent <Item>().IsHeated)
        {
            itemSlot.AddItemToSlot(playersItemSlot.Item);

            itemSlot.Item.transform.localScale = new Vector3(1, 1, 1);

            playersItemSlot.RemoveItemFromSlot();

            requiredOres = itemSlot.Item.GetComponent <Item>().RequiredOres;

            hits = requiredHits;

            // itemSlider = itemSlot.Item.GetComponentInChildren<Slider>();

            //itemSlider.value = 0;
        }
        else if (playersItemSlot.Item && playersItemSlot.Item.GetComponent <Ore>())
        {
            Destroy(playersItemSlot.Item);
            playersItemSlot.RemoveItemFromSlot();

            requiredOres--;

            if (requiredOres == 0)
            {
                StartMiniGame();
            }
        }
        else if (!playersItemSlot.Item && itemSlot.Item && itemSlot.Item.GetComponent <Item>() && itemSlot.Item.GetComponent <Item>().IsForged)
        {
            playersItemSlot.AddItemToSlot(itemSlot.Item);
            fillableCircle.transform.parent.gameObject.SetActive(false);
            // itemSlot.Item.GetComponentInChildren<ItemClock>().transform.GetChild(0).gameObject.SetActive(false);
            itemSlot.RemoveItemFromSlot();
        }
    }
Esempio n. 11
0
    public override void Use(ItemSlot playersItemSlot)
    {
        if (playersItemSlot.Item && !itemSlot.Item && playersItemSlot.Item.GetComponent <Item>().IsBroken)
        {
            itemSlot.AddItemToSlot(playersItemSlot.Item);

            playersItemSlot.RemoveItemFromSlot();
            fillableCircle.transform.parent.gameObject.SetActive(true);
            fillableCircle.fillAmount = 0;
            //itemSlot.Item.GetComponentInChildren<ItemClock>().transform.GetChild(0).gameObject.SetActive(true);
            //itemSlot.Item.GetComponentInChildren<ItemClock>().fillImage.fillAmount = 0;
        }
        else if (!playersItemSlot.Item && itemSlot.Item && itemSlot.Item.GetComponent <Item>() && itemSlot.Item.GetComponent <Item>().IsHeated)
        {
            playersItemSlot.AddItemToSlot(itemSlot.Item);
            fillableCircle.transform.parent.gameObject.SetActive(false);
            // itemSlot.Item.GetComponentInChildren<ItemClock>().transform.GetChild(0).gameObject.SetActive(false);
            itemSlot.RemoveItemFromSlot();
        }
    }