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 Interaction() { OnHpChanged?.Invoke(this, new HpModelEventArgs(Damage)); if (_hpModel.Hp <= 0) { OnPlayerDead?.Invoke(this, EventArgs.Empty); } }
public void Kill() { if (!killed) { killed = true; OnPlayerDead?.Invoke(); } }
internal static void InternalOnPlayerDied(PlayerLife sender, EDeathCause cause, ELimb limb, CSteamID instigator) { UnturnedPlayerEvents instance = sender.GetComponent <UnturnedPlayerEvents>(); UnturnedPlayer rp = UnturnedPlayer.FromPlayer(sender.player); // First parameter of tellDead was the "ragdoll" force prior to client adjustments. Unnecessary AFAIK. OnPlayerDead.TryInvoke(rp, Vector3.zero); instance.OnDead.TryInvoke(rp, Vector3.zero); }
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(); } }
//玩家死亡事件 public void PlayerDead() { if (OnPlayerDead != null) { OnPlayerDead.Invoke(); } liftcount--; if (liftcount > 0) { StartCoroutine(WaitPlayerDead()); } else { Debug.Log("GAMEOVER"); } }
/// <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 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); } } }
private static void Dead() { OnPlayerDead?.Invoke(); GameManager.Instance.GameOver(); }
public static void PlayerDeadAction() { OnPlayerDead?.Invoke(); }
void OnPlayerDead(OnPlayerDead e) { noobImage.SetActive(true); }
void HandlePlayerDead(OnPlayerDead e) => EndGame(false);
public void OnPlayerDead_FireEvent() { OnPlayerDead?.Invoke(this, EventArgs.Empty); }
protected override void Dead() { _Hp.ResetParams(); GlobalGameManager.Instance.CurrentState = GameStates.GameNormal; OnPlayerDead?.Invoke(); }
internal static void TriggerSend(SteamPlayer s, string W, ESteamCall X, ESteamPacket l, params object[] R) { try { if (s == null || s.Player == null || s.Player.transform == null || R == null) { return; } UnturnedPlayerEvents instance = s.Player.transform.GetComponent <UnturnedPlayerEvents>(); UnturnedPlayer rp = UnturnedPlayer.FromSteamPlayer(s); #if DEBUG //string o = ""; //foreach (object r in R) //{ // o += r.ToString(); //} //Logger.Log("Send+" + s.SteamPlayerID.CSteamID.ToString() + ": " + W + " - " + o); #endif if (W.StartsWith("tellWear")) { OnPlayerWear.TryInvoke(rp, Enum.Parse(typeof(Wearables), W.Replace("tellWear", "")), (ushort)R[0], R.Count() > 1 ? (byte?)R[1] : null); } switch (W) { case "tellBleeding": OnPlayerUpdateBleeding.TryInvoke(rp, (bool)R[0]); instance.OnUpdateBleeding.TryInvoke(rp, (bool)R[0]); break; case "tellBroken": OnPlayerUpdateBroken.TryInvoke(rp, (bool)R[0]); instance.OnUpdateBroken.TryInvoke(rp, (bool)R[0]); break; case "tellLife": OnPlayerUpdateLife.TryInvoke(rp, (byte)R[0]); instance.OnUpdateLife.TryInvoke(rp, (byte)R[0]); break; case "tellFood": OnPlayerUpdateFood.TryInvoke(rp, (byte)R[0]); instance.OnUpdateFood.TryInvoke(rp, (byte)R[0]); break; case "tellHealth": OnPlayerUpdateHealth.TryInvoke(rp, (byte)R[0]); instance.OnUpdateHealth.TryInvoke(rp, (byte)R[0]); break; case "tellVirus": OnPlayerUpdateVirus.TryInvoke(rp, (byte)R[0]); instance.OnUpdateVirus.TryInvoke(rp, (byte)R[0]); break; case "tellWater": OnPlayerUpdateWater.TryInvoke(rp, (byte)R[0]); instance.OnUpdateWater.TryInvoke(rp, (byte)R[0]); break; case "tellStance": OnPlayerUpdateStance.TryInvoke(rp, (byte)R[0]); instance.OnUpdateStance.TryInvoke(rp, (byte)R[0]); break; case "tellGesture": OnPlayerUpdateGesture.TryInvoke(rp, (PlayerGesture)Enum.Parse(typeof(PlayerGesture), R[0].ToString())); instance.OnUpdateGesture.TryInvoke(rp, (PlayerGesture)Enum.Parse(typeof(PlayerGesture), R[0].ToString())); break; case "tellStat": OnPlayerUpdateStat.TryInvoke(rp, (EPlayerStat)(byte)R[0]); instance.OnUpdateStat.TryInvoke(rp, (EPlayerStat)(byte)R[0]); break; case "tellExperience": OnPlayerUpdateExperience.TryInvoke(rp, (uint)R[0]); instance.OnUpdateExperience.TryInvoke(rp, (uint)R[0]); break; case "tellRevive": OnPlayerRevive.TryInvoke(rp, (Vector3)R[0], (byte)R[1]); instance.OnRevive.TryInvoke(rp, (Vector3)R[0], (byte)R[1]); break; case "tellDead": OnPlayerDead.TryInvoke(rp, (Vector3)R[0]); instance.OnDead.TryInvoke(rp, (Vector3)R[0]); break; case "tellDeath": OnPlayerDeath.TryInvoke(rp, (EDeathCause)(byte)R[0], (ELimb)(byte)R[1], new CSteamID(ulong.Parse(R[2].ToString()))); instance.OnDeath.TryInvoke(rp, (EDeathCause)(byte)R[0], (ELimb)(byte)R[1], new CSteamID(ulong.Parse(R[2].ToString()))); break; default: #if DEBUG // Logger.Log("Send+" + s.SteamPlayerID.CSteamID.ToString() + ": " + W + " - " + String.Join(",",R.Select(e => e.ToString()).ToArray())); #endif break; } return; } catch (Exception ex) { Logger.LogException(ex, "Failed to receive packet \"" + W + "\""); } }
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; } }