Inheritance: MegaMan.Engine.GameHandler
Exemple #1
0
        public ScreenLayer(ScreenLayerInfo info, StageHandler stage, IEntityRespawnTracker respawnTracker)
        {
            this._info           = info;
            this._stage          = stage;
            this._respawnTracker = respawnTracker;

            this._squares = new MapSquare[info.Tiles.Height][];
            for (int y = 0; y < info.Tiles.Height; y++)
            {
                this._squares[y] = new MapSquare[info.Tiles.Width];
                for (int x = 0; x < info.Tiles.Width; x++)
                {
                    try
                    {
                        Tile tile = info.Tiles.TileAt(x, y);
                        if (tile == null)
                        {
                            throw new Exception();
                        }

                        this._squares[y][x] = new MapSquare(this, tile, x, y, info.Tiles.Tileset.TileSize);
                    }
                    catch
                    {
                        throw new GameRunException(string.Format("There's an error in stage {0}, screen file {1}.scn.\nThere's a unrecognized tile number somewhere.", stage.Info.Name, info.Name));
                    }
                }
            }
        }
Exemple #2
0
        public void Start(StageHandler map, GameEntity player)
        {
            this.stage = map;

            this.player = player;
            playerPos   = player.GetComponent <PositionComponent>();

            isAutoscrolling = false;

            foreach (var layer in layers)
            {
                layer.Start();
            }

            foreach (JoinHandler join in joins)
            {
                join.Start(this);
            }

            foreach (BlocksPattern pattern in patterns)
            {
                pattern.Start();
            }

            var autoscroll = (SceneAutoscrollCommandInfo)this.Screen.Commands.FirstOrDefault(c => c.Type == SceneCommands.Autoscroll);

            if (autoscroll != null)
            {
                autoscrollX     = autoscroll.StartX;
                autoscrollSpeed = (float)autoscroll.Speed;
            }

            container.GameThink += Instance_GameThink;
        }
        public ScreenLayer(ScreenLayerInfo info, StageHandler stage, IEntityRespawnTracker respawnTracker)
        {
            this._info = info;
            this._stage = stage;
            this._respawnTracker = respawnTracker;

            this._squares = new MapSquare[info.Tiles.Height][];
            for (int y = 0; y < info.Tiles.Height; y++)
            {
                this._squares[y] = new MapSquare[info.Tiles.Width];
                for (int x = 0; x < info.Tiles.Width; x++)
                {
                    try
                    {
                        Tile tile = info.Tiles.TileAt(x, y);
                        if (tile == null)
                            throw new Exception();

                        this._squares[y][x] = new MapSquare(this, tile, x, y, info.Tiles.Tileset.TileSize);
                    }
                    catch
                    {
                        throw new GameRunException(string.Format("There's an error in stage {0}, screen file {1}.scn.\nThere's a unrecognized tile number somewhere.", stage.Info.Name, info.Name));
                    }
                }
            }
        }
        private JoinHandler CreateJoin(Join join, StageHandler stage, ScreenInfo screen)
        {
            if (join.bossDoor)
            {
                return(new BossDoorHandler(join, stage, _entityPool, screen.Tileset.TileSize, screen.PixelHeight, screen.PixelWidth, screen.Name));
            }

            return(new JoinHandler(join, screen.Tileset.TileSize, screen.PixelHeight, screen.PixelWidth, screen.Name));
        }
        public void TryLoad(StageLinkInfo info)
        {
            var       stageReader = Game.CurrentGame.FileReaderProvider.GetStageReader(info.StagePath);
            StageInfo map         = stageReader.Load(info.StagePath);

            var handler = new StageHandler(map);

            var joins = new Dictionary <ScreenInfo, Dictionary <Join, JoinHandler> >();

            foreach (var screen in map.Screens.Values)
            {
                joins[screen] = new Dictionary <Join, JoinHandler>();
            }

            foreach (Join join in map.Joins)
            {
                var screenOne = map.Screens[join.screenOne];
                var screenTwo = map.Screens[join.screenTwo];

                JoinHandler handlerOne = CreateJoin(join, handler, screenOne);

                joins[screenOne].Add(join, handlerOne);

                JoinHandler handlerTwo = CreateJoin(join, handler, screenTwo);

                joins[screenTwo].Add(join, handlerTwo);
            }

            var screens = new Dictionary <string, ScreenHandler>();

            foreach (var screen in map.Screens.Values)
            {
                screens[screen.Name] = CreateScreen(handler, screen, joins[screen].Values.ToList());
            }

            handler.InitScreens(screens);

            handler.WinHandler = info.WinHandler;

            if (info.LoseHandler == null)
            {
                // repeat this stage
                handler.LoseHandler = new HandlerTransfer {
                    Fade = true, Type = HandlerType.Stage, Name = info.Name
                };
            }
            else
            {
                handler.LoseHandler = info.LoseHandler;
            }

            _loadedStages[info.Name] = handler;
        }
Exemple #6
0
        public void TryLoad(StageLinkInfo info)
        {
            var stageReader = new StageXmlReader();
            StageInfo map = stageReader.LoadStageXml(info.StagePath);

            var handler = new StageHandler(map);

            var joins = new Dictionary<ScreenInfo, Dictionary<Join, JoinHandler>>();

            foreach (var screen in map.Screens.Values)
            {
                joins[screen] = new Dictionary<Join, JoinHandler>();
            }

            foreach (Join join in map.Joins)
            {
                var screenOne = map.Screens[join.screenOne];
                var screenTwo = map.Screens[join.screenTwo];

                JoinHandler handlerOne = CreateJoin(join, handler, screenOne);

                joins[screenOne].Add(join, handlerOne);

                JoinHandler handlerTwo = CreateJoin(join, handler, screenTwo);

                joins[screenTwo].Add(join, handlerTwo);
            }

            var screens = new Dictionary<string, ScreenHandler>();
            foreach (var screen in map.Screens.Values)
            {
                screens[screen.Name] = CreateScreen(handler, screen, joins[screen].Values.ToList());
            }

            handler.InitScreens(screens);

            handler.WinHandler = info.WinHandler;

            if (info.LoseHandler == null)
            {
                // repeat this stage
                handler.LoseHandler = new HandlerTransfer { Fade = true, Type = HandlerType.Stage, Name = info.Name };
            }
            else
            {
                handler.LoseHandler = info.LoseHandler;
            }

            _loadedStages[info.Name] = handler;
        }
        private ScreenHandler CreateScreen(StageHandler stage, ScreenInfo screen, IEnumerable <JoinHandler> joins)
        {
            var patterns = new List <BlocksPattern>(screen.BlockPatterns.Count);

            foreach (BlockPatternInfo info in screen.BlockPatterns)
            {
                BlocksPattern pattern = new BlocksPattern(info, stage, _entityPool);
                patterns.Add(pattern);
            }

            var layers = new List <ScreenLayer>();

            foreach (var layerInfo in screen.Layers)
            {
                layers.Add(new ScreenLayer(layerInfo, stage, _respawnTracker));
            }

            return(new ScreenHandler(screen, layers, joins, patterns, stage));
        }
Exemple #8
0
        public ScreenLayer(ScreenLayerInfo info, StageHandler stage, IEntityRespawnTracker respawnTracker)
        {
            this._info = info;
            this._stage = stage;
            this._respawnTracker = respawnTracker;

            this._squares = new MapSquare[info.Tiles.Height][];
            for (int y = 0; y < info.Tiles.Height; y++)
            {
                this._squares[y] = new MapSquare[info.Tiles.Width];
                for (int x = 0; x < info.Tiles.Width; x++)
                {
                    try
                    {
                        Tile tile = info.Tiles.TileAt(x, y);
                        this._squares[y][x] = new MapSquare(this, tile, x, y, info.Tiles.Tileset.TileSize);
                    }
                    catch
                    {
                        throw new GameRunException("There's an error in screen file " + info.Name + ".scn,\nthere's a bad tile number somewhere.");
                    }
                }
            }
        }
Exemple #9
0
        public ScreenLayer(ScreenLayerInfo info, StageHandler stage, IEntityRespawnTracker respawnTracker)
        {
            this._info           = info;
            this._stage          = stage;
            this._respawnTracker = respawnTracker;

            this._squares = new MapSquare[info.Tiles.Height][];
            for (int y = 0; y < info.Tiles.Height; y++)
            {
                this._squares[y] = new MapSquare[info.Tiles.Width];
                for (int x = 0; x < info.Tiles.Width; x++)
                {
                    try
                    {
                        Tile tile = info.Tiles.TileAt(x, y);
                        this._squares[y][x] = new MapSquare(this, tile, x, y, info.Tiles.Tileset.TileSize);
                    }
                    catch
                    {
                        throw new GameRunException("There's an error in screen file " + info.Name + ".scn,\nthere's a bad tile number somewhere.");
                    }
                }
            }
        }
Exemple #10
0
        public void Start(StageHandler map, GameEntity player)
        {
            this.stage = map;

            this.player = player;
            playerPos = player.GetComponent<PositionComponent>();

            isAutoscrolling = false;

            foreach (var layer in layers)
            {
                layer.Start();
            }

            foreach (JoinHandler join in joins)
            {
                join.Start(this);
            }

            foreach (BlocksPattern pattern in patterns)
            {
                pattern.Start();
            }

            var autoscroll = (SceneAutoscrollCommandInfo)this.Screen.Commands.FirstOrDefault(c => c.Type == SceneCommands.Autoscroll);
            if (autoscroll != null)
            {
                autoscrollX = autoscroll.StartX;
                autoscrollSpeed = (float)autoscroll.Speed;
            }

            container.GameThink += Instance_GameThink;
        }
Exemple #11
0
        private ScreenHandler CreateScreen(StageHandler stage, ScreenInfo screen, IEnumerable<JoinHandler> joins)
        {
            var patterns = new List<BlocksPattern>(screen.BlockPatterns.Count);

            foreach (BlockPatternInfo info in screen.BlockPatterns)
            {
                BlocksPattern pattern = new BlocksPattern(info, stage, _entityPool);
                patterns.Add(pattern);
            }

            var layers = new List<ScreenLayer>();
            foreach (var layerInfo in screen.Layers)
            {
                layers.Add(new ScreenLayer(layerInfo, stage, _respawnTracker));
            }

            return new ScreenHandler(screen, layers, joins, patterns, stage);
        }
Exemple #12
0
        private JoinHandler CreateJoin(Join join, StageHandler stage, ScreenInfo screen)
        {
            if (join.bossDoor)
            {
                return new BossDoorHandler(join, stage, _entityPool, screen.Tileset.TileSize, screen.PixelHeight, screen.PixelWidth, screen.Name);
            }

            return new JoinHandler(join, screen.Tileset.TileSize, screen.PixelHeight, screen.PixelWidth, screen.Name);
        }