/// <summary> /// Kills the unit /// </summary> /// <param id="noMessage">Should the kill be announced</param> public void Kill(bool noMessage = false) { Health = 0; State = GameObjectState.Idle; game.SendData(Network.MakeServerMessage(MessageType.GameObjKill, this)); if (!noMessage) { GameEffect ge = new UnitDeathEffect(this); ge.Initialize(this.game, NearestTile); this.game.Effects.Add(ge); game.SendData(Network.MakeServerMessage(MessageType.GameEffectCreate, ge)); ScrollUpMessage("Killed", 50, true); } Dispose(); }
/// <summary> /// Creates a new instance of the GameEffect class using the serialized data /// </summary> /// <param id="line">String array containing the serialized data</param> /// <param id="position">Current position in the array</param> /// <param id="context">Context of the serialized data, game where this INetworkSerializable object is in</param> /// <returns>GameEffect created using the provided serialized data</returns> public static GameEffect Create(string[] line, ref int position, WildmenGame context) { GameEffect e = null; EffectTypes et = (EffectTypes)int.Parse(line[position++]); switch (et) { case EffectTypes.Scripted: e = new GameEffect(); break; case EffectTypes.UnitDeath: e = new UnitDeathEffect(); break; case EffectTypes.ScrollText: e = new ScrollTextEffect(); break; case EffectTypes.Animation: e = new AnimationEffect(); break; case EffectTypes.Spawner: e = new SpawnerEffect(); break; default: throw new Exception("Unknown effect"); } e.game = context; e.Deserialize(MessageType.GameEffectCreate, line, ref position, context); return e; }