public override void SafeAwake()
        {
            Key1 = AddKey("Spawn block",             //按键信息
                          "Spawn",                   //名字
                          KeyCode.V);                //默认按键

            List <string> list = new List <string>();

            foreach (var pair in PrefabMaster.BlockPrefabs)
            {
                list.Add(pair.Value.name);
            }
            模块ID = AddMenu("Block", 0, list);
            模块ID.ValueChanged += (v) => {
                blockModified = true;
            };

            modifyBlock          = AddToggle("Modify Spawned Block", "modifySpawnedBlock", false);
            modifyBlock.Toggled += (b) => {
                if (b)
                {
                    if (blockModified)
                    {
                        SpawnChild();
                    }
                    modifyBlock.IsActive = false;
                    BlockMapper.Open(blockToSpawn);
                }
            };

            生成间隔 = AddSlider("Spawn Frequency",               //滑条信息
                             "Freq",                          //名字
                             0.25f,                           //默认值
                             0f,                              //最小值
                             10f);                            //最大值

            生成大小 = AddSlider("Block Scale",                   //滑条信息
                             "Scale",                         //名字
                             1f,                              //默认值
                             0.01f,                           //最小值
                             100f);                           //最大值

            继承速度 = AddToggle("Inherit My Velocity",           //toggle信息
                             "IMV",                           //名字
                             true);                           //默认状态
            FunnyMode = AddToggle("Funny Mode",               //toggle信息
                                  "FMD",                      //名字
                                  false);                     //默认状态
            FunnyMode.Toggled += (t) => {
                blockModified = true;
                modifyBlock.DisplayInMapper = !t;
            };
        }
Esempio n. 2
0
        private void DoneMapperUpdate()
        {
            if (InputManager.LeftMouseButton() || InputManager.LeftMouseButtonHeld())
            {
                return;
            }
            if (!rangeChanging && !radiusChanging)
            {
                return;
            }

            if (BlockMapper.CurrentInstance != null)
            {
                BlockMapper.Open(BlockMapper.CurrentInstance.Block);
            }
            rangeChanging  = false;
            radiusChanging = false;
        }
Esempio n. 3
0
        protected virtual void Toggled(bool active)
        {
            configuring = active;

            var keyMapModeButton = FindObjectOfType <KeyMapModeButton>();

            if (active)
            {
                keyMapModeButton?.KeyMapOff();
                Game.AddPiece.hudOccluding = true;
                AddPiece.keyMapMode        = true;
            }
            else
            {
                keyMapModeButton?.KeyMapOn();
                Game.AddPiece.hudOccluding = false;
                BlockMapper.Open(this);
            }
        }
Esempio n. 4
0
 public virtual void UpdateAllPortalDevicesCentering(float value)
 {
     if (updatingDevices)
     {
         return;
     }
     updatingDevices = true;
     Correction      = value;
     foreach (var device in PortalDevices)
     {
         if (device == this)
         {
             continue;
         }
         device.SetCentering(value);
     }
     if (fakeOpen)
     {
         BlockMapper.Open(Behaviour);
         fakeOpen = false;
     }
     updatingDevices = false;
 }
Esempio n. 5
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]);
                }
            }
        }