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(); }
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(); }
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); }