private void OnPlayerKilled() { // If there are no subscribed objects, // the PlayerKilled EventHandler will be null, // and nothing will be notified of this event. PlayerKilled?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Disable the Player Car /// </summary> protected override void DisableCar() { if (currentState == CarState.Enabled) { //Call Event PlayerKilled?.Invoke(); //Call base function base.DisableCar(); //Disable our movement if (playerControl) { playerControl.enabled = false; } if (controllingCar) { controllingCar.CarAccelerateInput = 0f; controllingCar.CarSteerInput = 0f; } //Disable this data this.enabled = false; } }
/// <summary> /// Damage the Player, if not invunverable /// </summary> /// <param name="damage">Health to remove from the player</param> public void DamagePlayer(float damage) { if (!isInvunerable) { //Reduce Score when damaged ScoreKeeper.CurrentScore -= damageScoreReduction; //Calculate the resultant health and make sure that it doesn't //go below zero float resultantHealth = playerHealth - damage; if (resultantHealth > 0) { //Call damage events and functionality playerHealth = resultantHealth; PlayerDamaged?.Invoke(playerHealth); //Set player to be invunerable for an amount of time //so they don't take damage 100 times while clipping through a wall StartCoroutine(DoInvunerableSequence(playerInvunerableTime)); } else { //Call game over/death events playerHealth = 0; PlayerKilled?.Invoke(); } } }
public override void OnEvent(PlayerKilled evnt) { Player[] players = GetAllPlayers(); foreach (Player Player in players) { Player.GetComponent <GUImanager>().KilFeedAdd(evnt.Killed.GetComponent <Player>().state.Username, evnt.Killer.GetComponent <Player>().state.Username); } }
//Collision with crater private void OnCollisionEnter(Collision other) { if (other.gameObject.GetComponent <Crater>()) { //Call Player Killed Event PlayerKilled?.Invoke(); Destroy(gameObject); } }
public override void Update(GameTime gameTime) { timer = (timer >= 500) ? 0 : timer + gameTime.ElapsedGameTime.TotalMilliseconds; if (timer == 0 && killed) { PlayerKilled?.Invoke(Owner, null); } base.Update(gameTime); }
//"Name<uid><wonid><team>" killed "Name<uid><wonid><team>" with "weapon" [57] /// <summary> /// Raises the <see cref="PlayerKilled"/> event. /// </summary> /// <param name="timestamp">Time at which <see cref="PlayerKilled"/> event was fired.</param> /// <param name="info">Information about <see cref="PlayerKilled"/> event.</param> protected virtual void OnKill(DateTime timestamp, string[] info) { var eventArgs = new KillEventArgs { Timestamp = timestamp, Player = GetPlayerInfo(info[0]), Victim = GetPlayerInfo(info[2]), Weapon = info[4] }; PlayerKilled.Fire(ServerEndPoint, eventArgs); }
public void Die() { if (!isDead) { AudioManager.PlaySound(AudioManager.Sound.PlayerDeath, transform.position); canMove = false; canRun = false; PlayerKilled?.Invoke(); Cursor.lockState = CursorLockMode.None; Cursor.visible = true; isDead = true; } }
//Check for collision with a fox and thus triggering the player killed event private void OnTriggerEnter(Collider collision) { //Check if we have collided with a fox if (collision.gameObject.GetComponent <FoxAI>()) { //Trigger Player Killed Event PlayerKilled?.Invoke(); //We have collided with a fox and have been caught //Call game over from the game state manager Destroy(gameObject); } }
private void Die() { if (entity.IsOwner) { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; var Event = PlayerKilled.Create(); Event.Killed = entity; Event.Killer = LastDamaged; Event.Send(); var Event2 = ClaimKill.Create(LastDamaged); Event2.Send(); var Event3 = ClaimScore.Create(LastDamaged); Event3.Score = 100; Event3.Send(); if (LastDamaged != entity) { LastDamaged.GetComponent <Player>().AddScore(100); } state.Deaths += 1; StartCoroutine(Respawn()); if (LastDamaged == entity) { GuiManager.ShowDeathScreen("You've commited suicide..."); if (state.Score > 0) { state.Score -= 100; } if (state.Score < 0) { state.Score = 0; } } else { GuiManager.ShowDeathScreen("You've been killed by: " + LastDamaged.GetComponent <Player>().state.Username); } GuiManager.ShowScoreBoard(); gameObject.GetComponent <Renderer>().enabled = false; } }
public void HandleKilled(NetworkMessage msg) { MsgKilled killed = msg as MsgKilled; KilledEventArgs args = new KilledEventArgs(); args.Victim = GetPlayerByID(killed.VictimID); args.Killer = GetPlayerByID(killed.KillerID); args.Reason = killed.Reason; args.KilledByFlag = FlagTypeList.GetFromAbriv(killed.FlagAbreviation); if (killed.Reason == BlowedUpReasons.DeathTouch) { args.InstrumentID = killed.PhysicsDriverID; } else { args.InstrumentID = killed.ShotID; if (killed.ShotID > 0) { // kill shot int bzfsShotID = (killed.KillerID * byte.MaxValue) + killed.ShotID; // tell the shot manager to kill that thar shot } } if (args.Victim != null) { args.Victim.SetTeleport(-1, null, null); args.Victim.Active = false; args.Victim.IsRabbit = false; } if (PlayerKilled != null) { PlayerKilled.Invoke(this, args); } }
public void PreprocessData(ReplayGamestate gamestate, MapMetaData mapmeta, EncounterDetectionData edData) { // Load and create standard data base.PreprocessMain(gamestate, mapmeta, edData); // Custom preprocessing for your game #region Collect positions for preprocessing and build hashtables of events var positions = new HashSet <Point3D>(); List <double> hurt_ranges = new List <double>(); List <double> support_ranges = new List <double>(); foreach (var round in gamestate.Match.Rounds) { foreach (var tick in round.ticks) { foreach (var gevent in tick.getTickevents()) { switch (gevent.GameeventType) //Build hashtables with events we need later { case "player_hurt": PlayerHurt ph = (PlayerHurt)gevent; // Remove Z-Coordinate because we later get keys from clusters with points in 2D space -> hashtable needs keys with 2d data edData.Hit_hashtable[ph.Actor.Position.ResetZ()] = ph.Victim.Position.ResetZ(); hurt_ranges.Add(DistanceFunctions.GetEuclidDistance3D(ph.Actor.Position, ph.Victim.Position)); continue; case "player_killed": PlayerKilled pk = (PlayerKilled)gevent; edData.Hit_hashtable[pk.Actor.Position.ResetZ()] = pk.Victim.Position.ResetZ(); hurt_ranges.Add(DistanceFunctions.GetEuclidDistance3D(pk.Actor.Position, pk.Victim.Position)); if (pk.Assister != null) { edData.DirectAssist_hashtable[pk.Actor.Position.ResetZ()] = pk.Assister.Position.ResetZ(); support_ranges.Add(DistanceFunctions.GetEuclidDistance3D(pk.Actor.Position, pk.Assister.Position)); } continue; } foreach (var player in gevent.getPlayers()) { var vz = player.Velocity.VZ; if (vz == 0) //If player is standing thus not experiencing an acceleration on z-achsis -> TRACK POSITION { positions.Add(player.Position); } else { positions.Add(player.Position.ChangeZ(-Player.CSGO_PLAYERMODELL_JUMPHEIGHT)); // Player jumped -> Z-Value is false -> correct with jumpheight } } } } } #endregion Console.WriteLine("\nRegistered Positions for Sightgraph: " + positions.Count); Console.WriteLine("\nRegistered Hits: " + edData.Hit_hashtable.Count); // Generate Map with a constructor edData.Map = SimpleMapConstructor.CreateMap(mapmeta, positions.ToList()); if (support_ranges.Count != 0) { edData.ATTACKRANGE_AVERAGE = hurt_ranges.Average(); } if (support_ranges.Count != 0) { edData.SUPPORTRANGE_AVERAGE = support_ranges.Average(); } // Generate Hurteventclusters // Keys of the hashtable are attacker positions, ordering defines a function on how to order the data before performing LEADER Func <Point3DDataPoint[], Point3DDataPoint[]> ordering = ops => ops.OrderBy(p => p.clusterPoint.X).ThenBy(p => p.clusterPoint.Y).ToArray(); var playerhurtattackerpositions = edData.Hit_hashtable.Keys.Cast <Point3D>(); var wrappedphpositions = new List <Point3DDataPoint>(); // Wrapp Point3D to execute Clustering playerhurtattackerpositions.ToList().ForEach(p => wrappedphpositions.Add(new Point3DDataPoint(p))); var leader = new LEADER <Point3DDataPoint>((float)edData.ATTACKRANGE_AVERAGE, wrappedphpositions.ToArray(), ordering); var attackerclusters = new List <PlayerHurtCluster>(); foreach (var cluster in leader.CreateClusters()) { var extractedpos = new List <Point3D>(); cluster.ClusterData.ForEach(data => extractedpos.Add(data.clusterPoint)); var attackcluster = new PlayerHurtCluster(extractedpos.ToArray()); attackcluster.CalculateClusterRanges(edData.Hit_hashtable); attackerclusters.Add(attackcluster); } edData.Clusters_PlayerHurt = attackerclusters.ToArray(); }
public void KillPlayer(ServerPlayer player, KilledEventArgs args) { if (args == null || player == null) { return; } if (!player.Info.Alive) { Logger.Log0("Player " + player.Callsign + " killed while dead"); } player.Info.Alive = false; PlayerKilled?.Invoke(this, args); Logger.Log4("Player " + player.Callsign + " killed by " + args.KillInfo.Reason.ToString()); bool wasFromAFlag = false; switch (args.KillInfo.Reason) { case BlowedUpReasons.GotKilledMsg: break; case BlowedUpReasons.GotShot: wasFromAFlag = true; Shots.RemoveShotForDeath(player, args.KillInfo.KillerID, args.KillInfo.ShotID); if (args.Shot != null) // tell the flag it took a hit { Flags.HandlePlayerTakeHit(player, args.Killer, args.Shot); } break; case BlowedUpReasons.GotRunOver: wasFromAFlag = true; break; case BlowedUpReasons.GotCaptured: break; case BlowedUpReasons.GenocideEffect: break; case BlowedUpReasons.SelfDestruct: break; case BlowedUpReasons.WaterDeath: break; case BlowedUpReasons.DeathTouch: break; case BlowedUpReasons.LastReason: case BlowedUpReasons.Unknown: Logger.Log0("Player " + player.Callsign + " killed by a method that should not happen"); break; } if (wasFromAFlag) // tell the flag it killed { Flags.HandlePlayerDoDamage(player, args.Killer, FlagTypeList.GetFromAbriv(args.KillInfo.FlagAbreviation)); } // process any scores PlayerInfo.ScoreInfo vicScores = new PlayerInfo.ScoreInfo(); PlayerInfo.ScoreInfo killerScores = new PlayerInfo.ScoreInfo(); if (ComputeScores(args.Victim, ref vicScores, args.Killer, ref killerScores, args.KillInfo.Reason)) { args.Victim.Info.Score.ApplyScore(vicScores); if (args.Killer != null) { args.Killer.Info.Score.ApplyScore(killerScores); } MsgScore scoreMessage = new MsgScore(); if (!vicScores.Empty) { Logger.Log3("Player " + player.Callsign + " score updated by " + vicScores.ToString()); ScoreUpdated?.Invoke(this, args.Victim); args.Victim.Info.Score.Pack(args.Victim.PlayerID, scoreMessage); } if (args.Killer != null && !killerScores.Empty) { Logger.Log3("Player " + player.Callsign + " score updated by " + killerScores.ToString()); ScoreUpdated?.Invoke(this, args.Killer); args.Killer.Info.Score.Pack(args.Killer.PlayerID, scoreMessage); } if (scoreMessage.Scores.Count > 0) { SendToAll(scoreMessage, false); } } MsgKilled killedMessage = new MsgKilled(); killedMessage.VictimID = args.Victim.PlayerID; killedMessage.KillerID = args.Killer != null ? args.Killer.PlayerID : PlayerConstants.ServerPlayerID; killedMessage.ShotID = args.Shot != null ? args.Shot.PlayerShotID : -1; killedMessage.Reason = args.KillInfo.Reason; killedMessage.FlagAbreviation = (args.Shot != null && args.Shot.SourceFlag != null) ? args.Shot.SourceFlag.FlagAbbv : string.Empty; killedMessage.PhysicsDriverID = args.KillInfo.PhysicsDriverID; SendToAll(killedMessage, false); }
public static void CallPlayerKilled() { PlayerKilled?.Invoke(); }
private void ActorMap_PlayerKilled(object sender, EventArgs e) { PlayerKilled?.Invoke(sender, null); }
private void HandleCurrentEvents() { foreach (BaseEvent baseEvent in currentTick.Events) { switch (baseEvent.Type) { case EventType.MatchStarted: MatchStarted?.Invoke(this, baseEvent); break; case EventType.RoundAnnounceMatchStarted: break; case EventType.RoundStart: RoundStart?.Invoke(this, (RoundStartEvent)baseEvent); break; case EventType.RoundEnd: RoundEnd?.Invoke(this, (RoundEndEvent)baseEvent); break; case EventType.WinPanelMatch: WinPanelMatch?.Invoke(this, baseEvent); break; case EventType.RoundFinal: break; case EventType.LastRoundHalf: break; case EventType.RoundOfficiallyEnd: RoundOfficiallyEnd?.Invoke(this, baseEvent); break; case EventType.RoundMVP: RoundMVP?.Invoke(this, (RoundMVPEvent)baseEvent); break; case EventType.FreezetimeEnded: FreezetimeEnded?.Invoke(this, baseEvent); break; case EventType.PlayerKilled: PlayerKilled?.Invoke(this, (PlayerKilledEvent)baseEvent); break; case EventType.PlayerTeam: PlayerTeam?.Invoke(this, (PlayerTeamEvent)baseEvent); break; case EventType.WeaponFired: WeaponFired?.Invoke(this, (WeaponFiredEvent)baseEvent); break; case EventType.SmokeNadeStarted: SmokeNadeStarted?.Invoke(this, (SmokeNadeStartedEvent)baseEvent); break; case EventType.SmokeNadeEnded: SmokeNadeEnded?.Invoke(this, (SmokeNadeEndedEvent)baseEvent); break; case EventType.DecoyNadeStarted: DecoyNadeStarted?.Invoke(this, (DecoyNadeStartedEvent)baseEvent); break; case EventType.DecoyNadeEnded: DecoyNadeEnded?.Invoke(this, (DecoyNadeEndedEvent)baseEvent); break; case EventType.FireNadeStarted: FireNadeStarted?.Invoke(this, (FireNadeStartedEvent)baseEvent); break; case EventType.FireNadeWithOwnerStarted: FireNadeWithOwnerStarted?.Invoke(this, (FireNadeWithOwnerStartedEvent)baseEvent); break; case EventType.FireNadeEnded: FireNadeEnded?.Invoke(this, (FireNadeEndedEvent)baseEvent); break; case EventType.FlashNadeExploded: FlashNadeExploded?.Invoke(this, (FlashNadeExplodedEvent)baseEvent); break; case EventType.ExplosiveNadeExploded: ExplosiveNadeExploded?.Invoke(this, (ExplosiveNadeExplodedEvent)baseEvent); break; case EventType.NadeReachedTarget: NadeReachedTarget?.Invoke(this, (NadeReachedTargetEvent)baseEvent); break; case EventType.BombBeginPlant: BombBeginPlant?.Invoke(this, (BombBeginPlantEvent)baseEvent); break; case EventType.BombAbortPlant: BombAbortPlant?.Invoke(this, (BombAbortPlantEvent)baseEvent); break; case EventType.BombPlanted: BombPlanted?.Invoke(this, (BombPlantedEvent)baseEvent); break; case EventType.BombDefused: BombDefused?.Invoke(this, (BombDefusedEvent)baseEvent); break; case EventType.BombExploded: BombExploded?.Invoke(this, (BombExplodedEvent)baseEvent); break; case EventType.BombBeginDefuse: BombBeginDefuse?.Invoke(this, (BombBeginDefuseEvent)baseEvent); break; case EventType.BombAbortDefuse: BombAbortDefuse?.Invoke(this, (BombAbortDefuseEvent)baseEvent); break; case EventType.PlayerHurt: PlayerHurt?.Invoke(this, (PlayerHurtEvent)baseEvent); break; case EventType.Blind: Blind?.Invoke(this, (BlindEvent)baseEvent); break; case EventType.PlayerBind: PlayerBind?.Invoke(this, (PlayerBindEvent)baseEvent); break; case EventType.PlayerDisconnect: PlayerDisconnect?.Invoke(this, (PlayerDisconnectEvent)baseEvent); break; case EventType.SayText: SayText?.Invoke(this, (SayTextEvent)baseEvent); break; case EventType.SayText2: SayText2?.Invoke(this, (SayText2Event)baseEvent); break; case EventType.PlayerJump: PlayerJump?.Invoke(this, (PlayerJumpEvent)baseEvent); break; case EventType.PlayerFootstep: PlayerFootstep?.Invoke(this, (PlayerFootstepEvent)baseEvent); break; case EventType.OtherDeath: OtherDeath?.Invoke(this, (OtherDeathEvent)baseEvent); break; case EventType.EntitySpawned: EntitySpawned?.Invoke(this, (EntitySpawnedEvent)baseEvent); break; case EventType.EntityRemoved: EntityRemoved?.Invoke(this, (EntityRemovedEvent)baseEvent); break; default: break; } } }