Пример #1
0
        public override void Create()
        {
            if (File.Exists(GameData.METALOCATION + "Error.txt"))
            {
                File.Delete(GameData.METALOCATION + "Error.txt");
            }

            Engine.SetPalette(Palettes.Default);
            Engine.Borderless();
            GameData.GAME = this;

            gameKeys = new KeyboardHandler();

            gameKeys.add(ConsoleKey.Enter, () => GameData.VConsole.switchState(), 0.5f);
            gameKeys.add(0xBF, () => GameData.VConsole.switchStateAndSlash(), 0.5f);

            TargetFramerate = 100;


            //GameData.VConsole.gameHandle = this;

            GameData.VConsole.writeLine("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLGMOPeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");

            //loops thru maps folder and adds the maps if valid
            String[] maps = Directory.GetFiles(GameData.MAPSLOCATION);
            for (int i = 0; i < maps.Length; i++)
            {
                String fileName = Path.GetFileName(maps[i]);

                if (fileName.Substring(fileName.Length - 4, 4) != ".txt")
                {
                    throw new Exception(fileName.Substring(fileName.Length - 4, 4) + "is not a valid file type");
                }

                GameData.allLevels.Add(fileName, new Level(fileName));
            }


            GameData.player.level = GameData.allLevels["openworld.txt"];

            foreach (KeyValuePair <string, Level> obj in GameData.allLevels)
            {
                obj.Value.loadLevel();
            }
        }
Пример #2
0
        public Player(Level owner, String name, Glyph sprite, Point loc, int health) : base(owner, loc)
        {
            this.name     = name;
            this.location = loc;
            this.health   = health;
            this.sprite   = sprite;

            setStats(new Glyph("@", Palettes.DARK_CYAN), 10, 1.6f, 0, 0, 0, 0);            //temp

            keyHandler   = new KeyboardHandler();
            movementKeys = new KeyboardHandler();
            //moveSpeed = 1.6f;

            //Timer movement = new Timer(moveSpeed.Value);

            movementKeys.add(ConsoleKey.RightArrow, () => move(location + new Point(1, 0)), updateTimer);
            movementKeys.add(ConsoleKey.DownArrow, () => move(location + new Point(0, 1)), updateTimer);
            movementKeys.add(ConsoleKey.UpArrow, () => move(location + new Point(0, -1)), updateTimer);
            movementKeys.add(ConsoleKey.LeftArrow, () => move(location + new Point(-1, 0)), updateTimer);

            keyHandler.add(ConsoleKey.B, () => say(randomNum() + ""), 0.1f);
            keyHandler.add(ConsoleKey.S, () => say("BEANS"), 3f);
        }