Inheritance: MegaMan.Engine.Component
        public static ScreenHandler CreateScreen(Screen screen, PositionComponent playerPos, IEnumerable<Join> mapJoins)
        {
            List<BlocksPattern> blockPatterns = new List<BlocksPattern>();
            foreach (BlockPatternInfo info in screen.BlockPatternInfo)
            {
                BlocksPattern pattern = new BlocksPattern(info);
                blockPatterns.Add(pattern);
            }

            var joinList = new List<JoinHandler>();
            foreach (Join join in mapJoins)
            {
                if (join.screenOne == screen.Name || join.screenTwo == screen.Name)
                {
                    //JoinHandler handler = CreateJoin(join);
                    //joinList.Add(handler);
                }
            }

            Music music = null;

            string intropath = (screen.MusicIntroPath != null) ? screen.MusicIntroPath.Absolute : null;
            string looppath = (screen.MusicLoopPath != null) ? screen.MusicLoopPath.Absolute : null;
            if (intropath != null || looppath != null) music = Engine.Instance.SoundSystem.LoadMusic(intropath, looppath, 1);

            return new ScreenHandler(screen, music, playerPos, joinList, blockPatterns);
        }
        public void Start()
        {
            if (!blocks.Any())
            {
                foreach (Common.BlockInfo blockinfo in info.Blocks)
                {
                    BlockInfo myInfo = new BlockInfo { entity = _entityPool.CreateEntity(info.Entity) };
                    // should always persist off screen
                    PositionComponent pos = myInfo.entity.GetComponent<PositionComponent>();
                    pos.PersistOffScreen = true;
                    myInfo.pos = new PointF(blockinfo.pos.X, blockinfo.pos.Y);
                    myInfo.on = blockinfo.on;
                    myInfo.off = blockinfo.off;
                    blocks.Add(myInfo);
                }
            }

            this.playerPos = container.Entities.GetEntityById("Player").GetComponent<PositionComponent>();
            container.GameThink += Update;
            stopped = false;
        }
Example #3
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;
        }
Example #4
0
 public override void RegisterDependencies(Component component)
 {
     if (component is PositionComponent) position = component as PositionComponent;
     else if (component is CollisionComponent) collision = component as CollisionComponent;
 }
 public void Initialize()
 {
     _entityMock = new Mock<IEntity>();
     _position = new PositionComponent();
     _position.Parent = _entityMock.Object;
 }
        protected override void Finish(PositionComponent playerPos)
        {
            scrollDist = JoinInfo.type == JoinType.Vertical ? Game.CurrentGame.PixelsAcross : Game.CurrentGame.PixelsDown;

            doorTwo.SendMessage(new StateMessage(null, "Closing"));
            (doorTwo.GetComponent<StateComponent>()).StateChanged += s =>
            {
                if (s == "Start")
                {
                    base.Finish(playerPos);
                }
            };
            open = false;
        }
 public override void Update(PositionComponent playerPos)
 {
     if (open)
     {
         base.Update(playerPos);
     }
 }
 public override Component Clone()
 {
     PositionComponent copy = new PositionComponent {PersistOffScreen = this.PersistOffScreen};
     return copy;
 }
 protected void MovePlayer(PositionComponent playerPos)
 {
     if (direction == Direction.Right) playerPos.SetPosition(new PointF(playerPos.Position.X + tickdist, playerPos.Position.Y));
     else if (direction == Direction.Left) playerPos.SetPosition(new PointF(playerPos.Position.X - tickdist, playerPos.Position.Y));
     else if (direction == Direction.Down) playerPos.SetPosition(new PointF(playerPos.Position.X, playerPos.Position.Y + tickdist));
     else if (direction == Direction.Up) playerPos.SetPosition(new PointF(playerPos.Position.X, playerPos.Position.Y - tickdist));
 }
Example #10
0
        protected virtual void Finish(PositionComponent playerPos)
        {
            if (direction == Direction.Right) { playerPos.SetPosition(new PointF(OffsetDist(), playerPos.Position.Y + NextScreenY)); }
            else if (direction == Direction.Left) { playerPos.SetPosition(new PointF(nextWidth - OffsetDist(), playerPos.Position.Y + NextScreenY)); }
            else if (direction == Direction.Down) { playerPos.SetPosition(new PointF(playerPos.Position.X + NextScreenX, OffsetDist())); }
            else if (direction == Direction.Up) { playerPos.SetPosition(new PointF(playerPos.Position.X + NextScreenX, nextHeight - OffsetDist())); }

            if (ScrollDone != null) ScrollDone(this);
        }
Example #11
0
        public virtual void Update(PositionComponent playerPos)
        {
            scrollDist += Const.ScrollSpeed;
            if (JoinInfo.type == JoinType.Vertical && scrollDist >= Game.CurrentGame.PixelsAcross ||
                JoinInfo.type == JoinType.Horizontal && scrollDist >= Game.CurrentGame.PixelsDown)
            {
                Finish(playerPos);
            }
            else
            {
                MovePlayer(playerPos);
            }

            Calculate();
        }
Example #12
0
        protected override void BeforeStart()
        {
            Player = Entities.CreateEntityWithId("Player", "Player");
            PlayerPos = Player.GetComponent<PositionComponent>();

            Player.Death += Player_Death;

            PlayerPos = Player.GetComponent<PositionComponent>();
            PlayerPos.SetPosition(new PointF(startX, 0));

            if (!info.Screens.ContainsKey(startScreen)) throw new GameRunException("The start screen for \""+info.Name+"\" is supposed to be \""+startScreen+"\", but it doesn't exist!");
            _currentScreen = screens[startScreen];
            StartScreen();

            Engine.Instance.SoundSystem.StopMusicNsf();

            if (music != null) music.Play();
            if (info.MusicNsfTrack != 0) Engine.Instance.SoundSystem.PlayMusicNSF((uint)info.MusicNsfTrack);

            // updateFunc isn't set until BeginPlay
            drawFunc = DrawScreen;

            BeginPlay();

            // make sure we can move
            (Player.GetComponent<InputComponent>()).Paused = false;
        }