当前位置: 首页>>代码示例>>C#>>正文


C# Weapon.PostCreate方法代码示例

本文整理汇总了C#中Weapon.PostCreate方法的典型用法代码示例。如果您正苦于以下问题:C# Weapon.PostCreate方法的具体用法?C# Weapon.PostCreate怎么用?C# Weapon.PostCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Weapon的用法示例。


在下文中一共展示了Weapon.PostCreate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetActiveWeapon

        public bool SetActiveWeapon( int index )
        {
            if( index < -1 || index >= weapons.Count )
                return false;

            if( index != -1 )
                if( !weapons[ index ].exists )
                    return false;

            if( activeWeapon != null )
            {
                if( index != -1 && Type.Weapons[ index ].WeaponType == activeWeapon.Type )
                    return true;

                activeWeapon.PreFire -= activeWeapon_PreFire;

                if( activeWeaponAttachedObject != null )
                {
                    Detach( activeWeaponAttachedObject );
                    activeWeaponAttachedObject = null;
                }

                Gun activeGun = activeWeapon as Gun;
                if( activeGun != null )
                {
                    int activeIndex = GetWeaponIndex( activeWeapon.Type );
                    weapons[ activeIndex ].normalMagazineCount =
                        activeGun.NormalMode.BulletMagazineCount;
                    weapons[ activeIndex ].alternativeMagazineCount =
                        activeGun.AlternativeMode.BulletMagazineCount;
                }

                activeWeapon.SetShouldDelete();
                activeWeapon = null;

                if( EntitySystemWorld.Instance.IsServer() )
                    Server_SendSetActiveWeaponToClients( EntitySystemWorld.Instance.RemoteEntityWorlds );
            }

            if( index != -1 )
            {
                activeWeapon = (Weapon)Entities.Instance.Create(
                    Type.Weapons[ index ].WeaponType, Parent );
                activeWeapon.Server_EnableSynchronizationPositionsToClients = false;

                Gun activeGun = activeWeapon as Gun;

                if( activeGun != null )
                {
                    activeGun.NormalMode.BulletCount = weapons[ index ].NormalBulletCount;
                    activeGun.NormalMode.BulletMagazineCount = weapons[ index ].NormalMagazineCount;

                    activeGun.AlternativeMode.BulletCount = weapons[ index ].AlternativeBulletCount;
                    activeGun.AlternativeMode.BulletMagazineCount =
                        weapons[ index ].AlternativeMagazineCount;
                }

                activeWeapon.PostCreate();

                CreateActiveWeaponAttachedObject();

                activeWeapon.PreFire += activeWeapon_PreFire;

                if( EntitySystemWorld.Instance.IsServer() )
                    Server_SendSetActiveWeaponToClients( EntitySystemWorld.Instance.RemoteEntityWorlds );
            }

            return true;
        }
开发者ID:DarrenHassan,项目名称:GDM4242-GroupD,代码行数:69,代码来源:PlayerCharacter.cs

示例2: SetActiveWeapon

        public bool SetActiveWeapon(int index)
        {
            if (index < -1 || index >= weapons.Count)
                return false;

            if (index != -1)
                if (!weapons[index].exists)
                    return false;

            if (activeWeapon != null)
            {
                activeWeapon.PreFire -= activeWeapon_PreFire;

                if (index != -1 && Type.Weapons[index].WeaponType == activeWeapon.Type)
                    return true;

                foreach (MapObjectAttachedObject attachedObject in AttachedObjects)
                {
                    MapObjectAttachedMapObject attachedMapObject = attachedObject as MapObjectAttachedMapObject;
                    if (attachedMapObject == null)
                        continue;

                    Weapon weapon = attachedMapObject.MapObject as Weapon;
                    if (weapon == activeWeapon)
                    {
                        Gun activeGun = activeWeapon as Gun;
                        if (activeGun != null)
                        {
                            int activeIndex = GetWeaponIndex(activeWeapon.Type);
                            weapons[activeIndex].normalMagazineCount =
                                activeGun.NormalMode.BulletMagazineCount;
                            weapons[activeIndex].alternativeMagazineCount =
                                activeGun.AlternativeMode.BulletMagazineCount;
                        }

                        Detach(attachedMapObject);
                        weapon.SetShouldDelete();
                        activeWeapon = null;
                        activeWeaponAttachedObject = null;
                        break;
                    }
                }
            }

            if (index != -1)
            {
                activeWeapon = (Weapon)Entities.Instance.Create(
                    Type.Weapons[index].WeaponType, Parent);

                Gun activeGun = activeWeapon as Gun;

                if (activeGun != null)
                {
                    activeGun.NormalMode.BulletCount = weapons[index].NormalBulletCount;
                    activeGun.NormalMode.BulletMagazineCount = weapons[index].NormalMagazineCount;

                    activeGun.AlternativeMode.BulletCount = weapons[index].AlternativeBulletCount;
                    activeGun.AlternativeMode.BulletMagazineCount =
                        weapons[index].AlternativeMagazineCount;
                }

                activeWeapon.PostCreate();

                CreateActiveWeaponAttachedObject();

                activeWeapon.PreFire += activeWeapon_PreFire;
            }

            return true;
        }
开发者ID:huytd,项目名称:fosproject,代码行数:70,代码来源:PlayerCharacter.cs


注:本文中的Weapon.PostCreate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。