private void HandleHPChanged(HPInfo info) { if (info.current <= 0) { OnPlayerDead?.Invoke(); } }
private void Update() { if (_playerCount == 0) { Debug.Log("F"); OnPlayerDead?.Invoke(this, EventArgs.Empty); } }
public void Kill() { if (!killed) { killed = true; OnPlayerDead?.Invoke(); } }
public void Interaction() { OnHpChanged?.Invoke(this, new HpModelEventArgs(Damage)); if (_hpModel.Hp <= 0) { OnPlayerDead?.Invoke(this, EventArgs.Empty); } }
private void CheckAlive() { if (_health <= 0) { isPlayerAlive = false; GetComponent <Animator>().SetBool("isDead", true); onPlayerDead.Invoke(isPlayerAlive); } }
void Update() { _timeLeft -= Time.deltaTime; LifeTime = _timeLeft; if (_timeLeft < 0 && !_dead) { _dead = true; OnPlayerDead?.Invoke(); } }
private void OnEnable() { GameCanvas gameCanvas = FindObjectOfType <GameCanvas>(); if (gameCanvas != null) { _health.OnDead += gameCanvas.ShowGameOverPanel; DisplayHealth displayHealth = gameCanvas.GetComponentInChildren <DisplayHealth>(); _health.OnHealthChanged += displayHealth.WriteHealth; } _health.OnDead += () => OnPlayerDead.Invoke(deadClip); _health.OnHealthChanged += PlayOnHit; }
private void OnTriggerEnter(Collider other) { if (!isPlayer) { if (other.gameObject.CompareTag(tagToTrigger.ToString())) { ExplodeObjects(gameObject, other.gameObject); } } else { ExplodeObjects(gameObject, other.gameObject); OnPlayerDead?.Invoke(); } }
/// <summary> /// Handle game event CEventNetworkEntityDamage, /// Useful for indicating entity damage/died/destroyed. /// </summary> /// <param name="victim">victim</param> /// <param name="attacker">attacker</param> /// <param name="arg2">Unknown</param> /// <param name="isDamageFatal">Is damage fatal to entity. or victim died/destroyed.</param> /// <param name="weaponInfoHash">Probably related to common.rpf/data/ai => Item type = "CWeaponInfo"</param> /// <param name="arg5">Unknown</param> /// <param name="arg6">Unknown</param> /// <param name="arg7">Unknown, might be int</param> /// <param name="arg8">Unknown, might be int</param> /// <param name="isMeleeDamage">Is melee damage</param> /// <param name="damageTypeFlag">0 for peds, 116 for the body of a vehicle, 93 for a tire, 120 for a side window, 121 for a rear window, 122 for a windscreen, etc</param> private void HandleCEventNetworkEntityDamaged( Entity victim, Entity attacker, int arg2, bool isDamageFatal, uint weaponInfoHash, int arg5, int arg6, object arg7, object arg8, bool isMeleeDamage, int damageTypeFlag) { if (isDamageFatal && victim is Ped p1 && attacker is Ped p2) { if (p2 == Game.PlayerPed) { OnPlayerKillPed?.Invoke(p1, isMeleeDamage, weaponInfoHash, damageTypeFlag); } } if (isDamageFatal && victim == Game.PlayerPed) { OnPlayerDead?.Invoke(); } }
//玩家死亡事件 public void PlayerDead() { if (OnPlayerDead != null) { OnPlayerDead.Invoke(); } liftcount--; if (liftcount > 0) { StartCoroutine(WaitPlayerDead()); } else { Debug.Log("GAMEOVER"); } }
public void RemovePlayer(int networkId, bool kick = true) { if (_players.ContainsKey(networkId)) { var player = _players[networkId]; if (player.IsAlive) { Logger.Log($"GAME remove player '{player.Name}'"); for (int i = player.Units.Count - 1; i >= 0; i--) { player.Units[i].TakeDamage(null, float.MaxValue); } player.PlayerStatus.Place = _config.MaxPlayers; OnPlayerDead?.Invoke(player.UserId, player.PlayerStatus); } if (kick) { _players.Remove(networkId); } } }
public void OnPlayerDead_FireEvent() { OnPlayerDead?.Invoke(this, EventArgs.Empty); }
private static void Dead() { OnPlayerDead?.Invoke(); GameManager.Instance.GameOver(); }
protected override void Dead() { _Hp.ResetParams(); GlobalGameManager.Instance.CurrentState = GameStates.GameNormal; OnPlayerDead?.Invoke(); }
public static void PlayerDeadAction() { OnPlayerDead?.Invoke(); }
public void Update(float deltaTime) { DeltaTime = deltaTime; //Rebuild unit tree _unitsTree = new OcTree(_worldZone, _units, true); //Get alive players count if (_gameMode == GameMode.Royale) { _alivePlayers = _players.Values.Where((p) => p.IsAlive && !p.IsNeutrall).Count(); //Kill all units if we have winner if (_alivePlayers == 1) { foreach (var unit in _units) { unit.TakeDamage(null, float.MaxValue); } } } else { _alivePlayers = _players.Values.Where((p) => p.IsAlive && !p.IsAI).Count(); } //Update players foreach (var player in _players.Values) { player.Update(this); if (!player.IsAlive && player.PlayerStatus.Place == 0) { player.PlayerStatus.Place = _alivePlayers > 0 ? _alivePlayers : 1; if (!player.IsAI) { OnPlayerDead?.Invoke(player.UserId, player.PlayerStatus); } Logger.Log($"GAME player dead {player.PlayerStatus.Place}/{_config.MaxPlayers}"); } } //No more players - end game if (_alivePlayers == 0) { OnGameEnd?.Invoke(); } //Mode processing switch (_gameMode) { case GameMode.Royale: //Royale mode - process zone float elapsedTime = (float)(DateTime.Now - _startTime).TotalSeconds; switch (_worldState) { case WorldState.Static: if (elapsedTime > _config.StaticTime) { _startTime = DateTime.Now; _worldState = WorldState.Resize; _beginZoneRadius = ZoneRadius; Logger.Log($"GAME zone begin"); } _timeToEnd = _config.StaticTime - elapsedTime; break; case WorldState.Resize: float percent = (_config.ResizeTime - elapsedTime) / _config.ResizeTime; if (percent < 0f) { percent = 0; _targetZoneRadius = 0f; _startTime = DateTime.Now; _worldState = WorldState.Static; } else { ZoneRadius = Lerp(_beginZoneRadius, _targetZoneRadius, 1f - percent); _timeToEnd = _config.ResizeTime - elapsedTime; } break; } if (_timeToEnd < 0) { _timeToEnd = 0; } break; case GameMode.Free: //Free mode - no zone _timeToEnd = 0; //Add runes if empty if (_runes.Count == 0) { Logger.Log("WORLD creating runes"); _runes.AddRange(GenerateRunes(_config.RuneCount)); Logger.Log("WORLD creating rune tree"); _runesTree = new OcTree(_worldZone, _runes, true); } break; } }