Beispiel #1
0
 public static SavedGameData FromModel(GameModel model)
 {
     return new SavedGameData
     {
         Inventory = model.Inventory.AllItems.ToDictionary(x => x.Key, x => SavedInventoryItemData.FromModel(x.Value)),
         PartyMember1Id = model.PartyMember1?.Id,
         PartyMember2Id = model.PartyMember2?.Id,
         PartyMember3Id = model.PartyMember3?.Id,
         PartyMember4Id = model.PartyMember4?.Id,
         Gold = model.CurrentGold,
         StepsTaken = model.CurrentSteps,
         TicksPlayed = model.TicksPlayed,
         PrimaryQuest = SavedPrimaryQuestData.FromModel(model.PrimaryQuest),
         SecondaryQuests = model.SecondaryQuests.ToArray(),
         PartyMembers = GameObjectFactory.Instance.GetAllPartyMembers().ToDictionary(x => x.Id, x => SavedPartyMemberData.FromModel(x)),
         MapModels = GameObjectFactory.Instance.GetAllMaps().ToDictionary(x => x.MapId, x => x.Model),
         GiftTypes = GameObjectFactory.Instance.GiftTypeContainer.GetAll().ToDictionary(x => x.Id, x => x.IsUnlocked)
     };
 }
Beispiel #2
0
        private void InitializeGameInfrastructure()
        {
            //point the resource utility to pull resources from our game implementation
            ResourceUtility.SetupAssemblies(Assembly.Load("VOStudios.Game1"));

            //We need to ensure the game object factory singleton is initialized early in the chain,
            //before any data is loaded or InitializeComponent is called
            GameObjectFactory.Instance = new ConcreteGameObjectFactory();

            ViewModel = GameModel.Instance;
        }
Beispiel #3
0
        public static void StartBattle(GameModel gameModel, String backgroundName, EnemyLayout enemyLayout)
        {
            //WPF requires dependency objects to be created on the UI thread.
            //TODO: How can I fix this?
            UiThread.Execute(() =>
            {
                BattleModel.Instance.BattlefieldData = BattlefieldData.New(backgroundName);
                BattleModel.Instance.BattleData = BattleData.New(gameModel.PartyMember1, gameModel.PartyMember2, gameModel.PartyMember3,
                    gameModel.PartyMember4, enemyLayout);
            });

            GameModel.Instance.State = GameState.InBattleNoInput;

            //start listening for messages 2 seconds after we start the process. This should give enough time
            //for the animation to play out, and the player to get his bearings. Also, start listening to messages at this point
            TimerUtility.ExecuteAfterDelay(DelayedAction.New(() =>
            {
                BattleModel.Instance.SubscribeToMessages();
                GameModel.Instance.State = GameState.InBattle;
            }, 2 * Constants.TIMING_TICKS_PER_SECOND));
        }