本文整理汇总了C#中Weapon.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# Weapon.Initialize方法的具体用法?C# Weapon.Initialize怎么用?C# Weapon.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Weapon
的用法示例。
在下文中一共展示了Weapon.Initialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
private void Awake()
{
foreach (var shootPoint in ShootPoints)
{
shootPoint.Initialize(WeaponPrefab.MuzzlePrefab);
}
_velocityReference = new VelocityReference(Vector3.zero);
if (Targetable == null)
{
Targetable = GetComponent<Targetable>();
}
_weaponInstance = Utility.InstantiateInParent(WeaponPrefab.gameObject, transform).GetComponent<Weapon>();
_weaponInstance.Initialize(gameObject, ShootPoints, _velocityReference, Targetable.Team);
_recoilCooldowns = new List<float>();
_barrelOffsets = new List<Vector3>();
for (var i = 0; i < ShootPoints.Count; i++)
{
_recoilCooldowns.Add(RecoilTime);
_barrelOffsets.Add(RecoilBarrels[i].localPosition);
}
_weaponInstance.OnShoot += (shootPointIndex) =>
{
_recoilCooldowns[shootPointIndex] = RecoilTime;
};
}
示例2: SetSecondaryWeapon
public void SetSecondaryWeapon(GameObject secondaryWeapon)
{
if (_secondaryWeaponInstance != null)
{
_secondaryWeaponInstance.IsTriggered = false;
_secondaryWeaponInstance.ClearTargetLock();
_secondaryWeaponInstance.OnShoot -= OnShoot;
Destroy(_secondaryWeaponInstance.gameObject);
}
if (secondaryWeapon != null)
{
_secondaryWeaponInstance = Utility.InstantiateInParent(secondaryWeapon.gameObject, transform).GetComponent<Weapon>();
_secondaryWeaponInstance.Initialize(gameObject, SecondaryShootPoints, _velocityReference, _targetable.Team);
_secondaryWeaponInstance.OnShoot += OnShoot;
}
}