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


C# Weapon.Initialize方法代码示例

本文整理汇总了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;
        };
    }
开发者ID:talford2,项目名称:SpaceX,代码行数:28,代码来源:Turret.cs

示例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;
     }
 }
开发者ID:talford2,项目名称:SpaceX,代码行数:16,代码来源:Vehicle.cs


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