Beispiel #1
0
        private void mapComponent_SceneFinished(object sender, MapComponentEventArgs e)
        {
            SpriteRenderer currentTop = Owner.FindComponent <SpriteRenderer>(r => r.Name == "TopRenderer");

            goal += currentTop.Size.X;

            MapComponent mapComponent = Owner.FirstComponentOfType <MapComponent>();

            // Scenet loppuivat, kartta on suoritettu.
            if (!mapComponent.TryToScene())
            {
                return;
            }

            Console.WriteLine("Scene finished");

            // Uusien renderöijien alustus.
            SpriteRenderer nextTop = CreateRenderer("NextTop", e.Next.TopAssetName);

            nextTop.Position = new Vector2(goal, 0.0f);

            SpriteRenderer nextBottom = CreateRenderer("NextBottom", e.Next.BottomAssetName);

            nextBottom.Position = new Vector2(goal, nextTop.Size.Y);

            // Uusien seinien alustus.
            GameObject upper = CreateWall("NextUpperWall", new Vector2(nextBottom.Position.X, nextBottom.Position.Y + 70f), new Vector2(nextBottom.Size.X, 8f));
            GameObject lower = CreateWall("NextLowerWall", new Vector2(nextBottom.Position.X, nextBottom.Position.Y + nextBottom.Size.Y), new Vector2(nextBottom.Size.X, 8f));
            GameObject left  = CreateWall("NextLeftWall", new Vector2(nextBottom.Position.X - 8f, nextBottom.Position.Y), new Vector2(8f, nextBottom.Size.Y));
            GameObject right = CreateWall("NextRightWall", new Vector2(nextBottom.Position.X + nextBottom.Size.X, nextBottom.Position.Y), new Vector2(8f, nextBottom.Size.Y));

            // Tuhotaan vasen seinä jotta päästään liikkumaan.
            GameObject currentRight = Owner.Game.FindGameObject(g => g.Name == "RightWall");

            Owner.Game.World.RemoveBody(currentRight.Body);
            currentRight.Disable();

            // Disabloidaan lefti jotta päästään kävelemään läpi.
            Owner.Game.World.RemoveBody(left.Body);
            left.Disable();

#if DEBUG
            currentRight.Hide();
            left.Hide();
#endif

            GameObject   player       = Owner.Game.FindGameObject(g => g.Name.Contains("Player"));
            GoalDetector goalDetector = new GoalDetector(player, new Vector2(goal + currentTop.Size.X * 0.5f, 0.0f));

            player.AddComponent(goalDetector);

            goalDetector.AtGoal += goalDetector_AtGoal;
            goalDetector.Initialize();

            // TODO: debug.
            TextRenderer arrowRenderer = new TextRenderer(Owner)
            {
                Font        = Owner.Game.Content.Load <SpriteFont>("default"),
                Text        = "UNKLE GO HIER PLS =>",
                ScaleX      = 0.25f,
                ScaleY      = 0.25f,
                Y           = 150f,
                X           = nextTop.X - 200f,
                FollowOwner = false
            };

            Owner.AddComponent(nextTop);
            Owner.AddComponent(nextBottom);
            Owner.AddComponent(arrowRenderer);

            Owner.InitializeComponents();

            area = new Rectangle(area.X, area.Y, area.Width + (int)goal, area.Height);
        }
Beispiel #2
0
 private void mapComponent_MapFinished(object sender, MapComponentEventArgs e)
 {
     Console.WriteLine("Map finished");
 }