Example #1
0
        //Coroutine ErrorMessageRoutine;
        //void Clicked(string BtnName)
        //{
        //    //foreach (var item in myCanvasMain.GetComponentsInChildren<RectTransform>())
        //    //{
        //    //    switch (item.gameObject.name)
        //    //    {
        //    //        case "myScrollViewContent":
        //    //            foreach (Transform child in item.transform)
        //    //            {
        //    //                Destroy(child.gameObject);
        //    //            }
        //    //            break;
        //    //        default:
        //    //            break;
        //    //    }
        //    //}


        //    //return;

        //    //foreach (ItemProto itemProto in LDB.items.dataArray)
        //    //{
        //    //    if (itemProto.ID == 2210)
        //    //    {

        //    //        itemProto.StackSize = 123;
        //    //        StorageComponent.itemStackCount[2210] = 123;
        //    //    }
        //    //}


        //    // SORT

        //    foreach (var factoryItem in GameMain.data.factories)
        //    {
        //        try
        //        {
        //            foreach (StorageComponent item in factoryItem.factoryStorage.storagePool)
        //            {
        //                try
        //                {

        //                    item.Sort(true);
        //                    Debug.LogError("SORTING");

        //                }
        //                catch (Exception)
        //                {
        //                    continue;
        //                }
        //            }
        //        }
        //        catch (Exception)
        //        {

        //            continue;
        //        }

        //    }

        //    Debug.LogError("SORTING PLAYER INVERNTORY");
        //    GameMain.mainPlayer.package.Sort(true);

        //    //UIRoot.instance.uiGame.inventory.OnSort();

        //    //SORT END

        //    //foreach (StorageComponent item in GameMain.mainPlayer.factory.factoryStorage.storagePool)
        //    //{
        //    //    try
        //    //    {

        //    //        item.Sort(true);
        //    //        Debug.LogError("SORTING");

        //    //    }
        //    //    catch (Exception)
        //    //    {
        //    //        //nothing
        //    //    }
        //    //}

        //    Debug.LogWarning($"Button \"{BtnName}\" pressed!");

        //    bool success = Int32.TryParse(myInputField.text, out int result);
        //    ItemProto selectedItem = null;
        //    if (success)
        //    {
        //        selectedItem = LDB.items.Select(result);
        //    }

        //    if (success && selectedItem != null)
        //    {
        //        //myHeaderText.enabled = false;
        //        //if (ErrorMessageRoutine != null)
        //        //{
        //        //    StopCoroutine(ErrorMessageRoutine);
        //        //}

        //        //thumb.sprite = selectedItem._iconSprite;
        //    }
        //    else
        //    {
        //        ErrorMessageRoutine = StartCoroutine(ShowError(2f));
        //    }

        //}

        //IEnumerator ShowError(float delay)
        //{
        //    if (ErrorMessageRoutine != null)
        //    {
        //        StopCoroutine(ErrorMessageRoutine);
        //    }
        //    myHeaderText.enabled = true;
        //    yield return new WaitForSeconds(delay);
        //    myHeaderText.enabled = false;
        //    ErrorMessageRoutine = null;
        //}

        private void Update()
        {
            bool keyDown = Input.GetKeyDown(KeyConfig.Value);

            //if (keyDown && GameMain.mainPlayer.factory != null && GameMain.mainPlayer.factory.factoryStorage != null && GameMain.mainPlayer.factory.factoryStorage.storagePool != null)
            if (keyDown && gameLoaded && GameMain.mainPlayer != null && (GameMain.mainPlayer.factory != null || (GameMain.data.mainPlayer.mecha != null && GameMain.data.mainPlayer.mecha.droneCount != 34)))
            {
                //Debug.LogError(GameMain.data.mainPlayer.mecha.droneCount);
                //Debug.LogWarning($"mainplayer is null? {(GameMain.mainPlayer.mecha == null)}");

                UIGame uiGame = UIRoot.instance.uiGame;
                if (VFInput.inFullscreenGUI && !myCanvas.activeSelf)
                {
                    return;
                }
                //if (!myCanvas.activeSelf)
                //{
                //    thumb.sprite = LDB.items.Select(2104)._iconSprite;
                //}
                myCanvas.SetActive(!myCanvas.activeSelf);
                VFInput.UpdateGameStates();
            }
            else if (Input.GetKeyDown(KeyCode.Escape) && myCanvas.activeSelf)
            {
                myCanvas.SetActive(false);
                //VFInput.UpdateGameStates();
            }
        }
Example #2
0
 void CloseUI()
 {
     myCanvas.SetActive(false);
     VFInput.UpdateGameStates();
 }