// Update is called once per frame void FixedUpdate() { if (transform.position.y < deathHeight) { DeathHandler.HandleDeath(gameObject); } }
void Start() { GetPlayerParts(); _deathHandler = GetComponent <DeathHandler>(); _deathHandler.PlayerDead += OnPlayerDied; _gameManager.GameEnded += OnGameEnded; }
private void ReportDeath(DeathHandler.Combatant victim) { print(attacker + " killed " + victim); DeathHandler dh = FindObjectOfType <DeathHandler>(); dh.RegisterDeath(attacker, victim); }
public void Awake() { listener = GetComponent<CharacterEventListener>(); deathHandler = GetComponent<DeathHandler>(); target = GetComponent<Target>(); stats = new Dictionary<StatType, Stat>(); awaitingRegen = new Queue<StatType>(); }
/// <summary> /// Handle how a piece dies. /// </summary> private void PieceDied() { //_Died = true; // TEmpory *************** gameObject.SetActive(false); gameObject.transform.position = new Vector3(1000, 1000, 1000); // move piece away from board; DeathHandler.Invoke(this); }
public virtual void OnDeath() { DeathHandler handler = Death; if (handler != null) { handler(); } }
//Constructor - Always read in the level! You can read in other stuff too if need be. public HealthSystem(Level level) { //Here is where you add the Required components requiredComponents.Add(GlobalVars.HEALTH_COMPONENT_NAME); //Health component this.level = level; //Always have this deathHandler = new DeathHandler(level); }
public void PlayerTakeDamage(int damageIn) { playerDamage -= damageIn; healthText.text = playerDamage.ToString() + maxHP; if (playerDamage <= 0) { DeathHandler deathHandler = GetComponent <DeathHandler>(); deathHandler.HandleDeath(); } }
void Awake() { _deathHandler = _playerRb.GetComponent <DeathHandler>(); _deathHandler.PlayerDead += OnPlayerDied; _gameManager.GameStarted += OnGameStarted; _gameManager.GameEnded += OnGameEnded; _upgradeController.UpgradeSucceeded += OnUpgradeSucceeded; _upgradeController.UpgradeFailed += OnUpgradeFailed; _upgradeController.MaxUpgraded += OnMaxUpgraded; }
public override void StartServerSide(ICoreServerAPI api) { ServerAPI = api; ServerChannel = api.Network.RegisterChannel(MOD_ID) .RegisterMessageType(typeof(PickUpMessage)) .RegisterMessageType(typeof(PlaceDownMessage)); DeathHandler = new DeathHandler(api); CarryHandler.InitServer(); }
private void Awake() { sr = GetComponent <SpriteRenderer>(); boxCollider = GetComponent <BoxCollider2D>(); myTransform = transform; animator = GetComponent <Animator>(); rb = GetComponent <Rigidbody2D>(); deathHandler = GetComponent <DeathHandler>(); maxDistanceJoint.enabled = false; defaultPosition = transform.position; }
static public void ReceiveRevive(string serializedEventModel) { try { TriggerEventForPlayersModel eventModel = Helpers.MsgPack.Deserialize <TriggerEventForPlayersModel>(serializedEventModel); DeathHandler.RevivePlayer(); DamageBitFlags.ClearAllDamageFlags(Game.PlayerPed); Function.Call(Hash.DECOR_SET_BOOL, Game.PlayerPed.Handle, "Ped.IsIncapacitated", false); } catch (Exception ex) { Log.Error($"ReceiveRevive ERROR: {ex.Message}"); } }
void Start() { target = FindObjectOfType <PlayerHealth>().transform; deathHandler = FindObjectOfType <DeathHandler>(); fpsController = FindObjectOfType <FirstPersonController>().GetComponent <FirstPersonController>(); enemyHealth = GetComponent <EnemyHealth>(); navMeshAgent = GetComponent <NavMeshAgent>(); navMeshObstacle = GetComponent <NavMeshObstacle>(); enemyAnimator = GetComponent <Animator>(); // Disable navmesh on start to prevent interference with idle animation navMeshAgent.enabled = false; }
public async Task RevivePlayer(IPlayer player, IPlayer targetPlayer) { try { if (player == null || !player.Exists || targetPlayer == null || !targetPlayer.Exists) { return; } int targetId = (int)targetPlayer.GetCharacterMetaId(); int charId = (int)player.GetCharacterMetaId(); if (charId <= 0 || targetId <= 0 || !Characters.IsCharacterUnconscious(targetId)) { return; } if (!CharactersInventory.ExistCharacterItem(charId, "Defibrilator", "inventory") && !CharactersInventory.ExistCharacterItem(charId, "Defibrilator", "backpack")) { HUDHandler.SendNotification(player, 3, 3500, "Du hast keinen Defibrilator dabei."); return; } InventoryHandler.InventoryAnimation(player, "revive", 15000); int rnd = new Random().Next(1, 100); await Task.Delay(15000); if (rnd >= 1 && rnd <= 50) { //Reanimation erfolgreich if (!player.IsInVehicle) { InventoryHandler.StopAnimation(player, "missheistfbi3b_ig8_2", "cpr_loop_paramedic"); } if (targetId <= 0 || !Characters.IsCharacterUnconscious(targetId)) { return; } Characters.SetCharacterUnconscious(targetId, false, 0); DeathHandler.revive(targetPlayer); Characters.SetCharacterHealth(targetId, 115); targetPlayer.Health = 115; } else if (rnd >= 51 && rnd <= 100) { //Reanimation nicht erfolgreich if (!player.IsInVehicle) { InventoryHandler.StopAnimation(player, "missheistfbi3b_ig8_2", "cpr_loop_paramedic"); } HUDHandler.SendNotification(player, 3, 3500, "Die Renimation war nicht erfolgreich, versuch es weiter!"); } } catch (Exception e) { Alt.Log($"{e}"); } }
// Start is called before the first frame update void Awake() { if (instance == null || instance.Equals(null)) { instance = this; health = maxHealth; } else { Destroy(this); } }
public ParasiteData(CharacterSpawner owner, DeathHandler deathHandler = null) { this.owner = owner; if (deathHandler == null) { deathHandler = DefaultDeathHandler; } this.deathHandler = deathHandler; hasHandledDeath = false; isVamparasite = false; ParasiteHealth = STARTING_HEALTH; }
public void DoDamage(int damage) { health.currentHealth = (int)Mathf.Clamp(health.currentHealth - damage, 0f, health.maxHealth); TWDebug.Log("Current Health", health.currentHealth); if (health.currentHealth == 0) { DeathHandler deathHandler = GetComponent <DeathHandler>(); if (deathHandler != null) { deathHandler.Die(); } } }
void Death() { if (onDeath != null) { onDeath(this); onDeath = null; } else { Debug.Log("No subscribers onDeath"); } Recycle(this); }
void Start() { _deathHandler = _player.GetComponent <DeathHandler>(); _lineRenderer = _player.GetComponent <LineRenderer>(); _trailRenderer = _player.GetComponent <TrailRenderer>(); _playerRb = _player.GetComponent <Rigidbody>(); _deathHandler.PlayerDead += OnPlayerDied; _gameManager.GameStarted += OnGameStarted; _gameManager.GameEnded += OnGameEnded; CountRaycastDirection(); _hookPosition = _raycastDirection; GetStartPositions(); _lineRenderer.enabled = true; ReleaseHook(); }
public override void StartServerSide(ICoreServerAPI api) { api.Register <EntityBehaviorDropCarriedOnDamage>(); ServerAPI = api; ServerChannel = api.Network.RegisterChannel(MOD_ID) .RegisterMessageType(typeof(PickUpMessage)) .RegisterMessageType(typeof(PlaceDownMessage)) .RegisterMessageType(typeof(SwapSlotsMessage)); DeathHandler = new DeathHandler(api); BackwardCompatHandler = new BackwardCompatHandler(api); CarryHandler.InitServer(); }
void Start() { currentsceneName = SceneManager.GetActiveScene().name; rigidBody = GetComponent <Rigidbody>(); audioSource = GetComponent <AudioSource>(); gameSession = FindObjectOfType <GameSession>(); sceneLoader = FindObjectOfType <SceneLoader>(); deathHandler = FindObjectOfType <DeathHandler>(); timer = FindObjectOfType <Timer>(); levelButtonManager = FindObjectOfType <LevelButtonManager>(); FindObjectOfType <GameSession>().AddToNumberOfGamesPlayed(GameNumber); }
public override bool Execute(string[] args) { int radius = -1; List <Identifiable.Id> toKill = new List <Identifiable.Id>(); foreach (var v in args ?? new string[0]) { if (uint.TryParse(v, out uint rad)) { radius = (int)rad; continue; } else { try { toKill.Add((Identifiable.Id)Enum.Parse(typeof(Identifiable.Id), v, true)); } catch { } } } List <GameObject> toDestroy = new List <GameObject>(); foreach (var v in SceneContext.Instance.GameModel.AllActors().Where(x => radius == -1 || Vector3.Distance(x.Value?.transform?.position ?? SceneContext.Instance.PlayerState.model.position, SceneContext.Instance.PlayerState.model.position) < radius)) { if (toKill.Count == 0 || toKill.Contains(v.Value.ident)) { toDestroy.Add(v.Value?.transform?.gameObject); } } int deletedCount = 0; foreach (var v in toDestroy) { if (v) { deletedCount++; DeathHandler.Kill(v, DeathHandler.Source.UNDEFINED, SceneContext.Instance.Player, "KillAllCommand.Execute"); } } Console.LogSuccess($"Destroyed {deletedCount} actors!"); return(true); }
public LevelController( MonoBehaviour coroutineRunner, LevelControls levelControls, EventBus gameEventBus, StartHandler startHandler, PauseHandler pauseHandler, DeathHandler deathHandler, ResetHandler resetHandler, FinishHandler finishHandler) { _coroutineRunner = coroutineRunner; _levelControls = levelControls; _gameEventBus = gameEventBus; _startHandler = startHandler; _pauseHandler = pauseHandler; _deathHandler = deathHandler; _resetHandler = resetHandler; _finishHandler = finishHandler; }
void Start() { scaleAmount = transform.localScale.x; int score = lifeCost * PlayerStats.Current.Level / 10; deathHandler = new DeathHandler(); deathHandler.AddAction(delegate { PlayerStats.Current.Score += score; }); deathHandler.AddAction(delegate { PlayerStats.Current.IncreaseLevel(lifeCost / 10); }); deathHandler.AddAction(delegate { if (scaleAmount == 10.0f) { PlayerStats.Current.Money += 1; } }); deathHandler.AddAction(delegate { Canvas canvasChild = GetComponentInChildren <Canvas>(true); if (canvasChild) { canvasChild.gameObject.SetActive(true); Text lifeCostChild = canvasChild.GetComponentInChildren <Text>(); if (lifeCostChild) { lifeCostChild.text = score.ToString(); } } }); deathHandler.AddAction(delegate { if (meteorSoundExplodeInAir && SettingsScript.EffectVolume > 0.01f) { meteorSoundExplodeInAir.volume = SettingsScript.EffectVolume * transform.localScale.x / 100; meteorSoundExplodeInAir.Play(); } }); deathHandler.AddAction(delegate { if (transform.localScale.x == 10 && coinSound && SettingsScript.EffectVolume > 0.01f) { coinSound.Play(); } }); animController = gameObject.GetComponent <Animator>(); movement = gameObject.GetComponent <MovementScript>(); }
public override bool Execute(string[] args) { if (Physics.Raycast(new Ray(Camera.main.transform.position, Camera.main.transform.forward), out var hit)) { var gameobject = hit.collider.gameObject; if (gameobject.GetComponent <Identifiable>()) { DeathHandler.Kill(gameobject, DeathHandler.Source.UNDEFINED, SceneContext.Instance.Player, "RemoveCommand.Execute"); } else if (gameobject.GetComponent <Gadget>()) { gameobject.GetComponent <Gadget>().DestroyGadget(); } else if (gameobject.GetComponentInParent <LandPlot>()) { gameobject.GetComponentInParent <LandPlotLocation>().Replace(gameobject.GetComponentInParent <LandPlot>(), GameContext.Instance.LookupDirector.GetPlotPrefab(LandPlot.Id.EMPTY)); } } failure: Console.LogError("Not looking at a valid object!"); return(false); }
private void KillThisUnit(PlayerIdentifier killer) { // This lock was put in as a result of bugs, // it's not just experimental! lock (DeathLock) { if (!IsDead) // If we're the first responder { Debug.Log("Player is dead!"); IsDead = true; DeathHandler handler = EventDeath; if (oem.shouldTriggerEvent(handler)) { handler( killer, transform.position, transform.eulerAngles ); } } } }
private void Start() { myDeathHandler = GetComponent <DeathHandler>(); myDamageDisplay = FindObjectOfType <DisplayDamage>(); }
public void SubscribeDeath(DeathHandler callback) { DeathNotify += callback; }
private static void ReplaceDeathHook() { StoreAndReplaceHook("Death", new ActionRunCoroutine(ret => DeathHandler.Execute())); }
public void Start() { deathHandler = FindObjectOfType <DeathHandler>(); }
private void Awake() { deathHandler = GetComponent <DeathHandler>(); hitReactionObject = GetComponentInChildren <HitReaction>(); }
private void Awake() { deathHandler = GetComponent <DeathHandler>(); }