Beispiel #1
0
        public static AvatarState CreateAvatarState(string name,
                                                    Address agentAddress,
                                                    Address avatarAddress,
                                                    long blockIndex,
                                                    AvatarSheets avatarSheets,
                                                    WorldSheet worldSheet,
                                                    GameConfigState gameConfigState,
                                                    Address rankingMapAddress)
        {
            var avatarState = new AvatarState(
                avatarAddress,
                agentAddress,
                blockIndex,
                avatarSheets,
                gameConfigState,
                rankingMapAddress,
                name != string.Empty ? name : "testId"
                )
            {
                worldInformation = new WorldInformation(
                    0,
                    worldSheet,
                    GameConfig.RequireClearedStageLevel.ActionsInShop),
            };

            return(avatarState);
        }
Beispiel #2
0
        public AvatarState(Address address,
                           Address agentAddress,
                           long blockIndex,
                           AvatarSheets avatarSheets,
                           GameConfigState gameConfigState,
                           Address rankingMapAddress,
                           string name = null) : base(address)
        {
            if (address == null)
            {
                throw new ArgumentNullException(nameof(address));
            }

            this.name         = name ?? string.Empty;
            characterId       = GameConfig.DefaultAvatarCharacterId;
            level             = 1;
            exp               = 0;
            inventory         = new Inventory();
            worldInformation  = new WorldInformation(blockIndex, avatarSheets.WorldSheet, GameConfig.IsEditor);
            updatedAt         = blockIndex;
            this.agentAddress = agentAddress;
            questList         = new QuestList(
                avatarSheets.QuestSheet,
                avatarSheets.QuestRewardSheet,
                avatarSheets.QuestItemRewardSheet,
                avatarSheets.EquipmentItemRecipeSheet,
                avatarSheets.EquipmentItemSubRecipeSheet
                );
            mailBox         = new MailBox();
            this.blockIndex = blockIndex;
            actionPoint     = gameConfigState.ActionPointMax;
            stageMap        = new CollectionMap();
            monsterMap      = new CollectionMap();
            itemMap         = new CollectionMap();
            const QuestEventType createEvent = QuestEventType.Create;
            const QuestEventType levelEvent  = QuestEventType.Level;

            eventMap = new CollectionMap
            {
                new KeyValuePair <int, int>((int)createEvent, 1),
                new KeyValuePair <int, int>((int)levelEvent, level),
            };
            combinationSlotAddresses = new List <Address>(CombinationSlotCapacity);
            for (var i = 0; i < CombinationSlotCapacity; i++)
            {
                var slotAddress = address.Derive(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        CombinationSlotState.DeriveFormat,
                        i
                        )
                    );
                combinationSlotAddresses.Add(slotAddress);
            }

            combinationSlotAddresses = combinationSlotAddresses
                                       .OrderBy(element => element)
                                       .ToList();

            RankingMapAddress = rankingMapAddress;
            UpdateGeneralQuest(new[] { createEvent, levelEvent });
            UpdateCompletedQuest();

            PostConstructor();
        }