Ejemplo n.º 1
0
        private StateOperationResult OnExchangeTreasureSelected(int index)
        {
            if (index < 0)
            {
                // Cancelled, put it back
                TalkPack talkPack = new TalkPack(this.Creature.Clone(), MessageId.Create(MessageId.MessageTypes.Message, 7));
                SendPack(talkPack);
            }
            else
            {
                // Picked up xxx, put back xxxx
                if (index >= 0 && index < this.Creature.Data.Items.Count)
                {
                    int      exchangeItemId = this.Creature.Data.Items[index];
                    TalkPack talkPack       = new TalkPack(this.Creature.Clone(), MessageId.Create(MessageId.MessageTypes.Message, 6, treasureItem.ItemId, exchangeItemId));
                    SendPack(talkPack);

                    this.Creature.Data.RemoveItemAt(index);
                    this.Creature.Data.AddItem(treasureItem.ItemId);

                    // Add that item back to the treasure
                    gameAction.UpdateTreasure(this.Creature.Position, exchangeItemId);
                }
            }

            gameAction.DoCreatureRest(this.CreatureId);
            return(StateOperationResult.Clear());
        }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="creatureId"></param>
 /// <param name="sequenceId"></param>
 /// <param name="startIndex"></param>
 /// <param name="endIndex"></param>
 public void ShowTalk(int sequenceId, int startIndex, int endIndex)
 {
     for (int i = startIndex; i <= endIndex; i++)
     {
         ConversationId conversationId = ConversationId.Create(this.ChapterId(), sequenceId, i);
         string         key            = conversationId.GetKeyForId();
         if (chapterDefinition.ConversationIds.ContainsKey(key))
         {
             int        creatureId = chapterDefinition.ConversationIds[key];
             FDCreature creature   = this.GetCreature(creatureId);
             TalkPack   pack       = new TalkPack(creature.Clone(), conversationId);
             gameCallback.OnHandlePack(pack);
         }
     }
 }
Ejemplo n.º 3
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());
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo 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());
            }
        }
Ejemplo n.º 6
0
        private static ActivityBase BuildTalkActivity(TalkPack pack)
        {
            if (pack == null)
            {
                throw new ArgumentNullException("pack");
            }

            TalkActivity activity;

            if (pack.ConversationId != null)
            {
                activity = new TalkActivity(pack.Creature, pack.ConversationId);
            }
            else
            {
                activity = new TalkActivity(pack.Creature, pack.MessageId);
            }

            return(activity);
        }
Ejemplo n.º 7
0
        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());
            });
        }