Esempio n. 1
0
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnPostCreate(Boolean)"/>.</summary>
        protected override void OnPostCreate( bool loaded )
        {
            base.OnPostCreate( loaded );

            fireworkBulletType = (BulletType)EntityTypes.Instance.GetByName( "FireworkBullet" );

            SubscribeToTickEvent();
        }
Esempio n. 2
0
        private void TickTask()
        {
            ControlKeyRelease(GameControlKeys.Fire1);
            ControlKeyRelease(GameControlKeys.Fire2);

            if (targetTask != null)
            {
                Vec3 targetPos = targetTask.Position;

                Turret turret = ControlledObject as Turret;
                if (turret != null)
                {
                    //to consider speed of the target
                    if (turret.MainGun != null)
                    {
                        BulletType bulletType = turret.MainGun.Type.NormalMode.BulletType;
                        if (bulletType.Velocity != 0)
                        {
                            float flyTime = (targetPos - ControlledObject.Position).Length() /
                                            bulletType.Velocity;

                            if (targetTask.PhysicsModel != null && targetTask.PhysicsModel.Bodies.Length != 0)
                            {
                                Body targetBody = targetTask.PhysicsModel.Bodies[0];
                                targetPos += targetBody.LinearVelocity * flyTime;
                            }
                        }
                    }

                    turret.SetMomentaryTurnToPosition(targetPos);
                }

                ControlKeyPress(GameControlKeys.Fire1, 1);
                ControlKeyPress(GameControlKeys.Fire2, 1);
            }
        }
Esempio n. 3
0
File: Gun.cs Progetto: whztt07/SDK
        public void AddBullets( BulletType bulletType, int count )
        {
            if( Type.NormalMode.BulletType == bulletType )
            {
                bool reload = normalMode.BulletCount == 0;

                normalMode.BulletCount += count;
                if( normalMode.BulletCount > Type.NormalMode.BulletCapacity )
                    normalMode.BulletCount = Type.NormalMode.BulletCapacity;

                if( reload )
                    TryReload();
            }
            if( Type.AlternativeMode.BulletType == bulletType )
            {
                alternativeMode.BulletCount += count;
                if( alternativeMode.BulletCount > Type.AlternativeMode.BulletCapacity )
                    alternativeMode.BulletCount = Type.AlternativeMode.BulletCapacity;
            }
        }
        public bool TakeBullets(BulletType bulletType, int count)
        {
            bool taked = false;

            for (int n = 0; n < weapons.Count; n++)
            {
                GunType gunType = Type.Weapons[n].WeaponType as GunType;
                if (gunType == null)
                    continue;

                if (gunType.NormalMode.BulletType == bulletType)
                {
                    if (weapons[n].normalBulletCount < gunType.NormalMode.BulletCapacity)
                    {
                        taked = true;
                        weapons[n].normalBulletCount += count;
                        if (weapons[n].normalBulletCount > gunType.NormalMode.BulletCapacity)
                            weapons[n].normalBulletCount = gunType.NormalMode.BulletCapacity;
                    }
                }
                if (gunType.AlternativeMode.BulletType == bulletType)
                {
                    if (weapons[n].alternativeBulletCount < gunType.AlternativeMode.BulletCapacity)
                    {
                        taked = true;
                        weapons[n].alternativeBulletCount += count;
                        if (weapons[n].alternativeBulletCount > gunType.AlternativeMode.BulletCapacity)
                            weapons[n].alternativeBulletCount = gunType.AlternativeMode.BulletCapacity;
                    }
                }
            }

            if (ActiveWeapon != null)
            {
                Gun activeGun = activeWeapon as Gun;
                if (activeGun != null)
                    activeGun.AddBullets(bulletType, count);
            }

            return taked;
        }