/// <summary>
        ///
        /// </summary>
        /// <param name="position"></param>
        /// <param name="walkingDirection">false for left true for right</param>
        public CivilianEnemy(Vector2 position, bool walkingDirection)
        {
            collidableObject      = new CollidableObject(colorMap, position, new Rectangle(120, 0, 98, 114), 0);
            this.walkingDirection = walkingDirection;
            health = (int)(defaultHealth * InGame.difficultyModifier);

            int walkingTime = 200;

            // Load all frames into Animation // Edited by Noble 12-11
            moveRightAnimation = new Animation(new List <Frame>
            {
                new Frame(new Rectangle(0, 0, 53, 142), walkingTime),
                new Frame(new Rectangle(53, 0, 53, 142), walkingTime),
                new Frame(new Rectangle(0, 0, 53, 142), walkingTime),
                new Frame(new Rectangle(106, 0, 53, 142), walkingTime),
            }
                                               );
            moveLeftAnimation = new Animation(new List <Frame>
            {
                new Frame(new Rectangle(0, 143, 53, 142), walkingTime),
                new Frame(new Rectangle(53, 143, 53, 142), walkingTime),
                new Frame(new Rectangle(0, 143, 53, 142), walkingTime),
                new Frame(new Rectangle(106, 143, 53, 142), walkingTime),
            }
                                              );
        }
        /// <summary>
        /// Called upon to load player textures etc.
        /// </summary>
        /// <param name="content"></param>
        public void LoadContent(ContentManager content)
        {
            // Create a new collidableObject
            collidableObject = new CollidableObject(
                content.Load <Texture2D>(@"Textures/CollisionMaps/PlayerCollisionMap"), // The collision map
                new Vector2(Game1.ScreenBounds.X / 2, InGame.groundRectangle.Top),      // The spawning position
                new Rectangle(0, 0, 79, 104),                                           // Initial size and position of source rectangle
                0f                                                                      // The rotation
                );

            // Create a new collidable object for attack collision map
            attackCollidableObject = new CollidableObject(content.Load <Texture2D>(@"Textures/CollisionMaps/PlayerAttackCollisionMap"),
                                                          collidableObject.Position,
                                                          collidableObject.SourceRectangle,
                                                          collidableObject.Rotation);

            // Load normal map texture
            normalMap = content.Load <Texture2D>(@"Textures/Characters/PlayerNormalMap");
            colorMap  = content.Load <Texture2D>(@"Textures/Characters/Player");

            Random rand = new Random();

            playerName = $"Player {rand.Next(1, 999).ToString()}";


            animations.Clear();
            LoadAnimations();
        }
 /// <summary>
 /// Creates a new pistol bullet/particle
 /// </summary>
 /// <param name="texture"></param>
 /// <param name="position">The spawn position of the object</param>
 /// <param name="velocity"></param>
 /// <param name="rotation"></param>
 public PistolParticle(Texture2D texture, Vector2 position, float velocity, float rotation)
 {
     // Create a new collidableobject
     collidableObject = new CollidableObject(texture, position)
     {
         Rotation = rotation
     };
     // Set velocity
     this.velocity = velocity;
     // Set direction
     direction = new Vector2((float)Math.Cos(rotation), (float)Math.Sin(rotation));
 }
Exemple #4
0
 /// <summary>
 ///     Detects a pixel level collision between this and an other CollidableObject.
 /// </summary>
 /// <param name="collidable">The CollidableObject to check a collision against</param>
 /// <returns>True if colliding, false if not.</returns>
 public bool IsColliding(CollidableObject collidable)
 {
     // If rectangle of objects intersects
     if (BoundingRectangle.Intersects(collidable.BoundingRectangle))
     {
         // And any of the pixels of objects intersect
         if (IntersectPixels(Transform, SourceRectangle, TextureData, collidable.Transform, collidable.SourceRectangle, collidable.TextureData))
         {
             // Then return true
             return(true);
         }
     }
     // Else return false
     return(false);
 }
Exemple #5
0
        // Edited by Noble 12-10, Alexander 12-11
        public MeleeEnemy(Vector2 position)
        {
            collidableObject = new CollidableObject(collisionMap, position, new Rectangle(120, 0, 98, 114), 0);
            health           = (int)(defaultHealth * InGame.difficultyModifier);
            int walkingTime = 200;

            // Load all frames into Animation // Edited by Noble 12-10
            moveRightAnimation = new Animation(new List <Frame>
            {
                new Frame(new Rectangle(0, 0, 98, 114), walkingTime),
                new Frame(new Rectangle(99, 0, 98, 114), walkingTime),
                new Frame(new Rectangle(198, 0, 98, 114), walkingTime),
                new Frame(new Rectangle(99, 0, 98, 114), walkingTime),
            }
                                               );
            moveLeftAnimation = new Animation(new List <Frame>
            {
                new Frame(new Rectangle(0, 115, 98, 113), walkingTime),
                new Frame(new Rectangle(99, 115, 98, 113), walkingTime),
                new Frame(new Rectangle(198, 115, 98, 113), walkingTime),
                new Frame(new Rectangle(99, 115, 98, 113), walkingTime),
            }
                                              );
        }
Exemple #6
0
 public Enemy(Texture2D texture, Vector2 position)
 {
     collidableObject = new CollidableObject(texture, position, new Rectangle(120, 0, 60, 120), 0);
 }