public RoomGameplay(FreelancerGame g, CGameSession session, string newBase, BaseRoom room = null, string virtualRoom = null) : base(g) { this.session = session; baseId = newBase; currentBase = g.GameData.GetBase(newBase); currentRoom = room ?? currentBase.StartRoom; currentRoom.InitForDisplay(); SwitchToRoom(); tophotspots = new List <BaseHotspot>(); foreach (var hp in currentRoom.Hotspots) { if (TOP_IDS.Contains(hp.Name)) { tophotspots.Add(hp); } } var rm = virtualRoom ?? currentRoom.Nickname; SetActiveHotspot(rm); this.virtualRoom = virtualRoom; ui = new UiContext(Game, "baseside.xml"); ui.GameApi = new BaseUiApi(this); ui.Start(); Game.Keyboard.TextInput += Game_TextInput; Game.Keyboard.KeyDown += Keyboard_KeyDown; cursor = Game.ResourceManager.GetCursor("arrow"); FadeIn(0.8, 1.7); }
public RoomGameplay(FreelancerGame g, GameSession session, string newBase, BaseRoom room = null, string virtualRoom = null) : base(g) { this.session = session; baseId = newBase; currentBase = g.GameData.GetBase(newBase); currentRoom = room ?? currentBase.StartRoom; SwitchToRoom(); var tophotspots = new List <BaseHotspot>(); foreach (var hp in currentRoom.Hotspots) { if (TOP_IDS.Contains(hp.Name)) { tophotspots.Add(hp); } } hud = new Hud(g, tophotspots); hud.RoomMode(); hud.OnEntered += Hud_OnTextEntry; hud.OnManeuverSelected += Hud_OnManeuverSelected; this.virtualRoom = virtualRoom; hud.SetManeuver(virtualRoom ?? currentRoom.Nickname); Game.Keyboard.TextInput += Game_TextInput; Game.Keyboard.KeyDown += Keyboard_KeyDown; cursor = Game.ResourceManager.GetCursor("arrow"); }
public CGameSession(FreelancerGame g, IPacketConnection connection) { Game = g; this.connection = connection; rpcServer = new RemoteServerPlayer(connection, this); ResponseHandler = new NetResponseHandler(); }
public Cutscene(IEnumerable <ThnScript> scripts, SpaceGameplay gameplay) { this.game = gameplay.FlGame; World = gameplay.world; spawnObjects = false; camera = new ThnCamera(game.Viewport); //thn = script; var evs = new List <ThnEvent>(); foreach (var thn in scripts) { totalDuration = Math.Max(totalDuration, thn.Duration); foreach (var ev in thn.Events) { ev.TimeOffset = 0; evs.Add(ev); } AddEntities(thn); } evs.Sort((x, y) => x.Time.CompareTo(y.Time)); foreach (var item in evs) { events.Enqueue(item); } }
public XmlUIManager(FreelancerGame game, string apiname, object api, string src) { Game = game; this.apiname = apiname; this.api = api; xml = XInterface.Load(src); defaultFont = game.Fonts.GetSystemFont("Arial"); foreach (var fnt in game.GameData.Ini.Fonts.UIFonts) { uiFonts.Add(fnt.Nickname, game.Fonts.GetSystemFont(fnt.Font)); } if (xml.ResourceFiles != null) { foreach (var file in xml.ResourceFiles) { game.ResourceManager.LoadResourceFile(game.GameData.ResolveDataPath(file.Substring(2))); } } DoStyles(xml); LoadScene(xml.DefaultScene); game.Mouse.MouseDown += Mouse_MouseDown; game.Mouse.MouseUp += Mouse_MouseUp; game.Keyboard.TextInput += Keyboard_TextInput; game.Keyboard.KeyDown += Keyboard_KeyDown; }
public MainMenu(FreelancerGame g) : base(g) { g.GameData.LoadHardcodedFiles(); g.GameData.PopulateCursors(); g.MouseVisible = false; logoOverlay = g.GameData.GetFreelancerLogo(); g.WillClose += G_WillClose; manager = new UIManager(g); manager.MenuButton = g.GameData.GetMenuButton(); manager.Clicked += (tag) => lastTag = tag; ConstructMainMenu(); intro = g.GameData.GetIntroScene(); scene = new Cutscene(intro.Scripts, Game); scene.Update(TimeSpan.FromSeconds(1f / 60f)); //Do all the setup events - smoother entrance GC.Collect(); //crap g.Sound.PlayMusic(intro.Music); #if DEBUG g.Keyboard.KeyDown += Keyboard_KeyDown; #endif cur = g.ResourceManager.GetCursor("arrow"); GC.Collect(); //GC before showing }
public RoomGameplay(FreelancerGame g, GameSession session, string newBase, BaseRoom room = null, string virtualRoom = null) : base(g) { this.session = session; baseId = newBase; currentBase = g.GameData.GetBase(newBase); currentRoom = room ?? currentBase.StartRoom; currentRoom.InitForDisplay(); SwitchToRoom(); tophotspots = new List <BaseHotspot>(); foreach (var hp in currentRoom.Hotspots) { if (TOP_IDS.Contains(hp.Name)) { tophotspots.Add(hp); } } var rm = virtualRoom ?? currentRoom.Nickname; SetActiveHotspot(rm); this.virtualRoom = virtualRoom; hud = new ScriptedHud(new LuaAPI(this), false, Game); hud.OnEntered += Hud_OnTextEntry; hud.Init(); Game.Keyboard.TextInput += Game_TextInput; Game.Keyboard.KeyDown += Keyboard_KeyDown; cursor = Game.ResourceManager.GetCursor("arrow"); FadeIn(0.8, 1.7); }
public LuaMenu(FreelancerGame g) : base(g) { api = new MenuAPI(this); ui = Game.Ui; ui.GameApi = api; ui.Visible = true; ui.OpenScene("mainmenu"); g.GameData.PopulateCursors(); g.CursorKind = CursorKind.None; intro = g.GameData.GetIntroScene(); scene = new Cutscene(new ThnScriptContext(null), Game.GameData, Game.RenderContext.CurrentViewport, Game); scene.BeginScene(intro.Scripts); FLLog.Info("Thn", "Playing " + intro.ThnName); cur = g.ResourceManager.GetCursor("arrow"); GC.Collect(); //crap g.Sound.PlayMusic(intro.Music); g.Keyboard.KeyDown += UiKeyDown; g.Keyboard.TextInput += UiTextInput; #if DEBUG g.Keyboard.KeyDown += Keyboard_KeyDown; #endif Game.Saves.Selected = -1; if (g.LoadTimer != null) { g.LoadTimer.Stop(); FLLog.Info("Game", $"Initial load took {g.LoadTimer.Elapsed.TotalSeconds} seconds"); g.LoadTimer = null; } FadeIn(0.1, 0.3); }
public LoadingScreen(FreelancerGame game, IEnumerator <object> loader) { this.game = game; this.loader = loader; manager = new XmlUIManager(game, "game", null, game.GameData.GetInterfaceXml("loading")); manager.OnConstruct(); }
public LoadingScreen(FreelancerGame game, IEnumerator <object> loader) { this.game = game; this.loader = loader; ui = new UiContext(game); ui.CreateAll("loading.xml"); }
public GameSession(FreelancerGame g) { Game = g; PlayerShip = "li_elite"; PlayerSystem = "li01"; PlayerPosition = new Vector3(-31000, 0, -26755); PlayerOrientation = Matrix3.Identity; MountedEquipment.Add("hpthruster01", "ge_s_thruster_02"); }
public ScreenshotManager(FreelancerGame game) { Thread thr = new Thread(new ThreadStart(SaveThread)); thr.Name = "ScreenshotSaver"; thr.Start(); g = game; screenshotdir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "FreelancerShots"); }
public SpaceGameplay(FreelancerGame g, GameSession session) : base(g) { FLLog.Info("Game", "Entering system " + session.PlayerSystem); g.ResourceManager.ClearTextures(); //Do before loading things this.session = session; font = Game.Fonts.GetSystemFont("Agency FB"); sys = g.GameData.GetSystem(session.PlayerSystem); loader = new LoadingScreen(g, g.GameData.LoadSystemResources(sys)); }
public SpaceGameplay(FreelancerGame g, CGameSession session) : base(g) { FLLog.Info("Game", "Entering system " + session.PlayerSystem); g.ResourceManager.ClearTextures(); //Do before loading things this.session = session; sys = g.GameData.GetSystem(session.PlayerSystem); ui = Game.Ui; ui.GameApi = uiApi = new LuaAPI(this); loader = new LoadingScreen(g, g.GameData.LoadSystemResources(sys)); loader.Init(); }
public GameSession(FreelancerGame g) { Game = g; PlayerShip = "ge_fighter"; PlayerSystem = "li01"; PlayerPosition = new Vector3(-31000, 0, -26755); PlayerOrientation = Matrix3.Identity; MountedEquipment.Add("hpthruster01", "ge_s_thruster_02"); MountedEquipment.Add("hpweapon01", "li_gun01_mark01"); MountedEquipment.Add("hpweapon02", "li_gun01_mark01"); MountedEquipment.Add("hpweapon03", "li_gun01_mark01"); //MountedEquipment.Add("hpweapon04", "li_gun01_mark01"); }
public RoomGameplay(FreelancerGame g, CGameSession session, string newBase, BaseRoom room = null, string virtualRoom = null) : base(g) { //Load room data this.session = session; baseId = newBase; currentBase = g.GameData.GetBase(newBase); currentRoom = room ?? currentBase.StartRoom; currentRoom.InitForDisplay(); var rm = virtualRoom ?? currentRoom.Nickname; this.virtualRoom = virtualRoom; //Find infocard sys = g.GameData.GetSystem(currentBase.System); var obj = sys.Objects.FirstOrDefault((o) => { return(o.Base?.Equals(newBase, StringComparison.OrdinalIgnoreCase) ?? false); }); int ids = 0; if (obj?.IdsInfo.Length > 0) { ids = obj.IdsInfo[0]; } roomInfocard = g.GameData.GetInfocard(ids, g.Fonts); if (g.GameData.GetRelatedInfocard(ids, g.Fonts, out var ic2)) { roomInfocard.Nodes.Add(new RichTextParagraphNode()); roomInfocard.Nodes.AddRange(ic2.Nodes); } //Create user interface tophotspots = new List <BaseHotspot>(); foreach (var hp in currentRoom.Hotspots) { if (TOP_IDS.Contains(hp.Name)) { tophotspots.Add(hp); } } SetActiveHotspot(rm); Game.Keyboard.TextInput += Game_TextInput; Game.Keyboard.KeyDown += Keyboard_KeyDown; Game.Mouse.MouseDown += MouseOnMouseDown; cursor = Game.ResourceManager.GetCursor("arrow"); talk_story = Game.ResourceManager.GetCursor("talk_story"); ui = Game.Ui; ui.GameApi = new BaseUiApi(this); ui.OpenScene("baseside"); //Set up THN SwitchToRoom(room == null); FadeIn(0.8, 1.7); }
public IntroMovie(FreelancerGame game, int index) : base(game) { player = new VideoPlayer(game, game.MpvOverride); if ((inited = player.Init()) && game.IntroMovies.Count > 0) { idx = index; game.Keyboard.KeyDown += HandleKeyDown; player.PlayFile(game.IntroMovies[index]); } else { Leave(); } }
public void Launch() { if (Platform.RunningOS == OS.Windows) { string bindir = Path.GetDirectoryName(typeof(GameConfig).Assembly.Location); var fullpath = Path.Combine(bindir, IntPtr.Size == 8 ? "x64" : "x86"); SetDllDirectory(fullpath); } else { ForceAngle = false; } game = new FreelancerGame(this); game.Run(); }
public EngineComponent(GameObject parent, Engine engine, FreelancerGame game) : base(parent) { var fx = game.GameData.GetEffect(engine.FireEffect); var hps = parent.GetHardpoints(); foreach (var hp in hps) { if (!hp.Name.Equals("hpengineglow", StringComparison.OrdinalIgnoreCase) && hp.Name.StartsWith("hpengine", StringComparison.OrdinalIgnoreCase)) { fireFx.Add(new AttachedEffect(hp, new ParticleEffectRenderer(fx))); } } this.parent = parent; Engine = engine; }
public Cutscene(IEnumerable <ThnScript> scripts, FreelancerGame game, GameObject playerShip = null) { this.playerShip = playerShip; this.game = game; camera = new ThnCamera(game.Viewport); Renderer = new SystemRenderer(camera, game.GameData, game.ResourceManager, game); World = new GameWorld(Renderer); //thn = script; var evs = new List <ThnEvent>(); foreach (var thn in scripts) { totalDuration = Math.Max(totalDuration, thn.Duration); foreach (var ev in thn.Events) { ev.TimeOffset = 0; evs.Add(ev); } AddEntities(thn); } //work around SET_CAMERA not being called in disco (match vanilla behaviour) var firstCamera = Objects.Values.Where(x => x.Camera != null).FirstOrDefault(); if (firstCamera != null) { camera.Transform = firstCamera.Camera; } evs.Sort((x, y) => x.Time.CompareTo(y.Time)); foreach (var item in evs) { events.Enqueue(item); } //Add starspheres in the right order var sorted = ((IEnumerable <Tuple <IDrawable, Matrix4, int> >)layers).Reverse().OrderBy(x => x.Item3).ToArray(); Renderer.StarSphereModels = new IDrawable[sorted.Length]; Renderer.StarSphereWorlds = new Matrix4[sorted.Length]; for (int i = 0; i < sorted.Length; i++) { Renderer.StarSphereModels[i] = sorted[i].Item1; Renderer.StarSphereWorlds[i] = sorted[i].Item2; } //Add objects to the renderer World.RegisterAll(); }
public DemoSystemView(FreelancerGame g) : base(g) { FLLog.Info("Game", "Starting System Viewer Demo"); sys = g.GameData.GetSystem("li01"); camera = new DebugCamera(g.Viewport); camera.Zoom = 5000; sysrender = new SystemRenderer(camera, g.GameData, g.ResourceManager, g); world = new GameWorld(sysrender); world.LoadSystem(sys, g.ResourceManager); g.Sound.PlayMusic(sys.MusicSpace); camera.UpdateProjection(); trender = new Renderer2D(Game.RenderState); font = g.Fonts.GetSystemFont("Agency FB"); g.Keyboard.KeyDown += G_Keyboard_KeyDown; g.Keyboard.TextInput += G_Keyboard_TextInput; }
public GameSession(FreelancerGame g) { Game = g; Credits = 2000; PlayerShip = "li_elite"; PlayerBase = "li01_01_base"; PlayerSystem = "li01"; PlayerPosition = new Vector3(-31000, 0, -26755); PlayerOrientation = Matrix3.Identity; MountedEquipment.Add("hpthruster01", "ge_s_thruster_02"); MountedEquipment.Add("hpweapon01", "li_gun01_mark01"); MountedEquipment.Add("hpweapon02", "li_gun01_mark01"); MountedEquipment.Add("hpweapon03", "li_gun01_mark01"); MountedEquipment.Add("hpweapon04", "li_gun01_mark01"); MountedEquipment.Add("HpContrail01", "contrail01"); MountedEquipment.Add("HpContrail02", "contrail01"); }
public XmlUIManager(FreelancerGame game, string apiname, object api, string src) { Game = game; this.apiname = apiname; this.api = api; xml = XInterface.Load(src); Font = game.Fonts.GetSystemFont("Agency FB"); if (xml.ResourceFiles != null) { foreach (var file in xml.ResourceFiles) { game.ResourceManager.LoadResourceFile(game.GameData.ResolveDataPath(file.Substring(2))); } } DoStyles(xml); LoadScene(xml.DefaultScene); game.Mouse.MouseDown += Mouse_MouseDown; game.Mouse.MouseUp += Mouse_MouseUp; }
public LuaMenu(FreelancerGame g) : base(g) { api = new LuaAPI(this); ui = new XmlUIManager(g, "menu", api, g.GameData.GetInterfaceXml("mainmenu")); ui.OnConstruct(); ui.Enter(); g.GameData.PopulateCursors(); g.CursorKind = CursorKind.None; intro = g.GameData.GetIntroScene(); scene = new Cutscene(intro.Scripts, Game); scene.Update(TimeSpan.FromSeconds(1f / 60f)); //Do all the setup events - smoother entrance cur = g.ResourceManager.GetCursor("arrow"); GC.Collect(); //crap g.Sound.PlayMusic(intro.Music); #if DEBUG g.Keyboard.KeyDown += Keyboard_KeyDown; #endif FadeIn(0.1, 0.3); }
public SpaceGameplay(FreelancerGame g, GameSession session) : base(g) { FLLog.Info("Game", "Entering system " + session.PlayerSystem); g.ResourceManager.ClearTextures(); //Do before loading things this.session = session; font = Game.Fonts.GetSystemFont("Agency FB"); #if false pyw = new DebugGraph(); pyw.AddLine(Color4.Red, 240, -1, 1); pyw.AddLine(Color4.Green, 240, -1, 1); pyw.AddLine(Color4.Blue, 240, -1, 1); pyw.X = 850; pyw.Y = 10; pyw.Width = 170; pyw.Height = 124; #endif sys = g.GameData.GetSystem(session.PlayerSystem); loader = new LoadingScreen(g, g.GameData.LoadSystemResources(sys)); }
public NebulaRenderer(Nebula n, ICamera c, FreelancerGame g) { Nebula = n; camera = c; game = g; rand = new Random(); if (n.HasInteriorClouds) { puffsinterior = new InteriorPuff[n.InteriorCloudCount]; for (int i = 0; i < n.InteriorCloudCount; i++) { puffsinterior[i].Spawned = false; } } GenerateExteriorPuffs(); //Set Timers dynLightningTimer = Nebula.DynamicLightningGap; bckLightningTimer = Nebula.BackgroundLightningGap; }
public Hud(FreelancerGame game, List <GameData.BaseHotspot> hotspots = null) { manager = new UIManager(game); //backgrounds contactslist = new HudModelElement(manager, "hud_target.cmp", -0.73f, -0.69f, 2.1f, 2.9f); manager.Elements.Add(contactslist); shipinfo = new HudModelElement(manager, "hud_shipinfo.cmp", 0.73f, -0.69f, 2.1f, 2.9f); manager.Elements.Add(shipinfo); numberbox = new HudNumberBoxElement(manager); manager.Elements.Add(numberbox); gauge = new HudGaugeElement(manager); manager.Elements.Add(gauge); chatbox = new HudChatBox(manager); manager.Elements.Add(chatbox); //Maneuvers if (hotspots == null) { mnvs = game.GameData.GetManeuvers().ToList(); navbuttons = new HudNavBox(mnvs, manager); } else { navbuttons = new HudNavBox(game.GameData.GetBaseNavbarIcons(), hotspots, manager); } navbuttons.Show(); manager.Clicked += Manager_OnClick; reticle = game.ResourceManager.GetDrawable(game.GameData.ResolveDataPath("INTERFACE/HUD/hud_reticle.3db")); reticle_health = game.ResourceManager.GetDrawable(game.GameData.ResolveDataPath("INTERFACE/HUD/hud_reticle_health.3db")); reticle_shields = game.ResourceManager.GetDrawable(game.GameData.ResolveDataPath("INTERFACE/HUD/hud_reticle_shields.3db")); UI_HUD_targetarrow = game.ResourceManager.FindMaterial(CrcTool.FLModelCrc("UI_HUD_targetarrow")).Render; UI_HUD_targetingblue = game.ResourceManager.FindMaterial(CrcTool.FLModelCrc("UI_HUD_targetingblue")).Render; TextEntry = false; }
public LuaMenu(FreelancerGame g) : base(g) { api = new MenuAPI(this); ui = new UiContext(g); ui.GameApi = new MenuAPI(this); widget = ui.CreateAll("mainmenu.xml"); g.GameData.PopulateCursors(); g.CursorKind = CursorKind.None; intro = g.GameData.GetIntroScene(); scene = new Cutscene(new ThnScriptContext(intro.Scripts), Game.GameData, Game.Viewport, Game); scene.Update(TimeSpan.FromSeconds(1f / 60f)); //Do all the setup events - smoother entrance FLLog.Info("Thn", "Playing " + intro.ThnName); cur = g.ResourceManager.GetCursor("arrow"); GC.Collect(); //crap g.Sound.PlayMusic(intro.Music); #if DEBUG g.Keyboard.KeyDown += Keyboard_KeyDown; #endif FadeIn(0.1, 0.3); }
public SpaceGameplay(FreelancerGame g, GameSession session) : base(g) { FLLog.Info("Game", "Entering system " + session.PlayerSystem); g.ResourceManager.ClearTextures(); //Do before loading things this.session = session; #if false pyw = new DebugGraph(); pyw.AddLine(Color4.Red, 240, -1, 1); pyw.AddLine(Color4.Green, 240, -1, 1); pyw.AddLine(Color4.Blue, 240, -1, 1); pyw.X = 850; pyw.Y = 10; pyw.Width = 170; pyw.Height = 124; #endif sys = g.GameData.GetSystem(session.PlayerSystem); loader = new LoadingScreen(g, g.GameData.LoadSystemResources(sys)); ui = new UiContext(g); ui.GameApi = uiApi = new LuaAPI(this); widget = ui.CreateAll("hud.xml"); }
public Cutscene(IEnumerable <ThnScript> scripts, FreelancerGame game, GameObject playerShip = null) { this.playerShip = playerShip; this.game = game; camera = new ThnCamera(game.Viewport); Renderer = new SystemRenderer(camera, game.GameData, game.ResourceManager, game); World = new GameWorld(Renderer); //thn = script; var evs = new List <ThnEvent>(); foreach (var thn in scripts) { totalDuration = Math.Max(totalDuration, thn.Duration); foreach (var ev in thn.Events) { ev.TimeOffset = 0; evs.Add(ev); } AddEntities(thn); } evs.Sort((x, y) => x.Time.CompareTo(y.Time)); foreach (var item in evs) { events.Enqueue(item); } //Add starspheres in the right order layers.Sort((x, y) => x.Item3.CompareTo(y.Item3)); Renderer.StarSphereModels = new IDrawable[layers.Count]; Renderer.StarSphereWorlds = new Matrix4[layers.Count]; for (int i = 0; i < layers.Count; i++) { Renderer.StarSphereModels[i] = layers[i].Item1; Renderer.StarSphereWorlds[i] = layers[i].Item2; } //Add objects to the renderer World.RegisterAll(); }