Esempio n. 1
0
        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());
            });
        }
Esempio n. 2
0
        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());
            });
        }
Esempio n. 3
0
        private StateOperationResult OnSelectedEquipItem(int index)
        {
            if (index < 0)
            {
                // Cancel the selection
                return(StateOperationResult.None());
            }

            this.Creature.Data.EquipItemAt(index);

            // Reopen the item dialog
            CreatureShowInfoPack pack = new CreatureShowInfoPack(this.Creature, CreatureInfoType.SelectEquipItem);

            SendPack(pack);

            subState = SubActionState.SelectEquipItem;
            return(StateOperationResult.None());
        }
Esempio n. 4
0
        private StateOperationResult OnExchangeTreasureConfirmed(int index)
        {
            if (index == 0)
            {
                // Put it back
                TalkPack talkPack = new TalkPack(this.Creature.Clone(), MessageId.Create(MessageId.MessageTypes.Message, 7));
                SendPack(talkPack);

                gameAction.DoCreatureRest(this.CreatureId);
                return(StateOperationResult.Clear());
            }

            subState = SubActionState.ConfirmExchangeSelecting;
            CreatureShowInfoPack pack = new CreatureShowInfoPack(this.Creature, CreatureInfoType.SelectAllItem);

            SendPack(pack);

            return(StateOperationResult.None());
        }
Esempio n. 5
0
        private StateOperationResult OnPickTreasureConfirmed(int index)
        {
            if (treasureItem == null)
            {
                return(StateOperationResult.Clear());
            }

            if (index == 1)
            {
                TalkPack pack = new TalkPack(this.Creature.Clone(), MessageId.Create(MessageId.MessageTypes.Message, 3, treasureItem.ItemId));
                SendPack(pack);

                if (!this.Creature.Data.IsItemsFull())
                {
                    // Pick up it
                    this.Creature.Data.Items.Add(treasureItem.ItemId);
                    gameAction.PickTreasure(this.Creature.Position);
                    gameAction.DoCreatureRest(this.CreatureId);
                    return(StateOperationResult.Clear());
                }
                else
                {
                    // Confirm to exchange it
                    subState = SubActionState.ConfirmExchangeTreature;
                    ////PromptPack prompt = new PromptPack(this.Creature.Definition.AnimationId, "");
                    ////SendPack(prompt);
                    TalkPack prompt = new TalkPack(this.Creature.Clone(), MessageId.Create(MessageId.MessageTypes.Confirm, 7));
                    SendPack(prompt);

                    return(StateOperationResult.None());
                }
            }
            else
            {
                // Then discard it
                TalkPack pack = new TalkPack(this.Creature, MessageId.Create(MessageId.MessageTypes.Message, 2));
                SendPack(pack);

                gameAction.DoCreatureRest(this.CreatureId);
                return(StateOperationResult.Clear());
            }
        }