Beispiel #1
0
        /// <summary>
        /// Instantiates an enemy and puts him in the level.
        /// </summary>
        private Tile LoadEnemyTile(int x, int y, string spriteSet)
        {
            Vector2 position = RectangleExtensions.GetBottomCenter(GetBounds(x, y));

            enemies.Add(new Enemy(this, new Vector2(position.X, position.Y), spriteSet));

            return(new Tile(null, TileCollision.Passable));
        }
Beispiel #2
0
        /// <summary>
        /// Instantiates a player, puts him in the level, and remembers where to put him when he is resurrected.
        /// </summary>
        private Tile LoadStartTile(int x, int y)
        {
            if (Player != null)
            {
                throw new NotSupportedException("A level may only have one starting point.");
            }

            start  = RectangleExtensions.GetBottomCenter(GetBounds(x, y));
            player = new Player(this, start, offsetX, offsetY, game, x, y);

            return(new Tile(null, TileCollision.Passable));
        }
Beispiel #3
0
        /// <summary>
        /// Update the position and direction based on input from BCI2000
        /// </summary>
        void UpdateFromBCI20002(TimeSpan elapsedTime)
        {
            AutoMovePlayer2(0, elapsedTime);
            //Check to see if a new command is available.
            if ((bool)game.Services.GetService(typeof(bool)) == true)
            {
                int Val = (int)game.Services.GetService(typeof(int));

                //update based on commnad
                switch (Val)
                {
                case 0:         //Dont move
                    isMoving = false;
                    break;

                case 1:         //move up
                    if (!collisionDetect(x, y - 1) && movementComplete)
                    {
                        isMoving    = true;
                        y          -= 1;
                        newPosition = RectangleExtensions.GetBottomCenter(Level.GetBounds(x, y));
                        AutoMovePlayer2(1, elapsedTime);
                    }
                    break;

                case 2:         //move down
                    if (!collisionDetect(x, y + 1) && movementComplete)
                    {
                        isMoving    = true;
                        y          += 1;
                        newPosition = RectangleExtensions.GetBottomCenter(Level.GetBounds(x, y));
                        AutoMovePlayer2(2, elapsedTime);
                    }
                    break;

                case 3:         //move right
                    if (!collisionDetect(x + 1, y) && movementComplete)
                    {
                        isMoving    = true;
                        x          += 1;
                        newPosition = RectangleExtensions.GetBottomCenter(Level.GetBounds(x, y));
                        AutoMovePlayer2(3, elapsedTime);
                    }
                    break;

                case 4:         //move left
                    if (!collisionDetect(x - 1, y) && movementComplete)
                    {
                        isMoving    = true;
                        x          -= 1;
                        newPosition = RectangleExtensions.GetBottomCenter(Level.GetBounds(x, y));
                        AutoMovePlayer2(4, elapsedTime);
                    }
                    break;

                case 99:
                    isMoving = false;
                    break;

                default:
                    AutoMovePlayer(0, elapsedTime);
                    break;
                }

                //set the new command status to false
                game.Services.RemoveService(typeof(bool));
                game.Services.AddService(typeof(bool), false);
            }
        }