Пример #1
0
        /// <summary>
        /// Gets called whenever a player is hit.
        /// </summary>
        /// <param name="playerHit"></param>
        public override void OnEvent(PlayerHit playerHit)
        {
            //Get the player-state via the bolt-entity from the playerHit-event.
            var playerState = playerHit.Target.GetState <IPlayer>();

            //Reduce the health.
            playerState.Health -= playerHit.Damage;

            //Check if the player died.
            if (!(playerState.Health <= 0))
            {
                return;
            }

            //Reset Chalk
            playerState.Weapons[0].IsEquipped            = true;
            playerState.Weapons[0].CurrentAmmoInMagazine = 0;
            playerState.Weapons[0].EntireAmmo            = 0;

            //Reset Stapler
            playerState.Weapons[1].IsEquipped            = false;
            playerState.Weapons[1].CurrentAmmoInMagazine = 0;
            playerState.Weapons[1].EntireAmmo            = 0;

            //Reset Slingshot
            playerState.Weapons[2].IsEquipped            = false;
            playerState.Weapons[2].CurrentAmmoInMagazine = 0;
            playerState.Weapons[2].EntireAmmo            = 0;

            //Reset Sponge
            playerState.Weapons[3].IsEquipped            = false;
            playerState.Weapons[3].CurrentAmmoInMagazine = 0;
            playerState.Weapons[3].EntireAmmo            = 0;

            //Reset Health
            playerState.Health = 100;

            var respawn = Respawn.Create(playerState.Entity, EntityTargets.Everyone);

            respawn.PlayerToRespawn    = playerState.Entity;
            respawn.KilledByPlayerName = playerHit.PlayerWhoShot;
            respawn.KilledByWeaponName = playerHit.WeaponName;
            respawn.Send();
        }