Esempio n. 1
0
        public Person(string fName, string lName, bool male, bool isHacker = false, string handle = null)
        {
            this.firstName = fName;
            this.lastName  = lName;
            this.isMale    = male;
            if (handle == null)
            {
                handle = UsernameGenerator.getName();
            }
            if (handle == null)
            {
                throw new InvalidOperationException();
            }
            this.handle     = handle;
            this.isHacker   = isHacker;
            this.birthplace = WorldLocationLoader.getRandomLocation();
            this.vehicles   = new List <VehicleRegistration>();
            this.degrees    = new List <Degree>();
            this.addRandomDegrees();
            this.addRandomVehicles();
            int num1 = 18;
            int num2 = 72;

            if (isHacker)
            {
                num2 = 45;
            }
            this.DateOfBirth   = DateTime.Now - TimeSpan.FromDays((double)(num1 * 365 + (int)(Utils.random.NextDouble() * (double)(num2 - num1) * 365.0)));
            this.medicalRecord = new MedicalRecord(this.birthplace, this.DateOfBirth);
            if (!Settings.EnableDLC || !DLC1SessionUpgrader.HasDLC1Installed || !isHacker && (double)Utils.randm(1f) >= 0.800000011920929)
            {
                return;
            }
            this.NeopalsAccount = NeopalsAccount.GenerateAccount(handle, Utils.flipCoin() && Utils.flipCoin() && isHacker && handle.ToLower() != "bit");
        }
Esempio n. 2
0
        protected override void LoadContent()
        {
            if (!CanLoadContent)
            {
                return;
            }
            PortExploits.populate();
            sman.controllingPlayer = PlayerIndex.One;
            if (Settings.isConventionDemo)
            {
                setWindowPosition(new Vector2(200f, 200f));
            }
            LoadGraphicsContent();
            LoadRegenSafeContent();
            var content = Content;

            GuiData.font        = content.Load <SpriteFont>("Font23");
            GuiData.titlefont   = content.Load <SpriteFont>("Kremlin");
            GuiData.smallfont   = Content.Load <SpriteFont>("Font12");
            GuiData.UISmallfont = GuiData.smallfont;
            GuiData.tinyfont    = Content.Load <SpriteFont>("Font10");
            GuiData.UITinyfont  = GuiData.tinyfont;
            GuiData.detailfont  = Content.Load <SpriteFont>("Font7");
            GuiData.spriteBatch = sman.SpriteBatch;
            GuiData.font        = content.Load <SpriteFont>("Font23");
            GuiData.titlefont   = content.Load <SpriteFont>("Kremlin");
            GuiData.smallfont   = Content.Load <SpriteFont>("Font12");
            GuiData.UISmallfont = GuiData.smallfont;
            GuiData.tinyfont    = Content.Load <SpriteFont>("Font10");
            GuiData.UITinyfont  = GuiData.tinyfont;
            GuiData.detailfont  = Content.Load <SpriteFont>("Font7");
            GuiData.init(Window);
            GuiData.InitFontOptions(Content);
            VehicleInfo.init();
            WorldLocationLoader.init();
            ThemeManager.init(content);
            MissionGenerationParser.init();
            MissionGenerator.init(content);
            UsernameGenerator.init();
            MusicManager.init(content);
            SFX.init(content);
            OldSystemSaveFileManifest.Load();
            SaveFileManager.Init();
            HasLoadedContent = true;
            LoadInitialScreens();
        }
Esempio n. 3
0
        public Person(string fName, string lName, bool male, bool isHacker = false, string handle = null)
        {
            firstName     = fName;
            lastName      = lName;
            isMale        = male;
            this.handle   = handle;
            this.isHacker = isHacker;
            birthplace    = WorldLocationLoader.getRandomLocation();
            vehicles      = new List <VehicleRegistration>();
            degrees       = new List <Degree>();
            addRandomDegrees();
            addRandomVehicles();
            var num1 = 18;
            var num2 = 72;

            if (isHacker)
            {
                num2 = 45;
            }
            DateOfBirth = DateTime.Now -
                          TimeSpan.FromDays(num1 * 365 + (int)(Utils.random.NextDouble() * (num2 - num1) * 365.0));
            medicalRecord = new MedicalRecord(birthplace, DateOfBirth);
        }
Esempio n. 4
0
        public static Person loadPersonFromFile(string path)
        {
            try
            {
                using (FileStream fileStream = new FileStream(path, FileMode.Open))
                {
                    XmlReader rdr = XmlReader.Create((Stream)fileStream, new XmlReaderSettings());
                    while (rdr.Name != "Person")
                    {
                        rdr.Read();
                    }
                    string str1;
                    string lName    = str1 = "unknown";
                    string fName    = str1;
                    string handle   = str1;
                    string str2     = str1;
                    bool   male     = true;
                    bool   isHacker = false;
                    bool   flag     = false;
                    if (rdr.MoveToAttribute("id"))
                    {
                        str2 = rdr.ReadContentAsString();
                    }
                    if (rdr.MoveToAttribute("handle"))
                    {
                        handle = rdr.ReadContentAsString();
                    }
                    if (rdr.MoveToAttribute("firstName"))
                    {
                        fName = rdr.ReadContentAsString();
                    }
                    if (rdr.MoveToAttribute("lastName"))
                    {
                        lName = rdr.ReadContentAsString();
                    }
                    if (rdr.MoveToAttribute("isMale"))
                    {
                        male = rdr.ReadContentAsBoolean();
                    }
                    if (rdr.MoveToAttribute("isHacker"))
                    {
                        isHacker = rdr.ReadContentAsBoolean();
                    }
                    if (rdr.MoveToAttribute("forceHasNeopals"))
                    {
                        flag = rdr.ReadContentAsBoolean();
                    }
                    Person person = new Person(fName, lName, male, isHacker, handle);
                    if (person.NeopalsAccount == null && flag && DLC1SessionUpgrader.HasDLC1Installed)
                    {
                        person.NeopalsAccount = NeopalsAccount.GenerateAccount(person.handle, Utils.flipCoin());
                    }
                    rdr.Read();
                    while (!(rdr.Name == "Person") || rdr.IsStartElement())
                    {
                        switch (rdr.Name)
                        {
                        case "Degrees":
                            List <Degree> degreeList = new List <Degree>();
                            rdr.Read();
                            while (!(rdr.Name == "Degrees") || rdr.IsStartElement())
                            {
                                if (rdr.Name == "Degree")
                                {
                                    string str3;
                                    string uniName = str3 = "UNKNOWN";
                                    double num     = 3.0;
                                    if (rdr.MoveToAttribute("uni"))
                                    {
                                        uniName = rdr.ReadContentAsString();
                                    }
                                    if (rdr.MoveToAttribute("gpa"))
                                    {
                                        num = rdr.ReadContentAsDouble();
                                    }
                                    int    content = (int)rdr.MoveToContent();
                                    Degree degree  = new Degree(rdr.ReadElementContentAsString(), uniName, (float)num);
                                    degreeList.Add(degree);
                                }
                                rdr.Read();
                            }
                            if (degreeList.Count > 0)
                            {
                                person.degrees = degreeList;
                                break;
                            }
                            break;

                        case "Birthplace":
                            string name = (string)null;
                            if (rdr.MoveToAttribute("name"))
                            {
                                name = rdr.ReadContentAsString();
                            }
                            if (name == null)
                            {
                                name = WorldLocationLoader.getRandomLocation().name;
                            }
                            person.birthplace = WorldLocationLoader.getClosestOrCreate(name);
                            break;

                        case "DOB":
                            CultureInfo cultureInfo = new CultureInfo("en-au");
                            int         content1    = (int)rdr.MoveToContent();
                            DateTime    dateTime    = Utils.SafeParseDateTime(rdr.ReadElementContentAsString());
                            if (dateTime.Hour == 0 && dateTime.Second == 0)
                            {
                                TimeSpan timeSpan = TimeSpan.FromHours(Utils.random.NextDouble() * 23.99);
                                dateTime += timeSpan;
                            }
                            person.DateOfBirth = dateTime;
                            break;

                        case "Medical":
                            person.medicalRecord = MedicalRecord.Load(rdr, person.birthplace, person.DateOfBirth);
                            break;
                        }
                        rdr.Read();
                    }
                    if (DLC1SessionUpgrader.HasDLC1Installed)
                    {
                        if (person.handle == "Minx" && person.NeopalsAccount == null)
                        {
                            person.NeopalsAccount = NeopalsAccount.GenerateAccount("Minx", false);
                        }
                        if (person.handle == "Orann" && person.NeopalsAccount == null && DLC1SessionUpgrader.HasDLC1Installed && People.PeopleWereGeneratedWithDLCAdditions)
                        {
                            person.NeopalsAccount = NeopalsAccount.GenerateAccount("Orann", false);
                        }
                    }
                    return(person);
                }
            }
            catch (FileNotFoundException ex)
            {
                return((Person)null);
            }
        }
Esempio n. 5
0
        public static Person loadPersonFromFile(string path)
        {
            try
            {
                using (var fileStream = new FileStream(path, FileMode.Open))
                {
                    var rdr = XmlReader.Create(fileStream, new XmlReaderSettings());
                    while (rdr.Name != "Person")
                    {
                        rdr.Read();
                    }
                    string str1;
                    var    lName    = str1 = "unknown";
                    var    fName    = str1;
                    var    handle   = str1;
                    var    male     = true;
                    var    isHacker = false;
                    if (rdr.MoveToAttribute("id"))
                    {
                        rdr.ReadContentAsString();
                    }
                    if (rdr.MoveToAttribute("handle"))
                    {
                        handle = rdr.ReadContentAsString();
                    }
                    if (rdr.MoveToAttribute("firstName"))
                    {
                        fName = rdr.ReadContentAsString();
                    }
                    if (rdr.MoveToAttribute("lastName"))
                    {
                        lName = rdr.ReadContentAsString();
                    }
                    if (rdr.MoveToAttribute("isMale"))
                    {
                        male = rdr.ReadContentAsBoolean();
                    }
                    if (rdr.MoveToAttribute("isHacker"))
                    {
                        isHacker = rdr.ReadContentAsBoolean();
                    }
                    var person = new Person(fName, lName, male, isHacker, handle);
                    rdr.Read();
                    while (!(rdr.Name == "Person") || rdr.IsStartElement())
                    {
                        switch (rdr.Name)
                        {
                        case "Degrees":
                            var list = new List <Degree>();
                            rdr.Read();
                            while (!(rdr.Name == "Degrees") || rdr.IsStartElement())
                            {
                                if (rdr.Name == "Degree")
                                {
                                    string str2;
                                    var    uniName = str2 = "UNKNOWN";
                                    var    num1    = 3.0;
                                    if (rdr.MoveToAttribute("uni"))
                                    {
                                        uniName = rdr.ReadContentAsString();
                                    }
                                    if (rdr.MoveToAttribute("gpa"))
                                    {
                                        num1 = rdr.ReadContentAsDouble();
                                    }
                                    var num2   = (int)rdr.MoveToContent();
                                    var degree = new Degree(rdr.ReadElementContentAsString(), uniName, (float)num1);
                                    list.Add(degree);
                                }
                                rdr.Read();
                            }
                            if (list.Count > 0)
                            {
                                person.degrees = list;
                            }
                            break;

                        case "Birthplace":
                            string name = null;
                            if (rdr.MoveToAttribute("name"))
                            {
                                name = rdr.ReadContentAsString();
                            }
                            if (name == null)
                            {
                                name = WorldLocationLoader.getRandomLocation().name;
                            }
                            person.birthplace = WorldLocationLoader.getClosestOrCreate(name);
                            break;

                        case "DOB":
                            var cultureInfo = new CultureInfo("en-au");
                            var num         = (int)rdr.MoveToContent();
                            var dateTime    = DateTime.Parse(rdr.ReadElementContentAsString(), cultureInfo);
                            if (dateTime.Hour == 0 && dateTime.Second == 0)
                            {
                                var timeSpan = TimeSpan.FromHours(Utils.random.NextDouble() * 23.99);
                                dateTime += timeSpan;
                            }
                            person.DateOfBirth = dateTime;
                            break;

                        case "Medical":
                            person.medicalRecord = MedicalRecord.Load(rdr, person.birthplace, person.DateOfBirth);
                            break;
                        }
                        rdr.Read();
                    }
                    return(person);
                }
            }
            catch (FileNotFoundException ex)
            {
                return(null);
            }
        }
Esempio n. 6
0
        protected override void LoadContent()
        {
            if (!this.CanLoadContent)
            {
                return;
            }
            PortExploits.populate();
            this.sman.controllingPlayer = PlayerIndex.One;
            if (Settings.isConventionDemo)
            {
                this.setWindowPosition(new Vector2(200f, 200f));
            }
            this.LoadGraphicsContent();
            this.LoadRegenSafeContent();
            ContentManager content = this.Content;

            GuiData.font        = content.Load <SpriteFont>("Font23");
            GuiData.titlefont   = content.Load <SpriteFont>("Kremlin");
            GuiData.smallfont   = this.Content.Load <SpriteFont>("Font12");
            GuiData.UISmallfont = GuiData.smallfont;
            GuiData.tinyfont    = this.Content.Load <SpriteFont>("Font10");
            GuiData.UITinyfont  = this.Content.Load <SpriteFont>("Font10");
            GuiData.detailfont  = this.Content.Load <SpriteFont>("Font7");
            GuiData.spriteBatch = this.sman.SpriteBatch;
            GuiData.InitFontOptions(this.Content);
            GuiData.init(this.Window);
            DLC1SessionUpgrader.CheckForDLCFiles();
            VehicleInfo.init();
            WorldLocationLoader.init();
            ThemeManager.init(content);
            MissionGenerationParser.init();
            MissionGenerator.init(content);
            UsernameGenerator.init();
            MusicManager.init(content);
            SFX.init(content);
            OldSystemSaveFileManifest.Load();
            try
            {
                SaveFileManager.Init(true);
            }
            catch (UnauthorizedAccessException ex)
            {
                MainMenu.AccumErrors += " ---- WARNING ---\nHacknet cannot access the Save File Folder (Path Below) to read/write save files.\nNO PROGRESS WILL BE SAVED.\n";
                MainMenu.AccumErrors += "Check folder permissions, run Hacknet.exe as Administrator, and try again.\n";
                MainMenu.AccumErrors += "If Errors Persist, search for \"Hacknet Workaround\" for a steam forums thread with more options.\n";
                MainMenu.AccumErrors  = MainMenu.AccumErrors + ":: Error Details ::\n" + Utils.GenerateReportFromException((Exception)ex);
            }
            if (this.NeedsSettingsLocaleActivation)
            {
                if (!Settings.ForceEnglish)
                {
                    string forActiveLanguage = PlatformAPISettings.GetCodeForActiveLanguage(LocaleActivator.SupportedLanguages);
                    LocaleActivator.ActivateLocale(forActiveLanguage, this.Content);
                    Settings.ActiveLocale = forActiveLanguage;
                }
            }
            else if (SettingsLoader.didLoad && Settings.ActiveLocale != "en-us")
            {
                LocaleActivator.ActivateLocale(Settings.ActiveLocale, this.Content);
            }
            Helpfile.init();
            FileEntry.init(this.Content);
            this.HasLoadedContent = true;
            this.LoadInitialScreens();
            if (!WebRenderer.Enabled)
            {
                return;
            }
            XNAWebRenderer.XNAWR_Initialize("file:///nope.html", WebRenderer.textureUpdated, 512, 512);
            WebRenderer.setSize(512, 512);
        }