예제 #1
0
파일: Program.cs 프로젝트: Th4tGuyyy/conrpg
        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
파일: Player.cs 프로젝트: Th4tGuyyy/conrpg
        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);
        }
예제 #3
0
        public InputBox(int x, int y, int width, int height)
        {
            bounds   = new Rect(new Point(x, y), new Point(x + width, y + height));
            maxWidth = width - 1;

            #region QWERTY
            //sorry father, for i have sinned
            keys.add(ConsoleKey.Q, () => handleKey("q"), inputDelay, true);
            keys.add(ConsoleKey.W, () => handleKey("w"), inputDelay, true);
            keys.add(ConsoleKey.E, () => handleKey("e"), inputDelay, true);
            keys.add(ConsoleKey.R, () => handleKey("r"), inputDelay, true);
            keys.add(ConsoleKey.T, () => handleKey("t"), inputDelay, true);
            keys.add(ConsoleKey.Y, () => handleKey("y"), inputDelay, true);
            keys.add(ConsoleKey.U, () => handleKey("u"), inputDelay, true);
            keys.add(ConsoleKey.I, () => handleKey("i"), inputDelay, true);
            keys.add(ConsoleKey.O, () => handleKey("o"), inputDelay, true);
            keys.add(ConsoleKey.P, () => handleKey("p"), inputDelay, true);
            keys.add(ConsoleKey.A, () => handleKey("a"), inputDelay, true);
            keys.add(ConsoleKey.S, () => handleKey("s"), inputDelay, true);
            keys.add(ConsoleKey.D, () => handleKey("d"), inputDelay, true);
            keys.add(ConsoleKey.F, () => handleKey("f"), inputDelay, true);
            keys.add(ConsoleKey.G, () => handleKey("g"), inputDelay, true);
            keys.add(ConsoleKey.H, () => handleKey("h"), inputDelay, true);
            keys.add(ConsoleKey.J, () => handleKey("j"), inputDelay, true);
            keys.add(ConsoleKey.K, () => handleKey("k"), inputDelay, true);
            keys.add(ConsoleKey.L, () => handleKey("l"), inputDelay, true);
            keys.add(ConsoleKey.Z, () => handleKey("z"), inputDelay, true);
            keys.add(ConsoleKey.X, () => handleKey("x"), inputDelay, true);
            keys.add(ConsoleKey.C, () => handleKey("c"), inputDelay, true);
            keys.add(ConsoleKey.V, () => handleKey("v"), inputDelay, true);
            keys.add(ConsoleKey.B, () => handleKey("b"), inputDelay, true);
            keys.add(ConsoleKey.N, () => handleKey("n"), inputDelay, true);
            keys.add(ConsoleKey.M, () => handleKey("m"), inputDelay, true);

            keys.add(ConsoleKey.D0, () => handleKey("0"), inputDelay, true);
            keys.add(ConsoleKey.D1, () => handleKey("1"), inputDelay, true);
            keys.add(ConsoleKey.D2, () => handleKey("2"), inputDelay, true);
            keys.add(ConsoleKey.D3, () => handleKey("3"), inputDelay, true);
            keys.add(ConsoleKey.D4, () => handleKey("4"), inputDelay, true);
            keys.add(ConsoleKey.D5, () => handleKey("5"), inputDelay, true);
            keys.add(ConsoleKey.D6, () => handleKey("6"), inputDelay, true);
            keys.add(ConsoleKey.D7, () => handleKey("7"), inputDelay, true);
            keys.add(ConsoleKey.D8, () => handleKey("8"), inputDelay, true);
            keys.add(ConsoleKey.D9, () => handleKey("9"), inputDelay, true);
            #endregion

            keys.add(0xBE, () => handleKey("."), inputDelay, true);
            keys.add(0xBF, () => handleKey("/"), inputDelay, true);
            keys.add(ConsoleKey.Spacebar, () => handleKey(" "), inputDelay, true);
            keys.add(ConsoleKey.Backspace, () => handleKey("bks"), inputDelay, true);
        }