コード例 #1
0
    // WeaponEffects

    public void Play()
    {
        if (_light != null)
        {
            SetLightAlpha(1);

            _light.enabled = true;
        }

        if (_particleSystem != null)
        {
            _particleSystem.Play();
        }

        if (_soundPrefab != null)
        {
            if (_sounds.Count > 0)
            {
                _sounds[0].gameObject.SetActive(true);
                _sounds.RemoveAt(0);
            }
            else
            {
                WeaponSound sound = Instantiate(_soundPrefab.gameObject).GetComponent <WeaponSound>();
                sound.OnSoundFinished += OnSoundFinished;
            }
        }
    }
コード例 #2
0
        private void Punch()
        {
            var weaponSound = WeaponSound.Create(GlobalTargets.Everyone, ReliabilityModes.Unreliable);

            weaponSound.Position = transform.position;
            weaponSound.Label    = weapon.Label;
            weaponSound.Player   = player.entity;
            weaponSound.Send();

            /*if (!Physics.SphereCast(player.playerCamera.transform.position, weapon.Radius,
             *  player.playerCamera.transform.forward, out var hit,
             *  weapon.MaxDistance)) return;*/

            var hits = Physics.SphereCastAll(player.playerCamera.transform.position, weapon.Radius,
                                             player.playerCamera.transform.forward, weapon.MaxDistance);

            foreach (var hit in hits)
            {
                var boltEntity = hit.transform.GetComponent <BoltEntity>();

                if (boltEntity == null || boltEntity.GetState <IPlayer>() == null || boltEntity.GetState <IPlayer>().Entity == player.entity)
                {
                    return;
                }

                var playerHit = PlayerHit.Create(GlobalTargets.OnlyServer);
                playerHit.Target        = boltEntity;
                playerHit.PlayerWhoShot = player.state.Username;
                playerHit.WeaponName    = weapon.Label;
                playerHit.Damage        = weapon.Damage;
                playerHit.Send();
            }
        }
コード例 #3
0
        public override void PlaySound(int ID)
        {
            if (ID > Sounds.Length - 1)
            {
                return;
            }

            if (Sounds[ID] != null && WeaponSound != null)
            {
                if (WeaponSound.isPlaying)
                {
                    WeaponSound.Stop();
                }

                if (ID == 2)                                    //THIS IS THE SOUND FOR BEND THE BOW
                {
                    WeaponSound.pitch = 1.03f / HoldTime;
                    StartCoroutine(BowHoldTimePlay(ID));
                }
                else
                {
                    WeaponSound.pitch = 1;
                    WeaponSound.PlayOneShot(Sounds[ID]);   //Play Draw/ Weapon Clip
                }
            }
        }
コード例 #4
0
 // Start is called before the first frame update
 void Start()
 {
     randomPunch = new System.Random();
     shootWeapon = GetComponent <ShootableWeapon>();
     shootWeapon.OnWeaponFired  += ShootableWeapon_OnWeaponFired;
     shootWeapon.OnWeaponReload += ReloadWeapon_OnWeaponReload;
     Instance = this;
 }
コード例 #5
0
        IEnumerator BowHoldTimePlay(int ID)
        {
            while (BowTension == 0)
            {
                yield return(null);
            }

            WeaponSound.PlayOneShot(Sounds[ID]);
        }
コード例 #6
0
 public Damage(float amount, DamageType type, WeaponSound weaponSound, DamageFlags flags, DamageInfoFlags infoFlags)
 {
     Amount      = amount;
     Type        = type;
     WeaponSound = weaponSound;
     Flags       = flags;
     InfoFlags   = infoFlags;
     Absorbed    = 0;
 }
コード例 #7
0
 public Damage(float amount, DamageType type, DamageFlags flags, DamageInfoFlags infoFlags)
 {
     Amount      = amount;
     Type        = type;
     Flags       = flags;
     InfoFlags   = infoFlags;
     WeaponSound = WeaponSound.None;
     Absorbed    = 0;
 }
コード例 #8
0
 public Damage(float amount, DamageType type)
 {
     Amount      = amount;
     Type        = type;
     WeaponSound = WeaponSound.None;
     Flags       = DamageFlags.None;
     InfoFlags   = DamageInfoFlags.None;
     Absorbed    = 0;
 }
コード例 #9
0
        private void Shoot(int spreadFactor)
        {
            var weaponFired = WeaponFired.Create(GlobalTargets.OnlyServer, ReliabilityModes.ReliableOrdered);

            weaponFired.WeaponId = weapon.Id;
            weaponFired.Entity   = weapon.Player;
            weaponFired.Send();

            var weaponSound = WeaponSound.Create(GlobalTargets.Everyone, ReliabilityModes.Unreliable);

            weaponSound.Position = transform.position;
            weaponSound.Label    = weapon.Label;
            weaponSound.Player   = player.entity;
            weaponSound.Send();

            var dir = Spread(spreadFactor);

            if (!Physics.Raycast(cameraTransform.transform.position, dir, out var hit, 100))
            {
                return;
            }

            if (hit.transform.CompareTag("Stalin"))
            {
                AudioSource soundSource = hit.transform.GetComponent <AudioSource>();
                if (!soundSource.isPlaying)
                {
                    soundSource.Play();
                }
            }

            var boltEntity = hit.transform.GetComponent <BoltEntity>();

            if (boltEntity != null && boltEntity.GetState <IPlayer>() != null)
            {
                var playerHit = PlayerHit.Create(GlobalTargets.OnlyServer);
                playerHit.Target        = boltEntity;
                playerHit.PlayerWhoShot = player.state.Username;
                playerHit.WeaponName    = weapon.Label;
                playerHit.Damage        = weapon.Damage;
                playerHit.Send();


                var applyHitIndicator = ApplyHitIndicator.Create(ReliabilityModes.Unreliable);
                applyHitIndicator.Message  = "Damage: " + weapon.Damage;
                applyHitIndicator.Position = hit.point;
                applyHitIndicator.Send();
            }
            else
            {
                var impactEffect = ImpactEffect.Create(ReliabilityModes.Unreliable);
                impactEffect.Position = hit.point;
                impactEffect.Send();
            }
        }
コード例 #10
0
    private void OnSoundFinished(WeaponSound sound)
    {
        sound.gameObject.SetActive(false);

        _sounds.Add(sound);
    }
コード例 #11
0
        public override void OnEvent(WeaponSound weaponSound)
        {
            var newWeaponSound = Instantiate(soundSpawner);

            newWeaponSound.Play(weaponSound.Label, weaponSound.Player);
        }
コード例 #12
0
ファイル: Weapon.cs プロジェクト: reqnux/reqnux_TillDeath
 protected virtual void Awake()
 {
     gunEnding = GameObject.Find("GunEnding").transform;
     weaponSound = transform.GetComponentInChildren<WeaponSound>();
     bulletsPerShot = 1;
     shotConeWidth = 30;
 }