public Game() { m_promiseTasks = new List <PromiseTask>(); m_over = false; RenderUI = true; UseDebugCamera = false; // Init network if (App.Steam) { m_network = new SteamworksNetwork( AchievementExtensions.GetAllIDs(), StatisticExtensions.GetAllIDs() ); } else { m_network = new BuiltinNetwork(); } if (m_network.SupportsAchievements) { m_network.SetAchievementCorner(AchievementCorner.TopRight); } // Init user m_user = LoadUser(); // Init window var title = App.Info.Title + " " + App.Info.Version.ToString(); if (App.Debug && App.Steam) { title += " (Steam Debug build)"; } else if (App.Debug) { title += " (Debug build)"; } bool fullscreen = m_user.Settings.Fullscreen; bool vsync = m_user.Settings.VSync; using (var icon = new Bitmap(Path.Combine(App.AssetPath, "icon.png"))) { m_window = new SDL2Window( title, m_user.Settings.WindowWidth, m_user.Settings.WindowHeight, m_user.Settings.Fullscreen, m_user.Settings.WindowMaximised, m_user.Settings.VSync ); m_window.SetIcon(icon); } m_window.OnClosed += delegate(object sender, EventArgs e) { Over = true; }; m_window.OnResized += delegate(object sender, EventArgs e) { Resize(); if (!m_window.Fullscreen) { if (m_window.Maximised) { m_user.Settings.WindowMaximised = true; } else { m_user.Settings.WindowMaximised = false; m_user.Settings.WindowWidth = m_window.Width; m_user.Settings.WindowHeight = m_window.Height; } m_user.Settings.Save(); } }; // Init audio if (App.Arguments.GetBool("nosound")) { m_audio = new NullAudio(); } else { m_audio = new OpenALAudio(); } m_audio.EnableSound = m_user.Settings.EnableSound; m_audio.SoundVolume = m_user.Settings.SoundVolume / 11.0f; m_audio.EnableMusic = m_user.Settings.EnableMusic; m_audio.MusicVolume = m_user.Settings.MusicVolume / 11.0f; m_gameAudio = new GameAudio(m_audio); // Init input m_keyboard = new SDL2Keyboard(m_window); m_mouse = new SDL2Mouse(m_window); m_gamepads = new SDL2GamepadCollection(m_window); m_activeGamepad = null; if (App.Steam) { m_steamControllers = new SteamworksSteamControllerCollection( m_window, SteamControllerActionSetExtensions.GetAllIDs(), SteamControllerButtonExtensions.GetAllIDs(), SteamControllerJoystickExtensions.GetAllIDs(), SteamControllerAxisExtensions.GetAllIDs() ); m_readOnlySteamControllers = m_steamControllers; m_activeSteamController = null; } else { m_steamControllers = null; m_readOnlySteamControllers = new List <ISteamController>(0).ToReadOnly(); m_activeSteamController = null; } // Init tiles Tiles.Init(); // Load early assets var earlyAssetFileStore = new FolderFileStore(Path.Combine(App.AssetPath, "early")); var earlyAssets = new FileAssetSource("early", earlyAssetFileStore); Assets.AddSource(earlyAssets); Assets.LoadAll(); // Find mods Mods.Refresh(Network); if (Network.SupportsWorkshop) { // See if any mods are worthy of the popular mod achievement var myModIDs = new List <ulong>(); foreach (var mod in Mods.AllMods) { if (mod.Source == ModSource.Editor && mod.SteamWorkshopID.HasValue) { myModIDs.Add(mod.SteamWorkshopID.Value); } } if (myModIDs.Count > 0) { QueuePromiseTask( m_network.Workshop.GetItemInfo(myModIDs.ToArray()), delegate(Promise <WorkshopItemInfo[]> result) { if (result.Status == Status.Complete) { var infos = result.Result; int subs = 0; for (int i = 0; i < infos.Length; ++i) { var info = infos[i]; if (info.AuthorID == m_network.LocalUser.ID && info.UpVotes >= info.DownVotes) { subs = Math.Max(info.TotalSubscribers, subs); } } int oldSubs = User.Progress.GetStatistic(Statistic.MostPopularModSubscriptions); if (subs >= 25) { User.Progress.SetStatistic(Statistic.MostPopularModSubscriptions, subs); User.Progress.UnlockAchievement(Achievement.CreatePopularMod); User.Progress.Save(); } else if (subs > oldSubs) { User.Progress.SetStatistic(Statistic.MostPopularModSubscriptions, subs); User.Progress.IndicateAchievementProgress(Achievement.CreatePopularMod, subs, 25); User.Progress.Save(); } } } ); } } // Load language SelectLanguage(); // Load debug stuff m_debugCameraController = new DebugCameraController(this); // Load game Load(); }
private static void InputGamepadOnButtonUp(IGamepad arg1, Button arg2) { Console.WriteLine($"G{arg1.Index}> {arg2.Name} up."); }
/// <summary> /// Gets the <see cref="ButtonName.LeftStick" /> button. /// </summary> public static Button LeftStick(this IGamepad gamepad) => First(gamepad, ButtonName.LeftStick);
/// <summary> /// Gets the <see cref="ButtonName.DPadUp" /> button. /// </summary> public static Button DPadUp(this IGamepad gamepad) => First(gamepad, ButtonName.DPadUp);
/// <summary> /// Gets the <see cref="ButtonName.RightBumper" /> button. /// </summary> public static Button RightBumper(this IGamepad gamepad) => First(gamepad, ButtonName.RightBumper);
/// <summary> /// Gets the <see cref="ButtonName.Start" /> button. /// </summary> public static Button Start(this IGamepad gamepad) => First(gamepad, ButtonName.Start);
public InputState(IGamepad controller) => this.controller = controller;
/// <summary> /// Gets the <see cref="ButtonName.Y" /> button. /// </summary> public static Button Y(this IGamepad gamepad) => First(gamepad, ButtonName.Y);
public static GamepadState CaptureState(this IGamepad obj) => new GamepadState(obj);
public AggregateGamepad(IEnumerable <IGamepad> gamepads) { this.gamepads_ = gamepads; this.activeGamepad_ = gamepads.First(); }
public void Add(IGamepad gamepad) { m_GamepadList.Add(gamepad); }
public static FlightController FromGamepad( IGamepad gamepad, double thrustTrimStep, double pitchTrimStep, double rollTrimStep, double yawTrimStep) { var thrust = new Subject <double>(); var pitch = new Subject <double>(); var roll = new Subject <double>(); var yaw = new Subject <double>(); var controller = new FlightController(thrust, pitch, roll, yaw); gamepad.ThumbstickChanged += (sender, e) => { switch (e.Thumbstick) { case GamepadThumbstick.Left: thrust.OnNext(Math.Min(Math.Max(-e.Vertical, -1d), 1d)); yaw.OnNext(Math.Min(Math.Max(e.Horizontal, -1d), 1d)); break; case GamepadThumbstick.Right: pitch.OnNext(Math.Min(Math.Max(e.Vertical, -1d), 1d)); roll.OnNext(Math.Min(Math.Max(e.Horizontal, -1d), 1d)); break; } }; gamepad.ButtonPressed += (sender, e) => { switch (e.Button) { case GamepadButton.Up: controller.ThrustTrim += thrustTrimStep; break; case GamepadButton.Down: controller.ThrustTrim -= thrustTrimStep; break; case GamepadButton.Left: controller.YawTrim -= yawTrimStep; break; case GamepadButton.Right: controller.YawTrim += yawTrimStep; break; case GamepadButton.Y: controller.PitchTrim -= pitchTrimStep; break; case GamepadButton.A: controller.PitchTrim += pitchTrimStep; break; case GamepadButton.X: controller.RollTrim -= rollTrimStep; break; case GamepadButton.B: controller.RollTrim += rollTrimStep; break; case GamepadButton.Back: controller.ThrustTrim = 0d; controller.PitchTrim = 0d; controller.RollTrim = 0d; controller.YawTrim = 0d; break; } }; return(controller); }
public static FlightController FromGamepad(IGamepad gamepad, double trimStep = 0.01d) { return(FromGamepad(gamepad, trimStep, trimStep, trimStep, trimStep)); }
private static void GamepadOnTriggerMoved(IGamepad g, Trigger t) { Console.WriteLine($"G{g.Index}> {t.Index} trigger moved: {t.Position}"); }
public GamepadStateSnapshot GetStateSnapshot() { return(IGamepad.GetStateSnapshot(this)); }
private static void GamepadOnThumbstickMoved(IGamepad g, Thumbstick t) { Console.WriteLine($"G{g.Index}> {t.Index} thumbstick moved: ({t.X}, {t.Y})"); }
/// <summary> /// Gets the <see cref="ButtonName.DPadDown" /> button. /// </summary> public static Button DPadDown(this IGamepad gamepad) => First(gamepad, ButtonName.DPadDown);
/// <summary> /// Gets the <see cref="ButtonName.LeftBumper" /> button. /// </summary> public static Button LeftBumper(this IGamepad gamepad) => First(gamepad, ButtonName.LeftBumper);
private void GamepadTriggerMoved(IGamepad arg1, Trigger arg2) { internalState.SetTrigger(arg2); }
/// <summary> /// Gets the <see cref="ButtonName.Back" /> button. /// </summary> public static Button Back(this IGamepad gamepad) => First(gamepad, ButtonName.Back);
private void GamepadThumbstickMoved(IGamepad arg1, Thumbstick arg2) { internalState.SetThumbstick(arg2); }
/// <summary> /// Gets the <see cref="ButtonName.Home" /> button. /// </summary> public static Button Home(this IGamepad gamepad) => First(gamepad, ButtonName.Home);
private void GamepadButtonDown(IGamepad arg1, Silk.NET.Input.Button arg2) { internalState.SetButtonDown(arg2); }
/// <summary> /// Gets the <see cref="ButtonName.RightStick" /> button. /// </summary> public static Button RightStick(this IGamepad gamepad) => First(gamepad, ButtonName.RightStick);
private static void InputGamepadOnButtonDown(IGamepad arg1, Button arg2) { Console.WriteLine($"G{arg1.Index}> {arg2.Name} down. {(int) arg2.Name}"); }
/// <summary> /// Gets the <see cref="ButtonName.DPadRight" /> button. /// </summary> public static Button DPadRight(this IGamepad gamepad) => First(gamepad, ButtonName.DPadRight);
public GamepadVM(IGamepad gamepad) { //set fields _gamepad = gamepad; }