Beispiel #1
0
 void DisplayInventory()
 {
     if (crop.HasCrop())
     {
         //waterBar.gameObject.SetActive(false);
         iconBox.SetIcon(crop.GetCropSprite());
     }
     else if (tool != null)
     {
         if (tool.isWaterCan)
         {
             //canUse = true;
             // waterBar.gameObject.SetActive(true);
         }
         else if (!tool.isWaterCan)
         {
             //canUse = false;
             // waterBar.gameObject.SetActive(false);
         }
     }
     else
     {
         // canUse = false;
         // waterBar.gameObject.SetActive(false);
         iconBox.Close();
     }
 }
    public override void Interact(Player player)
    {
        if (_currentItem == null)
        {
            if (player.activeItem == null)
            {
                return;
            }
            if (player.activeItem.currentState != availableState)
            {
                return;
            }

            _currentItem      = player.activeItem;
            player.activeItem = null;
            _endTime          = Time.time + processTime;

            iconBox.isProcessing = true;
            iconBox.SetIcon(processImage);

            _isProcessing = true;
        }
        else
        {
            if (player.activeItem != null)
            {
                return;
            }
            if (_endTime > Time.time)
            {
                return;
            }
            if (!_isFinishProcessing)
            {
                return;
            }

            player.activeItem = _currentItem;
            _currentItem      = null;

            iconBox.Close();
        }
    }
 void DisplayInventory()
 {
     if (crop.HasCrop())
     {
         iconBox.SetIcon(crop.GetCropSprite());
     }
     else if (tool != null)
     {
         iconBox.SetIcon(tool.sprite);
     }
     else
     {
         iconBox.Close();
     }
 }
 private void UpdateItemDialog()
 {
     if (_activeItem != null)
     {
         if (_activeItem.currentState == Item.State.Done)
         {
             iconBox.showTickIcon = true;
         }
         else
         {
             iconBox.showTickIcon = false;
         }
         iconBox.SetIcon(_activeItem.image);
     }
     else
     {
         iconBox.Close();
     }
 }
    public override void Interact(Player player)
    {
        if (_currentItem == null)
        {
            if (player.activeItem == null)
            {
                return;
            }
            if (!availableStates.Contains(player.activeItem.currentState))
            {
                return;
            }

            _currentItem      = player.activeItem;
            player.activeItem = null;

            iconBox.SetIcon(GetTargetToolImage(_currentItem.currentState));
        }
        else
        {
            if (_isFinishProcessing)
            {
                if (player.activeItem != null)
                {
                    return;
                }
                if (_endTime > Time.time)
                {
                    return;
                }

                player.activeItem = _currentItem;
                _currentItem      = null;

                _isFinishProcessing = false;
                _isProcessing       = false;

                iconBox.Close();
            }
            else
            {
                if (player.activeItem == null)
                {
                    return;
                }
                if (player.activeItem.currentState != Item.State.Tool)
                {
                    return;
                }

                player.activeItem = null;

                _endTime = Time.time + processTime;


                StartCoroutine(ChangeIconCoroutine(processImage, true));

                _isProcessing = true;
            }
        }
    }
Beispiel #6
0
 public void CloseDisplay()
 {
     display.Close();
 }
 public override void OnTouchLeave()
 {
     base.OnTouchLeave();
     iconBox.Close();
 }
Beispiel #8
0
 public void DeSelect()
 {
     iconBox.Close();
 }
Beispiel #9
0
    public void SetItem()
    {
        //====================== MouseScroll ==============================//

        if (Input.mouseScrollDelta.y >= 1)
        {
            scrollPosition--;
            ResetToogle();
            EventSystem.current.SetSelectedGameObject(null);
            if (scrollPosition <= -1)
            {
                scrollPosition = -1;
            }
        }

        if (Input.mouseScrollDelta.y <= -1)
        {
            scrollPosition++;
            ResetToogle();
            EventSystem.current.SetSelectedGameObject(null);
            if (scrollPosition >= 3)
            {
                scrollPosition = 3;
            }
        }

        //===================== MouseClick =============================//
        if (slots[0].gameObject == EventSystem.current.currentSelectedGameObject)
        {
            plowClick = !plowClick;

            scrollPosition = 0;
            ResetToogle();

            EventSystem.current.SetSelectedGameObject(null);
        }

        else if (slots[1].gameObject == EventSystem.current.currentSelectedGameObject)
        {
            waterClick = !waterClick;

            scrollPosition = 1;
            ResetToogle();

            EventSystem.current.SetSelectedGameObject(null);
        }

        else if (slots[2].gameObject == EventSystem.current.currentSelectedGameObject)
        {
            fishingRodClick = !fishingRodClick;

            scrollPosition = 2;
            ResetToogle();
            EventSystem.current.SetSelectedGameObject(null);
        }

        else if (slots[3].gameObject == EventSystem.current.currentSelectedGameObject)
        {
            seedClick = !seedClick;

            scrollPosition = 3;
            ResetToogle();
            EventSystem.current.SetSelectedGameObject(null);
        }

        if (!plowClick && !waterClick && !fishingRodClick && !seedClick && !isClick)
        {
            scrollPosition = -1;
            ResetToogle();
        }

        if (scrollPosition == -1)
        {
            isClick = true;

            if (isClick)
            {
                iconBox.Close();
                ResetToogle();
            }

            plowClick       = false;
            waterClick      = false;
            fishingRodClick = false;
            seedClick       = false;
        }

        if (scrollPosition == 0)
        {
            plowClick = true;

            if (plowClick)
            {
                tool.isPlow = true;
                iconBox.SetIcon(tool.sprite[1]);
            }

            isClick         = false;
            waterClick      = false;
            fishingRodClick = false;
            seedClick       = false;
        }

        if (scrollPosition == 1)
        {
            waterClick = true;

            if (waterClick)
            {
                tool.isWaterCan = true;
                iconBox.SetIcon(tool.sprite[2]);
            }

            isClick         = false;
            plowClick       = false;
            fishingRodClick = false;
            seedClick       = false;
        }

        if (scrollPosition == 2)
        {
            fishingRodClick = true;

            if (fishingRodClick)
            {
                tool.isFishingRod = true;
                iconBox.SetIcon(tool.sprite[3]);
            }

            isClick    = false;
            plowClick  = false;
            waterClick = false;
            seedClick  = false;
        }

        if (scrollPosition == 3)
        {
            seedClick = true;

            if (seedClick)
            {
                tool.isSeed = true;
                SeedBar.SetActive(true);
            }

            isClick         = false;
            plowClick       = false;
            waterClick      = false;
            fishingRodClick = false;
        }

        if (button[0].gameObject == EventSystem.current.currentSelectedGameObject)
        {
            tool.seeds[0].isSelected = true;
            tool.seeds[1].isSelected = false;
            tool.seeds[2].isSelected = false;

            crop = tool.seeds[0].crop;
            iconBox.SetIcon(crop.asset.seedSprite);
            seedSelectButton();
        }
        else if (button[1].gameObject == EventSystem.current.currentSelectedGameObject)
        {
            tool.seeds[0].isSelected = false;
            tool.seeds[1].isSelected = true;
            tool.seeds[2].isSelected = false;

            crop = tool.seeds[1].crop;
            iconBox.SetIcon(crop.asset.seedSprite);
            seedSelectButton();
        }
        else if (button[2].gameObject == EventSystem.current.currentSelectedGameObject)
        {
            tool.seeds[0].isSelected = false;
            tool.seeds[1].isSelected = false;
            tool.seeds[2].isSelected = true;

            crop = tool.seeds[2].crop;
            iconBox.SetIcon(crop.asset.seedSprite);
            seedSelectButton();
        }

        SelectButton();
    }