public MenuActionState(IGameAction gameAction, int creatureId, FDPosition position) : base(gameAction, position) { this.CreatureId = creatureId; this.Creature = gameAction.GetCreature(creatureId); // Magic this.SetMenu(0, MenuItemId.ActionMagic, IsMenuMagicEnabled(), () => { CreatureShowInfoPack pack = new CreatureShowInfoPack(this.Creature, CreatureInfoType.SelectMagic); gameAction.GetCallback().OnHandlePack(pack); subState = SubActionState.SelectMagic; return(StateOperationResult.None()); }); // Attack this.SetMenu(1, MenuItemId.ActionAttack, IsMenuAttackEnabled(), () => { SelectAttackTargetState attackState = new SelectAttackTargetState(gameAction, this.Creature); return(StateOperationResult.Push(attackState)); }); // Item this.SetMenu(2, MenuItemId.ActionItems, IsMenuItemEnabled(), () => { MenuItemState itemState = new MenuItemState(gameAction, this.CreatureId, this.Central); return(StateOperationResult.Push(itemState)); }); // Rest this.SetMenu(3, MenuItemId.ActionRest, true, () => { // Check Treasure treasureItem = gameAction.GetTreatureAt(this.Creature.Position); if (treasureItem != null) { subState = SubActionState.ConfirmPickTreasure; return(StateOperationResult.None()); } gameAction.DoCreatureRest(this.CreatureId); return(StateOperationResult.Clear()); }); }
public MenuItemState(IGameAction gameAction, int creatureId, FDPosition position) : base(gameAction, position) { this.CreatureId = creatureId; this.Creature = gameAction.GetCreature(creatureId); // Exchange this.SetMenu(0, MenuItemId.ItemExchange, IsMenuExchangeEnabled(), () => { CreatureShowInfoPack pack = new CreatureShowInfoPack(this.Creature, CreatureInfoType.SelectAllItem); SendPack(pack); subState = SubActionState.SelectExchangeItem; return(StateOperationResult.None()); }); // Use this.SetMenu(1, MenuItemId.ItemUse, IsMenuUseEnabled(), () => { CreatureShowInfoPack pack = new CreatureShowInfoPack(this.Creature, CreatureInfoType.SelectUseItem); SendPack(pack); subState = SubActionState.SelectUseItem; return(StateOperationResult.None()); }); // Equip this.SetMenu(2, MenuItemId.ItemEquip, IsMenuEquipEnabled(), () => { CreatureShowInfoPack pack = new CreatureShowInfoPack(this.Creature, CreatureInfoType.SelectEquipItem); SendPack(pack); subState = SubActionState.SelectEquipItem; return(StateOperationResult.None()); }); // Discard this.SetMenu(3, MenuItemId.ItemDiscard, IsMenuDiscardEnabled(), () => { CreatureShowInfoPack pack = new CreatureShowInfoPack(this.Creature, CreatureInfoType.SelectAllItem); SendPack(pack); subState = SubActionState.SelectDiscardItem; return(StateOperationResult.None()); }); }
/// <summary> /// /// </summary> /// <param name="gameAction"></param> public SelectItemExchangeTargetState(IGameAction gameAction, int creatureId, int itemIndex) : base(gameAction) { this.CreatureId = creatureId; this.Creature = gameAction.GetCreature(creatureId); this.SelectedItemIndex = itemIndex; }
public override bool IsMatched(IGameAction gameAction) { FDCreature creature = gameAction.GetCreature(creatureId); return(creature != null && creature.Data.Hp <= 0); }