Ejemplo n.º 1
0
        private IEnumerator Punching()
        {
            canSwitch = false;
            var punchStart = PunchFired.Create(GlobalTargets.OnlyServer, ReliabilityModes.ReliableOrdered);

            punchStart.WeaponId   = weapon.Id;
            punchStart.Player     = weapon.Player;
            punchStart.IsPunching = true;
            punchStart.Send();

            yield return(new WaitForSeconds(.4f));

            var punchFinish = PunchFired.Create(GlobalTargets.OnlyServer, ReliabilityModes.ReliableOrdered);

            punchFinish.WeaponId   = weapon.Id;
            punchFinish.Player     = weapon.Player;
            punchFinish.IsPunching = false;
            punchFinish.Send();

            _nextTimeToFire = Time.time + 1f / weapon.FireRate;
            canSwitch       = true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets called whenever a punch has been punched
        /// </summary>
        /// <param name="punchFired"></param>
        public override void OnEvent(PunchFired punchFired)
        {
            var playerState = punchFired.Player.GetState <IPlayer>();

            playerState.Weapons[punchFired.WeaponId].IsPunching = punchFired.IsPunching;
        }