예제 #1
0
파일: Game.cs 프로젝트: TheOnlyMrFlow/FizX
        public Game(IGameBoundaries boundaries)
        {
            _inputManager  = boundaries.InputManager;
            _logger        = boundaries.Logger;
            _physicsEngine = boundaries.PhysicsEngine;
            _renderer      = boundaries.Renderer;
            _worldLoader   = boundaries.WorldLoader;
            _eventBus      = boundaries.EventBus;

            World = _worldLoader.LoadWorld();
        }
예제 #2
0
파일: Game.cs 프로젝트: Kripner/yolo
        public void StartLevel(IWorldLoader worldLoader)
        {
            ctx.Score = new Score();

            Entity player = CreatePlayer(worldLoader.PlayerStartVector);

            ctx.Player = (PlayerBehaviour)player.Behavior;

            ctx.World = worldLoader.LoadWorld(ctx);
            ctx.World.CurrentScene.AddEntity(player);

            ctx.Camera.Target = player;
            ctx.Camera.Update();

            ctx.Renderer.RebuildTerrainMesh();
        }
예제 #3
0
        public World([NotNull] IWorldLoader worldLoader, [NotNull] string world)
        {
            worldLoader.LoadWorld(world);
            this._worldSize         = worldLoader.WorldSize;
            this._tiles             = worldLoader.FloorTiles;
            this._restartInSameRoom = worldLoader.RestartInSameRoom;
            this._playerStartStates = worldLoader.PlayerStartStates;

            var boundMovementFactory = new BoundMovementFactory(this._worldSize);

            GlobalServices.SetBoundMovementFactory(boundMovementFactory);

            var gameObjectCollection = new GameObjectCollection(worldLoader.WorldSize);
            var gameState            = new GameState(gameObjectCollection);

            GlobalServices.SetGameState(gameState);
            worldLoader.AddGameObjects(gameState);
            this._player = gameState.Player;

            this._worldClock = new WorldClock();
            if (worldLoader.UnlockLevels)
            {
                this._worldClock.AddEventHandler(new UnlockLevel(this));
            }
            foreach (var dist in worldLoader.FruitDistributions.Where(item => item.PopulationMethod.WillReplenish()))
            {
                var replenishFruit = new ReplenishFruit(dist);
                this._worldClock.AddEventHandler(replenishFruit);
            }

            this._worldWindow = new WorldWindow();
            GlobalServices.SetCentrePointProvider(this._worldWindow);

            ValidateGameState(gameState);

            Messenger.Default.Register <WorldCompleted>(this, WorldCompleted);
            Messenger.Default.Register <LifeLost>(this, LostLife);
        }