Пример #1
0
        public static void PrepareTabLookup(Dictionary <string, object> dict, string currentIns, string helpText)
        {
            // Update help text.
            ConsoleTrack.helpText = helpText;

            // Make sure you're on the last instruction, otherwise no tab lookup applies.
            if (!ConsoleTrack.OnLastInstruction())
            {
                return;
            }

            if (currentIns.Length > 0)
            {
                // Scan for instructions that start with the arg provided:
                string tab = dict.Where(pv => pv.Key.StartsWith(currentIns)).FirstOrDefault().Key;

                // Update the tab lookup.
                ConsoleTrack.tabLookup = tab != null?Regex.Replace(tab, "^" + currentIns, "") : string.Empty;
            }
            else
            {
                ConsoleTrack.tabLookup = string.Empty;
            }

            // Update possible tabs.
            ConsoleTrack.possibleTabs = "Options: " + String.Join(", ", dict.Keys.ToArray());
        }
Пример #2
0
        public static void ConsoleAssignHead()
        {
            string currentIns = ConsoleTrack.GetArgAsString();

            // Update the tab lookup.
            ConsoleTrack.PrepareTabLookup(headCodes, currentIns, "Assign the character's head.");

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                // If "head" is the only instruction, give a random head to the character.
                if (currentIns == string.Empty)
                {
                    Head.AssignToCharacter(ConsoleTrack.character, (byte)HeadSubType.RandomStandard, true);
                    Systems.settings.login.HeadVal = 0;
                    Systems.settings.login.SaveSettings();
                    return;
                }

                // Get the Head Type by instruction:
                if (headCodes.ContainsKey(currentIns))
                {
                    byte subType = byte.Parse(headCodes[currentIns].ToString());
                    Head.AssignToCharacter(ConsoleTrack.character, (byte)subType, true);
                    Systems.settings.login.HeadVal = subType;
                    Systems.settings.login.SaveSettings();
                }
            }
        }
Пример #3
0
        public static void ResizeHeight()
        {
            EditorRoomScene scene         = ((EditorScene)Systems.scene).CurrentRoom;
            int             currentHeight = scene.yCount;

            ConsoleTrack.possibleTabs = "Example: `resize height 180`";
            ConsoleTrack.helpText     = "Resize the level's height between " + (byte)TilemapEnum.MinHeight + " and " + (short)TilemapEnum.MaxTilesHigh + ". Currently at " + currentHeight + ".";

            // Prepare Height
            int getHeight = ConsoleTrack.GetArgAsInt();

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                if (getHeight < (byte)TilemapEnum.MinHeight)
                {
                    getHeight = (byte)TilemapEnum.MinHeight;
                }
                if (getHeight > (short)TilemapEnum.MaxTilesHigh)
                {
                    getHeight = (short)TilemapEnum.MaxTilesHigh;
                }
                scene.ResizeHeight((short)getHeight);
            }
        }
Пример #4
0
        public static void ConsoleTeleport()
        {
            string arg = ConsoleTrack.GetArgAsString(false);

            if (arg == "coords")
            {
                ConsoleTrack.instructionArgIndex++;
                ConsoleLevel.ConsoleTeleportCoords();
                return;
            }

            // Secret "room" option.
            if (arg == "room")
            {
                ConsoleTrack.instructionArgIndex++;
                ConsoleLevel.ConsoleTeleportRoom();
                return;
            }

            ConsoleTrack.possibleTabs = "Options: coords, room, # #";
            ConsoleTrack.helpText     = "The grid square (e.g. \"10, 10\") to teleport to. Or `move coords` for exact precision.";

            int x = ConsoleTrack.GetArgAsInt() * (byte)TilemapEnum.TileWidth;
            int y = ConsoleTrack.GetArgAsInt() * (byte)TilemapEnum.TileHeight;

            if (ConsoleTrack.activate && x > 0 && y > 0)
            {
                Character.Teleport(ConsoleTrack.character, x, y);
            }
        }
Пример #5
0
        public static void CheatCodeMobility()
        {
            string currentIns = ConsoleTrack.GetArgAsString();

            ConsoleTrack.PrepareTabLookup(mobilityCodes, currentIns, "Assign mobility power to the character; e.g. `power mobility levitate`");

            if (ConsoleTrack.activate)
            {
                UIHandler.AddNotification(UIAlertType.Success, "Mobility Granted", "Granted Mobility Power to Character.", 180);

                if (mobilityCodes.ContainsKey(currentIns))
                {
                    if (currentIns == "none")
                    {
                        ConsoleTrack.character.mobilityPower = null;
                        return;
                    }

                    byte subType = byte.Parse(mobilityCodes[currentIns].ToString());
                    Power.AssignPower(ConsoleTrack.character, (byte)subType);
                    return;
                }

                // "wand" was the final valid instruction. Give a random wand to the character.
                Power.AssignPower(ConsoleTrack.character, (byte)PowerSubType.RandomBolt);
            }
        }
Пример #6
0
        public static void CheatStatSlide()
        {
            string currentIns = ConsoleTrack.GetArgAsString();

            ConsoleTrack.PrepareTabLookup(slideStatCodes, currentIns, "Assign sliding-related stats for the character.");

            // If the stat instruction is a full word, then we can indicate that it's time to provide additional help text:
            if (slideStatCodes.ContainsKey(currentIns))
            {
                ConsoleTrack.possibleTabs = "";
                ConsoleTrack.helpText     = slideStatCodes[currentIns].ToString();
            }

            if (ConsoleTrack.activate)
            {
                Character character = ConsoleTrack.character;

                // Slide
                if (currentIns == "cooldown")
                {
                    character.stats.SlideWaitDuration = (byte)Math.Round(ConsoleTrack.GetArgAsFloat());
                }
                else if (currentIns == "duration")
                {
                    character.stats.SlideDuration = (byte)Math.Round(ConsoleTrack.GetArgAsFloat());
                }
                else if (currentIns == "strength")
                {
                    character.stats.SlideStrength = FInt.Create(ConsoleTrack.GetArgAsFloat());
                }
            }
        }
Пример #7
0
        public static void ResizeWidth()
        {
            EditorRoomScene scene        = ((EditorScene)Systems.scene).CurrentRoom;
            int             currentWidth = scene.xCount;

            ConsoleTrack.possibleTabs = "Example: `resize width 250`";
            ConsoleTrack.helpText     = "Resize the level's width between " + (byte)TilemapEnum.MinWidth + " and " + (short)TilemapEnum.MaxTilesWide + ". Currently at " + currentWidth + ".";

            // Prepare Width
            int getWidth = ConsoleTrack.GetArgAsInt();

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                if (getWidth < (byte)TilemapEnum.MinWidth)
                {
                    getWidth = (byte)TilemapEnum.MinWidth;
                }
                if (getWidth > (short)TilemapEnum.MaxTilesWide)
                {
                    getWidth = (short)TilemapEnum.MaxTilesWide;
                }
                scene.ResizeWidth((short)getWidth);
            }
        }
Пример #8
0
        public void ProcessInstruction(string insText)
        {
            // Clean the instruction text.
            string cleanText = insText.Trim().ToLower();

            // If there is no instruction text, no need to continue.
            if (cleanText.Length == 0)
            {
                ConsoleTrack.tabLookup = string.Empty;
                return;
            }

            // If there was a pipe, split into multiple instructions UNLESS the instruction starts with "macro"
            if (insText.Contains('|') && !cleanText.StartsWith("macro"))
            {
                string[] multiInstructions = insText.Split('|');

                // If we're activating the instructions, run all of them.
                if (ConsoleTrack.activate)
                {
                    foreach (string ins in multiInstructions)
                    {
                        this.ProcessInstruction(ins);
                    }
                }

                // If we're not activating the instructions, only run the last pipe (since we only need to identify that one).
                else
                {
                    this.ProcessInstruction(multiInstructions.Last());
                }

                return;
            }

            // Load Console Track Information
            ConsoleTrack.LoadInstructionText(cleanText);

            // Must have at least one part for a valid instruction.
            if (ConsoleTrack.instructionList.Count < 1)
            {
                return;
            }

            string currentIns = ConsoleTrack.GetArg();

            // Assign Default Character and Player
            ConsoleTrack.player    = Systems.localServer.MyPlayer;
            ConsoleTrack.character = Systems.localServer.MyCharacter;

            // Update the tab lookup.
            ConsoleTrack.PrepareTabLookup(this.consoleDict, currentIns, this.baseHelperText);

            // Invoke the Relevant Next Function
            if (this.consoleDict.ContainsKey(currentIns))
            {
                this.consoleDict[currentIns].Invoke();
            }
        }
Пример #9
0
        public static void SetLevel()
        {
            byte gridX = (byte)ConsoleTrack.GetArgAsInt();

            ConsoleTrack.possibleTabs = "Example: setLevel 10 10 MyLevelID";

            // If gridX is assigned:
            if (ConsoleTrack.instructionList.Count >= 2)
            {
                byte gridY = (byte)ConsoleTrack.GetArgAsInt();

                // If gridY is assigned:
                if (ConsoleTrack.instructionList.Count >= 3)
                {
                    // Check if this X, Y grid is valid (has a node at it).
                    WEScene         scene  = (WEScene)Systems.scene;
                    WorldZoneFormat zone   = scene.currentZone;
                    byte[]          wtData = scene.worldContent.GetWorldTileData(zone, gridX, gridY);

                    // If the location is a valid node, we can attempt to add a level ID.
                    if (NodeData.IsObjectANode(wtData[5], false, false, true))
                    {
                        string coordStr = Coords.MapToInt(gridX, gridY).ToString();
                        string levelId  = ConsoleTrack.GetArg();
                        ConsoleTrack.helpText = "Assign a level ID to the specified node.";

                        if (zone.nodes.ContainsKey(coordStr))
                        {
                            ConsoleTrack.helpText += " Current level ID is: " + zone.nodes[coordStr];
                        }

                        // If the console was activated:
                        if (ConsoleTrack.activate)
                        {
                            zone.nodes[coordStr] = levelId;
                            return;
                        }
                    }

                    // If the location is invalid:
                    else
                    {
                        ConsoleTrack.helpText = "WARNING! There is not a level node at " + gridX.ToString() + ", " + gridY.ToString();
                    }
                }

                // If gridY has not been assigned:
                else
                {
                    ConsoleTrack.helpText = "Assign a level ID to a node at the specified X, Y coordinate. Enter the Y position.";
                }
            }

            // If gridX has not been assigned:
            else
            {
                ConsoleTrack.helpText = "Assign a level ID to a node at the specified X, Y coordinate. Enter the X position.";
            }
        }
Пример #10
0
        public static void CheatCodeKill()
        {
            ConsoleTrack.PrepareTabLookup("Kills the character.");

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                UIHandler.AddNotification(UIAlertType.Warning, "Killed Self", "Character chose to respawn.", 180);
                ConsoleTrack.character.wounds.ReceiveWoundDamage(DamageStrength.InstantKill);
            }
        }
Пример #11
0
 public void Open()
 {
     UIHandler.SetMenu(this, true);
     ConsoleTrack.ResetValues();
     ConsoleTrack.PrepareTabLookup(this.consoleDict, "", this.baseHelperText);
     if (!this.beenOpened)
     {
         this.OnFirstOpen();
     }
     this.OnOpen();
 }
Пример #12
0
        public static void CheatCodeWound()
        {
            ConsoleTrack.PrepareTabLookup("Causes a standard wound. Deals 1 health damage.");

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                UIHandler.AddNotification(UIAlertType.Warning, "Damage Inflicted", "Recieved 1 Wound Damage.", 180);
                ConsoleTrack.character.wounds.ReceiveWoundDamage(DamageStrength.Standard);
            }
        }
Пример #13
0
        public static void CheatStatRun()
        {
            string currentIns = ConsoleTrack.GetArgAsString();

            ConsoleTrack.PrepareTabLookup(runStatCodes, currentIns, "Assign ground and running-related stats for the character.");

            Character character = ConsoleTrack.character;

            // If the stat instruction is a full word, then we can indicate that it's time to provide additional help text:
            if (runStatCodes.ContainsKey(currentIns))
            {
                ConsoleTrack.possibleTabs = "";
                ConsoleTrack.helpText     = runStatCodes[currentIns].ToString() + " Current: ";

                if (currentIns == "accel")
                {
                    ConsoleTrack.helpText += String.Format("{0:G2}", character.stats.RunAcceleration.ToDouble()).ToString();
                }
                else if (currentIns == "decel")
                {
                    ConsoleTrack.helpText += String.Format("{0:G2}", character.stats.RunDeceleration.ToDouble()).ToString();
                }
                else if (currentIns == "max-speed")
                {
                    ConsoleTrack.helpText += character.stats.RunMaxSpeed.ToString();
                }
                else if (currentIns == "walk-mult")
                {
                    ConsoleTrack.helpText += String.Format("{0:G2}", character.stats.SlowSpeedMult.ToDouble()).ToString();
                }
            }

            if (ConsoleTrack.activate)
            {
                if (currentIns == "accel")
                {
                    character.stats.RunAcceleration = FInt.Create(ConsoleTrack.GetArgAsFloat());
                }
                else if (currentIns == "decel")
                {
                    character.stats.RunDeceleration = FInt.Create(ConsoleTrack.GetArgAsFloat());
                }
                else if (currentIns == "max-speed")
                {
                    character.stats.RunMaxSpeed = (byte)ConsoleTrack.GetArgAsInt();
                }
                else if (currentIns == "walk-mult")
                {
                    character.stats.SlowSpeedMult = FInt.Create(ConsoleTrack.GetArgAsFloat());
                }

                // Regarldess of what changes, we need to re-run any effects that hats or other effects have.
            }
        }
Пример #14
0
        public static void CheatCodeHealth()
        {
            ConsoleTrack.PrepareTabLookup("Assign a given number of health (e.g. 'health 2'). Default is max health.");

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                byte health = ConsoleTrack.instructionList.Count >= 2 ? (byte)ConsoleTrack.GetArgAsInt() : (byte)100;
                UIHandler.AddNotification(UIAlertType.Success, "Health Granted", "Granted " + health + " Health to Character.", 180);
                ConsoleTrack.character.wounds.SetHealth(health);
            }
        }
Пример #15
0
        public static void LoadLevelEditor()
        {
            string currentIns = ConsoleTrack.GetArgAsString();

            ConsoleTrack.possibleTabs = "Example: `load-level QCALQOD16`";
            ConsoleTrack.helpText     = "The level ID of the level to load.";

            if (ConsoleTrack.activate)
            {
                SceneTransition.ToLevelEditor("", currentIns);
            }
        }
Пример #16
0
        public static void CheatCodePowers()
        {
            string statIns = ConsoleTrack.GetArgAsString();

            ConsoleTrack.PrepareTabLookup(basePowerCodes, statIns, "Assign a power to the character.");

            if (basePowerCodes.ContainsKey(statIns))
            {
                basePowerCodes[statIns].Invoke();
                return;
            }
        }
Пример #17
0
        public static void CheatCodeArmor()
        {
            ConsoleTrack.PrepareTabLookup("Assign a given number of armor (e.g. 'armor 2'). Default is max armor.");

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                byte armor = ConsoleTrack.instructionList.Count >= 2 ? (byte)ConsoleTrack.GetArgAsInt() : (byte)100;
                UIHandler.AddNotification(UIAlertType.Success, "Armor Granted", "Granted " + armor + " Armor to Character.", 180);
                ConsoleTrack.character.wounds.SetArmor(armor);
            }
        }
Пример #18
0
        public static void DebugBase()
        {
            string statIns = ConsoleTrack.GetArgAsString();

            ConsoleTrack.PrepareTabLookup(debugBaseList, statIns, "View or change debug settings.");

            if (debugBaseList.ContainsKey(statIns))
            {
                debugBaseList[statIns].Invoke();
                return;
            }
        }
Пример #19
0
        public static void NoPower()
        {
            string currentIns = ConsoleTrack.GetArgAsString();

            ConsoleTrack.PrepareTabLookup(weaponCodes, currentIns, "Removes attack power from character.");

            if (ConsoleTrack.activate)
            {
                ConsoleTrack.character.attackPower = null;
                return;
            }
        }
Пример #20
0
        public static void ResetOptions()
        {
            string currentIns = ConsoleTrack.GetArgAsString();

            ConsoleTrack.PrepareTabLookup(resetCodes, currentIns, "Reset options for this world.");

            if (resetCodes.ContainsKey(currentIns))
            {
                resetCodes[currentIns].Invoke();
                return;
            }
        }
Пример #21
0
        public static void WorldChange()
        {
            string currentIns = ConsoleTrack.GetArgAsString();

            ConsoleTrack.possibleTabs = "Example: `load-world worldIdHere`";
            ConsoleTrack.helpText     = "This will load a world (if it exists). Enter the world ID of the world to load.";

            if (ConsoleTrack.activate && currentIns.Length > 0)
            {
                SceneTransition.ToWorld(currentIns);
            }
        }
Пример #22
0
        public static void LoadWorldEditor()
        {
            string currentIns = ConsoleTrack.GetArgAsString();

            ConsoleTrack.possibleTabs = "Example: `load-world worldIdHere`";
            ConsoleTrack.helpText     = "The world ID of the world to load. Will load a world (if it exists).";

            if (ConsoleTrack.activate)
            {
                SceneTransition.ToWorldEditor(currentIns);
            }
        }
Пример #23
0
        public static void CheatCodeInvincible()
        {
            ConsoleTrack.PrepareTabLookup("Grant invincibility for X seconds (e.g. 'invincible 30'). Default is 60 seconds.");

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                int duration = ConsoleTrack.instructionList.Count >= 2 ? (byte)ConsoleTrack.GetArgAsInt() : 60;
                UIHandler.AddNotification(UIAlertType.Success, "Invincibility Granted", "Granted Invincibility for " + duration + " Seconds.", 180);
                ConsoleTrack.character.wounds.SetInvincible(duration * 60);
            }
        }
Пример #24
0
        public static void Resize()
        {
            string currentIns = ConsoleTrack.GetArgAsString();

            ConsoleTrack.PrepareTabLookup(resizeCodes, currentIns, "Resize a room. WARNING: BE CAREFUL! Reducing a room size can remove tiles you've placed.");

            if (resizeCodes.ContainsKey(currentIns))
            {
                resizeCodes[currentIns].Invoke();
                return;
            }
        }
Пример #25
0
        public static void ConsoleTeleportCoords()
        {
            ConsoleTrack.possibleTabs = "Example: `move coords 5000 450`";
            ConsoleTrack.helpText     = "The exact coordinates (e.g. \"5000, 450\") to teleport to.";

            int x = ConsoleTrack.GetArgAsInt();
            int y = ConsoleTrack.GetArgAsInt();

            if (ConsoleTrack.activate && x > 0 && y > 0)
            {
                Character.Teleport(ConsoleTrack.character, x, y);
            }
        }
Пример #26
0
        public static void ConsoleTeleportRoom()
        {
            ConsoleTrack.possibleTabs = "Example: `move room 2 500 300`";
            ConsoleTrack.helpText     = "The Room ID, X Coordinate, Y Coordinate to teleport to.";

            byte roomID = (byte)ConsoleTrack.GetArgAsInt();
            int  x      = ConsoleTrack.GetArgAsInt();
            int  y      = ConsoleTrack.GetArgAsInt();

            if (ConsoleTrack.activate && x > 0 && y > 0)
            {
                ActionMap.Transport.StartAction(ConsoleTrack.character, roomID, x, y);
            }
        }
Пример #27
0
        public static void ResizeMap()
        {
            string currentIns = ConsoleTrack.GetArgAsString();
            int    curVal     = ConsoleTrack.GetArgAsInt();

            ConsoleTrack.PrepareTabLookup(resizeOpts, currentIns, "Resize World Map");

            // Width Option
            if (currentIns == "width")
            {
                int currentWidth = ((WEScene)Systems.scene).xCount;
                ConsoleTrack.possibleTabs = "Example: resize width 60";
                ConsoleTrack.helpText     = "Choose a width between " + (byte)WorldmapEnum.MinWidth + " and " + (byte)WorldmapEnum.MaxWidth + ". Currently at " + currentWidth + ".";
            }

            // Height Option
            else if (currentIns == "height")
            {
                int currentHeight = ((WEScene)Systems.scene).yCount;
                ConsoleTrack.possibleTabs = "Example: resize height 60";
                ConsoleTrack.helpText     = "Choose a height between " + (byte)WorldmapEnum.MinHeight + " and " + (byte)WorldmapEnum.MaxHeight + ". Currently at " + currentHeight + ".";
            }

            else
            {
                return;
            }

            // Activate Resize
            if (ConsoleTrack.activate && curVal > 0)
            {
                WEScene scene = (WEScene)Systems.scene;

                if (currentIns == "width" && curVal >= (byte)WorldmapEnum.MinWidth && curVal <= (byte)WorldmapEnum.MaxWidth)
                {
                    scene.ResizeWidth((byte)curVal);
                }

                else if (currentIns == "height" && curVal >= (byte)WorldmapEnum.MinHeight && curVal <= (byte)WorldmapEnum.MaxHeight)
                {
                    scene.ResizeHeight((byte)curVal);
                }

                else
                {
                    UIHandler.AddNotification(UIAlertType.Error, "Invalid Resize", "Resize must be within the allowed range.", 240);
                }
            }
        }
Пример #28
0
        private static void DebugSpeed()
        {
            string currentIns = ConsoleTrack.GetArgAsString();

            ConsoleTrack.PrepareTabLookup(debugSpeedCodes, currentIns, "Assign a debug speed / tick rate that the game runs at.");

            if (ConsoleTrack.activate)
            {
                if (debugSpeedCodes.ContainsKey(currentIns))
                {
                    DebugConfig.SetTickSpeed((DebugTickSpeed)debugSpeedCodes[currentIns]);
                    return;
                }
            }
        }
Пример #29
0
        public static void SetMusicTrack()
        {
            string currentIns = ConsoleTrack.GetArgAsString();

            // Update the tab lookup.
            ConsoleTrack.PrepareTabLookup(ConsoleEditData.TrackCategory, currentIns, "Choose a music category for the track to play.");

            if (!ConsoleEditData.TrackCategory.ContainsKey(currentIns))
            {
                return;
            }

            EditorScene scene = (EditorScene)Systems.scene;

            // Remove Music From Level
            if (currentIns == "none")
            {
                scene.levelContent.SetMusicTrack(0);
                UIHandler.AddNotification(UIAlertType.Warning, "Removed Music Track", "Level currently has no music assigned.", 240);
                return;
            }

            Dictionary <string, object> trackCat = ConsoleEditData.TrackLookup[currentIns];

            string trackName = ConsoleTrack.GetArgAsString();

            ConsoleTrack.PrepareTabLookup(trackCat, trackName, "Set a music track for the level.");

            if (MusicAssets.TrackNames.ContainsKey(scene.levelContent.data.music))
            {
                ConsoleTrack.helpText += "Currently: \"" + MusicAssets.TrackNames[scene.levelContent.data.music].Replace("Music/", "") + "\".";
            }

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                if (trackCat.ContainsKey(trackName))
                {
                    byte track = (byte)trackCat[trackName];
                    scene.levelContent.SetMusicTrack((byte)track);
                    UIHandler.AddNotification(UIAlertType.Success, "Set Music Track", "Music Track set to " + MusicAssets.TrackNames[track].Replace("Music/", "") + ".", 240);
                    return;
                }

                // Prevent Rename if it exceeds name length.
                UIHandler.AddNotification(UIAlertType.Error, "Invalid Music Track", "Designated music track doesn't exist.", 240);
            }
        }
Пример #30
0
        // Returns the next instruction arg as a float.
        public static float GetArgAsFloat(bool increment = true)
        {
            string arg = ConsoleTrack.GetArg(increment);

            if (arg != string.Empty)
            {
                float floatVal;
                if (!float.TryParse(arg, out floatVal))
                {
                    floatVal = 0;
                }
                return(floatVal);
            }

            return(0);
        }