private static CallbackActivity BuildBattleFightActivity(BattleFightPack fightPack) { if (fightPack == null) { throw new ArgumentNullException("fightPack"); } FDCreature subject = fightPack.Subject; FDCreature target = fightPack.Target; FightInformation fightInfo = fightPack.FightInformation; CallbackActivity activity = new CallbackActivity( (gameInterface) => { gameInterface.BattleFight(subject, target, fightInfo); }); return(activity); }
public void DoCreatureAttack(int creatureId, FDPosition targetPosition) { FDCreature creature = this.GetCreature(creatureId); if (creature == null) { throw new ArgumentNullException("creature"); } FDCreature target = this.GetCreatureAt(targetPosition); if (target == null) { throw new ArgumentNullException("target"); } FightInformation fighting = DamageFormula.DealWithAttack(creature, target, gameField, true); BattleFightPack fightPack = new BattleFightPack(creature, target, fighting); gameCallback.OnHandlePack(fightPack); // Remove dead creature if (target.Data.Hp <= 0) { this.DisposeCreature(target.CreatureId, true, true); } if (creature.Data.Hp <= 0) { this.DisposeCreature(creature.CreatureId, true, true); } if (creature.Faction == CreatureFaction.Friend) { // Talk about experience MessageId mId = MessageId.Create(MessageId.MessageTypes.Message, 5, 33); TalkPack talk = new TalkPack(creature, mId); gameCallback.OnHandlePack(talk); } PostCreatureAction(creature); }