Beispiel #1
0
        public override void Shoot(VehicleShootBehaviour shootBehaviour)
        {
            var randomOffset = new Vector3(Random.Range(-Spread, Spread), Random.Range(0, Spread), 0);
            var point        = GunBarrel.TransformPoint(randomOffset);

            shootBehaviour.CmdFireRound(point, GunBarrel.rotation, ShotStrength);
        }
Beispiel #2
0
        public override void Shoot()
        {
            for (int i = 0; i < PelletCount; i++)
            {
                var point = new Vector2(Random.Range(-Spread, Spread), Random.Range(-Spread, Spread));

                CmdFireRound(GunBarrel.TransformPoint(point), GunBarrel.rotation, ShotStrength);
                //weaponAnimator.SetTrigger("Fire");
            }
        }
Beispiel #3
0
    public override void Rebuild(WeaponCallBack callBack)
    {
        Receiver = GetComponent<GunReceiver>();
        Barrel = GetComponent<GunBarrel>();
        Stock = GetComponent<GunStock>();

        _isCooledDown = true;

        OnSuccessfulShot = callBack;
    }
Beispiel #4
0
        public override void Shoot(VehicleShootBehaviour shootBehaviour)
        {
            for (int i = 0; i < PelletCount; i++)
            {
                var point             = new Vector2(Random.Range(-Spread, Spread), Random.Range(-Spread, Spread));
                var transformed_point = GunBarrel.TransformPoint(point);

                shootBehaviour.CmdFireRound(transformed_point, GunBarrel.rotation, ShotStrength);
                //weaponAnimator.SetTrigger("Fire");
            }
        }
Beispiel #5
0
    // Use this for initialization
    protected override void Start()
    {
        base.Start();
        base.damage = _damage;
        base.ammoCostPerShot = _ammoCostPerShot;
        base.fireRate = _fireRate;
        base.shootOrigin = _shootOrigin;
        base.chargeTime = 0;
        GunBarrel barrel1 = new GunBarrel();
        barrel1.barrelEnd = shootOrigin[0];
        barrel1.cooldownRemaining = 0;
        GunBarrel barrel2 = new GunBarrel();
        barrel2.barrelEnd = shootOrigin[1];
        barrel2.cooldownRemaining = fireRate/2;
        barrels = new GunBarrel[] {barrel1, barrel2};

        bulletSound = GetComponent<AudioSource>();
    }
Beispiel #6
0
    // Use this for initialization
    protected override void Start()
    {
        base.Start();
        base.damage          = _damage;
        base.ammoCostPerShot = _ammoCostPerShot;
        base.fireRate        = _fireRate;
        base.shootOrigin     = _shootOrigin;
        base.chargeTime      = 0;
        GunBarrel barrel1 = new GunBarrel();

        barrel1.barrelEnd         = shootOrigin[0];
        barrel1.cooldownRemaining = 0;
        GunBarrel barrel2 = new GunBarrel();

        barrel2.barrelEnd         = shootOrigin[1];
        barrel2.cooldownRemaining = fireRate / 2;
        barrels = new GunBarrel[] { barrel1, barrel2 };

        bulletSound = GetComponent <AudioSource>();
    }
Beispiel #7
0
    private void Start()
    {
        entity = GetComponent <PlayerEntity>();

        this.barrel       = entity.barrel;
        this.gunMesh      = entity.gun;
        this.bulletPrefab = entity.bulletPrefab;
        this.bulletSpawn  = entity.bulletSpawn;
        this.reloadCD     = entity.reloadCD;
        this.shootDelay   = entity.shootDelay;
        this.ammoPrefab   = entity.ammoPrefab;
        this.ammoSlots    = entity.ammoSlots;
        this.ammoTypes    = entity.ammoTypes;

        body      = GetComponent <Rigidbody>();
        gunBarrel = barrel.GetComponent <GunBarrel>();
        gun       = gunMesh.GetComponent <Gun>();

        LoadGun();
    }
Beispiel #8
0
 // Use this for initialization
 void Start()
 {
     gunScript = GameObject.FindWithTag("Gun").GetComponent <GunBarrel>();
 }
Beispiel #9
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();
    }