Ejemplo n.º 1
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            keyboardState = Keyboard.GetState();

            if (keyboardState.IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (hero.HP > 0)
            {
                enemys.Move(gameLand, gameLand.Block, hero);

                hero.CheckForMonsters(enemys);

                if (keyboardState.IsKeyDown(Keys.Up))
                {
                    hero.Move(Direction.UP, gameLand, gameLand.Block, gameLand.H, gameLand.W, bonuses, bonuses.BonusBoard, gameTime);
                }
                if (keyboardState.IsKeyDown(Keys.Down))
                {
                    hero.Move(Direction.Down, gameLand, gameLand.Block, gameLand.H, gameLand.W, bonuses, bonuses.BonusBoard, gameTime);
                }
                if (keyboardState.IsKeyDown(Keys.Right))
                {
                    hero.Move(Direction.Right, gameLand, gameLand.Block, gameLand.H, gameLand.W, bonuses, bonuses.BonusBoard, gameTime);
                }
                if (keyboardState.IsKeyDown(Keys.Left))
                {
                    hero.Move(Direction.Left, gameLand, gameLand.Block, gameLand.H, gameLand.W, bonuses, bonuses.BonusBoard, gameTime);
                }
            }

            base.Update(gameTime);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            string command     = string.Empty;
            int    meters      = 0;
            Hero   svetiGeorgi = new Hero(new SmallSword(), new Walking());

            Console.WriteLine("Hello Goshe");
            Console.WriteLine(string.Format("Second level: after {0} meters", METERS_REQUIRED_LEVEL_2));
            Console.WriteLine(string.Format("Third level: after {0} meters", METERS_REQUIRED_LEVEL_3));
            Console.WriteLine(string.Format("God level: after {0} meters", FAR_FAR_AWAY));

            while (!command.Equals(QUIT_COMMAND))
            {
                command = Console.ReadLine();

                switch (command)
                {
                case MOVE_COMMAND:
                    meters += svetiGeorgi.Move();
                    ChooseGear(meters, svetiGeorgi);
                    Console.WriteLine(string.Format("Current distance: {0} meters", meters));
                    break;

                case ATTACK_COMMAND:
                    svetiGeorgi.Attack();
                    break;

                case INFO_COMMAND:
                    Console.WriteLine(svetiGeorgi.Preview());
                    break;
                }
            }

            Console.WriteLine("The game is over.");
            Console.ReadLine();
        }