Ejemplo n.º 1
0
 public void SelectWeapon(Weapon weapon)
 {
     if (weapon.IsPrimary)
         SelectedPrimaryWeapon = weapon;
     else
         SelectedSecondaryWeapon = weapon;
 }
Ejemplo n.º 2
0
        public void AddWeapon(Weapon weapon)
        {
            if (weapon.IsPrimary)
            {
                primaryWeapons.Add(weapon);
                if (SelectedPrimaryWeapon == null)
                    SelectedPrimaryWeapon = weapon;
            }
            else
            {
                if (PlayerType == PlayerTypes.human)
                    secondaryWeapons.Add(weapon);
                else
                    weaponCache.Add(weapon);

                if (SelectedSecondaryWeapon == null && secondaryWeapons.Count > 0)
                    SelectedSecondaryWeapon = weapon;

            }
        }
Ejemplo n.º 3
0
        public void LoadWeaponDefinitions()
        {
            XDocument doc = XDocument.Load("../../../Furniture.xml");

            foreach (var f in doc.Elements("items").Elements("weapondefinitions").Elements())
            {
                Weapon weapon = new Weapon
                {
                    Power = int.Parse(f.Attribute("power").Value),
                    IsPrimary = bool.Parse(f.Attribute("isprimary").Value),
                    Texture = Content.Load<Texture2D>("Cards/" + f.Attribute("name").Value),
                    Name = f.Attribute("name").Value,
                    CoolDown = int.Parse(f.Attribute("cooldown").Value),
                    DrainsPower = bool.Parse(f.Attribute("drainspower").Value),
                    Damage = int.Parse(f.Attribute("damage").Value),
                    Range = int.Parse(f.Attribute("range").Value),
                    Push = int.Parse(f.Attribute("push").Value)
                };

                if (f.Elements("animatedtexture").Count() > 0)
                    weapon.UserTexture = new AnimatedTexture(Content.Load<Texture2D>("WeaponSprites/" + f.Elements("animatedtexture").ElementAt(0).Attribute("name").Value), int.Parse(f.Elements("animatedtexture").ElementAt(0).Attribute("horizontal").Value), int.Parse(f.Elements("animatedtexture").ElementAt(0).Attribute("vertical").Value), bool.Parse(f.Elements("animatedtexture").ElementAt(0).Attribute("repeat").Value), int.Parse(f.Elements("animatedtexture").ElementAt(0).Attribute("framespersecond").Value), spriteBatch, int.Parse(f.Elements("animatedtexture").ElementAt(0).Attribute("width").Value), int.Parse(f.Elements("animatedtexture").ElementAt(0).Attribute("height").Value), new Vector2(int.Parse(f.Elements("animatedtexture").ElementAt(0).Attribute("originx").Value), int.Parse(f.Elements("animatedtexture").ElementAt(0).Attribute("originy").Value)), null);

                if (f.Elements("animatedtexture").Count() > 1)
                    weapon.EffectTexture = new AnimatedTexture(Content.Load<Texture2D>("WeaponSprites/" + f.Elements("animatedtexture").ElementAt(1).Attribute("name").Value), int.Parse(f.Elements("animatedtexture").ElementAt(1).Attribute("horizontal").Value), int.Parse(f.Elements("animatedtexture").ElementAt(1).Attribute("vertical").Value), bool.Parse(f.Elements("animatedtexture").ElementAt(1).Attribute("repeat").Value), int.Parse(f.Elements("animatedtexture").ElementAt(1).Attribute("framespersecond").Value), spriteBatch, int.Parse(f.Elements("animatedtexture").ElementAt(1).Attribute("width").Value), int.Parse(f.Elements("animatedtexture").ElementAt(1).Attribute("height").Value), new Vector2(int.Parse(f.Elements("animatedtexture").ElementAt(1).Attribute("originx").Value), int.Parse(f.Elements("animatedtexture").ElementAt(1).Attribute("originy").Value)), Content.Load<SoundEffect>("Sounds/" + f.Elements("animatedtexture").ElementAt(1).Attribute("sound").Value));

                weaponDefinitions.Add(weapon);
            }
        }
Ejemplo n.º 4
0
        public Weapon Clone()
        {
            Weapon weapon = new Weapon
            {
                Power = Power,
                IsPrimary = IsPrimary,
                Texture = Texture,
                Name = Name,
                CoolDown = CoolDown,
                DrainsPower = DrainsPower,
                Damage = Damage,
                Range = Range,
                Push = Push
            };

            if (UserTexture != null)
                weapon.UserTexture = UserTexture.Clone();

            if (EffectTexture != null)
                weapon.EffectTexture = EffectTexture.Clone();

            return weapon;
        }
Ejemplo n.º 5
0
 public void SendShoting(Player thisPlayer, Int64 shotPlayerId, List<Weapon> weaponDefinitions, Weapon weapon, int x, int y)
 {
     NetOutgoingMessage om = client.CreateMessage();
     om.Write((byte)MessageRouts.Fire);
     om.Write((Int64)shotPlayerId);
     om.Write((byte)weaponDefinitions.IndexOf(weaponDefinitions.SingleOrDefault(w => w.Name == weapon.Name)));
     om.Write((byte)((-Math.Atan2(thisPlayer.Direction.X, thisPlayer.Direction.Y) * 40)));
     om.Write((int)x);
     om.Write((int)y);
     client.SendMessage(om, NetDeliveryMethod.Unreliable);
 }