예제 #1
0
 public Player AddPlayer(Player p)
 {
     long id = 0;
     if( players.Keys.Count > 0 )
         id = players.Keys.Last() + 1;
     return AddPlayer(id, p);
 }
예제 #2
0
 public override void Pickup(Player p)
 {
     if (p.BombRange < Config.BombMaxRange) {
         p.BombRange++;
         // mark for death
         base.Pickup (p);
     }
 }
 // constructor (each player will need their own Counter and Meter objects)
 public UserInterface(Player pl)
 {
     player = pl;
     player.MacGuffinCount = 0;
     stunCharge = 0;
     stunCountdown = 100;
     stunIsActive = false;
 }
예제 #4
0
 public Player AddPlayer(long id, Player p)
 {
     SpawnPoint spawn = engine.BlockManager.RequestSpawnPoint();
     p.Position = new Vector2(spawn.Point.X*32, spawn.Point.Y*32);
     p.Engine = engine;
     p.ID = id;
     players.Add(id, p);
     return p;
 }
예제 #5
0
 public override void OnPass(Player p)
 {
     base.OnPass (p);
     if (p.Rectangle.Intersects (Rectangle)) {
         Vector2 offset = Vector2.Divide (new Vector2 (Width, Height), 2.5f);
         Rectangle killArea = new Rectangle(Convert.ToInt16(Rectangle.X+offset.X), Convert.ToInt16(Rectangle.Y+offset.Y), Convert.ToInt16(Rectangle.Width-offset.X), Convert.ToInt16(Rectangle.Height-offset.Y));
         if (p.Rectangle.Intersects (killArea)) {
             //p.Kill ();
             bomb.Player.Killed(p);
         }
     }
 }
예제 #6
0
        protected override void Initialize()
        {
            base.Initialize ();
            WindowWidth = GraphicsDevice.DisplayMode.Width;
            WindowHeight = GraphicsDevice.DisplayMode.Height;

            graphics.PreferredBackBufferWidth = WindowWidth;
            graphics.PreferredBackBufferHeight = WindowHeight;
            graphics.ApplyChanges();

            Player = new Player ((WindowWidth - 32.0f) / 2.0f, (WindowHeight - 32.0f) / 2.0f, this, squid);
            Enemy = new Enemy (WindowWidth / 4.0f, WindowHeight / 4.0f, 4, EnemyTexture, this);
        }
예제 #7
0
 public void Killed(Player p)
 {
     if (p == this)
         --score;
     else
         ++score;
 }
예제 #8
0
 public override void Pickup(Player p)
 {
     Console.WriteLine ("More speed!");
     p.Acceleration = new Vector2(p.Acceleration.X+.1f, p.Acceleration.Y+.1f);
     base.Pickup (p);
 }
예제 #9
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            screenManager.AddScreen(new MainMenuScreen("Menu"), PlayerIndex.One);
            screenManager.Initialize();
            otherScreens = screenManager.GetScreens();

            startPlace = new Rectangle(400, 300, 28, 62);

            player1 = new Player(1, Color.Red);
            user1 = new UserInterface(player1);
            char1 = new Character(player1);
            char1.Place = new Rectangle(400, 300, 28, 62);

            player2 = new Player(2, Color.Blue);
            user2 = new UserInterface(player2);
            char2 = new Character(player2);
            char2.Place = new Rectangle(475, 300, 28, 62);

            player3 = new Player(3, Color.Green);
            user3 = new UserInterface(player3);
            char3 = new Character(player3);
            char3.Place = new Rectangle(550, 300, 28, 62);

            player4 = new Player(4, Color.Yellow);
            user4 = new UserInterface(player4);
            char4 = new Character(player4);
            char4.Place = new Rectangle(625, 300, 28, 62);

            characters.Add(char1);
            characters.Add(char2);
            characters.Add(char3);
            characters.Add(char4);

            // read the map
            ReadMap("map1.txt");
            base.Initialize();
        }
예제 #10
0
 public virtual void OnPass(Player p)
 {
 }
예제 #11
0
        int startY; // holds current Y position

        #endregion Fields

        #region Constructors

        public Character(Player pl)
        {
            player = pl;
            startY = place.Y;
            jumpSpeed = 0;
        }
예제 #12
0
 public virtual void Pickup(Player p)
 {
     Kill ();
 }
예제 #13
0
 public override void OnPass(Player p)
 {
     base.OnPass (p);
     Pickup (p);
 }
예제 #14
0
        private void DrawPlayerName(SpriteBatch spriteBatch, Player player, int x, int nameOffset, int pointsOffset, SpriteFont font)
        {
            if(player.CurrentMove)
            {
                var playerNameSize = _smallMenuFont.MeasureString(player.Name);
                var playerPointsSize = _smallMenuFont.MeasureString(player.Points + "");

                var width = (int)(playerNameSize.X > playerPointsSize.X ? playerNameSize.X : playerPointsSize.X) + 10;
                var height = (int)(playerNameSize.Y + playerPointsSize.Y);

                var currentPlayerBox = CreateBox(width, height, x - 5, nameOffset - 5);

                var fillText = new Texture2D(GraphicsDevice, 1, 1);
                fillText.SetData(new[] { _gameBackgroundColor });
                DrawBorder(spriteBatch, currentPlayerBox, Color.MediumVioletRed, 2);
            }

            spriteBatch.DrawString(font, player.Name, new Vector2(x, nameOffset), player.Color);
            spriteBatch.DrawString(font, player.Points + "", new Vector2(x, pointsOffset), player.Color);
        }
예제 #15
0
 public GameScene(Game game)
     : base(game)
 {
     player = new Player(game);
     enemy = new Enemy(game);
 }