Example #1
0
    void IDropHandler.OnDrop(PointerEventData eventData)
    {
        if (IsLocked)
        {
            return;
        }

        DraggableItemUI droppedItem = eventData.pointerDrag.gameObject.GetComponent <DraggableItemUI>();

        if (droppedItem == null)
        {
            return;
        }

        DroppableSlotUI fromSlot = droppedItem.GetComponentInParent <DroppableSlotUI>();

        if (fromSlot == null || fromSlot == this)
        {
            return;
        }

        if (inventoryUI == null)
        {
            Debug.LogError("Inventory Does Not Exists!!!\nAdd Inventory Component.");
            return;
        }

        // Check IsLocked
        if (inventoryUI.itemUIs[Index]?.Item.LockItemSlot ?? false || droppedItem.Item.LockItemSlot)
        {
            return;
        }

        // Trigger Action
        UI_Screen screen = null;

        if (fromSlot.onMoveItem(fromSlot.Index, inventoryUI.inventory, Index))
        {
            // Drop Success
            OnDropSuccess();

            // Get This Screen
            screen = GetComponentInParent <UI_Screen>();
        }
        else
        {
            // Drop Fail
            OnDropFail();

            // Get Item Screen
            screen = droppedItem.GetComponent <UI_Screen>();
        }

        // Send Screen to Top
        if (screen != null)
        {
            CloseableScreenManager.Inst.SendScreenToTop(screen);
        }
    }
Example #2
0
    public void SendScreenToTop(UI_Screen screen)
    {
        screen.transform.SetAsFirstSibling();

        for (int i = 0; i < transform.childCount; i++)
        {
            if (transform.GetChild(i).gameObject.activeSelf)
            {
                transform.GetChild(i).GetComponent <UI_Screen>().thisCanvas.sortingOrder = -i;
            }
        }
    }
Example #3
0
 protected void AnimateScreen(UI_Screen previousScreen, UI_Screen currentScreen)
 {
     //previousScreen.gameObject.transform.localPosition = new Vector3(1080, 0, 0);
     currentScreen.gameObject.transform.localPosition = new Vector3(xPos, 0, 0);
     LeanTween.moveLocalX(currentScreen.gameObject, 0f, 1f).setEase(LeanTweenType.easeInOutQuad)
     .setOnStart(() => {
         eventSystem.enabled = false;
         currentScreen.GetComponentInParent <UI_System>().StartScreen(currentScreen);
     })
     .setOnComplete(() => {
         previousScreen.GetComponentInParent <UI_System>().CloseScreen(previousScreen);
         eventSystem.enabled = true;
         currentScreen.SetSelectable();
     });
     LeanTween.moveLocalX(previousScreen.gameObject, -xPos, 1f).setEase(LeanTweenType.easeInOutQuad);
 }
Example #4
0
 public void SwitchScreens(UI_Screen uiScreen)
 {
     if (uiScreen)
     {
         if (currentScreen)
         {
             currentScreen.CloseScreen();
             previousScreen = currentScreen;
         }
         currentScreen = uiScreen;
         currentScreen.StartScreen();
         if (onSwitchScreen != null)
         {
             onSwitchScreen.Invoke();
         }
     }
 }
 public void ChangeScreen(UI_Screen nextScreen)
 {
     if ((nextScreen == Screen21) && (Gas || Rock))
     {
         if (Gas)
         {
             ScreenSys.SwitchScreens(aScreen: Screen21);
         }
         else if (Rock)
         {
             ScreenSys.SwitchScreens(aScreen: Screen22);
         }
     }
     else if ((Gas || Rock))
     {
         ScreenSys.SwitchScreens(nextScreen);
     }
 }
Example #6
0
    //show or hide touch screen controls
    void SetTouchScreenControls(UI_Screen UI)
    {
        if (UI.UI_Name == "TouchScreenControls")
        {
            return;
        }
        InputManager inputManager = GameObject.FindObjectOfType <InputManager>();

        if (inputManager != null && inputManager.inputType == INPUTTYPE.TOUCHSCREEN)
        {
            if (UI.showTouchControls)
            {
                ShowMenu("TouchScreenControls", false);
            }
            else
            {
                CloseMenu("TouchScreenControls");
            }
        }
    }
Example #7
0
 public void SetUIReferences(UI_System.UI_System uiSys, UI_Screen uiScr)
 {
     SetUISystem(uiSys);
     SetUIScreen(uiScr);
 }
Example #8
0
 public void SetUIScreen(UI_Screen uiScr)
 {
     _uiScreen = uiScr;
 }
Example #9
0
    IEnumerator Die(float waitTime)
    {
        if (!_Check)
        {
            _Check = true;
            _anim.SetBool("Die", true);
            GameObject.Find("BossSounds").transform.GetChild(0).GetComponent <AudioSource>().Play();

            dataQuest _data = GameObject.Find("QuestManager").GetComponent <dataQuest>();
            _data._Stage = BossStage.ToString();

            yield return(new WaitForSeconds(waitTime));

            A_screen.Hide_AllScreen();
            A_screen.EndStage.SetActive(true);
            A_screen.EndButtom.SetActive(true);

            EndStage  _end = GameObject.Find("EndStage Panel").GetComponent <EndStage>();
            UI_Screen data = GameObject.Find("Canvas").GetComponent <UI_Screen>();


            if (levelStage == "S")
            {
                _end.itemAmount = 4;
                sumExp         += ((bossExp * 2) + (bossExp / 2));
            }
            else if (levelStage == "A")
            {
                _end.itemAmount = 3;
                sumExp         += (bossExp * 2);
            }
            else if (levelStage == "B")
            {
                _end.itemAmount = 2;
                sumExp         += ((bossExp * 2) - (bossExp / 2));
            }
            else if (levelStage == "C")
            {
                _end.itemAmount = 1;
                sumExp         += bossExp;
            }

            P_Sta.Exp      += Convert.ToInt32(sumExp);
            data.data.text += "\n ท่านได้รับค่าประสบการณ์ " + sumExp + " หน่วย";

            if (BossStage.ToString() == "Stage_1")
            {
                _end.addItemEnd(_end.itemAmount, itemAd, 3);
            }
            else if (BossStage.ToString() == "Stage_2")
            {
                _end.addItemEnd(_end.itemAmount, itemAd2, 6);
            }
            else if (BossStage.ToString() == "Stage_3")
            {
                _end.addItemEnd(_end.itemAmount, itemAd3, 3);
            }

            GameObject.Find("InventoryManager").GetComponent <Inventory>().ScrollDown();

            _end.LavelStage = levelStage;
            _end.TimeStage  = timeStage;
            _data._Degree   = _end.LavelStage;
            _data.QuestEnd();
            Destroy(gameObject, 1.4f);
        }
    }