本文整理汇总了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;
}
示例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;
}