public ViewModelFactory() { playerHand = new PlayerHand(); IPlayerService player = new PlayerService(playerHand); _controller = new SimulationController(player); }
public void Initialize( ISimulationController <WS> simulationController, OnlineSession onlineSession, int localPlayerControllersCapacity, int totalPlayerControllersCapacity, int initialReceivedPlayerCommandsCapacity, int snapshotsRingBufferCapacity) { _simulationController = simulationController; OnlineSession = onlineSession; LocalPlayerControllers = new Dictionary <int, PC>(localPlayerControllersCapacity); RegisteredPlayerControllers = new Dictionary <int, PC>(totalPlayerControllersCapacity); ReceivedPlayerCommandsBuffer = new List <TimestampedIdentifiedConnectionData <CMD> >(initialReceivedPlayerCommandsCapacity); OnlineSession.NetworkEventHandler = this; // Initialize snapshots SnapshotsCapacity = snapshotsRingBufferCapacity; SnapshotsRingBuffer = new GlobalSnapshot <CMD, WS> [SnapshotsCapacity]; for (int i = 0; i < SnapshotsCapacity; i++) { SnapshotsRingBuffer[i].SimulationEvents = new List <ISimulationEvent>(); SnapshotsRingBuffer[i].CommandsSnapshot.Initialize(totalPlayerControllersCapacity); _simulationController.InitializeSnapshot(ref SnapshotsRingBuffer[i].WorldSnapshot); } _tmpConnectionsToUpdateBuffer = new Dictionary <int, int>(totalPlayerControllersCapacity); InitializeAtTick(0); }
public MainWindow() { InitializeComponent(); _imageRunway = new Image(); _worker = new BackgroundWorker() { WorkerSupportsCancellation = true }; _worker.DoWork += BackgroundWorkerDoWork; _fpsList = new List <int>(); var bindings = new Bindings(); using (IKernel kernel = new StandardKernel(bindings)) { SimProperties = kernel.Get <ISimulationProperties>(); SimProperties.SimulationSpeed = 1; SimProperties.InstructionsPerMinute = 10; var canvas = new Ninject.Parameters.ConstructorArgument("canvas", CanvasDraw); SimController = kernel.Get <ISimulationController>(); kernel.Get <IDrawController>(canvas); _weatherController = kernel.Get <IWeatherController>(); } SimController.AirplaneManager.Collision += (o, e) => OnCollision(); Loaded += MainWindow_Loaded; SizeChanged += Image_Runway_Loaded; SimController.FlightDirector.AircraftLanded += FlightDirector_AircraftLanded; }
/// <summary> /// Creates a new thin client, instantly joining the specified server. /// </summary> /// <param name="server">The local server to join.</param> /// <param name="playerName">The player name to use.</param> /// <param name="playerData">The player data to use.</param> public ThinClientController(ISimulationController <IServerSession> server, string playerName, TPlayerData playerData) : base(new HybridClientSession <TPlayerData>()) { _server = server; Session.Join(_server.Session, playerName, playerData); }
public DrawController(Canvas canvas, ISimulationController simcontroller) { this._canvas = canvas; this._simController = simcontroller; this.AircraftImageList = new Dictionary <Aircraft, Image>(); this._simController.AircraftLanded += SimController_Aircraft_Landed; }
public MainViewModel(ISimulationController controller, IPlayerHand playerHand) { _controller = controller; _playerHand = playerHand; _roundCounts = controller.InitializeRoundCounts(); _simulatedDoubleQuote = "0% (0/0)"; _result = new Result(); My = 22; Sigma = 12; }
/// <summary> /// Creates a new client that will automatically connect to the given local server, and reuse the server's game /// state. /// </summary> /// <param name="game">The game to create the client for.</param> /// <param name="server">The server to couple the client with.</param> /// <returns>A new client.</returns> public static IClientController <FrameCommand> CreateLocalClient( Program game, ISimulationController <IServerSession> server) { // Create actual controller. var controller = new ThinClientController <Profile>( server, Settings.Instance.PlayerName, (Profile)Settings.Instance.CurrentProfile); // Check if the server has all the services we need (enough to // check for one, because we only add all at once -- here). if (server.Simulation.Manager.GetSystem(CameraSystem.TypeId) == null) { // Needed by some systems. Add all systems we need in // *addition* to the ones the server already has. AddSpaceClientSystems(server.Simulation.Manager, game, controller.Session, server); } // Done. return(controller); }
/// <summary>Adds systems only used by the client.</summary> /// <typeparam name="TSession">The type of the session.</typeparam> /// <param name="manager">The manager.</param> /// <param name="game">The game.</param> /// <param name="session">The session.</param> /// <param name="controller">The controller.</param> private static void AddSpaceClientSystems <TSession>( IManager manager, Game game, IClientSession session, ISimulationController <TSession> controller) where TSession : ISession { var audioEngine = (AudioEngine)game.Services.GetService(typeof(AudioEngine)); var audioRange = audioEngine.GetGlobalVariable("MaxAudibleDistance"); var soundBank = (SoundBank)game.Services.GetService(typeof(SoundBank)); var simulationSpeed = new Func <float>(() => controller.ActualSpeed); manager.AddSystems( new AbstractSystem[] { // Provide local player's avatar ID. new LocalPlayerSystem(session), // Trigger combat text rendering. new CombatTextSystem { Enabled = true }, // Provides interpolation of objects in view space. This uses the camera // for the viewport, but the camera uses it for its own position (based // on the avatar position). It's not so bad if we use the viewport of the // previous frame, but it's noticeable if the avatar is no longer at the // center, so we do it this way around. new CameraCenteredInterpolationSystem { Enabled = true }, // Update camera first, as it determines what to render. new CameraSystem(game.GraphicsDevice, game.Services), new CameraMovementSystem(), // Handle sound. new CameraCenteredSoundSystem(soundBank, audioRange) { Enabled = true }, // Biome system triggers background changes and stuff. new BiomeSystem { Enabled = true }, // Setup for post processing. new PostProcessingPreRenderSystem(), // Draw background behind everything else. new CameraCenteredBackgroundSystem { Enabled = true }, // Mind the order: orbits below planets below suns below normal // objects below particle effects below radar. new OrbitRenderSystem { Enabled = true }, new PlanetRenderSystem { Enabled = true }, new SunRenderSystem { Enabled = true }, new CameraCenteredTextureRenderSystem { Enabled = true }, new ShieldRenderSystem { Enabled = true }, new CameraCenteredParticleEffectSystem(simulationSpeed) { Enabled = true }, new InformationDisplaySystem { Enabled = true }, // Perform post processing on the rendered scene. new PostProcessingPostRenderSystem { Enabled = Settings.Instance.PostProcessing, Bloom = ParseBloomFromSettings() }, // Do not apply post processing to overlays. new FloatingTextSystem { Enabled = true }, new RadarRenderSystem { Enabled = true } }); // Add some systems for debug overlays. AddDebugSystems(manager); }