Exemplo n.º 1
0
 public Vector2D Subtract(Vector2D vec)
 {
     Vector2D newVec = new Vector2D(x, y);
     newVec.X = vec.X - this.x;
     newVec.Y = vec.Y - this.y;
     return newVec;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="imagePath"></param>
 /// <param name="startPos"></param>
 /// <param name="scaleFactor"></param>
 /// <param name="enemyWeapon">Which weapon the enemy should use</param>
 public Enemy(string imagePath, Vector2D startPos, float scaleFactor, Weapon enemyWeapon)
     : base(imagePath, startPos, scaleFactor)
 {
     currentEnemyWeapon = enemyWeapon;
     GameWorld.objects.Add(currentEnemyWeapon);//Weapon should also be added to the list of objects
     Random hp = new Random();
     health = hp.Next(60, 101);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="imagePath"></param>
        /// <param name="startPos"></param>
        /// <param name="scaleFactor"></param>
        /// <param name="player">Target for speechbubble</param>
        public SpeechBubble(string imagePath, Vector2D startPos, float scaleFactor, Player player)
            : base(imagePath, startPos, scaleFactor)
        {
            this.player = player;

            //The insults
            string[] insults =
            {
                "F**k you!",
                "Screw you!",
                "C**t!",
                "You c**t!",
                "Bitch!",
                "You f**k!",
                "You piece of shit!",
                "M**********r!",
                "Terrorist!",
                "Midget!",
                "You ugly!",
                "You are a bitch!",
                "Eat a dick!",
                "You suck!",
                "Jewish scum!",
                "Damn son, you bad!",
                "You fat f**k!",
                "You play like a girl!",
                "Nazi bitch!",
                "Transvestite f**k!",
                "ISIS loving shit!",
                "F*****g hippie!",
                "You retard!",
                "You soulless ginger\n piece of crap!",
                "F*****g muggle!",
                "You homeless\n greenlander!",
                "You alchoholic\n muslim!",
                "F*****g wanker!",
                "You f****t!",
                "You stinkin' cripple!"
            };
            Random myRandom = new Random();

            //List needed to get random insult
            List<string> randomInsultList = new List<string>();
            randomInsultList.AddRange(insults);

            //Getting the final insult
            int randomInsultSelected = myRandom.Next(0, randomInsultList.Count);
            insult = randomInsultList[randomInsultSelected];

            insultText.Text = insult;
            insultText.AutoSize = true;
            insultText.Hide();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="imagePath"></param>
        /// <param name="startPos"></param>
        /// <param name="scaleFactor"></param>
        public GameObject(string imagePath, Vector2D startPos, float scaleFactor)
        {
            position = startPos;
            this.scaleFactor = scaleFactor;
            string[] imagePaths = imagePath.Split(';');
            animationFrames = new List<Image>();
            foreach (string path in imagePaths)
            {
                animationFrames.Add(Image.FromFile(path));
            }

            this.sprite = animationFrames[0];
        }
Exemplo n.º 5
0
        /// <summary>
        /// Handles the movement for the bullet
        /// </summary>
        /// <param name="fps"></param>
        public override void Update(float fps)
        {
            //Calculate distance between player and enemy

            if (!hasAttacked)
            {
                velocity = position.Subtract(player.Position); //only do this once
                velocity.Normalize();
                hasAttacked = true;
            }

            position.X += 1 / fps * (velocity.X * speed);
            position.Y += 1 / fps * (velocity.Y * speed);
            if (CollisionBox.Right < 0 || CollisionBox.Left < 0 || CollisionBox.Top < 0) //optimaahzation
            {
                GameWorld.removeList.Add(this);
            }

            base.Update(fps);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Resolves collisions of two game objects.
 /// </summary>
 /// <param name="rigidbody">Player</param>
 /// <param name="b"></param>
 private void ResolveAABBCollision(GameObject rigidbody, GameObject b)
 {
     RectangleF result = RectangleF.Intersect(rigidbody.CollisionBox, b.CollisionBox);
     if (result.Width > 0 || result.Height > 0)
     {
         Vector2D rigidbodyCenter = new Vector2D(
             rigidbody.CollisionBox.Left + rigidbody.CollisionBox.Width * 0.5f,
             rigidbody.CollisionBox.Top + rigidbody.CollisionBox.Height * 0.5f
         );
         if (result.Height > result.Width)
         //resolve horisontally
         {
             float distanceFromRight = Math.Abs(rigidbodyCenter.X - b.CollisionBox.Right);
             float distanceFromLeft = Math.Abs(rigidbodyCenter.X - b.CollisionBox.Left);
             if (distanceFromRight > distanceFromLeft)
             {
                 // Go left
                 rigidbody.Position.X -= result.Width;
             }
             else
             {
                 // Go right
                 rigidbody.Position.X += result.Width;
             }
         }
         else
         {
             float distanceFromTop = Math.Abs(rigidbodyCenter.Y - b.CollisionBox.Top);
             float distanceFromBottom = Math.Abs(rigidbodyCenter.Y - b.CollisionBox.Bottom);
             if (distanceFromTop < distanceFromBottom)
             {
                 // Go up
                 rigidbody.Position.Y -= result.Height;
                 Player.isGrounded = true;
                 if (Player.velocity.Y > 0) // Don't pull player down
                 {
                     Player.velocity.Y = 0;
                 }
             }
             else
             {
                 // Go down
                 //Player.isGrounded = false;
                 //Don't make the position go down as we go below the map
                 rigidbody.Position.Y += result.Height;
             }
         }
     }
 }
Exemplo n.º 7
0
 public RigidBodyBox(string imagePath, Vector2D startPos, float scaleFactor)
     : base(imagePath, startPos, scaleFactor)
 {
 }
Exemplo n.º 8
0
        /// <summary>
        /// Constructor for the player. Handles the weapon index as well.
        /// </summary>
        /// <param name="imagePath">sprite</param>
        /// <param name="startPos">Starting position</param>
        /// <param name="scaleFactor"></param>
        public Player(string imagePath, Vector2D startPos, float scaleFactor)
            : base(imagePath, startPos, scaleFactor)
        {
            velocity = new Vector2D(0, 0);
            health = 100;
            isAlive = true;

            switch (weaponIndexNumber)
            {
                case 0:
                    currentPlayerWeapon = new BaseballBat(new Vector2D(0, 0), .3f);
                    break;

                case 1:
                    currentPlayerWeapon = new CricketPlayer(new Vector2D(0, 0), .8f);
                    break;

                case 2:
                    currentPlayerWeapon = new Knife(new Vector2D(0, 0), .3f);
                    break;

                case 3:
                    currentPlayerWeapon = new Guitar(new Vector2D(0, 0), .5f);
                    break;

                case 4:
                    currentPlayerWeapon = new Katana(new Vector2D(0, 0), .3f);
                    break;

                case 5:
                    currentPlayerWeapon = new DildoSword(new Vector2D(0, 0), .3f);
                    break;

                case 6:
                    currentPlayerWeapon = new Axe(new Vector2D(0, 0), .2f);
                    break;

                case 7:
                    currentPlayerWeapon = new Beaver(new Vector2D(0, 0), .5f);
                    break;

                case 8:
                    currentPlayerWeapon = new ISISFlag(new Vector2D(0, 0), .5f);
                    break;

                case 9:
                    currentPlayerWeapon = new AssaultRifle(new Vector2D(0, 0), .2f);
                    break;

                case 10:
                    currentPlayerWeapon = new RPG(new Vector2D(0, 0), .3f);
                    break;

                case 11:
                    currentPlayerWeapon = new SMG(new Vector2D(0, 0), .3f);
                    break;

                case 12:
                    currentPlayerWeapon = new LMG(new Vector2D(0, 0), .3f);
                    break;

                case 13:
                    currentPlayerWeapon = new Pistol(new Vector2D(0, 0), .1f);
                    break;
            }
            GameWorld.GameWeapons.Add(currentPlayerWeapon); //add it to objects as it should get drawn
        }
Exemplo n.º 9
0
        private Vector2D velocity; //for storing the value

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor for the bullet.
        /// </summary>
        /// <param name="imagePath"></param>
        /// <param name="startPos"></param>
        /// <param name="scaleFactor"></param>
        /// <param name="speed">Bullet speed</param>
        /// <param name="player">Player to follow</param>
        public Bullet(string imagePath, Vector2D startPos, float scaleFactor, float speed, GameObject player)
            : base(imagePath, startPos, scaleFactor)
        {
            this.player = player;
            this.speed = speed;
        }
Exemplo n.º 10
0
 public Impact( Vector2D startPos, float scaleFactor)
     : base(imagePath, startPos, scaleFactor)
 {
 }
Exemplo n.º 11
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="startPos"></param>
 /// <param name="scaleFactor"></param>
 public Coin(Vector2D startPos, float scaleFactor)
     : base(imagePath, startPos, scaleFactor)
 {
     this.animationSpeed = 10;
     canPickup = false;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Constructor, plays a sound on init
 /// </summary>
 /// <param name="imagepath"></param>
 /// <param name="startPos"></param>
 /// <param name="scalefactor"></param>
 public Baby(string imagepath, Vector2D startPos, float scalefactor)
     : base(imagepath, startPos, scalefactor)
 {
     GameWorld.eng.Play2D("BabyCrying.wav", true);
 }