private StateOperationResult OnMagicSelected(int index) { Debug.Log("MenuActionState: OnMagicSelected."); if (index < 0 || index >= this.Creature.Data.Magics.Count) { // Cancelled return(StateOperationResult.Pop()); } int magicId = this.Creature.Data.Magics[index]; MagicDefinition magicDefinition = DefinitionStore.Instance.GetMagicDefinition(magicId); if (magicDefinition != null && this.Creature.Data.CanSpellMagic() && magicDefinition.MpCost <= this.Creature.Data.Mp) { // Enough MP to spell SelecteMagicTargetState magicTargetState = new SelecteMagicTargetState(gameAction, this.Creature, magicDefinition); return(StateOperationResult.Push(magicTargetState)); } else { // Go back to open magic info CreatureShowInfoPack pack = new CreatureShowInfoPack(this.Creature, CreatureInfoType.SelectMagic); SendPack(pack); return(StateOperationResult.None()); } }
private StateOperationResult OnSelectedExchangeItem(int index) { if (index < 0) { return(StateOperationResult.Pop()); } // Selete Target Friend SelectItemExchangeTargetState exchangeTargetState = new SelectItemExchangeTargetState(gameAction, this.CreatureId, index); return(StateOperationResult.Push(exchangeTargetState)); }
private StateOperationResult OnSelectedUseItem(int index) { int itemId = this.Creature.Data.GetItemAt(index); if (itemId < 0) { // Item not found, should not reach here return(StateOperationResult.Clear()); } // Selete Target Friend SelectItemUseTargetState selectTargetState = new SelectItemUseTargetState(gameAction, this.CreatureId, index); return(StateOperationResult.Push(selectTargetState)); }
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 MenuSystemState(IGameAction gameAction, FDPosition central) : base(gameAction, central) { // Matching this.SetMenu(0, MenuItemId.SystemMatching, false, () => { subState = SubState.ConfirmMatching; MessageId message = MessageId.Create(MessageId.MessageTypes.Confirm, 1); TalkPack pack = new TalkPack(null, message); SendPack(pack); return(StateOperationResult.None()); }); // Record this.SetMenu(1, MenuItemId.SystemRecord, true, () => { ActionState nextState = new MenuRecordState(gameAction, central); return(StateOperationResult.Push(nextState)); }); // Settings this.SetMenu(2, MenuItemId.SystemSettings, true, () => { ActionState nextState = new MenuSettingsState(gameAction, central); return(StateOperationResult.Push(nextState)); }); // Rest All this.SetMenu(3, MenuItemId.SystemRestAll, true, () => { subState = SubState.ConfirmRestAll; MessageId message = MessageId.Create(MessageId.MessageTypes.Confirm, 1); TalkPack pack = new TalkPack(null, message); SendPack(pack); return(StateOperationResult.None()); }); }