public static void HandleData(GetDataEventArgs args, MemoryStream data, PvPPlayer player) { switch (args.MsgID) { case PacketTypes.PlayerHurtV2: PlayerHurt?.Invoke(typeof(DataHandler), new PlayerHurtArgs(args, data, player)); return; case PacketTypes.TogglePvp: PvPToggled?.Invoke(typeof(DataHandler), new TogglePvPArgs(player)); return; case PacketTypes.PlayerSlot: PlayerSlotUpdated?.Invoke(typeof(DataHandler), new PlayerSlotArgs(data, player)); return; case PacketTypes.PlayerDeathV2: PlayerDied?.Invoke(typeof(DataHandler), new PlayerDeathArgs(player)); return; case PacketTypes.ProjectileNew: ProjectileNew?.Invoke(typeof(DataHandler), new ProjectileNewArgs(args, data, player)); return; case PacketTypes.ProjectileDestroy: ProjectileDestroyed?.Invoke(typeof(DataHandler), new ProjectileDestroyArgs(data)); return; case PacketTypes.PlayerUpdate: PlayerUpdated?.Invoke(typeof(DataHandler), new PlayerUpdateArgs(data, player)); return; } }
public static void HandleData(GetDataEventArgs args, MemoryStream data, PvPPlayer player) { switch (args.MsgID) { case PacketTypes.PlayerHurtV2: if (new PlayerHurtArgs().ExtractData(args, data, player, out var playerhurt)) { PlayerHurt?.Invoke(typeof(DataHandler), playerhurt); } return; case PacketTypes.TogglePvp: if (new TogglePvPArgs().ExtractData(player, out var togglepvp)) { PvPToggled?.Invoke(typeof(DataHandler), togglepvp); } return; case PacketTypes.PlayerSlot: if (new PlayerSlotArgs().ExtractData(data, player, out var playerslot)) { SlotUpdate?.Invoke(typeof(DataHandler), playerslot); } return; case PacketTypes.PlayerDeathV2: if (new PlayerDeathArgs().ExtractData(player, out var playerdeath)) { PlayerDeath?.Invoke(typeof(DataHandler), playerdeath); } return; case PacketTypes.ProjectileNew: if (new ProjectileNewArgs().ExtractData(args, data, player, out var projectilenew)) { ProjectileNew?.Invoke(typeof(DataHandler), projectilenew); } return; case PacketTypes.ProjectileDestroy: if (new ProjectileDestroyArgs().ExtractData(data, out var projectiledestroy)) { ProjectileDestroyed?.Invoke(typeof(DataHandler), projectiledestroy); } return; case PacketTypes.PlayerUpdate: if (new PlayerUpdateArgs().ExtractData(data, player, out var playerupdate)) { PlayerUpdate?.Invoke(typeof(DataHandler), playerupdate); } return; } }
public static void InvokePlayerHurt(PlayerStats stats, ref PlayerStats.HitInfo info, GameObject obj, int pid = 0) { PlayerHurt playerHurt = PlayerHurtEvent; if (playerHurt == null) { return; } PlayerHurtEvent ev = new PlayerHurtEvent { Attacker = pid == 0 ? stats.gameObject.GetPlayer() : Player.GetPlayer(pid), Player = obj.GetPlayer(), Info = info }; if (string.IsNullOrEmpty(ev.Player.characterClassManager.UserId)) { return; } playerHurt.Invoke(ref ev); info = ev.Info; }
public void ApplyDamage(DamageMessage data) { if (currentHitPoints <= 0) {//ignore damage if already dead. TODO : may have to change that if we want to detect hit on death... return; } if (isInvulnerable) { OnHitWhileInvulnerable.Invoke(); return; } Vector3 forward = transform.forward; forward = Quaternion.AngleAxis(hitForwardRotation, transform.up) * forward; //we project the direction to damager to the plane formed by the direction of damage Vector3 positionToDamager = data.damageSource - transform.position; positionToDamager -= transform.up * Vector3.Dot(transform.up, positionToDamager); if (Vector3.Angle(forward, positionToDamager) > hitAngle * 0.5f) { return; } isInvulnerable = true; currentHitPoints -= data.amount; if (currentHitPoints <= 0) { schedule += OnDeath.Invoke; //This avoid race condition when objects kill each other. if (this.gameObject.layer == 9) //Player { if (data.damager.gameObject.name == "BodyDamager") { PlayerDeathEvent?.Invoke(ENEMY_TYPE.CHOMPER); } else if (data.damager.gameObject.name == "Spit(Clone)") { PlayerDeathEvent?.Invoke(ENEMY_TYPE.SPITTER); } } else if (this.gameObject.layer == 23) // Enemy { if (gameObject.name == "Chomper") { EnemyDeathEvent?.Invoke(gameObject, ENEMY_TYPE.CHOMPER); } else if (gameObject.name == "Spitter") { EnemyDeathEvent?.Invoke(gameObject, ENEMY_TYPE.SPITTER); } } } else { if (data.damager.gameObject.name == "BodyDamager") { PlayerHurtEvent?.Invoke(ENEMY_TYPE.CHOMPER); } else if (data.damager.gameObject.name == "Spit(Clone)") { PlayerHurtEvent?.Invoke(ENEMY_TYPE.SPITTER); } OnReceiveDamage.Invoke(); } var messageType = currentHitPoints <= 0 ? MessageType.DEAD : MessageType.DAMAGED; for (var i = 0; i < onDamageMessageReceivers.Count; ++i) { var receiver = onDamageMessageReceivers[i] as IMessageReceiver; receiver.OnReceiveMessage(messageType, this, data); } }
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; } } }