Defines the Bullet entity type.
Inheritance: DynamicType
Example #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" );

            AddTimer();
        }
Example #2
0
        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).LengthFast() /
                                            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);
            }
        }
        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;
        }
Example #4
0
        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;
            }
        }