public Enemy(int id, string name, AllStats stats, int exp)
 {
     this.id          = id;
     this.name        = name;
     this.stats       = stats;
     this.expReceived = exp;
 }
            public void Should_return_team_stats_correctly()
            {
                // Arrange

                // Act
                AllStats allStats = MatchData.CreateFiles(ProcessedData, false);

                // Assess
                allStats.teamStats.Count.ShouldBe(2);

                allStats.teamStats[0].Round.ShouldBe(1);
                allStats.teamStats[0].TeamAlphaKills.ShouldBe(1);
                allStats.teamStats[0].TeamAlphaDeaths.ShouldBe(0);
                allStats.teamStats[0].TeamAlphaHeadshots.ShouldBe(1);
                allStats.teamStats[0].TeamBravoKills.ShouldBe(0);
                allStats.teamStats[0].TeamBravoDeaths.ShouldBe(1);
                allStats.teamStats[0].TeamBravoHeadshots.ShouldBe(0);
                allStats.teamStats[0].TeamAlphaShotsFired.ShouldBe(3);
                allStats.teamStats[0].TeamBravoShotsFired.ShouldBe(0);

                allStats.teamStats[1].Round.ShouldBe(2);
                allStats.teamStats[1].TeamAlphaKills.ShouldBe(1);
                allStats.teamStats[1].TeamAlphaDeaths.ShouldBe(0);
                allStats.teamStats[1].TeamAlphaHeadshots.ShouldBe(1);
                allStats.teamStats[1].TeamBravoKills.ShouldBe(0);
                allStats.teamStats[1].TeamBravoDeaths.ShouldBe(1);
                allStats.teamStats[1].TeamBravoHeadshots.ShouldBe(0);
                allStats.teamStats[1].TeamAlphaShotsFired.ShouldBe(3);
                allStats.teamStats[1].TeamBravoShotsFired.ShouldBe(1);
            }
        public void TestInitialize()
        {
            this.mockRepository = new MockRepository(MockBehavior.Strict);

            this.mockAverageValues    = this.mockRepository.Create <IAverageValues>();
            this.mockPercentageValues = this.mockRepository.Create <IPercentageValues>();

            var binDirectory   = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location).TrimEnd(@"\bin".ToArray());
            var dataFilePath   = Path.GetFullPath(Path.Combine(binDirectory, Constants.DataFileName));
            var testDataString = File.ReadAllText(dataFilePath);

            testData = JsonConvert.DeserializeObject <List <ProcessedTweet> >(testDataString);

            var dataAllStatsFilePath   = Path.GetFullPath(Path.Combine(binDirectory, Constants.DataFileAllStatsName));
            var testDataAllStatsString = File.ReadAllText(dataAllStatsFilePath);

            testDataAllStats = JsonConvert.DeserializeObject <AllStats>(testDataAllStatsString);


            this.mockAverageValues.Setup(o => o.GetAverage(testData, TimeDivision.PerSecond)).Returns(57.45645);
            this.mockAverageValues.Setup(o => o.GetAverage(testData, TimeDivision.PerMinute)).Returns(245.3563);
            this.mockAverageValues.Setup(o => o.GetAverage(testData, TimeDivision.PerHour)).Returns(3456.435324);

            topValues = new TopValues();
            var top5domains  = topValues.TopDomains(testData.Select(o => o.Urls).ToList());
            var top5Hashtags = topValues.TopEmoji(testData.Select(o => o.Emojis).ToList());
            var top5Mentions = topValues.TopValue(testData.Select(o => o.Hashtags).ToList());
            var top5Emojis   = topValues.TopDomains(testData.Select(o => o.Urls).ToList());

            this.mockPercentageValues.Setup(o => o.GetPercentage(testData, SearchType.InstagramLink)).Returns(25.539568345323744);
            this.mockPercentageValues.Setup(o => o.GetPercentage(testData, SearchType.TwitterPicture)).Returns(25.539568345323744);
            this.mockPercentageValues.Setup(o => o.GetPercentage(testData, SearchType.Emojis)).Returns(25.539568345323744);
            this.mockPercentageValues.Setup(o => o.GetPercentage(testData, SearchType.Urls)).Returns(35.611510791366911);
        }
            public void Should_return_rounds_stats_correctly()
            {
                // Arrange

                // Act
                AllStats allStats = MatchData.CreateFiles(ProcessedData, false);

                // Assess
                allStats.roundsStats.Count.ShouldBe(2);

                allStats.roundsStats[0].BombPlantPositionX.ShouldBe(100);
                allStats.roundsStats[0].BombPlantPositionY.ShouldBe(100);
                allStats.roundsStats[0].BombPlantPositionZ.ShouldBe(100);
                allStats.roundsStats[0].BombsiteErrorMessage.ShouldBeNull();
                allStats.roundsStats[0].BombsitePlantedAt.ShouldBe("A");
                allStats.roundsStats[0].Half.ShouldBe("First");
                allStats.roundsStats[0].HostageAPickedUpErrorMessage.ShouldBeNull();
                allStats.roundsStats[0].HostageBPickedUpErrorMessage.ShouldBeNull();
                allStats.roundsStats[0].Length.ShouldBe(80);
                allStats.roundsStats[0].Overtime.ShouldBe(0);
                allStats.roundsStats[0].PickedUpAllHostages.ShouldBe(true);
                allStats.roundsStats[0].PickedUpHostageA.ShouldBe(true);
                allStats.roundsStats[0].PickedUpHostageB.ShouldBe(true);
                allStats.roundsStats[0].RescuedAllHostages.ShouldBe(true);
                allStats.roundsStats[0].RescuedHostageA.ShouldBe(true);
                allStats.roundsStats[0].RescuedHostageB.ShouldBe(true);
                allStats.roundsStats[0].Round.ShouldBe(1);
                allStats.roundsStats[0].TimeInRoundPlanted.ShouldBe(35);
                allStats.roundsStats[0].TimeInRoundExploded.ShouldBe(75);
                allStats.roundsStats[0].TimeInRoundDefused.ShouldBeNull();
                allStats.roundsStats[0].TimeInRoundRescuedHostageA.ShouldBe(50);
                allStats.roundsStats[0].TimeInRoundRescuedHostageB.ShouldBe(51);
                allStats.roundsStats[0].WinMethod.ShouldBe("Bombed");
                allStats.roundsStats[0].Winners.ShouldBe("Terrorist");

                allStats.roundsStats[1].BombPlantPositionX.ShouldBe(400);
                allStats.roundsStats[1].BombPlantPositionY.ShouldBe(400);
                allStats.roundsStats[1].BombPlantPositionZ.ShouldBe(400);
                allStats.roundsStats[1].BombsiteErrorMessage.ShouldBeNull();
                allStats.roundsStats[1].BombsitePlantedAt.ShouldBe("B");
                allStats.roundsStats[1].Half.ShouldBe("Second");
                allStats.roundsStats[1].HostageAPickedUpErrorMessage.ShouldBeNull();
                allStats.roundsStats[1].HostageBPickedUpErrorMessage.ShouldBeNull();
                allStats.roundsStats[1].Length.ShouldBe(105);
                allStats.roundsStats[1].Overtime.ShouldBe(0);
                allStats.roundsStats[1].PickedUpAllHostages.ShouldBe(false);
                allStats.roundsStats[1].PickedUpHostageA.ShouldBe(true);
                allStats.roundsStats[1].PickedUpHostageB.ShouldBe(false);
                allStats.roundsStats[1].RescuedAllHostages.ShouldBe(false);
                allStats.roundsStats[1].RescuedHostageA.ShouldBe(false);
                allStats.roundsStats[1].RescuedHostageB.ShouldBe(false);
                allStats.roundsStats[1].Round.ShouldBe(2);
                allStats.roundsStats[1].TimeInRoundPlanted.ShouldBe(60);
                allStats.roundsStats[1].TimeInRoundExploded.ShouldBeNull();
                allStats.roundsStats[1].TimeInRoundDefused.ShouldBe(100);
                allStats.roundsStats[1].TimeInRoundRescuedHostageA.ShouldBeNull();
                allStats.roundsStats[1].TimeInRoundRescuedHostageB.ShouldBeNull();
                allStats.roundsStats[1].WinMethod.ShouldBe("Defused");
                allStats.roundsStats[1].Winners.ShouldBe("CounterTerrorist");
            }
Exemple #5
0
 public Stat this[int idx]
 {
     get
     {
         return(AllStats.GetStat(idx));
     }
 }
            public void Should_return_map_info_correctly_for_wingman_hostage_maps()
            {
                // Arrange
                var ProcessedData3 = ProcessedData;

                ProcessedData3.DemoInformation = new DemoInformation()
                {
                    DemoName = "demo4",
                    MapName  = "de_testmap4",
                    TestDate = new DateTime(2020, 1, 1, 0, 0, 0).ToString(),
                    TestType = "Wingman",
                };
                ProcessedData3.MatchStartValues = new List <MatchStartedEventArgs>()
                {
                    new MatchStartedEventArgs
                    {
                        Mapname      = "de_testmap4",
                        HasBombsites = false,
                    }
                };

                // Act
                AllStats allStats = MatchData.CreateFiles(ProcessedData, false);

                // Assess
                allStats.mapInfo.DemoName.ShouldBe("demo4");
                allStats.mapInfo.MapName.ShouldBe("de_testmap4");
                allStats.mapInfo.TestDate.ShouldBe(new DateTime(2020, 1, 1, 0, 0, 0).ToString());
                allStats.mapInfo.TestType.ShouldBe("Wingman");
            }
            public void Should_return_chicken_stats_correctly()
            {
                // Arrange

                // Act
                AllStats allStats = MatchData.CreateFiles(ProcessedData, false);

                // Assess
                allStats.chickenStats.Killed.ShouldBe(1);
            }
Exemple #8
0
    void RandomCharacterStars()
    {
        stars = new AllStats();

        FieldInfo[] fInfos = stars.GetType().GetFields();
        FieldInfo   fInfo  = stars.GetType().GetFields()[UnityEngine.Random.Range(0, fInfos.Length)];

        fInfo.SetValue(this.stars, (int)fInfo.GetValue(this.stars) + 1);
        Debug.Log($"{name} {fInfo.Name}");
    }
            public void Should_return_version_number_correctly()
            {
                // Arrange

                // Act
                AllStats allStats = MatchData.CreateFiles(ProcessedData, false);

                // Assess
                allStats.versionNumber.Version.ShouldBe("1.1.16");
            }
Exemple #10
0
 public void IncreaseStats(AllStats _stats)
 {
     stats.craftsmanship += _stats.craftsmanship;
     stats.immunity      += _stats.immunity;
     stats.intelligence  += _stats.intelligence;
     stats.luck          += _stats.luck;
     stats.perception    += _stats.perception;
     stats.speed         += _stats.speed;
     stats.strength      += _stats.strength;
 }
Exemple #11
0
 public void DecreaseStats(AllStats _stats)
 {
     stats.craftsmanship -= _stats.craftsmanship;
     stats.immunity      -= _stats.immunity;
     stats.intelligence  -= _stats.intelligence;
     stats.luck          -= _stats.luck;
     stats.perception    -= _stats.perception;
     stats.speed         -= _stats.speed;
     stats.strength      -= _stats.strength;
 }
Exemple #12
0
            public void Should_return_winners_stats_correctly()
            {
                // Arrange

                // Act
                AllStats allStats = MatchData.CreateFiles(ProcessedData, false);

                // Assess
                allStats.winnersStats.TeamAlphaRounds.ShouldBe(2);
                allStats.winnersStats.TeamBetaRounds.ShouldBe(0);
                allStats.winnersStats.WinningTeam.ShouldBe("Team Alpha");
            }
Exemple #13
0
            public void Should_return_feedback_messages_correctly()
            {
                // Arrange

                // Act
                AllStats allStats = MatchData.CreateFiles(ProcessedData, false);

                // Assess
                allStats.feedbackMessages.Count.ShouldBe(1);
                allStats.feedbackMessages[0].Round.ShouldBe(1);
                allStats.feedbackMessages[0].Message.ShouldBe("bad map");
            }
Exemple #14
0
            public void Should_return_supported_gamemodes_correctly()
            {
                // Arrange

                // Act
                AllStats allStats = MatchData.CreateFiles(ProcessedData, false);

                // Assess
                allStats.supportedGamemodes.Count.ShouldBe(3);
                allStats.supportedGamemodes[0].ShouldBe("Defuse");
                allStats.supportedGamemodes[1].ShouldBe("Hostage");
                allStats.supportedGamemodes[2].ShouldBe("Wingman");
            }
Exemple #15
0
            public void Should_return_map_info_correctly_for_defuse_maps()
            {
                // Arrange

                // Act
                AllStats allStats = MatchData.CreateFiles(ProcessedData, false);

                // Assess
                allStats.mapInfo.DemoName.ShouldBe("demo1");
                allStats.mapInfo.MapName.ShouldBe("de_testmap");
                allStats.mapInfo.TestDate.ShouldBe(new DateTime(2020, 1, 1, 0, 0, 0).ToString());
                allStats.mapInfo.TestType.ShouldBe("Defuse");
            }
Exemple #16
0
            public void Should_return_tanooki_stats_correctly()
            {
                // Arrange

                // Act
                AllStats allStats = MatchData.CreateFiles(ProcessedData, false);

                // Assess
                allStats.tanookiStats.Joined.ShouldBe(true);
                allStats.tanookiStats.Left.ShouldBe(true);
                allStats.tanookiStats.RoundJoined.ShouldBe(1);
                allStats.tanookiStats.RoundLeft.ShouldBe(2);
                allStats.tanookiStats.RoundsLasted.ShouldBe(1);
            }
Exemple #17
0
            public void Should_return_kills_stats_correctly()
            {
                // Arrange

                // Act
                AllStats allStats = MatchData.CreateFiles(ProcessedData, false);

                // Assess
                allStats.killsStats.Count.ShouldBe(2);
                allStats.killsStats[0].Round.ShouldBe(1);
                allStats.killsStats[0].TimeInRound.ShouldBe(40);
                allStats.killsStats[1].Round.ShouldBe(2);
                allStats.killsStats[1].TimeInRound.ShouldBe(90);
            }
Exemple #18
0
        public override string KeywordsHelp()
        {
            string helpText = "";

            foreach (string group in AnimaCharacter.StatGroups)
            {
                helpText += group + " :" + Environment.NewLine;
                helpText += "```";
                helpText += string.Join(", ", AllStats.Where(x => x.Group == group).Select(x => x.Name));
                helpText += "```";
            }

            return($"Available keywords for !c info/r :{Environment.NewLine}{helpText}");
        }
Exemple #19
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }

        allStats[PlayerProperties.TotalDefence]       = 0;
        allStats[PlayerProperties.TypeOfWeaponInHand] = (int)WeaponType.Unarmed;
    }
Exemple #20
0
            public void Should_return_bombsite_stats_correctly()
            {
                // Arrange

                // Act
                AllStats allStats = MatchData.CreateFiles(ProcessedData, false);

                // Assess
                allStats.bombsiteStats.Count.ShouldBe(2);
                allStats.bombsiteStats[0].Plants.ShouldBe(1);
                allStats.bombsiteStats[0].Explosions.ShouldBe(1);
                allStats.bombsiteStats[0].Defuses.ShouldBe(0);
                allStats.bombsiteStats[1].Plants.ShouldBe(1);
                allStats.bombsiteStats[1].Explosions.ShouldBe(0);
                allStats.bombsiteStats[1].Defuses.ShouldBe(1);
            }
Exemple #21
0
            public void Should_return_grenade_specific_stats_correctly()
            {
                // Arrange

                // Act
                AllStats allStats = MatchData.CreateFiles(ProcessedData, false);

                // Assess
                allStats.grenadesSpecificStats.Count.ShouldBe(6);
                allStats.grenadesSpecificStats[0].NadeType.ShouldBe(EquipmentElement.Flash.ToString());
                allStats.grenadesSpecificStats[1].NadeType.ShouldBe(EquipmentElement.Smoke.ToString());
                allStats.grenadesSpecificStats[2].NadeType.ShouldBe(EquipmentElement.HE.ToString());
                allStats.grenadesSpecificStats[3].NadeType.ShouldBe(EquipmentElement.Molotov.ToString());
                allStats.grenadesSpecificStats[4].NadeType.ShouldBe(EquipmentElement.Incendiary.ToString());
                allStats.grenadesSpecificStats[5].NadeType.ShouldBe(EquipmentElement.Decoy.ToString());
            }
Exemple #22
0
    void RandomCharacterStats()
    {
        stats = new AllStats();

        FieldInfo[] fInfos = stats.GetType().GetFields();
        for (int i = 0; i < fInfos.Length; i++)
        {
            FieldInfo fInfo = fInfos[i];
            fInfo.SetValue(this.stats, (int)fInfo.GetValue(this.stats) + 1);
        }
        for (int i = 0; i < (50 - fInfos.Length); i++)
        {
            FieldInfo fInfo = stats.GetType().GetFields()[UnityEngine.Random.Range(0, fInfos.Length)];
            fInfo.SetValue(this.stats, (int)fInfo.GetValue(this.stats) + 1);
        }
    }
Exemple #23
0
        public Item(string id, ItemType type, Set set, Grade grade, int iLvl, int enhance, Stat main, Stat[] subStats, Hero equipped, bool locked)
        {
            ID            = id;
            this.type     = type;
            this.set      = set;
            this.grade    = grade;
            this.iLvl     = iLvl;
            this.enhance  = enhance;
            this.main     = main;
            this.subStats = subStats;
            Equipped      = equipped;
            Locked        = locked;

            AllStats.SetStat(main);
            AllStats.SetStats(subStats);

            calcWSS();
        }
Exemple #24
0
            public void Should_return_hostage_stats_correctly()
            {
                // Arrange

                // Act
                AllStats allStats = MatchData.CreateFiles(ProcessedData, false);

                // Assess
                allStats.hostageStats.Count.ShouldBe(2);
                allStats.hostageStats[0].Hostage.ShouldBe('A');
                allStats.hostageStats[0].HostageIndex.ShouldBe(250);
                allStats.hostageStats[0].PickedUps.ShouldBe(2);
                allStats.hostageStats[0].Rescues.ShouldBe(1);
                allStats.hostageStats[1].Hostage.ShouldBe('B');
                allStats.hostageStats[1].HostageIndex.ShouldBe(251);
                allStats.hostageStats[1].PickedUps.ShouldBe(1);
                allStats.hostageStats[1].Rescues.ShouldBe(1);
            }
        private void SubmitChangeButton_Click(object sender, RoutedEventArgs e)
        {
            this.PreviousValue = ValueToEditTextBox.Text;
            this.NewValue      = NewValueTextBox.Text;

            var tempList = new List <string>();

            foreach (string path in AllFilePathes)
            {
                if (path.EndsWith(FileTypeTextBox.Text))
                {
                    tempList.Add(path);
                }
            }
            var tempPathes = tempList.ToArray();

            Parallel.For(0, tempPathes.Length, (i, state) => ReplaceAll(tempPathes[i]));

            var window = new LogFile(AllStats.ToList());
        }
Exemple #26
0
            public void Should_return_grenade_total_stats_correctly()
            {
                // Arrange

                // Act
                AllStats allStats = MatchData.CreateFiles(ProcessedData, false);

                // Assess
                allStats.grenadesTotalStats.Count.ShouldBe(5);
                allStats.grenadesTotalStats[0].NadeType.ShouldBe(EquipmentElement.Flash.ToString());
                allStats.grenadesTotalStats[0].AmountUsed.ShouldBe(1);
                allStats.grenadesTotalStats[1].NadeType.ShouldBe(EquipmentElement.Smoke.ToString());
                allStats.grenadesTotalStats[1].AmountUsed.ShouldBe(1);
                allStats.grenadesTotalStats[2].NadeType.ShouldBe(EquipmentElement.HE.ToString());
                allStats.grenadesTotalStats[2].AmountUsed.ShouldBe(1);
                allStats.grenadesTotalStats[3].NadeType.ShouldBe(EquipmentElement.Incendiary.ToString());
                allStats.grenadesTotalStats[3].AmountUsed.ShouldBe(2);
                allStats.grenadesTotalStats[4].NadeType.ShouldBe(EquipmentElement.Decoy.ToString());
                allStats.grenadesTotalStats[4].AmountUsed.ShouldBe(1);
            }
Exemple #27
0
            public void Should_return_player_stats_correctly()
            {
                // Arrange

                // Act
                AllStats allStats = MatchData.CreateFiles(ProcessedData, false);

                // Assess
                allStats.playerStats.Count.ShouldBe(2);

                allStats.playerStats[0].Assists.ShouldBe(0);
                allStats.playerStats[0].AssistsIncludingBots.ShouldBe(0);
                allStats.playerStats[0].Deaths.ShouldBe(0);
                allStats.playerStats[0].DeathsIncludingBots.ShouldBe(0);
                allStats.playerStats[0].Defuses.ShouldBe(1);
                allStats.playerStats[0].Headshots.ShouldBe(1);             // took over a bot for one of them
                allStats.playerStats[0].Kills.ShouldBe(1);                 // took over a bot for one of them
                allStats.playerStats[0].KillsIncludingBots.ShouldBe(2);
                allStats.playerStats[0].MVPs.ShouldBe(2);
                allStats.playerStats[0].Plants.ShouldBe(1);
                allStats.playerStats[0].PlayerName.ShouldBe("JimWood");
                allStats.playerStats[0].Rescues.ShouldBe(0);
                allStats.playerStats[0].Shots.ShouldBe(6);
                allStats.playerStats[0].SteamID.ShouldBe(32443298432);

                allStats.playerStats[1].Assists.ShouldBe(1);
                allStats.playerStats[1].AssistsIncludingBots.ShouldBe(1);
                allStats.playerStats[1].Deaths.ShouldBe(1);                 // took over a bot for one of them
                allStats.playerStats[1].DeathsIncludingBots.ShouldBe(2);
                allStats.playerStats[1].Defuses.ShouldBe(0);
                allStats.playerStats[1].Headshots.ShouldBe(0);
                allStats.playerStats[1].Kills.ShouldBe(0);
                allStats.playerStats[1].KillsIncludingBots.ShouldBe(0);
                allStats.playerStats[1].MVPs.ShouldBe(0);
                allStats.playerStats[1].Plants.ShouldBe(1);
                allStats.playerStats[1].PlayerName.ShouldBe("TheWhaleMan");
                allStats.playerStats[1].Rescues.ShouldBe(2);
                allStats.playerStats[1].Shots.ShouldBe(1);
                allStats.playerStats[1].SteamID.ShouldBe(12321313213);
            }
        public AllStats CollectStats(List <ProcessedTweet> records)
        {
            AllStats allStats = new AllStats();

            allStats.Averages = new Averages();
            allStats.Stats    = new Statistics();

            try
            {
                if (records.Count > 0)
                {
                    allStats.Averages.TotalRecived = records.Count();

                    allStats.Averages.PerSecondAverage = _averageValues.GetAverage(records, TimeDivision.PerSecond);
                    allStats.Averages.PerMinuteAverage = _averageValues.GetAverage(records, TimeDivision.PerMinute);
                    allStats.Averages.PerHourAverage   = _averageValues.GetAverage(records, TimeDivision.PerHour);

                    allStats.Stats.TopEmojis   = string.Join(",", _topValues.TopEmoji(records.Select(o => o.Emojis).ToList()).Take(5));
                    allStats.Stats.TopHashtags = string.Join(",", _topValues.TopValue(records.Select(o => o.Hashtags).ToList()).Take(5));
                    allStats.Stats.TopMentions = string.Join(",", _topValues.TopValue(records.Select(o => o.Mentions).ToList()).Take(5));
                    allStats.Stats.TopDomains  = string.Join(",", _topValues.TopDomains(records.Select(o => o.Urls).ToList()).Take(5));

                    var ercentInstagramPics = _percentageValues.GetPercentage(records, SearchType.InstagramLink);
                    var ercentTwitterPics   = _percentageValues.GetPercentage(records, SearchType.TwitterPicture);

                    allStats.Stats.PercentPics   = ercentInstagramPics + ercentTwitterPics;
                    allStats.Stats.PercentEmojis = _percentageValues.GetPercentage(records, SearchType.Emojis);
                    allStats.Stats.PercentUrls   = _percentageValues.GetPercentage(records, SearchType.Urls);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(allStats);
        }
Exemple #29
0
    void Update()
    {
        bool done = (con.deck.Count == 0 && !con.dragging);

        if (done || Game.triesLeft == 0)
        {
            Game.stats.SetGrade();
            if (!File.Exists(Application.persistentDataPath + "/stats.xml"))
            {
                TextAsset t = Resources.Load("AllStatsTemplate") as TextAsset;
                using (StreamWriter s = new StreamWriter(Application.persistentDataPath + "/stats.xml"))
                {
                    s.Write(t.text);
                }
            }

            Game.UploadStatsToAnalytics();

            XmlSerializer xml = new XmlSerializer(typeof(AllStats));
            AllStats      all = new AllStats();
            using (Stream inputStream = File.OpenRead(Application.persistentDataPath + "/stats.xml"))
            {
                all = (AllStats)xml.Deserialize(inputStream);
            }

            all.stats.Add(Game.stats);

            // Serialize.
            using (Stream outputStream = File.OpenWrite(Application.persistentDataPath + "/stats.xml"))
            {
                xml.Serialize(outputStream, all);
            }
            StartCoroutine(ShowResults());
            this.enabled = false;
            Game.pause   = true;
        }
    }
Exemple #30
0
    public Character(string name)
    {
        id        = GenerateID();
        this.name = name;
        gender    = Convert.ToBoolean(UnityEngine.Random.Range(0, 2)) ? GenderType.Male : GenderType.Female;


        stats = new AllStats();

        FieldInfo[] fInfos = stats.GetType().GetFields();
        for (int i = 0; i < fInfos.Length; i++)
        {
            FieldInfo fInfo = fInfos[i];
            fInfo.SetValue(this.stats, (int)fInfo.GetValue(this.stats) + 1);
        }
        for (int i = 0; i < (50 - fInfos.Length); i++)
        {
            FieldInfo fInfo = stats.GetType().GetFields()[UnityEngine.Random.Range(0, fInfos.Length)];
            fInfo.SetValue(this.stats, (int)fInfo.GetValue(this.stats) + 1);
        }


        currentHitPoint = MaxHitPoint;

        level = 1;

        RandomBirthMark(ref birthMarks);



        equipments   = new List <Equipment>();
        workStatus   = WorkStatus.Idle;
        healthStatus = HealthStatus.Healthly;
        spritePath   = "Sprites/Character/Character" + UnityEngine.Random.Range(1, 10).ToString();
        effects      = new List <Resource.Effect>();
    }