Beispiel #1
0
        public override void Load(IContentLoader loader)
        {
            _loader = loader;

            // Player
            player = new Player(eventBus, Camera);
            player.Load(loader);
            GameObjects.Add(player);

            // Game variables
            Jumps = new GameVariable <int>();
            Jumps.Load(loader);
            GameObjects.Add(Jumps);
            CoinsCount = new GameVariable <int>();
            CoinsCount.Load(loader);
            GameObjects.Add(CoinsCount);

            // Message manager
            textPopupManager = new TextPopupManager(ContentPaths.FONT_UI_GENERAL, StackingMethod.Parallel);
            textPopupManager.Load(loader);
            GameObjects.Add(textPopupManager);

            // HUD
            hud = new HUD(this);
            hud.ScreenBounds = base.Game.GraphicsDevice.Viewport.Bounds;
            hud.DrawOrder    = DrawOrderPosition.HUD;
            hud.Load(loader);
            GameObjects.Add(hud);

            // Physics
            phys = new MapPhysics(chunkMap, physSettings);
            GameObjects.Add(chunkMap);

            // Camera
            GameObjects.Add(Camera);

            // Services
            setupKeyListeners();

            // Event listeners
            eventBusSubscriptionIds.AddRange(new[] {
                eventBus.Subscribe(Events.PlayerPickedUpCoin, (p) => CoinsCount.Value += 1),
                eventBus.Subscribe(Events.PlayerJumped, (p) => Jumps.Value            += 1),
                eventBus.Subscribe(Events.PlayerEnteredDoor, (p) => playerTouchedDoor()),
                eventBus.Subscribe(Events.PlayerDied, (p) => playerDied()),
                eventBus.Subscribe(Events.CreateProjectile, (p) => playerCreatedProjectile(p as Projectile)),
            });

            // Load first map
            loadMap(ContentPaths.PATH_MAP_1);

            startGameTimer = new MillisecCounter(1500);
            Camera.SetFocus(playerExit, immediateFocus: true);
            isPlayerFocused = false;
        }
Beispiel #2
0
        public AnimationOverlay(string name, SpriteAnimationType animType, SpriteOriginType origin, int width, int height, int frames, int framerateMillisec, int yOffset)
        {
            drawingRect = new Rectangle(0, yOffset, width, height);

            ID             = Guid.NewGuid().ToString();
            Name           = name;
            AnimationType  = animType;
            FrameCount     = frames;
            FrameRateTimer = new MillisecCounter(framerateMillisec);

            //assign origin
            if (origin == SpriteOriginType.Center)
            {
                Origin = new Vector2(drawingRect.Width * 0.5f, drawingRect.Height * 0.5f);
            }
            else
            {
                Origin = Vector2.Zero;
            }
        }