public Screen(Game game, bool fadeIn = false) : base(game) { Game = game as TerminalGame; _rectangle = new Rectangle(0, 0, Globals.Settings.GameWidth, Globals.Settings.GameHeight); _elements = new List <UIElement>(); _spriteBatch = new SpriteBatch(Game.GraphicsDevice); Content = Game.Content; _isInitialized = false; _opacity = fadeIn ? 0.0f : 1.0f; }
public virtual void Init(TerminalGame game, string optstring = null, string[] args = null) { if (!_isInitialized) { Game = game; _timer = new Timer(); _timer.Elapsed += Timer_Tick; _opString = optstring; _args = args; _isInitialized = true; } Run(); }
public void Init(TerminalGame game) { if (!_isInitialized) { if (ViewData == null) { ViewData = RemoteViewDataGenerator.GetDefaultViewData(this); } IsPlayerConnected = false; PlayerHasRoot = false; IsMissionObjective = false; IsShownOnMap = true; IsOnline = true; Game = game; SetPublicName(); _isInitialized = true; } }
public static Computer GenerateComputer(Company company, TerminalGame game, ComputerType type) { string fullType; switch (type) { case ComputerType.Laptop: { fullType = "Mobile Workstation"; break; } case ComputerType.Mainframe: { fullType = "Central Mainframe"; break; } case ComputerType.Server: { fullType = "Public Accses Server"; break; } case ComputerType.Workstation: { fullType = "Internal Workstation " + _rnd.Next(1, 101); break; } default: { fullType = type.ToString(); break; } } FileSystem gfs = Files.FileSystem.Generator.FileSystemGenerator.GenerateDefaultFilesystem(); return(new Computer(company.Name + "§¤§" + fullType, new int[] { 21, 22, 67, 80, 110, 443, 27015 }, type, company, fileSystem: gfs) { Game = game }); }
/// <summary> /// Generate a new, random world. /// </summary> public void CreateWorld(TerminalGame game, int companies) { DateTime beginWorld = DateTime.Now; Game = game; GameClock.Initialize(); CurrentGameTime = GameClock.GameTime; Player = new Player(); Player.CreateNewPlayer("testPlayer", "abc123"); Computers = new List <Computer>(); People = new List <Person>(); CompanyList = new List <Company>(); Files.File testFile = new Files.File("testFile", "this is a test", FileType.Text); Files.File testSubDir = new Files.File("test2"); testSubDir.AddFile(testFile); Files.File testDir = new Files.File("test"); testDir.AddFile(testSubDir); Files.File testRoot = new Files.File(""); testRoot.AddFile(testDir); Files.File testFile2 = new Files.File("testFile2", "test 2", FileType.Text); testRoot.AddFile(testFile2); FileSystem pfs = new FileSystem(testRoot); var bin = new Files.File("bin"); bin.AddFile(new Files.File("terminal", "terminal executable", FileType.Binary, 48374)); bin.AddFile(new Files.File("notepad", "notepad executable", FileType.Binary, 7522)); bin.AddFile(new Files.File("remoteview", "remoteview executable", FileType.Binary, 61325)); bin.AddFile(new Files.File("netmap", "netmap executable", FileType.Binary, 879820)); pfs.RootDir.AddFile(bin); Company mCorp = new Company("Mission Corp"); Computer mComp = new Computer("Mission Hub", new int[] { 80 }, ComputerType.Server, mCorp, "123.123.123.123", "swordfish", FileSystemGenerator.GenerateDefaultFilesystem()); mCorp.GetComputers.Add(mComp); CompanyList.Add(mCorp); Company pc = new Company("Unknown", new Person("Unknown", DateTime.Parse("1970-01-01"), (Gender)(-1), (EducationLevel)(-1)), new Person("Unknown", DateTime.Parse("1970-01-01"), (Gender)(-1), (EducationLevel)(-1)), 0, 0);; Computer PlayerComp = new Computer("localhost", new int[] { 69, 1337 }, ComputerType.Workstation, pc, "127.0.0.1", Player.Password, pfs) { Game = game }; Computers.Add(PlayerComp); DateTime beginCompanies = DateTime.Now; for (int i = 0; i < companies; i++) { Console.Write($"Creating company {i}/{companies}..."); Company comp = Company.GetRandomCompany(game); int whoops = 0; while (CheckIfNameExists(comp.Name)) { comp.Name = Companies.Generator.CompanyGenerator.GenerateName(); whoops++; } comp.GenerateComputers(); Console.WriteLine($"Done: {comp.Name}, whoopses: {whoops}."); CompanyList.Add(comp); } Console.WriteLine("Generated {0} companies in {1} seconds.", CompanyList.Count, (DateTime.Now.Subtract(beginCompanies).TotalSeconds).ToString("N4")); List <string> names = new List <string>(); foreach (Company c in CompanyList) { Computers.AddRange(c.GetComputers); People.AddRange(c.GetPeople); names.Add(c.Name); } List <string> test = SortByLength(names.AsEnumerable()).ToList(); foreach (string s in test) { Console.WriteLine(s); } foreach (Computer c in Computers) { c.Init(Game); if (c.Owner == CompanyList[35]) { c.IsMissionObjective = true; } } PlayerComp.PlayerHasRoot = true; PlayerComp.AccessLevel = AccessLevel.Root; Player.PlayerComp = PlayerComp; Console.WriteLine("Generated world in {0} seconds.", (DateTime.Now.Subtract(beginWorld).TotalSeconds).ToString("N4")); }
public static Company GetRandomCompany(TerminalGame game) => new Company(new Person(AgeRange.MiddleAged), new Person(AgeRange.Adult)) { Game = game };
public static void Parse(CommandToken token, TerminalGame game) { Console.WriteLine("Command: {0}", token.Command); switch (token.Command) { case "": { game.Terminal.Write(""); break; } case "echo": { Echo.GetInstance().Init(game, null, token.Args); break; } case "sudo": { game.Terminal.WriteLine("user is not in the sudoers file. This incidient will be reported."); break; } case "man": { break; } case "ip": { Ip.GetInstance().Init(game, null, token.Args); break; } case "ifconfig": case "ipconfig": { Ifconfig.GetInstance().Init(game, null, token.Args); break; } case "pwd": { game.Terminal.WriteLine($"{World.World.GetInstance().Player.ConnectedComp.FileSystem.CurrentDir.Name}"); break; } case "cls": case "clear": { game.Terminal.Clear(); break; } case "help": { game.Terminal.WriteLine(Utils.Help.GetHelp()); break; } case "reboot": { break; } case "shutdown": { break; } case "quit": case "exit": { break; } case "login": { break; } case "disconnect": case "dc": { Disconnect.GetInstance().Init(game, null, token.Args); break; } case "connect": { Connect.GetInstance().Init(game, null, token.Args); break; } case "rm": { Rm.GetInstance().Init(game, null, token.Args); break; } case "rmdir": { break; } case "mkdir": { Mkdir.GetInstance().Init(game, null, token.Args); break; } case "touch": { Touch.GetInstance().Init(game, null, token.Args); break; } case "cat": { Cat.GetInstance().Init(game, null, token.Args); break; } case "ls": case "dir": { Ls.GetInstance().Init(game, null, token.Args); break; } case "cd": { Cd.GetInstance().Init(game, null, token.Args); break; } case "save": { World.World.GetInstance().Save(); game.Terminal.WriteLine("Game saved."); break; } case "nmap": { Nmap.GetInstance().Init(game, null, token.Args); break; } case "sshnuke": { Sshnuke.GetIsntance().Init(game, null, token.Args); break; } default: { game.Terminal.WriteLine(token.Command + " is not a recognized command"); break; } } }