public void LoadScene(string path)
    {
        byte[] ojson = File.ReadAllBytes(path);

        var newRoot = SerializationUtility.DeserializeValue <Dictionary <string, SceneGameObject> >(ojson, DataFormat.JSON);

        mapLoader.LoadMap(newRoot);
    }
        public Environment Setup(string mapName, string troopFile)
        {
            var map         = _mapLoader.LoadMap(mapName);
            var allies      = _troopLoader.LoadAllies(troopFile);
            var adversaries = _troopLoader.LoadAdversaries(troopFile);
            var env         = _environmentFactory.CreateEnvironment(map, allies, adversaries);

            return(env);
        }
Esempio n. 3
0
        private async Task ChangeMapCore(int mMapID, int targetEntryPoint, int targetX, int targetY)
        {
            if (gameState.Map == null)
            {
                Player.MapID = mMapID;
                return;
            }

            var saveMap = gameState.MapExtender;
            var saveX   = Player.X;
            var saveY   = Player.Y;

            SetReturnLocationIfOutside();

            if (saveMap.MapID == mMapID || mMapID == 0)
            {
                var ep = DetermineEntryPoint(targetEntryPoint, targetX, targetY);

                MoveToEntryPoint(ep);

                return;
            }

            try
            {
                gameState.MapExtender = mapLoader.LoadMap(mMapID);
                Player.MapID          = mMapID;

                TransferAngryStateIfNeeded(saveMap);

                textArea.Clear();

                targetEntryPoint = ModifyTargetEntryPoint(targetEntryPoint);

                var ep = DetermineEntryPoint(targetEntryPoint, targetX, targetY);

                MoveToEntryPoint(ep);

                SetTilesAndCommands();
                gameState.MapExtender.OnLoad();
                museumCoinSale.ResetCoinOffers();
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Print(e.ToString());

                Player.MapID          = saveMap.MapID;
                gameState.MapExtender = saveMap;
                Player.X = saveX;
                Player.Y = saveY;

                throw;
            }

            await gameState.MapExtender.OnAfterEntry();
        }
Esempio n. 4
0
        public void Goto(string mapName)
        {
            Player player = GameState.Player;

            MapInfo mapInfo = FindMapByPartialName(mapName);

            if (mapInfo == null)
            {
                return;
            }

            var map = mapLoader.LoadMap(mapInfo.ParentMapID);
            int targetX = 0, targetY = 0;

            if (map == null)
            {
                Shell.WriteLine("Map not found.");
                return;
            }

            foreach (ChangeMapEvent evt in from evt in map.TheMap.Events
                     where evt is ChangeMapEvent
                     select(ChangeMapEvent) evt)
            {
                if (evt.MapID == mapInfo.ID)
                {
                    targetX = evt.X;
                    targetY = evt.Y;
                }
            }

            if (map.CanPlayerStepIntoImpl(targetX + 2, targetY))
            {
                targetX += 2;
            }
            else if (map.CanPlayerStepIntoImpl(targetX - 2, targetY))
            {
                targetX -= 2;
            }
            else if (map.CanPlayerStepIntoImpl(targetX, targetY + 2))
            {
                targetY += 2;
            }
            else if (map.CanPlayerStepIntoImpl(targetX, targetY - 2))
            {
                targetY -= 2;
            }

            ChangeMap(player, map.MapID, new Point(targetX, targetY));

            TextArea.Clear();
            commandExecutor.Prompt();
        }
Esempio n. 5
0
        public void Run(Player thePlayer)
        {
            if (thePlayer == null)
            {
                return;
            }

            gameState.Initialize(thePlayer);

            systemState.Factory = gameFactory;
            systemState.Factory.LoadSurfaces();
            systemState.Factory.SetGameSpeed(gameState, thePlayer.Gamespeed);

            var map = mapLoader.LoadMap(gameState.Player.MapID);

            mapChanger.SetMap(map);

            textArea.Clear();
            commandExecutor.Prompt();
        }
 public void LoadMap()
 {
     _mapLoader.LoadMap(EntityWorld);
     EventBus.Post(new CoreLoadedEvent());
     EventBus.Register(this);
 }