void Start() { playerStatistics.ResetValues(); EntityKilledEvent.Register(onEntityKilled); CrystalDeliveredEvent.Register(onCrystalDelivered); conditionChecker = GetComponent <ConditionChecker>(); }
void onEntityKilled(EntityKilledEvent entityKilled) { if (entityKilled.Entity.Equals(gameObject)) { Debug.LogFormat("Playing dying sound"); audioSource.PlayOneShot(Clip, volume); } }
public void OnPlayerDeath(EntityKilledEvent e) { if (e.Entity is OpenPlayer player) { player.SetGamemode(GameMode.Spectator); player.Teleport(player.SpawnPosition); } }
void onEntityKilled(EntityKilledEvent entityKilled) { if (entityKilled.Entity == null) { return; } Debug.LogFormat("Received EntityKilled. KillerTag: {0}", entityKilled.KillerTag); if (entityKilled.KillerTag == "Projectile") { playerStatistics.IncreaseEnemiesKilled(); } }
public void OnKilled(EntityKilledEvent e) { if (IsActive) { if ((e.AttackerEntity is Laser) && TypeOfLaser.Player == (e.AttackerEntity as Laser).Type && typeOfSubject == e.SubjectEntity.GetType()) { TaskComplete(); } else if (/*Owner*/ TypeOfBullet.Player == (e.AttackerEntity as Bullet).Type /* <-- kan hanteras bättre */ && typeOfSubject == e.SubjectEntity.GetType()) { TaskComplete(); } } }
private void OnDestroy() { EntityKilledEvent.DeRegister(onEntityKilled); }
// Use this for initialization void Start() { audioSource = GetComponent <AudioSource>(); EntityKilledEvent.Register(onEntityKilled); }
public override void Kill() { if (Entity.Level is OpenLevel lvl) { EntityKilledEvent killedEvent = new EntityKilledEvent(Entity); lvl.EventDispatcher.DispatchEvent(killedEvent); if (killedEvent.IsCancelled) { return; } } if (Entity is MiNET.Player player) { ResetHealth(); player.HungerManager.ResetHunger(); player.SendUpdateAttributes(); player.BroadcastSetEntityData(); //player. if (!player.Level.KeepInventory) { player.DropInventory(); } player.SetPosition(player.SpawnPosition); } else { lock (_killSync) { if (IsDead) { return; } IsDead = true; Health = 0; } Entity.BroadcastEntityEvent(); Entity.BroadcastSetEntityData(); Entity.DespawnEntity(); if (LastDamageSource is MiNET.Player) { var drops = Entity.GetDrops(); foreach (var drop in drops) { Entity.Level.DropItem(Entity.KnownPosition.ToVector3(), drop); } } } /*if (Entity is MiNET.Player player) * { * player.SendUpdateAttributes(); * player.BroadcastEntityEvent(); * * player.BroadcastSetEntityData(); * player.DespawnEntity(); * * if (!player.KeepInventory) * { * player.DropInventory(); * } * * var mcpeRespawn = McpeRespawn.CreateObject(); * mcpeRespawn.x = player.SpawnPosition.X; * mcpeRespawn.y = player.SpawnPosition.Y; * mcpeRespawn.z = player.SpawnPosition.Z; * player.SendPackage(mcpeRespawn); * } * else * { * Entity.BroadcastEntityEvent(); * Entity.BroadcastSetEntityData(); * Entity.DespawnEntity(); * * if (LastDamageSource is MiNET.Player) * { * var drops = Entity.GetDrops(); * foreach (var drop in drops) * { * Entity.Level.DropItem(Entity.KnownPosition.ToVector3(), drop); * } * } * }*/ }