Example #1
0
        public void AddWeapon(TypesWeapon weapon)
        {
            uint index = (uint)weapon;

            weapons[index].TypesWeapon = weapon;
            OnChangeCharacter(TypesChangeCharacter.AddWeapon, index);
        }
Example #2
0
 public Weapon GetWeapon(TypesWeapon typeWeapon)
 {
     try
     {
         return(weapons[(int)typeWeapon]);
     }
     catch (Exception) { return(null); }
 }
Example #3
0
 public void ChangeBulletInWeapon(TypesWeapon type, int countBullets)
 {
     for (uint i = 0; i < weapons.Length; i++)
     {
         if (weapons[i].TypesWeapon == type)
         {
             weapons[i].CountBullets = countBullets;
             OnChangeCharacter(TypesChangeCharacter.BulletInWeapon, i);
             break;
         }
     }
 }
Example #4
0
        public Magazin(IWeapon parent, TypesWeapon typeWeapon, int duration_BetweenShots,
                       int duration_Magazin, int bulletsInMagazin) : base(parent)
        {
            TypeMagazin = typeWeapon;
            Reload      = TypesReload.Not;

            _bulletsInMagazin = bulletsInMagazin;

            _durationReload_BetweenShots = duration_BetweenShots;
            _durationReload_Magazin      = duration_Magazin;
            //cоздаем новый магазин
            _bulletsInMagazinNow = bulletsInMagazin;
        }
Example #5
0
        public void Test_UpdateComponent_MakeReload()
        {
            TypesWeapon typesWeapon           = TypesWeapon.Gun;
            int         bullet_In_Magazine    = 8;
            int         duration_Magazine     = 300;
            int         duration_betweenShots = 50;

            var model  = new MockRoyalGameModel();
            var player = new MockPlayer()
            {
                Model = model
            };
            var weapon = new Weapon(model, TypesGameObject.Weapon, TypesBehaveObjects.Active, TypesWeapon.Gun);

            weapon.Owner = player;

            Magazin magazin = new Magazin(weapon, typesWeapon, duration_betweenShots, duration_Magazine, bullet_In_Magazine);

            weapon.Components.Add(magazin);
            weapon.Setup();

            Assert.IsNotNull(magazin.GetBullet());
            player.Update_MakeReloadWeapon(new MakeReloadWeapon(weapon.ID));                    // игров собирается выполнить перезарядку
            Assert.IsNull(magazin.GetBullet());

            weapon.Update(new TimeQuantPassed(duration_Magazine - 1));
            Assert.IsNull(magazin.GetBullet());

            weapon.Update(new TimeQuantPassed(1));
            Assert.IsNotNull(magazin.GetBullet());

            var outMgs = model.outgoingMessages;

            Assert.IsTrue(outMgs.Dequeue().Count == 7);

            var msg_startReload    = outMgs.Dequeue();
            var msg_ChangeBullet_1 = outMgs.Dequeue();
            var mgs_endReload      = outMgs.Dequeue();
            var msg_ChangeBullet_2 = outMgs.Dequeue();

            Assert.IsTrue(msg_startReload.StartOrEnd == true);
            Assert.IsTrue(msg_ChangeBullet_1.Count == 8);
            Assert.IsTrue(mgs_endReload.StartOrEnd == false);
            Assert.IsTrue(msg_ChangeBullet_2.Count == 7);
        }
Example #6
0
        public override void Update()
        {
            var pos = modelObject.Location;

            translateTransform.OffsetX = pos.X;
            translateTransform.OffsetY = pos.Y;

            modelHands.SetPosition(modelObject.Location3D);

            var gamer = (Gamer)modelObject;

            if (lastCurrentWeapon != gamer.CurrentWeapon)
            {
                lastCurrentWeapon = gamer.CurrentWeapon;
                modelHands.Remove();
                modelHands = new Model3D(models, new Hand(modelObject as Gamer));
                modelHands.CreateImage();
            }

            modelHands.Rotation(modelObject.Angle);
        }
Example #7
0
 public Hand(Gamer player) : base(player.ID, player.Location, player.Size)
 {
     currentWeapon = player.CurrentWeapon;
     SetSize(player.Size);
 }
Example #8
0
 public ChoiceWeapon(ulong iD, TypesWeapon selectedWeapon)
 {
     ID         = iD;
     TypeWeapon = selectedWeapon;
 }
Example #9
0
 public WeaponCharacter(TypesWeapon typesWeapon, int countBullets)
 {
     this.TypesWeapon  = typesWeapon;
     this.CountBullets = countBullets;
 }
Example #10
0
 public void ChangeCurrentWeapon(TypesWeapon weapon)
 {
     OnChangeCharacter(TypesChangeCharacter.CurrentWepon);
 }
Example #11
0
 public ChangedCurrentWeapon(ulong iD, TypesWeapon newCurrentWeapon)
 {
     ID         = iD;
     TypeWeapon = newCurrentWeapon;
 }
Example #12
0
 public ChangeBulletInWeapon(ulong iD, TypesWeapon typeWeapon, int count)
 {
     ID         = iD;
     TypeWeapon = typeWeapon;
     Count      = count;
 }
Example #13
0
 public WeaponState(ulong id, TypesGameObject type, TypesWeapon typeWeapon, List <IMessage> statesComponents) : base(id, type, statesComponents)
 {
     TypeWeapon = typeWeapon;
 }
Example #14
0
        private static Magazin CreateMagazin(Weapon weapon, WeaponSetups weaponSetup, TypesWeapon typeWeapon)
        {
            var magazin = new Magazin(weapon, typeWeapon, weaponSetup.timeBetweenShot,
                                      weaponSetup.timeReload, weaponSetup.bulletsInMagazin);

            weapon.Components.Add(magazin);

            return(magazin);
        }
Example #15
0
        private static Weapon CreateShotWeapon(IModelForComponents model, PhysicsSetups physicsSetupsWeapon,
                                               WeaponSetups weaponSetups, SizeF sizeWeapon, TypesWeapon typeWeapon, PointF location)
        {
            var weapon = new Weapon(model, TypesGameObject.Weapon, TypesBehaveObjects.Active, typeWeapon);

            CreateStandartComponentForWeapon(weapon, physicsSetupsWeapon, weaponSetups, sizeWeapon, typeWeapon, location);

            var shot = new Shot(weapon);

            weapon.Components.Add(shot);

            return(weapon);
        }
Example #16
0
 public Model3DGamer(Model3DGroup models, IModelObject modelObject) : base(models, modelObject)
 {
     lastCurrentWeapon = TypesWeapon.Not;
     modelHands        = new Model3D(models, new Hand(modelObject as Gamer));
 }
Example #17
0
 public Weapon(IModelForComponents model, TypesGameObject typeGameObject, TypesBehaveObjects typeBehaveObject, TypesWeapon typeWeapon)
     : base(model, typeGameObject, typeBehaveObject)
 {
     TypeWeapon = typeWeapon;
 }
Example #18
0
 public WeaponCharacter(TypesWeapon typesWeapon)
 {
     this.TypesWeapon  = typesWeapon;
     this.CountBullets = 0;
 }
Example #19
0
 private static void CreateStandartComponentForWeapon(Weapon weapon, PhysicsSetups physicsSetupsWeapon,
                                                      WeaponSetups weaponSetups, SizeF sizeWeapon, TypesWeapon typeWeapon, PointF location)
 {
     CreateBodyWeapon(weapon, location, physicsSetupsWeapon, sizeWeapon);
     CreateMagazin(weapon, weaponSetups, typeWeapon);
 }
Example #20
0
 public AddWeapon(ulong iD, TypesWeapon typeWeapon, List <IMessage> insertCollections)
 {
     ID                = iD;
     TypeWeapon        = typeWeapon;
     InsertCollections = insertCollections;
 }
Example #21
0
 public CurrentWeaponState(TypesWeapon typeWeapon)
 {
     TypeWeapon = typeWeapon;
 }
Example #22
0
 public Weapon(ulong ID, TypesWeapon typesWeapon) : base(ID)
 {
     TypesWeapon = typesWeapon;
 }