Exemplo n.º 1
0
        private static void RunDTSetCommand(UserDebugger debugger, string rootPathToSave, string moduleFullName, string typeName)
        {
            {
                string cmd    = ".sympath \"" + rootPathToSave + "\"";
                int    result = debugger.Execute(DEBUG_OUTCTL.IGNORE, cmd, DEBUG_EXECUTE.NOT_LOGGED);
                if (result != (int)HResult.S_OK)
                {
                    Console.WriteLine("failed to run command: " + cmd);
                    return;
                }
            }

            {
                string cmd    = $".reload /s /f {moduleFullName}";
                int    result = debugger.Execute(DEBUG_OUTCTL.IGNORE, cmd, DEBUG_EXECUTE.NOT_LOGGED);
                if (result != (int)HResult.S_OK)
                {
                    Console.WriteLine("failed to run command: " + cmd);
                    return;
                }
            }

            debugger.SetOutputText(true);
            {
                string cmd    = $"dt {typeName}";
                int    result = debugger.Execute(cmd);
                if (result != (int)HResult.S_OK)
                {
                    Console.WriteLine("failed to run command: " + cmd);
                    return;
                }
            }
        }
Exemplo n.º 2
0
 public void Start()
 {
     instance = this;
     if (originalText == null)
     {
         originalText = text.text;
     }
     text.text = originalText;
     dbgContent.Clear();
     gameObject.SetActive(false);
     firstActive = false;
     if (UnitaleUtil.printDebuggerBeforeInit != "")
     {
         UserWriteLine(UnitaleUtil.printDebuggerBeforeInit);
         UnitaleUtil.printDebuggerBeforeInit = "";
     }
 }
Exemplo n.º 3
0
    public void SwitchState(UIState state)
    {
        //Pre-state
        if (parentStateCall)
        {
            parentStateCall = false;
            encounter.script.Call("EnteringState", new DynValue[] { DynValue.NewString(state.ToString()), DynValue.NewString(this.state.ToString()) });
            parentStateCall = true;

            if (childStateCalled)
            {
                childStateCalled = false;
                return;
            }
        }
        else
        {
            childStateCalled = true;
        }

        // TODO Quick and dirty addition to add some humor to the Run away command.
        // Will be removed without question.
        if (musicPausedFromRunning)
        {
            Camera.main.GetComponent <AudioSource>().UnPause();
            musicPausedFromRunning = false;
        }
        // END DEBUG

        // below: actions based on ending a previous state, or actions that affect multiple states
        if (this.state == UIState.DEFENDING && state != UIState.DEFENDING)
        {
            encounter.endWave();
        }

        if (state != UIState.ENEMYDIALOGUE && state != UIState.DEFENDING)
        {
            ArenaSizer.instance.Resize(ArenaSizer.UIWidth, ArenaSizer.UIHeight);
            PlayerController.instance.invulTimer = 0.0f;
            PlayerController.instance.setControlOverride(true);
        }

        if (this.state == UIState.ENEMYSELECT && action == Actions.FIGHT)
        {
            foreach (LifeBarController lbc in arenaParent.GetComponentsInChildren <LifeBarController>())
            {
                Destroy(lbc.gameObject);
            }
        }

        if (state == UIState.DEFENDING || state == UIState.ENEMYDIALOGUE)
        {
            textmgr.destroyText();
            PlayerController.instance.SetPosition(320, 160, false);
            PlayerController.instance.GetComponent <Image>().enabled = true;
            fightBtn.overrideSprite = null;
            actBtn.overrideSprite   = null;
            itemBtn.overrideSprite  = null;
            mercyBtn.overrideSprite = null;
            textmgr.setPause(true);
        }

        if (this.state == UIState.ENEMYDIALOGUE)
        {
            TextManager[] textmen = FindObjectsOfType <TextManager>();
            foreach (TextManager textman in textmen)
            {
                if (textman.gameObject.name.StartsWith("DialogBubble")) // game object name is hardcoded as it won't change
                {
                    Destroy(textman.gameObject);
                }
            }
        }

        this.state = state;
        switch (state)
        {
        case UIState.ATTACKING:
            textmgr.destroyText();
            PlayerController.instance.GetComponent <Image>().enabled = false;
            fightUI.Init(encounter.enabledEnemies[selectedEnemy]);
            break;

        case UIState.ACTIONSELECT:
            PlayerController.instance.setControlOverride(true);
            PlayerController.instance.GetComponent <Image>().enabled = true;
            setPlayerOnAction(action);
            textmgr.setPause(ArenaSizer.instance.isResizeInProgress());
            textmgr.setCaller(encounter.script);     // probably not necessary due to ActionDialogResult changes
            textmgr.setText(new RegularMessage(encounter.EncounterText));
            break;

        case UIState.ACTMENU:
            string[] actions = new string[encounter.enabledEnemies[selectedEnemy].ActCommands.Length];
            for (int i = 0; i < actions.Length; i++)
            {
                actions[i] = encounter.enabledEnemies[selectedEnemy].ActCommands[i];
            }

            selectedAction = 0;
            setPlayerOnSelection(selectedAction);
            textmgr.setText(new SelectMessage(actions, false));
            break;

        case UIState.ITEMMENU:
            string[] items = getInventoryPage(0);
            selectedItem = 0;
            setPlayerOnSelection(0);
            textmgr.setText(new SelectMessage(items, false));

            /*ActionDialogResult(new TextMessage[] {
             *  new TextMessage("Can't open inventory.\nClogged with pasta residue.", true, false),
             *  new TextMessage("Might also be a dog.\nIt's ambiguous.",true,false)
             * }, UIState.ENEMYDIALOG);*/
            break;

        case UIState.MERCYMENU:
            selectedMercy = 0;
            string[] mercyopts = new string[1 + (encounter.CanRun ? 1 : 0)];
            mercyopts[0] = "Spare";
            foreach (EnemyController enemy in encounter.enabledEnemies)
            {
                if (enemy.CanSpare)
                {
                    mercyopts[0] = "[starcolor:ffff00][color:ffff00]" + mercyopts[0] + "[color:ffffff]";
                    break;
                }
            }
            if (encounter.CanRun)
            {
                mercyopts[1] = "Flee";
            }
            setPlayerOnSelection(0);
            textmgr.setText(new SelectMessage(mercyopts, true));
            break;

        case UIState.ENEMYSELECT:
            string[] names         = new string[encounter.enabledEnemies.Length];
            string[] colorPrefixes = new string[names.Length];
            for (int i = 0; i < encounter.enabledEnemies.Length; i++)
            {
                names[i] = encounter.enabledEnemies[i].Name;
                if (encounter.enabledEnemies[i].CanSpare)
                {
                    colorPrefixes[i] = "[color:ffff00]";
                }
            }

            textmgr.setText(new SelectMessage(names, true, colorPrefixes));
            if (action == Actions.FIGHT)
            {
                int maxWidth = (int)initialHealthPos.x;
                for (int i = 0; i < encounter.enabledEnemies.Length; i++)
                {
                    int mNameWidth = UnitaleUtil.fontStringWidth(textmgr.Charset, "* " + encounter.enabledEnemies[i].Name) + 50;
                    if (mNameWidth > maxWidth)
                    {
                        maxWidth = mNameWidth;
                    }
                }
                for (int i = 0; i < encounter.enabledEnemies.Length; i++)
                {
                    LifeBarController lifebar = Instantiate(Resources.Load <LifeBarController>("Prefabs/HPBar"));
                    lifebar.transform.SetParent(textmgr.transform);
                    RectTransform lifebarRt = lifebar.GetComponent <RectTransform>();
                    lifebarRt.anchoredPosition = new Vector2(maxWidth, initialHealthPos.y - i * textmgr.Charset.LineSpacing);
                    lifebarRt.sizeDelta        = new Vector2(90, lifebarRt.sizeDelta.y);
                    lifebar.setFillColor(Color.green);
                    float hpFrac = (float)encounter.enabledEnemies[i].HP / (float)encounter.enabledEnemies[i].getMaxHP();
                    lifebar.setInstant(hpFrac);
                }
            }

            if (selectedEnemy >= encounter.enabledEnemies.Length)
            {
                selectedEnemy = 0;
            }
            setPlayerOnSelection(selectedEnemy * 2);     // single list so skip right row by multiplying x2
            break;

        case UIState.DEFENDING:
            ArenaSizer.instance.Resize((int)encounter.ArenaSize.x, (int)encounter.ArenaSize.y);
            PlayerController.instance.setControlOverride(false);
            encounter.nextWave();
            // ActionDialogResult(new TextMessage("This is where you'd\rdefend yourself.\nBut the code was spaghetti.", true, false), UIState.ACTIONSELECT);
            break;

        case UIState.DIALOGRESULT:
            PlayerController.instance.GetComponent <Image>().enabled = false;
            break;

        case UIState.ENEMYDIALOGUE:
            PlayerController.instance.GetComponent <Image>().enabled = true;
            ArenaSizer.instance.Resize(155, 130);
            encounter.CallOnSelfOrChildren("EnemyDialogueStarting");
            monDialogues = new TextManager[encounter.enabledEnemies.Length];
            for (int i = 0; i < encounter.enabledEnemies.Length; i++)
            {
                string[] msgs = encounter.enabledEnemies[i].GetDefenseDialog();
                if (msgs == null)
                {
                    UserDebugger.warn("Entered ENEMYDIALOGUE, but no current/random dialogue was set for " + encounter.enabledEnemies[i].Name);
                    SwitchState(UIState.DEFENDING);
                    break;
                }
                GameObject    speechBub = Instantiate(SpriteFontRegistry.BUBBLE_OBJECT);
                RectTransform enemyRt   = encounter.enabledEnemies[i].GetComponent <RectTransform>();
                TextManager   sbTextMan = speechBub.GetComponent <TextManager>();
                monDialogues[i] = sbTextMan;
                sbTextMan.setCaller(encounter.enabledEnemies[i].script);
                Image speechBubImg = speechBub.GetComponent <Image>();
                SpriteUtil.SwapSpriteFromFile(speechBubImg, encounter.enabledEnemies[i].DialogBubble);
                Sprite speechBubSpr = speechBubImg.sprite;
                // TODO improve position setting/remove hardcoding of position setting
                speechBub.transform.SetParent(encounter.enabledEnemies[i].transform);
                speechBub.GetComponent <RectTransform>().anchoredPosition = encounter.enabledEnemies[i].DialogBubblePosition;
                sbTextMan.setOffset(speechBubSpr.border.x, -speechBubSpr.border.w);
                sbTextMan.setFont(SpriteFontRegistry.Get(SpriteFontRegistry.UI_MONSTERTEXT_NAME));
                sbTextMan.setEffect(new RotatingEffect(sbTextMan));

                MonsterMessage[] monMsgs = new MonsterMessage[msgs.Length];
                for (int j = 0; j < monMsgs.Length; j++)
                {
                    monMsgs[j] = new MonsterMessage(msgs[j]);
                }

                sbTextMan.setTextQueue(monMsgs);
                speechBub.GetComponent <Image>().enabled = true;
            }
            break;

        case UIState.DONE:
            StaticInits.Reset();
            Application.LoadLevel("ModSelect");
            break;
        }
    }
Exemplo n.º 4
0
 void Awake()
 {
     instance     = this;
     originalText = text.text;
     gameObject.SetActive(false);
 }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                return;
            }

            if (args.Length == 2)
            {
                UnpackDummyApp();
            }

            string  typeName       = args[0];
            string  moduleFullName = args[1];
            string  moduleFileName = Path.GetFileNameWithoutExtension(moduleFullName);
            int     pid            = 0;
            Process child          = null;
            string  proxyExePath   = "DummyApp.exe";

            if (args.Length >= 3)
            {
                if (Int32.TryParse(args[2], out pid) == false)
                {
                    proxyExePath = args[2];
                }
            }

            string rootPathToSave = Path.Combine(Environment.CurrentDirectory, "sym");

            using (UserDebugger debugger = new UserDebugger())
            {
                debugger.SetOutputText(false);
                debugger.FlushCallbacks();

                if (pid == 0)
                {
                    ProcessStartInfo psi = new ProcessStartInfo();
                    psi.FileName         = proxyExePath;
                    psi.UseShellExecute  = false;
                    psi.CreateNoWindow   = true;
                    psi.LoadUserProfile  = false;
                    psi.WorkingDirectory = Path.GetDirectoryName(typeof(Program).Assembly.Location);

                    child = Process.Start(psi);
                    pid   = child.Id;
                }

                bool attached = false;

                try
                {
                    debugger.ModuleLoaded += (ModuleInfo modInfo) =>
                    {
                        if (modInfo.ModuleName.IndexOf(moduleFileName, StringComparison.OrdinalIgnoreCase) == -1)
                        {
                            return;
                        }

                        byte[] buffer;
                        int    readBytes = debugger.ReadMemory(modInfo.BaseOffset, modInfo.ModuleSize, out buffer);
                        if (readBytes != modInfo.ModuleSize)
                        {
                            return;
                        }

                        PEImage.DownloadPdb(modInfo.ModuleName, buffer, new IntPtr((long)modInfo.BaseOffset), (int)modInfo.ModuleSize, rootPathToSave);

                        RunDTSetCommand(debugger, rootPathToSave, moduleFullName, typeName);

                        debugger.SetOutputText(false);
                        debugger.Execute(DEBUG_OUTCTL.IGNORE, (child == null) ? "q" : "qd", DEBUG_EXECUTE.NOT_LOGGED);
                    };

                    if (debugger.AttachTo(pid) == false)
                    {
                        Console.WriteLine("Failed to attach");
                        return;
                    }

                    attached = true;
                    debugger.WaitForEvent(DEBUG_WAIT.DEFAULT, 1000 * 5);
                }
                finally
                {
                    if (attached == true)
                    {
                        debugger.Detach();
                    }

                    try
                    {
                        if (child != null)
                        {
                            child.Kill();
                        }
                    }
                    catch { }
                }
            }
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            using (UserDebugger debugger = new UserDebugger())
            {
                Console.CancelKeyPress += (s, e) =>
                {
                    e.Cancel = true;
                    debugger.SetInterrupt();
                };

                ProcessStartInfo psi = new ProcessStartInfo();
                psi.FileName        = "DummyApp.exe";
                psi.UseShellExecute = true;

                Process child = Process.Start(psi);

                try
                {
                    if (debugger.AttachTo(child.Id) == false)
                    {
                        Console.WriteLine("Failed to attach");
                        return;
                    }

                    int hr = debugger.WaitForEvent();

                    while (true)
                    {
                        hr = debugger.GetExecutionStatus(out DEBUG_STATUS status);
                        if (hr != (int)HResult.S_OK)
                        {
                            break;
                        }

                        if (status == DEBUG_STATUS.NO_DEBUGGEE)
                        {
                            Console.WriteLine("No Target");
                            break;
                        }

                        if (status == DEBUG_STATUS.GO || status == DEBUG_STATUS.STEP_BRANCH ||
                            status == DEBUG_STATUS.STEP_INTO || status == DEBUG_STATUS.STEP_OVER)
                        {
                            hr = debugger.WaitForEvent();
                            continue;
                        }

                        if (debugger.StateChanged)
                        {
                            Console.WriteLine();
                            debugger.StateChanged = false;
                            if (debugger.BreakpointHit)
                            {
                                debugger.OutputCurrentState(DEBUG_OUTCTL.THIS_CLIENT, DEBUG_CURRENT.DEFAULT);
                                debugger.BreakpointHit = false;
                            }
                        }

                        debugger.OutputPromptWide(DEBUG_OUTCTL.THIS_CLIENT, null);
                        Console.Write(" ");
                        Console.ForegroundColor = ConsoleColor.Gray;
                        string command = Console.ReadLine();
                        debugger.ExecuteWide(command);
                    }
                }
                finally
                {
                    try
                    {
                        debugger.Detach();
                    } catch { }

                    try
                    {
                        child.Kill();
                    }
                    catch { }
                }
            }
        }