public override void OnLoad()
        {
            GameObject go  = new GameObject("Camera Tracking Mod");
            ChewChew   chw = go.AddComponent <ChewChew>();

            StatMaster.DontDestroyOnLoad(go);
            ButtonBalls.INNIT(chw);
        }
    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);
    }
        public static void INNIT(ChewChew yumyum)
        {
            GameObject          broadCast = new GameObject("MousePosBroadCaster");
            MouseRayBroadCaster 广播者       = broadCast.AddComponent <MouseRayBroadCaster>();

            yumyumyum = yumyum;
            GameObject ShowUpAll = GameObject.CreatePrimitive(PrimitiveType.Sphere);

            StatMaster.DontDestroyOnLoad(ShowUpAll);
            ShowUpAlll = ShowUpAll.AddComponent <ClickButtonBall>();
            UpdateEvent EUSUA = new UpdateEvent(ShowThemAll);

            ShowUpAlll.SetUp(Color.red, Color.white, true, false, "Show Camera \n Tracking Menu", EUSUA, new Vector3(0, 40, 35), new Vector3(0, 40, -15));
            ShowUpAlll.Show();
            广播者.AddMeIn(ShowUpAlll);



            GameObject SetTriggerKey = GameObject.CreatePrimitive(PrimitiveType.Cube);

            StatMaster.DontDestroyOnLoad(SetTriggerKey);
            TriggerSetter = SetTriggerKey.AddComponent <KeyAssignButtonBall>();
            UpdateEvent EUTS = new UpdateEvent(UpdateKey);

            TriggerSetter.SetUp(Color.cyan, Color.red, KeyCode.RightAlt, "Key For \nTracking: {0}", EUTS, new Vector3(20, 40, 15), new Vector3(120, 120, -150));
            广播者.AddMeIn(TriggerSetter);


            GameObject SetOffKey = GameObject.CreatePrimitive(PrimitiveType.Cube);

            StatMaster.DontDestroyOnLoad(SetOffKey);
            TriggerOffSetter = SetOffKey.AddComponent <KeyAssignButtonBall>();
            UpdateEvent EUTOS = new UpdateEvent(UpdateOffKey);

            TriggerOffSetter.SetUp(Color.cyan, Color.red, KeyCode.Mouse1, "Key For Disable\nTracking: {0}", EUTOS, new Vector3(40, 40, 15), new Vector3(120, 130, -150));
            广播者.AddMeIn(TriggerOffSetter);



            GameObject ActivationRangeBall = GameObject.CreatePrimitive(PrimitiveType.Capsule);

            StatMaster.DontDestroyOnLoad(ActivationRangeBall);
            ActivationRange = ActivationRangeBall.AddComponent <SliderButtonBall>();
            UpdateEvent EUAR = new UpdateEvent(UpdateActivationRange);

            ActivationRange.SetUp(1, 100, 35, 0.1f, "Track when target \nat {0}% on the screen", EUAR, new Vector3(15, 60, 25), new Vector3(120, 140, -150));
            广播者.AddMeIn(ActivationRange);
        }
Exemple #4
0
        void TextEditor(Event current)
        {
            GUI.SetNextControlName("codeInput");
            if (GUI.GetNameOfFocusedControl() != "codeInput")
            {
                if (blockingKeys)
                {
                    blockingKeys = false;
                    StatMaster.StopHotKeys(false);
                }
                return;
            }

            if (!blockingKeys)
            {
                blockingKeys = true;
                StatMaster.StopHotKeys(true);
            }

            //if (lastKBFocus != GUIUtility.keyboardControl)
            //    return;

            if ((current.type == EventType.KeyDown || current.type == EventType.KeyUp) && current.isKey)
            {
                var    te = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
                int    start, end;
                string text;
                void PrepareForTab()
                {
                    start = Math.Min(te.cursorIndex, te.selectIndex);
                    end   = Math.Max(te.cursorIndex, te.selectIndex);
                    text  = te.text;
                    while (start >= 0 && text[start] != '\n')
                    {
                        --start;
                    }
                    ++start;
                    if (end > start)
                    {
                        --end;
                    }
                    while (end >= 0 && text[end] != '\n')
                    {
                        --end;
                    }
                    ++end;
                }

                if ((current.keyCode == KeyCode.Tab || current.character == '\t'))
                {
                    if (current.type == EventType.KeyUp)
                    {
                        if (!current.shift)
                        {
                            if (!te.hasSelection)
                            {
                                for (var i = 0; i < 4; i++)
                                {
                                    te.Insert(' ');
                                }

                                editedScript = te.text;
                            }
                            else
                            {
                                PrepareForTab();
                                var pos = start;
                                while (pos <= end)
                                {
                                    text = text.Insert(pos, "    ");
                                    end += 4;
                                    if (pos == start)
                                    {
                                        if (te.cursorIndex < te.selectIndex)
                                        {
                                            te.cursorIndex += 4;
                                        }
                                        else
                                        {
                                            te.selectIndex += 4;
                                        }
                                    }
                                    if (te.cursorIndex > te.selectIndex)
                                    {
                                        te.cursorIndex += 4;
                                    }
                                    else
                                    {
                                        te.selectIndex += 4;
                                    }
                                    while (pos < text.Length && text[pos] != '\n')
                                    {
                                        ++pos;
                                    }
                                    ++pos;
                                }
                                editedScript = text;
                            }
                        }
                        else
                        {
                            PrepareForTab();
                            if (te.cursorIndex < te.selectIndex)
                            {
                                te.cursorIndex = start;
                            }
                            else
                            {
                                te.selectIndex = start;
                            }
                            var pos = start;
                            while (pos <= end)
                            {
                                int i;
                                for (i = 0; i < 4; ++i)
                                {
                                    if (text[pos] != ' ')
                                    {
                                        break;
                                    }
                                    text = text.Remove(pos, 1);
                                }
                                end -= i;
                                if (pos != end)
                                {
                                    if (te.cursorIndex > te.selectIndex)
                                    {
                                        te.cursorIndex -= i;
                                    }
                                    else
                                    {
                                        te.selectIndex -= i;
                                    }
                                }
                                while (pos < text.Length && text[pos] != '\n')
                                {
                                    ++pos;
                                }
                                ++pos;
                            }
                            editedScript = text;
                        }
                        editHistory.Add(editedScript);
                        UpdateScriptStatus(SelectedCpu.CheckScript(editedScript));
                    }
                    current.Use();
                }
                else if (current.keyCode == KeyCode.Return)
                {
                    if (current.type == EventType.keyDown)
                    {
                        lastEnterPos = Math.Min(te.cursorIndex, te.selectIndex) - 1;
                    }
                    else if (current.type == EventType.KeyUp && lastEnterPos >= 0)
                    {
                        text         = te.text;
                        start        = lastEnterPos;
                        lastEnterPos = -1;
                        while (start >= 0 && text[start] != '\n')
                        {
                            --start;
                        }
                        ++start;
                        int pos = start;
                        while (pos < text.Length && text[pos] == ' ')
                        {
                            ++pos;
                        }
                        var spaceCount = pos - start;
                        var spacing    = text.Substring(start, spaceCount);
                        text            = text.Insert(te.cursorIndex, spacing);
                        te.cursorIndex += spacing.Length;
                        te.selectIndex  = te.cursorIndex;
                        editedScript    = text;
                        editHistory.Add(editedScript);
                        UpdateScriptStatus(SelectedCpu.CheckScript(editedScript));
                    }
                    current.Use();
                }
                else if (current.keyCode == KeyCode.Z && current.control && current.type == EventType.KeyDown)
                {
                    var prev = editHistory.Back();
                    if (prev != null && editedScript != prev)
                    {
                        var len = Math.Min(editedScript.Length, prev.Length);
                        for (int i = 0; i < len; ++i)
                        {
                            if (editedScript[i] != prev[i])
                            {
                                te.selectIndex = te.cursorIndex = i;
                                break;
                            }
                        }
                        editedScript = prev;
                        UpdateScriptStatus(SelectedCpu.CheckScript(editedScript));
                    }
                    current.Use();
                }
                else if (current.keyCode == KeyCode.Y && current.control && current.type == EventType.KeyDown)
                {
                    var prev = editHistory.Forward();
                    if (prev != null)
                    {
                        var len = Math.Min(editedScript.Length, prev.Length);
                        for (int i = 0; i < len; ++i)
                        {
                            if (editedScript[i] != prev[i])
                            {
                                te.selectIndex = te.cursorIndex = i;
                                break;
                            }
                        }
                        editedScript = prev;
                        UpdateScriptStatus(SelectedCpu.CheckScript(editedScript));
                    }
                    current.Use();
                }
            }
        }