Exemplo n.º 1
0
 //Creates the wepaons that are int the game
 public static void CreateWeapons(ContentManager Content)
 {
     //Adds the pistol
     weapons[0] = new Melee(Content, false, 0, 5, "Pistol", 2, "Ammo", "Knife", 1, 1000, 0);
     weapons[0].ShootSound = Content.Load<SoundEffect>("knifeSound");
     //Adds the pistol
     weapons[1] = new Weapon(Content);
     weapons[1].ShootSound = Content.Load<SoundEffect>("gunshot");
     weapons[1].ReloadSound = Content.Load<SoundEffect>("pistolReload");
     //Adds the Tommy Gun
     weapons[2] = new Weapon(Content, true, 10, 14, "SubmachineGun", 2, "Ammo", "SMG", 15, 3, 800, 7, 2, false, Content.Load<SoundEffect>("gunshot"), Content.Load<SoundEffect>("smgReload"));
     //Adds the Shotgun
     weapons[3] = new Weapon(Content, false, 20, 2, "shotgun", 3, "Shell", "Shotgun", 5, 2, 1500, 4, 3, false, Content.Load<SoundEffect>("shotgunSound"), Content.Load<SoundEffect>("shotgunReload"));
     //Adds the Rifle
     weapons[4] = new Weapon(Content, false, 1, 6, "Rifle", 5, "RifleBullet", "Rifle", 4, 3, 1000, 10, 4, false, Content.Load<SoundEffect>("rifleSound"), Content.Load<SoundEffect>("rifleReload"));
 }
Exemplo n.º 2
0
        public Character(ContentManager content) : base(content) {
            loc = new Coord();
            entTexture = content.Load<Texture2D>("NoTexture");
            collision = false;

            //default character creates default weapon which is a pistol
            weapon = new Weapon(content);
            //Set Health
            maxHealth = 20;
            health = maxHealth;
            //set stamina
            stamina = 100;
            cont = content;
        }
Exemplo n.º 3
0
        public bool CheckHit(Character e, Weapon w) {
            //Converts the direction from radians to degrees
            double directionDegrees = this.direction * 57.2958;

            //Checks collision based on the direction the projectile is rotated to
            //Checks angles in the fourth quadrant
            if (directionDegrees > 270 && directionDegrees <= 360) {
                if (this.loc.X + 1 < e.Loc.X + 0.5 && this.loc.X + 1 > e.Loc.X - 0.5 && this.loc.Y + 1 < e.Loc.Y + 0.5 && this.loc.Y + 1 > e.Loc.Y - 0.5) {
                    //Decrements the character's health
                    if (e.IsPlayer && !playerShot) {
                        e.Health -= w.Damage;
                        return true;
                    } else if (!e.IsPlayer && playerShot) {
                        e.Health -= w.Damage;
                        return true;
                    }
                }
            }
            //Checks angles in the third quadrant
            else if (directionDegrees > 180 && directionDegrees <= 270) {
                if (this.loc.X < e.Loc.X + 0.5 && this.loc.X > e.Loc.X - 0.5 && this.loc.Y + 1 < e.Loc.Y + 0.5 && this.loc.Y + 1 > e.Loc.Y - 0.5) {
                    //Decrements the character's health
                    if (e.IsPlayer && !playerShot) {
                        e.Health -= w.Damage;
                        return true;
                    } else if (!e.IsPlayer && playerShot) {
                        e.Health -= w.Damage;
                        return true;
                    }
                }
            }
            //Checks angles in the second quadrant
            else if (directionDegrees > 90 && directionDegrees <= 180) {
                if (this.loc.X < e.Loc.X + 0.5 && this.loc.X > e.Loc.X - 0.5 && this.loc.Y < e.Loc.Y + 0.5 && this.loc.Y > e.Loc.Y - 0.5) {
                    //Decrements the character's health
                    if (e.IsPlayer && !playerShot) {
                        e.Health -= w.Damage;
                        return true;
                    } else if (!e.IsPlayer && playerShot) {
                        e.Health -= w.Damage;
                        return true;
                    }
                }
            }
            //Checks angles in the first quadrant
            else {
                if (this.loc.X < e.Loc.X + 0.5 && this.loc.X > e.Loc.X - 0.5 && this.loc.Y < e.Loc.Y + 0.5 && this.loc.Y > e.Loc.Y - 0.5) {
                    //Decrements the character's health
                    if (e.IsPlayer && !playerShot) {
                        e.Health -= w.Damage;
                        return true;
                    } else if (!e.IsPlayer && playerShot) {
                        e.Health -= w.Damage;
                        return true;
                    }
                }
            }

            //Else returns false if no collision occurs
            return false;
        }