示例#1
0
文件: Gun.cs 项目: tegates/Warzone
    public override void Rebuild(WeaponCallBack callBack)
    {
        Receiver = GetComponent<GunReceiver>();
        Barrel = GetComponent<GunBarrel>();
        Stock = GetComponent<GunStock>();

        _isCooledDown = true;

        OnSuccessfulShot = callBack;
    }
示例#2
0
    public override void Rebuild(WeaponCallBack callBack, Item weaponItem)
    {
        Receiver = GetComponent <GunReceiver>();
        Barrel   = GetComponent <GunBarrel>();
        Stock    = GetComponent <GunStock>();
        Magazine = GetComponent <GunMagazine>();

        this.WeaponItem = weaponItem;

        _isCooledDown = true;

        _onSuccessfulShot = callBack;

        _sparks       = MuzzleFlash.Find("Sparks").GetComponent <ParticleSystem>();
        _flame        = MuzzleFlash.GetComponent <ParticleSystem>();
        _bulletOrigin = MuzzleFlash.Find("BulletOrigin").gameObject;
        //_bulletTrail.ParentWeapon = this;
        _light       = MuzzleFlash.Find("Light").GetComponent <Light>();
        _foreGripPos = this.ForeGrip.localPosition;
        _isEquipped  = true;

        float _npcRecoilReduction = 1;

        if (Attacker.MyAI.ControlType == AIControlType.NPC)
        {
            _npcRecoilReduction = 0f;
            Barrel.Accuracy     = 1;
        }
        else
        {
            Barrel.Accuracy = (float)weaponItem.GetAttributeByName("Accuracy").Value;
        }


        Barrel.Impact         = (float)weaponItem.GetAttributeByName("Impact").Value;
        Barrel.MuzzleVelocity = (float)weaponItem.GetAttributeByName("_Muzzle Velocity").Value;
        Barrel.Range          = (float)weaponItem.GetAttributeByName("Range").Value;
        Barrel.Handling       = (float)weaponItem.GetAttributeByName("Handling").Value;

        Magazine.MaxCapacity = (int)weaponItem.GetAttributeByName("Magazine Size").Value;
        Receiver.Recoil      = (float)weaponItem.GetAttributeByName("Recoil").Value *_npcRecoilReduction;

        GunshotSoundName = weaponItem.GetAttributeByName("_GunshotSound").Value.ToString();

        _reloadToUnjam = (bool)weaponItem.GetAttributeByName("_ReloadToUnjam").Value;

        switch (Receiver.FireModes[0])
        {
        case GunFireModes.Semi:
            Receiver.SemiFireRate = (float)weaponItem.GetAttributeByName("Rate of Fire").Value;
            break;

        case GunFireModes.Full:
            Receiver.AutoFireRate = (float)weaponItem.GetAttributeByName("Rate of Fire").Value;
            break;

        case GunFireModes.Burst:
            Receiver.BurstFireRate = (float)weaponItem.GetAttributeByName("Rate of Fire").Value;
            break;

        case GunFireModes.Pump:
            Receiver.ManualFireRate = (float)weaponItem.GetAttributeByName("Rate of Fire").Value;
            break;
        }

        _pumpStarted = false;


        Refresh();
    }