/// <summary> /// Kills a unit /// TODO: Find out how to handle killer / victim packets /// </summary> /// <param name="unit">The unit who died</param> /// <param name="killer">The unit who killed him</param> /// <param name="weapon">The weapon that killed him</param> public void KillUnit(Unit unit, Unit killer = null, Weapon weapon = null, Skill skill = null) { // Call ondeath unit.OnDeath(); // Destroy? if (unit.Owner != null) { unit.Owner.CurrentUnit = null; } // Remove from units list _units.Remove(unit.Id, out var trash); // TODO: Use an interface here? if (weapon != null) { // Notify all RoomInstance.MulticastPacket(new UnitDestroyed(unit, killer, weapon)); // Call hook AfterUnitKilled(unit, killer, weapon); } else { // Notify all RoomInstance.MulticastPacket(new UnitDestroyed(unit, killer, skill)); // Call hook AfterUnitKilled(unit, killer, skill); } }
/// <summary> /// Notifies users when an attack is made /// </summary> /// <param name="attacker"></param> /// <param name="victim"></param> /// <param name="damage"></param> public void NotifyUnitAttacked(Unit attacker, List <HitResult> hits, Weapon weapon) { while (hits.Count < 4) { hits.Add(HitResult.Miss); } if (weapon is Gun) { RoomInstance.MulticastPacket(new Attack(attacker, hits, weapon)); } else if (weapon is Fist) { RoomInstance.MulticastPacket(new AttackBlade(attacker, hits, weapon)); } }
/// <summary> /// Kills a unit /// TODO: Find out how to handle killer / victim packets /// </summary> /// <param name="unit">The unit who died</param> /// <param name="killer">The unit who killed him</param> /// <param name="weapon">The weapon that killed him</param> public void KillUnit(Unit unit, Unit killer = null, Weapon weapon = null) { // unit.Health = 0; // unit.SetWeaponSet(0); // unit.WeaponSet1Left.Target = null; // unit.WeaponSet1Left.IsAttacking = false; // unit.WeaponSet1Left.IsOverheated = false; // unit.WeaponSet1Left.CurrentOverheat = 0.0f; // // if (unit.WeaponSet1Right != null) // { // unit.WeaponSet1Right.Target = null; // unit.WeaponSet1Right.IsAttacking = false; // unit.WeaponSet1Right.IsOverheated = false; // unit.WeaponSet1Right.CurrentOverheat = 0.0f; // } // // unit.WeaponSet2Left.Target = null; // unit.WeaponSet2Left.IsAttacking = false; // unit.WeaponSet2Left.IsOverheated = false; // unit.WeaponSet2Left.CurrentOverheat = 0.0f; // // if (unit.WeaponSet2Right != null) // { // unit.WeaponSet2Right.Target = null; // unit.WeaponSet2Right.IsAttacking = false; // unit.WeaponSet2Right.IsOverheated = false; // unit.WeaponSet2Right.CurrentOverheat = 0.0f; // } // unit.Alive = false; // Destroy? if (unit.Owner != null) { unit.Owner.CurrentUnit = null; } // Remove from units list _units.Remove(unit.Id, out var trash); // Notify all RoomInstance.MulticastPacket(new UnitDestroyed(unit, killer, weapon)); // Call hook AfterUnitKilled(unit, killer, weapon); }
/// <summary> /// Kills a unit /// TODO: Find out how to handle killer / victim packets /// </summary> /// <param name="unit">The unit who died</param> /// <param name="killer">The unit who killed him</param> /// <param name="weapon">The weapon that killed him</param> public void KillUnit(Unit unit, Unit killer = null, Weapon weapon = null, Skill skill = null) { // Update scores if (killer != null && killer != unit) { killer.Owner.User.Scores.Kills++; killer.Owner.User.Scores.Points += 30; killer.Owner.User.Scores.Credits += 100; } // Do not add score updates to npcs if (unit.Owner != null) { unit.Owner.User.Scores.Deaths++; } // TODO: Use an interface here? if (weapon != null) { // Notify all RoomInstance.MulticastPacket(new UnitDestroyed(unit, killer, weapon)); // Call hook AfterUnitKilled(unit, killer, weapon); } else { // Notify all RoomInstance.MulticastPacket(new UnitDestroyed(unit, killer, skill)); // Call hook AfterUnitKilled(unit, killer, skill); } // Notify of stats update NotifyScoreChanged(); // Notify unit of regain unit.Owner?.SendPacket(new RegainInfo(unit.Owner, false)); // Flag for death unit.State = UnitState.Dying; }
/// <summary> /// Notifies users when an attack is made /// </summary> /// <param name="attacker"></param> /// <param name="victim"></param> /// <param name="damage"></param> public void NotifyUnitAttacked(Unit attacker, HitResult hit, Weapon weapon) { NotifyUnitAttacked(attacker, new List <HitResult> { hit, HitResult.Miss, HitResult.Miss, HitResult.Miss }, weapon); }
/// <summary> /// Notifies users when a unit overheats a weapon /// </summary> /// <param name="unit"></param> /// <param name="weapon"></param> public void NotifyUnitOverheatStatus(Unit unit, Weapon weapon) { RoomInstance.MulticastPacket(new OverheatStatus(unit, weapon)); }
/// <summary> /// Called when a unit is killed /// </summary> /// <param name="unit"></param> /// <param name="killer"></param> /// <param name="weapon"></param> protected abstract void AfterUnitKilled(Unit unit, Unit killer, Weapon weapon);
/// <summary> /// Notifies users an ifo was launched /// </summary> /// <param name="ifo"></param> /// <param name="hits"></param> public void NotifyIfoLaunched(Unit unit, Weapon weapon, Ifo ifo) { RoomInstance.MulticastPacket(new AttackIfo(unit, weapon, ifo)); }