Example #1
0
        public static Level readFromFile(String file, Player[] players,
                                         Camera.FollowMode followMode, main main)
        {
            // SETUP
            string[] lines     = File.ReadAllLines(file);
            int      platformc = Int32.Parse(
                lines[0].Substring(0, lines[0].IndexOf(" ")));
            int sentryc = Int32.Parse(
                lines[0].Substring(lines[0].IndexOf(" ") + 1));

            Platform[] platforms = new Platform[platformc];
            Sentry[]   sentries  = new Sentry[sentryc];
            int[]      key       = new int[sentryc];

            // NAME
            String name = lines[1];

            // PLATFORMS
            int l = 2;

            for (int i = 0; i < platformc; i++)
            {
                string line = lines[l + i];

                int x = Int32.Parse(line.Substring(0, line.IndexOf(" ")));
                line = line.Substring(line.IndexOf(" ") + 1);
                int y = Int32.Parse(line.Substring(0, line.IndexOf(" ")));
                line = line.Substring(line.IndexOf(" ") + 1);
                int w = Int32.Parse(line);
                platforms[i] = new Platform(new Point(x, y), w);
            }

            l += platformc;

            // NOTE
            String note = lines[l];

            // SENTRIES
            l++;

            for (int i = 0; i < sentryc; i++)
            {
                string line = lines[l + i];

                Enum.TryParse(line.Substring(0, line.IndexOf(" ")),
                              out Sentry.Type type);
                line = line.Substring(line.IndexOf(" ") + 1);
                int speed = Int32.Parse(line.Substring(0, line.IndexOf(" ")));
                line = line.Substring(line.IndexOf(" ") + 1);
                Enum.TryParse(line.Substring(0, line.IndexOf(" ")),
                              out Sentry.Type secondary);

                if (type == Sentry.Type.SPAWN)
                {
                    sentries[i] = new Sentry(type, speed, secondary);
                }
                else
                {
                    sentries[i] = new Sentry(type, speed);
                }

                line = line.Substring(line.IndexOf(" ") + 1);

                key[i] = Int32.Parse(line);
            }

            return(new Level(players, platforms, sentries,
                             key, followMode, main, name, note));
        }
Example #2
0
 public static EditorLevel newEditor(main main)
 {
     return(new EditorLevel(main));
 }
Example #3
0
        public static Level fetchLevel(String id, int playerc,
                                       Camera.FollowMode followMode, main main)
        {
            Debug.Assert(playerc == 1 || playerc == 2);

            Player[]   players;
            Platform[] platforms = new Platform[] { new Platform(new Point(1000, 1000), 200) };
            Sentry[]   sentries  = new Sentry[] { };
            int[]      key       = new int[] { };

            if (playerc == 2)
            {
                players = new Player[] { new Player(main.getSettings().getControlMode()),
                                         new Player((GameSettings.ControlMode)(1 -
                                                                               (int)main.getSettings().getControlMode())) };
            }
            else
            {
                players = new Player[] { new Player(main.getSettings().getControlMode()) };
            }

            switch (id)
            {
            case "staircase1":
                platforms = new Platform[] {
                    new Platform(new Point(1000, 1000), 200),
                    new Platform(new Point(800, 900), 200),
                    new Platform(new Point(1200, 800), 200),
                    new Platform(new Point(800, 700), 200),
                    new Platform(new Point(1200, 600), 200),
                    new Platform(new Point(800, 500), 200)
                };
                sentries = new Sentry[] {
                    new Sentry(Sentry.Type.PUSH, 10),
                    new Sentry(Sentry.Type.SPAWN, -10),
                    new Sentry(Sentry.Type.RANDOM, 14)
                };
                key = new int[] { 1, 2, 4 };
                break;

            case "behemoth":
                platforms = new Platform[] {
                    new Platform(new Point(1100, 1250), 100),
                    new Platform(new Point(700, 1150), 200),
                    new Platform(new Point(1150, 1075), 100),
                    new Platform(new Point(1000, 1000), 150),
                    new Platform(new Point(650, 1000), 200),
                    new Platform(new Point(1350, 1000), 150),
                    new Platform(new Point(850, 925), 100),
                    new Platform(new Point(1300, 850), 200),
                    new Platform(new Point(900, 750), 100)
                };
                sentries = new Sentry[] {
                    new Sentry(Sentry.Type.GRAV_DOUBLE, 10),
                    new Sentry(Sentry.Type.MOVE, 14),
                    new Sentry(Sentry.Type.GRAV_INC, 10),
                    new Sentry(Sentry.Type.GRAV_RED, -10),
                    new Sentry(Sentry.Type.GRAV_FLIP, -10),
                    new Sentry(Sentry.Type.PULL, 12)
                };
                key = new int[] { 1, 3, 4, 5, 7, 8 };
                break;

            case "Take Flight":
                platforms = new Platform[] {
                    new Platform(new Point(1100, 1250), 100),
                    new Platform(new Point(700, 1150), 200),
                    new Platform(new Point(2000, 1000), 150)
                };
                sentries = new Sentry[] {
                    new Sentry(Sentry.Type.GRAV_DOUBLE, 10),
                    new Sentry(Sentry.Type.DECAY, 14)
                };
                key = new int[] { 1, 2 };
                break;

            default:
                String file = "../../Resources/" + id + ".txt";
                return(readFromFile(file, players, followMode, main));
            }
            return(new Level(players, platforms, sentries, key, followMode, main));
        }
Example #4
0
        public static MenuFrame fromString(String s, main main)
        {
            MenuObject[] pauseObjs;

            // for ordered stuff
            int mid    = 360;
            int unit   = 80;
            int offset = 30;

            // for two column setups
            int lc = 480;
            int rc = 800;

            switch (s.ToLower())
            {
            case "main":
                mid  = 360;
                unit = 100;
                MenuObject[] menuObjs = new MenuObject[] {
                    new MenuObject(new Point(640, 100),
                                   Resources.t3logo_664_164, main),
                    new MenuObject(true, "PLAY", 4, new Point(640, mid - unit),
                                   MenuObject.Task.SET_MODE, "GAME", main),
                    new MenuObject(true, "MY CONTENT", 4, new Point(640, mid),
                                   MenuObject.Task.SET_MENU, "my-content", main),
                    new MenuObject(true, "<TODO>", 4, new Point(640, mid + unit),
                                   MenuObject.Task.SET_MENU, "settings-main", main),
                    new MenuObject(true, "QUIT", 4, new Point(640, mid + (2 * unit)),
                                   MenuObject.Task.CLOSE, null, main)
                };
                return(new MenuFrame(menuObjs, main));

            case "my-content":
                mid      = 360;
                unit     = 100;
                menuObjs = new MenuObject[] {
                    new MenuObject(false, "MY CONTENT", 8, new Point(640, 100),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "CAMPAIGNS", 4, new Point(640, mid - unit),
                                   MenuObject.Task.SET_MENU, "my-campaigns", main),
                    new MenuObject(true, "LEVELS", 4, new Point(640, mid),
                                   MenuObject.Task.SET_MENU, "my-levels", main),
                    new MenuObject(true, "LEVEL EDITOR", 4, new Point(640, mid + unit),
                                   MenuObject.Task.SET_MODE, "EDITOR", main),
                    new MenuObject(true, "BACK", 4, new Point(640, 660),
                                   MenuObject.Task.SET_MENU, "main", main)
                };
                return(new MenuFrame(menuObjs, main));

            case "editor-level-finish":
                lc       = 320;
                rc       = 960;
                mid      = 360;
                unit     = 100;
                offset   = 20;
                menuObjs = new MenuObject[] {
                    new MenuObject(false, "LEVEL INFO", 8, new Point(640, 100),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "LEVEL NAME:", 4, new Point(640,
                                                                      mid - unit - offset),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "\"" + main.getEditor().getName() + "\"",
                                   4, new Point(640, mid - unit + offset),
                                   MenuObject.Task.TYPE, "setlevelname", main),
                    new MenuObject(false, "LEVEL NOTE:", 4, new Point(640,
                                                                      mid - offset),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "\"" + main.getEditor().getNote() + "\"",
                                   2, new Point(640, mid + offset),
                                   MenuObject.Task.TYPE, "setlevelnote", main),
                    new MenuObject(true, "SAVE TO FILE", 4, new Point(lc, 660),
                                   MenuObject.Task.SAVE_EDITOR, null, main),
                    new MenuObject(true, "FINISH", 4, new Point(640, 660),
                                   MenuObject.Task.SET_MENU, "my-content", main),
                    new MenuObject(true, "BACK", 4, new Point(rc, 660),
                                   MenuObject.Task.SET_MODE, "EDITOR", main)
                };
                return(new MenuFrame(menuObjs, main));

            case "pause":
                String levelName = main.getLevel().getName().ToUpper();
                String levelNote = main.getLevel().getNote().ToUpper();

                if (levelName != "")
                {
                    if (levelNote == "")
                    {
                        levelNote = " ";
                    }
                    pauseObjs = new MenuObject[] {
                        new MenuObject(false, levelName, 8, new Point(640, 100),
                                       MenuObject.Task.NULL, null, main),
                        new MenuObject(false, levelNote, 2, new Point(640, 150),
                                       MenuObject.Task.NULL, null, main),
                        new MenuObject(true, "RESUME", 4, new Point(640, 260),
                                       MenuObject.Task.UNPAUSE, null, main),
                        new MenuObject(true, "SETTINGS", 4, new Point(640, 360),
                                       MenuObject.Task.SET_PAUSE, "settings-pause", main),
                        new MenuObject(true, "MAIN MENU", 4, new Point(640, 460),
                                       MenuObject.Task.SET_MENU, "main", main),
                        new MenuObject(true, "QUIT", 4, new Point(640, 560),
                                       MenuObject.Task.SET_PAUSE, "are-you-sure", main)
                    };
                    return(new MenuFrame(pauseObjs, main));
                }
                pauseObjs = new MenuObject[] {
                    new MenuObject(false, "PAUSED", 8, new Point(640, 100),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "RESUME", 4, new Point(640, 260),
                                   MenuObject.Task.UNPAUSE, null, main),
                    new MenuObject(true, "SETTINGS", 4, new Point(640, 360),
                                   MenuObject.Task.SET_PAUSE, "settings-pause", main),
                    new MenuObject(true, "MAIN MENU", 4, new Point(640, 460),
                                   MenuObject.Task.SET_MENU, "main", main),
                    new MenuObject(true, "QUIT", 4, new Point(640, 560),
                                   MenuObject.Task.SET_PAUSE, "are-you-sure", main)
                };
                return(new MenuFrame(pauseObjs, main));

            case "are-you-sure":
                pauseObjs = new MenuObject[] {
                    new MenuObject(false, "Are you sure you want to quit?",
                                   4, new Point(640, 310),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "BACK", 4, new Point(540, 410),
                                   MenuObject.Task.SET_PAUSE, "pause", main),
                    new MenuObject(true, "YES", 4, new Point(740, 410),
                                   MenuObject.Task.CLOSE, null, main)
                };
                return(new MenuFrame(pauseObjs, main));

            case "settings-pause":
                GameSettings stgs = main.getSettings();
                mid       = 360;
                unit      = 80;
                offset    = 30;
                pauseObjs = new MenuObject[] {
                    new MenuObject(false, "SETTINGS", 8, new Point(640, 100),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "BACK", 4, new Point(640, 660),
                                   MenuObject.Task.SET_PAUSE, "pause", main),
                    new MenuObject(false, "CAMERA FOLLOW MODE", 3,
                                   new Point(640, mid - (2 * unit)),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, stgs.getFollowMode().ToString(), 3,
                                   new Point(640, mid - (2 * unit) + offset),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "<", 3,
                                   new Point(520, mid - (2 * unit) + offset),
                                   MenuObject.Task.SWITCH_FOLLOW, "-1", main),
                    new MenuObject(true, ">", 3,
                                   new Point(760, mid - (2 * unit) + offset),
                                   MenuObject.Task.SWITCH_FOLLOW, "1", main),
                    new MenuObject(false, "WINDOW MODE", 3,
                                   new Point(640, mid - unit),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, stgs.getWindowMode().ToString(),
                                   3, new Point(640, mid - unit + offset),
                                   MenuObject.Task.SET_PAUSE, null, main),
                    new MenuObject(true, "<", 3, new Point(520, mid - unit + offset),
                                   MenuObject.Task.SWITCH_WINDOW, null, main),
                    new MenuObject(true, ">", 3, new Point(760, mid - unit + offset),
                                   MenuObject.Task.SWITCH_WINDOW, null, main),
                    new MenuObject(false, "HUD", 3, new Point(640, mid),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, stgs.getHUDStatus().ToString(),
                                   3, new Point(640, mid + offset), MenuObject.Task.NULL,
                                   null, main),
                    new MenuObject(true, "<", 3, new Point(520, mid + offset),
                                   MenuObject.Task.SWITCH_HUD, null, main),
                    new MenuObject(true, ">", 3, new Point(760, mid + offset),
                                   MenuObject.Task.SWITCH_HUD, null, main),
                    new MenuObject(false, "CONTROL MODE", 3, new Point(640, mid + unit),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, stgs.getControlMode().ToString(),
                                   3, new Point(640, mid + unit + offset), MenuObject.Task.SET_PAUSE,
                                   "controls-pause", main),
                    new MenuObject(true, "<", 3, new Point(520, mid + unit + offset),
                                   MenuObject.Task.SWITCH_CONTROLS, null, main),
                    new MenuObject(true, ">", 3, new Point(760, mid + unit + offset),
                                   MenuObject.Task.SWITCH_CONTROLS, null, main),
                    new MenuObject(false, "GAME SPEED", 3, new Point(640, mid + (2 * unit)),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, stgs.gameSpeed(), 3,
                                   new Point(640, mid + (2 * unit) + offset),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "<", 3, new Point(520, mid + (2 * unit) + offset),
                                   MenuObject.Task.SWITCH_PERIOD, "1", main),
                    new MenuObject(true, ">", 3, new Point(760, mid + (2 * unit) + offset),
                                   MenuObject.Task.SWITCH_PERIOD, "-1", main)
                };
                return(new MenuFrame(pauseObjs, main));

            case "controls-pause":
                Keys[] controls = main.getSettings().getControls();
                lc        = 480;
                rc        = 800;
                pauseObjs = new MenuObject[] {
                    new MenuObject(false, "CONTROLS", 8, new Point(640, 100),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "BACK", 4, new Point(640, 660),
                                   MenuObject.Task.SET_PAUSE, "settings-pause", main),
                    new MenuObject(false, "JUMP", 4, new Point(lc, 200),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[0].ToString(), 4,
                                   new Point(rc, 200), MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "DROP", 4, new Point(lc, 240),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[1].ToString(), 4,
                                   new Point(rc, 240), MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "LEFT", 4, new Point(lc, 280),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[2].ToString(), 4,
                                   new Point(rc, 280), MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "RIGHT", 4, new Point(lc, 320),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[3].ToString(), 4,
                                   new Point(rc, 320), MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "SAVE LOCATION", 4, new Point(lc, 360),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[4].ToString(), 4,
                                   new Point(rc, 360), MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "LOAD LOCATION", 4, new Point(lc, 400),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[5].ToString(), 4,
                                   new Point(rc, 400), MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "TELEPORT", 4, new Point(lc, 440),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[6].ToString(), 4,
                                   new Point(rc, 440), MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "CAMERA ZOOM", 4, new Point(lc, 480),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[7].ToString(), 4,
                                   new Point(rc, 480), MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "PAUSE", 4, new Point(lc, 520),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, controls[8].ToString(), 4,
                                   new Point(rc, 520), MenuObject.Task.NULL, null, main)
                };
                return(new MenuFrame(pauseObjs, main));

            default:
                return(new MenuFrame(new MenuObject[] {
                    new MenuObject(false, "THIS DOES NOT EXIST",
                                   8, new Point(640, 100),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(false, "(Yet.)",
                                   16, new Point(640, 360),
                                   MenuObject.Task.NULL, null, main),
                    new MenuObject(true, "RETURN TO MAIN MENU",
                                   4, new Point(640, 660),
                                   MenuObject.Task.SET_MENU, "main", main)
                }, main));
            }
        }