GameEntities.Weapon.GetFireRotation C# (CSharp) Method

GetFireRotation() protected method

protected GetFireRotation ( WeaponType typeMode ) : Quat
typeMode WeaponType
return Quat
        protected Quat GetFireRotation( WeaponType.WeaponMode typeMode )
        {
            return ( setForceFireRotation ? forceFireRotation : Rotation ) * typeMode.StartOffsetRotation;
        }

Same methods

Weapon::GetFireRotation ( bool alternative ) : Quat

Usage Example

コード例 #1
0
ファイル: PlayerCharacter.cs プロジェクト: gsaone/forklift
        void WeaponTryFire(bool alternative)
        {
            if (activeWeapon == null)
            {
                return;
            }

            //set real weapon fire direction
            {
                Vec3 seeDir = (TurnToPosition - Position).GetNormalize();
                Vec3 lookTo = TurnToPosition;

                for (int iter = 0; iter < 100; iter++)
                {
                    activeWeapon.SetForceFireRotationLookTo(lookTo);
                    Vec3   fireDir = activeWeapon.GetFireRotation(alternative).GetForward();
                    Degree angle   = MathUtils.GetVectorsAngle(seeDir, fireDir);
                    if (angle < 80)
                    {
                        break;
                    }
                    const float step = .3f;
                    lookTo += seeDir * step;
                }

                activeWeapon.SetForceFireRotationLookTo(lookTo);
            }

            bool fired = activeWeapon.TryFire(alternative);

            Gun activeGun = activeWeapon as Gun;

            if (activeGun != null)
            {
                if (fired)
                {
                    int index = GetWeaponIndex(activeWeapon.Type);
                    weapons[index].normalBulletCount        = activeGun.NormalMode.BulletCount;
                    weapons[index].normalMagazineCount      = activeGun.NormalMode.BulletMagazineCount;
                    weapons[index].alternativeBulletCount   = activeGun.AlternativeMode.BulletCount;
                    weapons[index].alternativeMagazineCount =
                        activeGun.AlternativeMode.BulletMagazineCount;
                }
            }
        }