public override void Set()
    {
        AddPiece.Instance.SetBlockType(myIndex);
        AddPiece.usingCopiedBlock = false;
        blockMenuControllerCode.CheckIfActive(true);

        if (StatMaster.isSearching)
        {
            BlockTabController tabController = blockMenuControllerCode.TabController;
            int tabIndex = tabController.GetTabIndex(myIndex);
            tabController.OpenTab(tabIndex);
        }
        StatMaster.ChangeSelectedBlock(myIndex);
    }
Ejemplo n.º 2
0
        private void Update()
        {
            if (!Game.AddPiece)
            {
                return;
            }

            if (increaseTime.Pressed())
            {
                TimeSliderObject sliderObj = FindObjectOfType <TimeSliderObject>();
                TimeSlider       slider    = FindObjectOfType <TimeSlider>();
                sliderObj.SetPercentage(
                    Mathf.Clamp01((slider.delegateTimeScale + 0.1f) / 2f));
            }
            if (decreaseTime.Pressed())
            {
                TimeSliderObject sliderObj = FindObjectOfType <TimeSliderObject>();
                TimeSlider       slider    = FindObjectOfType <TimeSlider>();
                sliderObj.SetPercentage(
                    Mathf.Clamp01((slider.delegateTimeScale - 0.1f) / 2f));
            }
            if (timeTo100.Pressed())
            {
                FindObjectOfType <TimeSliderObject>().SetPercentage(0.5f);
            }
            if (timeTo0.Pressed())
            {
                FindObjectOfType <TimeSliderObject>().SetPercentage(0.0f);
            }

            if (Game.IsSimulating)
            {
                return;
            }

            //Debug code helpful for filling out blockIndices table
#if DEBUG
            if (Input.GetKeyDown(KeyCode.N))
            {
                var buttons = tabController.tabs[tabController.activeTab]
                              .GetComponent <BlockMenuControl>().buttons;
                for (int i = 0; i < buttons.Length; i++)
                {
                    Debug.Log("buttons[" + i + "] = " + buttons[i]);
                }
            }
#endif

            if (pipette.Pressed())
            {
                RaycastHit hit;
                var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hit))
                {
                    var myName = hit.transform.GetComponent <MyBlockInfo>().blockName;
                    for (int i = 0; i < PrefabMaster.BlockPrefabs.Count; i++)
                    {
                        var type = PrefabMaster.BlockPrefabs[i].gameObject;
                        if ((type.GetComponent <MyBlockInfo>() &&
                             type.GetComponent <MyBlockInfo>().blockName == myName) ||
                            (type.GetComponentInChildren <MyBlockInfo>() &&
                             type.GetComponentInChildren <MyBlockInfo>().blockName == myName))
                        {
                            StartCoroutine(ExecuteWithDisabledGhost(() => { Game.AddPiece.SetBlockType(i); }));
                            break;
                        }
                    }
                }
            }

            if (openSettings.Pressed())
            {
                RaycastHit hit;
                var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hit))
                {
                    var block = hit.transform.gameObject.GetComponent <BlockBehaviour>();
                    FindObjectOfType <KeyMapModeButton>().KeyMapOn();
                    BlockSelect(block);
                    BlockMapper.Open(block);
                }
            }

            if (nextTab.Pressed())
            {
                currentTab = InternalToOrderedTabIndex(tabController.activeTab);
                tabController.OpenTab(tabIndices[mod(++currentTab, tabIndices.Length)]);
            }
            if (previousTab.Pressed())
            {
                currentTab = InternalToOrderedTabIndex(tabController.activeTab);
                tabController.OpenTab(tabIndices[mod(--currentTab, tabIndices.Length)]);
            }

            // Don't react to block shortcuts when block settings are open to prevent
            // typing a slider value changing what block is selected
            if (BlockMapper.CurrentInstance == null)
            {
                for (int i = 0; i < 9; i++)
                {
                    if (blockKeys[i].Pressed())
                    {
                        var index = blockIndices[
                            InternalToOrderedTabIndex(tabController.activeTab)][i];
                        if (index != -1)
                        {
                            StartCoroutine(ExecuteWithDisabledGhost(() =>
                            {
                                tabController.tabs[tabController.activeTab]
                                .GetComponent <BlockMenuControl>()
                                .buttons[index].Set();
                            }));
                        }
                    }
                }
            }

            for (int i = 0; i < 7; i++)
            {
                if (tabKeys[i].Pressed())
                {
                    tabController.OpenTab(tabIndices[i]);
                }
            }
        }