Ejemplo n.º 1
0
 public void PlayerWalkOnTile(PlayerEntity player)
 {
     if (!isWalkable)
     {
         player.WalkOnUnwalkableTile();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Check for player collisions with tiles
 /// </summary>
 /// <param name="player"></param>
 public void CheckCollisions(PlayerEntity player)
 {
     for (int i = 0; i < tileset.Length; i++)
     {
         if (tileset[i].tilespace.Intersects(player.collisionBox))
         {
             tileset[i].PlayerWalkOnTile(player);
         }
     }
 }
Ejemplo n.º 3
0
 public TileEnvironment(Game game, PlayerEntity player, int width, int height)
     : base(game)
 {
     this.player = player;
     location = new Point((int)player.getLocation().X, (int)player.getLocation().Y);
     prevLocation = location;
     this.width = width;
     this.height = height;
     tileset = new Tile[width * height];
     texLoader = new TileTextureLoader();
 }
Ejemplo n.º 4
0
 public StateSingle(LeGame g)
     : base(g)
 {
     #region Entities Construction
     player = new PlayerEntity(game, LeGame.PLAYER_STARTING_LOCATION);
     ogre = new OgreEntity(game, LeGame.OGRE_STARTING_LOCATION, 0.0f);
     mouse = new MouseEntity(game);
     #endregion
     #region Component Construction
     environment = new TileEnvironment(game, player, LeGame.ENVIRONMENT_WIDTH, LeGame.ENVIRONMENT_HEIGHT);
     audioControl = new AudioController(game, false, false);
     #endregion
 }
Ejemplo n.º 5
0
 public void DrawRelativeToPlayer(PlayerEntity p, SpriteBatch s)
 {
     #region Get draw location relative to player location
     int dX = (int)(PlayerEntity.drawLocation.X - PlayerEntity.location.X + location.X);
     int dY = (int)(PlayerEntity.drawLocation.Y - PlayerEntity.location.Y + location.Y);
     Rectangle drawLocation = new Rectangle(dX, dY, SIZE, SIZE);
     #endregion
     #region Draw sprite
     sprite.Draw(s, drawLocation, angle);
     #endregion
     #region Draw sight area
     if (LeGame.SHOW_ENEMY_SIGHT)
         s.Draw(sightAreaTexture, drawLocation, Color.White);
     #endregion
     #region Draw health bar and Tag
     s.Draw(healthTexture, new Rectangle(drawLocation.X - (SIZE / 2) - 1, drawLocation.Y - 11 - (SIZE / 2), SIZE + 2, 12), BackdropColor);
     s.Draw(healthTexture, new Rectangle(drawLocation.X - (SIZE / 2), drawLocation.Y - 10 - (SIZE / 2), SIZE, 10), HealthBarColor);
     s.DrawString(LeGame.gameFont, "Ogre", new Vector2(drawLocation.X - (SIZE / 4), drawLocation.Y - 13 - (SIZE / 2)), TextColor);
     #endregion
 }
Ejemplo n.º 6
0
        public void Update(PlayerEntity player, GameTime gt)
        {
            target = player.getLocation();
            moveDestination = new Rectangle((int)location.X, (int)location.Y, SIZE, SIZE);
            if (moveDestination.Intersects(player.collisionBox))
            {
                sprite.currentFrame = 0;
                if (!LeGame.AUDIO_IS_MUTED) laughSound.Play();
                isWalking = false;
            }
            else if (Vector2.Distance(location, target) >= FOLLOW_DISTANCE)
            {
                isWalking = false;
                sprite.currentFrame = 0;
            }
            else
            {
                isWalking = true;
                Vector2 direction = location - target;
                direction.Normalize();
                this.angle = Vector2ToRadian(direction) + (float)Math.PI;
                location -= direction * MOVEMENT_SPEED;
                if (laughSound.State == SoundState.Playing) laughSound.Stop();
            }

            if (isWalking) sprite.Update();
        }