public override AIStats.Command SetCommand(GeneralStats stats) { GameObject attackingTarget = AIManager.GetCurrentAttkTarget; Vector3 moveDestination = AIManager.GetCurrentMoveDest; if (attackingTarget != null) { moveDestination = attackingTarget.transform.position; // Set back to default behaviour if target is too far from self if (aiStats.CheckTargetTooFar(transform.position, moveDestination)) { AIManager.UnregisterBehaviour(behaviourCode); return(AIStats.Command.Idle); } // Set back to default behaviour if chasing target too far if (aiStats.CheckShouldBackToPatrol(transform.position)) { AIManager.UnregisterBehaviour(behaviourCode); return(AIStats.Command.Idle); } return(AIStats.Command.AttackingDest); } else { // If no target is found, set state to patrolling Debug.Log("Target is destroyed"); AIManager.UnregisterBehaviour(behaviourCode); return(AIStats.Command.Idle); } }
// public static string GetLocalizedName(StatType TypeOfStat) // { // return StringUtil.TR_StatName(TypeOfStat); // } // // public static string GetLocalizedDescription(StatType TypeOfStat) // { // return StringUtil.TR_StatDescription(TypeOfStat); // } public static bool IsStatADisplayedStat(StatType TypeOfStat) { return(GeneralStats.Contains(TypeOfStat) || FirepowerStats.Contains(TypeOfStat) || SupportStats.Contains(TypeOfStat) || FrontlinerStats.Contains(TypeOfStat)); }
public override bool evaluate(GeneralStats generalStats) { if (generalStats.totalCoins >= totalCoins) { return(true); } return(false); }
// TODO public override bool evaluate(GeneralStats generalStats) { if (generalStats.lastGameStats.coins == 0) { return(true); } return(false); }
public override bool evaluate(GeneralStats generalStats) { if (generalStats.totalEnemiesDefeated >= totalEnemies) { return(true); } return(false); }
public override bool evaluate(GeneralStats generalStats) { if (generalStats.lastGameStats.enemiesDefeated >= enemies) { return(true); } return(false); }
public static GeneralStats getRandomGenStats(GeneralStats genStats, byte level) { genStats.Battles = new Random().Next(level * 5, level * 15); genStats.Win = new Random().Next(level * 5, level * 15); genStats.Loss = new Random().Next(level * 5, level * 15); genStats.Tie = new Random().Next(level * 1, level * 5); return(genStats); }
// Start is always called after any Awake functions. void Start() { // Set up the references. attackTrigger = Animator.StringToHash("Attack1"); attackTrigger2 = Animator.StringToHash("Attack2"); engagedBool = Animator.StringToHash("Engaged"); lockedonBool = Animator.StringToHash("LockedOn"); stats = GetComponent <GeneralStats> (); }
public static GeneralStats fromStorage() { string str = PlayerPrefs.GetString("stats", null); GeneralStats stats = JsonUtility.FromJson <GeneralStats>(str); if (str == null || stats == null) { return(new GeneralStats()); } return(stats); }
public void Awake() { if (instance == null) { instance = this; achievements = new List <Achievement> (); ballMaterial = MaterialsRepository.Get("green"); SkinsRepository.addSkin(new Skin(SpriteRepository.Get("green"), ballMaterial)); addAchievements(); DontDestroyOnLoad(this.gameObject); } }
private float attackCounter; // Counter to count when the next attack comes void Awake() { behaviours = new List <GenericAIBehaviour> (); anim = GetComponent <Animator> (); agent = GetComponent <UnityEngine.AI.NavMeshAgent> (); stats = GetComponent <GeneralStats> (); currentCommand = stats.GetAIStats.GetCommand; speedFloat = Animator.StringToHash("Speed"); attackTrigger = Animator.StringToHash("Attack"); }
// Update is called once per frame void Update() { if (!isFirstRun) { if (shouldPlayVoice) { shouldPlayVoice = false; if (playerCharNew.isCampPlayer) { dieVoicesToPlay = initialInfo.voiceInfo.CampModeDie; } else { dieVoicesToPlay = initialInfo.voiceInfo.Die; } AudioInfo dieNewAudInf = GameObject.Instantiate(dieAudioInfo, transform.position, transform.rotation) as AudioInfo; dieNewAudInf.Init(); dieNewAudInf.PlayClip(dieVoicesToPlay); DieInTime dieAudInfDieInTime = dieNewAudInf.gameObject.AddComponent <DieInTime>(); dieAudInfDieInTime.time = SoldierStats.MaxTimeOfDeadSoldVoice; } } if (isFirstRun) { isFirstRun = false; } if (isEnabled) { if (!startingAnimDone) { timeCounter += Time.deltaTime; if (timeCounter > delayToStartDeadAnim) { startingAnimDone = true; animation[initialInfo.deadSoldAnim.animName].time = 0; animation.CrossFade(initialInfo.deadSoldAnim.animName, initialInfo.deadSoldAnim.initialCrossfadeTime); } } else { if (GeneralStats.IsUnloopedAnimFinishedOnObject(gameObject, initialInfo.deadSoldAnim.animName, 0)) { StopThisZombie(); } } } }
public void save() { GeneralStats stats = GeneralStats.fromStorage(); if (stats.localStats.Count == 0) { stats.localStats.Add(new LocalStats { }); } if (stats.highScore < this.score) { stats.highScore = this.score; } stats.save(); }
public static LocalStats fromStorage() { GeneralStats stats = GeneralStats.fromStorage(); if (stats.localStats.Count == 0) { LocalStats newStats = new LocalStats { }; return(newStats); } else { return(stats.localStats[0]); } }
public void UpdateAnims() { GeneralStats.EmptyAnimationStateArray(gameObject); foreach (AnimationClip anClip in animType.animClips) { if (anClip != null) { animation.AddClip(anClip, anClip.name); } else { print("Nulle!!!!!"); } } }
private void GeneralStatusToolStripMenuItem_Click(object sender, EventArgs e) { // default value is 5k int numberOfVoteToMp = 5000; using (ConfigMp mp = new ConfigMp()) { if (mp.ShowDialog(this) == DialogResult.OK) { numberOfVoteToMp = mp.NumberOfVoteToMp; } } using (GeneralStats generalStats = new GeneralStats(numberOfVoteToMp)) { generalStats.ShowDialog(this); } }
public override AIStats.Command SetCommand(GeneralStats stats) { GameObject attackingTarget = AIManager.GetCurrentAttkTarget; Vector3 moveDestination = AIManager.GetCurrentMoveDest; // If get to patrol point then move to next patrol if (AIManager.GetAgent.remainingDistance < 0.5f) { Debug.Log("Move to next patrol point!"); aiStats.MoveToNextPatrolPoint(); AIManager.GetCurrentMoveDest = aiStats.GetCurrentPatrolPoint; Debug.Log(aiStats.GetCurrentPatrolPoint); } // Set run or walk return(aiStats.GetCommandToPatrolDest(transform.position)); }
public void SaveFile() { StreamWriter file = new System.IO.StreamWriter(File.Create(fileName)); GeneralStats stats = GeneralStats.instance; string content = string.Format("{0};{1};{2};{3};{4};{5};{6}\n", stats.gamesPlayed, stats.maxCoins, stats.totalCoins, stats.maxTime, stats.totalTime, stats.maxEnemiesDefeated, stats.totalEnemiesDefeated); int i; for (i = 0; i < stats.achievements.Count - 1; i++) { content += stats.getAchievement(i).isAchieved + ";"; } content += stats.getAchievement(i).isAchieved; file.Write(content); file.Close(); }
void Update() { if (step == 1) { foreach (SoldierDetectableCube dude in checkableDudes) { if (dude.IsStarted()) { if (GeneralStats.IsVecInView(dude.transform.position, transform.position, transform.rotation, startAngle, endAngle, viewRange)) { Vector3 startPoint = transform.position; Vector3 direction = dude.transform.position - startPoint; float rayMagnitude = direction.magnitude; bool isInView = false; RaycastHit hit = new RaycastHit(); if (Physics.Raycast(startPoint, direction, out hit, viewRange, GameGeneralInfo.Instance.SoldierViewRaycastLayer)) { if (hit.transform.name == dude.transform.name) { isInView = true; } } if (isInView) { SetDudeNashSeen(); } } } } } }
private void Awake() { _rigidbody2D = GetComponent <Rigidbody>(); _stats = GetComponent <GeneralStats>(); }
public bool IsInPlayerView() { return(GeneralStats.IsVecInView(spineTr.position, playerCharNew.soldNashDetectorTr.position, playerCharNew.soldNashDetectorTr.rotation, -100, 100, 120)); }
public bool IsPlayerInView_ForCamp() { if (PlayerCharacterNew.Instance == null) { Debug.LogError("Player doesn't exist in map!"); return(false); } PlayerCharacterNew player = PlayerCharacterNew.Instance; GameObject playerObj = PlayerCharacterNew.Instance.gameObject; Vector3 rayCastPos = soldierEye.position; Quaternion rayCastRot = soldierEye.rotation; float viewRange = mapLogic.camp_CurUpdate_SoldsViewRange * mapLogic.campSoldierViewRangeCoef; float viewHalfAng = mapLogic.camp_CurUpdate_SoldsViewAngle; float distToPlayer = Vector3.Magnitude(playerObj.transform.position - transform.position); //Back if (player.IsVertMovementState(PlayerVertMovementStateEnum.Stand) || player.IsVertMovementState(PlayerVertMovementStateEnum.Jump)) { if (distToPlayer <= SoldierStats.campSoldier_BackMaxDist) { Transform targTr = player.campViewRaysactTargets[0]; if (!GeneralStats.IsVecInView(targTr.position, rayCastPos, rayCastRot, -viewHalfAng, viewHalfAng, viewRange)) //<--- NOT { Vector3 raycastDirection = targTr.position - soldierEye.position; float rayDirMag = raycastDirection.magnitude; float range = rayDirMag; if (range > viewRange) { return(false); } Vector3 raycastStart = soldierEye.position; RaycastHit[] hits = Physics.RaycastAll(raycastStart, raycastDirection, range, GameGeneralInfo.Instance.SoldierCampModeViewRaycastLayer); bool isHittedToObs = false; foreach (RaycastHit hit in hits) { if (hit.transform.root == gameObject.transform) { continue; } if (hit.transform.gameObject.tag.ToLower() == GeneralStats.camWallTagName_ToLower) { CampWall cWall = hit.transform.gameObject.GetComponent <CampWall>(); if (mapLogic.CanKeepRaycastingThroughCampWall(cWall, hit.point)) { continue; } } isHittedToObs = true; } if (!isHittedToObs) { return(true); } } } } foreach (Transform targTr in player.campViewRaysactTargets) { if (!GeneralStats.IsVecInView(targTr.position, rayCastPos, rayCastRot, -viewHalfAng, viewHalfAng, viewRange)) { return(false); } Vector3 raycastDirection = targTr.position - soldierEye.position; float rayDirMag = raycastDirection.magnitude; float range = rayDirMag; if (range > viewRange) { return(false); } Vector3 raycastStart = soldierEye.position; RaycastHit[] hits = Physics.RaycastAll(raycastStart, raycastDirection, range, GameGeneralInfo.Instance.SoldierCampModeViewRaycastLayer); foreach (RaycastHit hit in hits) { if (hit.transform.root == gameObject.transform) { continue; } if (hit.transform.gameObject.tag.ToLower() == GeneralStats.camWallTagName_ToLower) { CampWall cWall = hit.transform.gameObject.GetComponent <CampWall>(); if (mapLogic.CanKeepRaycastingThroughCampWall(cWall, hit.point)) { continue; } } return(false); } } return(true); //CharRaycastResult charRaycastRes; //mapLogic.IsCharacterOkAsTarget(gameObject, playerObj, soldierEye.position, soldierEye.rotation, viewRange, -viewHalfAng, viewHalfAng, out charRaycastRes); //return charRaycastRes.isCharacterHitted; }
private void Start() { _shooterPosition = Shooter.GetComponent <Transform>().position; _stats = Shooter.GetComponent <GeneralStats>(); }
public override void RunIt() { base.RunIt(); if (shouldCountLaneTimes) { laneTimeCounter = MathfPlus.DecByDeltatimeToZero(laneTimeCounter); if (laneTimeCounter == 0) { SetSoldierCurrentLaneNum(soldierCurrentLaneNum + 1, true); } } if (isFollowWaiting) { if ((followDatJob == null) || (followDatJob != null && followDatJob.status == LogicJobStatus.Finished)) { isFollowWaiting = false; followJobCounter = MathfPlus.GetRandomFloat(followDelayTimeMin, followDelayTimeMax); } } if (followJobCounter > 0) { followJobCounter = MathfPlus.DecByDeltatimeToZero(followJobCounter); } StartSteps: #region 1 Running if (step == 1) //Running { if (IsCreatingSoldiersStoppedAndAllSoldsDead()) { SetFinished(true); return; } if (needsToBeFinished) { SetStep(2); goto StartSteps; } if (fightReg.respawnPointCollection != null) { if (!isFollowWaiting && followJobCounter == 0) { if (fightReg.respawnPointCollection.IsReady()) { CreateAndInitSoldier(); } } } if (grenadeEnabled) { if (!nowReadyForGreandeLaunch && grenadeCount > 0) { grenadeDelayTimeCounter = MathfPlus.DecByDeltatimeToZero(grenadeDelayTimeCounter); } if (!grenadeIsControlledByOwnerGroup) { if (CanSetReadyForLaunchGrenade()) { SetItsNowReadyForLaunchGrenade(); } } } } #endregion #region 2 Start Finishing if (step == 2) //StartFinishing { StopCreatingMoreSoldiers(); if (GeneralStats.IsCharacterAlive(controlledSoldier)) { curFightInRegAct.SetNeedsToBeFinished(evenStopMovingForFinish); } SetStep(3); } #endregion #region 3 Check Finished if (step == 3) //Check Finished { if (!GeneralStats.IsCharacterAlive(controlledSoldier)) { SetFinished(true); return; } else { //<Alpha> if (needsToBeFinished) { curFightInRegAct.SetNeedsToBeFinished(evenStopMovingForFinish); } //</Alpha> if (curFightInRegAct.status == SoldierAction.ActionStatusEnum.Finished) { SetFinished(true); return; } } } #endregion EndSteps: ; }
public static GeneralStats DeserializeGeneralStatsFor(this JObject jObject, string guid) { if (jObject == null) { return(new GeneralStats()); } var json = (JObject)jObject[Misc.Results][guid]; var result = new GeneralStats { Guid = guid, Casual = new ModeStatsContainer { Kills = json.GetUInt(GeneralCasual.Kills), Deaths = json.GetUInt(GeneralCasual.Deaths), Kd = json.GetFloat(GeneralCasual.Kills, 1) / json.GetFloat(GeneralCasual.Deaths, 1), Wins = json.GetUInt(GeneralCasual.Wins), Losses = json.GetUInt(GeneralCasual.Losses), Wl = json.GetFloat(GeneralCasual.Wins, 1) / json.GetFloat(GeneralCasual.Losses, 1), MatchesPlayed = json.GetUInt(GeneralCasual.MatchesPlayed), TimePlayed = TimeSpan.FromSeconds(json.GetDouble(GeneralCasual.Time)), }, Training = new ModeStatsContainer { Kills = json.GetUInt(GeneralTraining.Kills), Deaths = json.GetUInt(GeneralTraining.Deaths), Kd = json.GetFloat(GeneralTraining.Kills, 1) / json.GetFloat(GeneralTraining.Deaths, 1), Wins = json.GetUInt(GeneralTraining.Wins), Losses = json.GetUInt(GeneralTraining.Losses), Wl = json.GetFloat(GeneralTraining.Wins, 1) / json.GetFloat(GeneralTraining.Losses, 1), TimePlayed = TimeSpan.FromSeconds(json.GetDouble(GeneralTraining.Time)), MatchesPlayed = json.GetUInt(GeneralTraining.Wins) + json.GetUInt(GeneralTraining.Losses) }, Ranked = new ModeStatsContainer { Kills = json.GetUInt(GeneralRanked.Kills), Deaths = json.GetUInt(GeneralRanked.Deaths), Kd = json.GetFloat(GeneralRanked.Kills, 1) / json.GetFloat(GeneralRanked.Deaths, 1), Wins = json.GetUInt(GeneralRanked.Wins), Losses = json.GetUInt(GeneralRanked.Losses), Wl = json.GetFloat(GeneralRanked.Wins, 1) / json.GetFloat(GeneralRanked.Losses, 1), TimePlayed = TimeSpan.FromSeconds(json.GetDouble(GeneralRanked.Time)), MatchesPlayed = json.GetUInt(GeneralRanked.MatchesPlayed), }, Overall = new ModeStatsContainer { Kills = json.GetUInt(OverallMultiplayer.Kills), Deaths = json.GetUInt(OverallMultiplayer.Deaths), Kd = json.GetFloat(OverallMultiplayer.Kills, 1) / json.GetFloat(OverallMultiplayer.Deaths, 1), Wins = json.GetUInt(OverallMultiplayer.Wins), Losses = json.GetUInt(OverallMultiplayer.Losses), Wl = json.GetFloat(OverallMultiplayer.Wins, 1) / json.GetFloat(OverallMultiplayer.Losses, 1), TimePlayed = TimeSpan.FromSeconds(json.GetDouble(OverallMultiplayer.Time)), //matches played set at the bottom... }, Highscores = new HighScoreContainer { Secure = json.GetInt(Highscores.Secure), Bomb = json.GetInt(Highscores.Bomb), Hostage = json.GetInt(Highscores.Hostage), }, // Non-Containered Stats Barricades = json.GetUInt(General.Barricades), Reinforcements = json.GetUInt(General.Reinforcements), Downs = json.GetUInt(General.Downs), Revives = json.GetUInt(General.Revives), Penetrations = json.GetUInt(General.Penetrations), Headshots = json.GetUInt(General.Headshots), Knifes = json.GetUInt(General.Knives), Assists = json.GetUInt(General.Assists), Suicides = json.GetUInt(General.Suicides), ShotsFired = json.GetLong(General.BulletFired), ShotsConnected = json.GetLong(General.BulletHit) }; result.Overall.MatchesPlayed = result.Casual.MatchesPlayed + result.Ranked.MatchesPlayed + result.Training.MatchesPlayed; return(result); }
public async void GetDataFromMessageFile(object o) { Console.CursorTop = consoleStartIndex + 1; string messFilePath = (string)o; Console.WriteLine("getting data for user: {0}", fileInfos.Find(x => x.realPath == messFilePath).personName); for (int arr = 0; arr < jsonForCharts.Count(); arr++) { jsonForCharts[arr] = "null"; } Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); string data = String.Empty; using (var reader = new StreamReader(messFilePath)) { data = reader.ReadToEnd(); } Console.WriteLine("{0}ms read all data", stopwatch.ElapsedMilliseconds); MessagesObject jsonObj = JsonConvert.DeserializeObject <MessagesObject>(data); Console.WriteLine("{0}ms deserialized JSON", stopwatch.ElapsedMilliseconds); int i = 0; StringBuilder stringBuilder = new StringBuilder(); HashSet <Char> charsToRemove = new HashSet <Char> { '!', '-', '"', '?', ',', '/', '.', '\\', '§' }; for (i = jsonObj.messages.Count - 1; i >= 0; i--) { var mess = jsonObj.messages[i]; if (mess.content == null) //remove empty messages { jsonObj.messages.RemoveAt(i); } else { string veta = GetRidOfEncodings(mess.content); stringBuilder.Clear(); bool lastCharSpace = false; foreach (Char ch in veta) { if (charsToRemove.Contains(ch) || Char.IsWhiteSpace(ch)) { if (!lastCharSpace) { stringBuilder.Append(' '); lastCharSpace = true; } } else { stringBuilder.Append(Char.ToLower(ch)); lastCharSpace = false; } } veta = stringBuilder.ToString(); mess.content = veta; if (mess.sender_name != null) { mess.sender_name = GetRidOfEncodings(mess.sender_name); } else { mess.sender_name = "deleted account"; } } } Console.WriteLine("{0}ms cleaned JSON contents", stopwatch.ElapsedMilliseconds); List <Message> messages = jsonObj.messages; messages = messages.OrderBy(x => x.timestamp_ms).ToList(); Console.WriteLine("{0}ms list ordered by timestamp", stopwatch.ElapsedMilliseconds); int w, c; ThreadPool.GetMinThreads(out w, out c); var countTask1 = Task.Factory.StartNew(() => CountWordsDoubleCores(messages, x => x.sender_name == selectedIdentity, w >= 8)); var countTask2 = Task.Factory.StartNew(() => CountWordsDoubleCores(messages, x => x.sender_name != selectedIdentity, w >= 8)); if (w >= 8) { Console.WriteLine("{0}ms counting will run on 8 threads", stopwatch.ElapsedMilliseconds); } else { Console.WriteLine("{0}ms counting will run on 4 threads", stopwatch.ElapsedMilliseconds); } var info = new GeneralStats(); /* zpravy za den */ var count1 = new List <int>(); var count2 = new List <int>(); var time = new List <string>(); var timeNow = DateTimeOffset.FromUnixTimeMilliseconds((messages[0].timestamp_ms)); var timePrev = DateTimeOffset.FromUnixTimeMilliseconds((messages[0].timestamp_ms)); var currDay = timeNow.Day; int c1 = 0; int c2 = 0; for (i = 1; i < messages.Count; i++) { var thisAday = timeNow.Day; if (thisAday != currDay) { count1.Add(c1); count2.Add(c2); c1 = 0; c2 = 0; time.Add(timePrev.Day + ". " + (timePrev.Month) + ". " + (timePrev.Year - 2000)); var diffSec = ((timePrev - timeNow).TotalSeconds); while (diffSec > 86400) //rozdil je vetsi jak den { count1.Add(0); count2.Add(0); time.Add(timePrev.Day + ". " + (timePrev.Month) + ". " + (timePrev.Year - 2000)); timePrev = timePrev.AddSeconds(86400); diffSec = ((timePrev - timeNow).TotalSeconds); } currDay = thisAday; } if (messages[i].sender_name == selectedIdentity) { c2++; } else { c1++; } timePrev = timeNow; timeNow = DateTimeOffset.FromUnixTimeMilliseconds((messages[i].timestamp_ms)); } jsonForCharts[0] = JsonConvert.SerializeObject(new GraphData { count1 = count1, count2 = count2, dates = time }); Console.WriteLine("{0}ms got messages per day count", stopwatch.ElapsedMilliseconds); /* pocet zprav za mesic */ count1 = new List <int>(); count2 = new List <int>(); var prevCount1 = new List <int>(); var prevCount2 = new List <int>(); time = new List <string>(); timeNow = DateTimeOffset.FromUnixTimeMilliseconds((messages[0].timestamp_ms)); timePrev = DateTimeOffset.FromUnixTimeMilliseconds((messages[0].timestamp_ms)); var currMonth = timeNow.Month; c1 = 0; c2 = 0; int pc1 = 0; int pc2 = 0; if (messages[0].sender_name == selectedIdentity) { c2++; info.totalCountMy++; } else { c1++; info.totalCountP++; } for (i = 1; i < messages.Count; i++) { var thisM = timeNow.Month; if (thisM != currMonth) { count1.Add(c1); count2.Add(c2); prevCount1.Add(c1 - pc1); prevCount2.Add(c2 - pc2); pc1 = c1; pc2 = c2; c1 = 0; c2 = 0; time.Add((timePrev.Month) + ". " + (timePrev.Year - 2000)); currMonth = thisM; } if (messages[i].sender_name == selectedIdentity) { c2++; info.totalCountMy++; } else { c1++; info.totalCountP++; } timePrev = timeNow; timeNow = DateTimeOffset.FromUnixTimeMilliseconds((messages[i].timestamp_ms)); } jsonForCharts[1] = JsonConvert.SerializeObject(new GraphData { count1 = count1, count2 = count2, dates = time }); jsonForCharts[2] = JsonConvert.SerializeObject(new GraphData { count1 = prevCount1, count2 = prevCount2, dates = time }); Console.WriteLine("{0}ms got messages per month count", stopwatch.ElapsedMilliseconds); count1 = new List <int>(); count2 = new List <int>(); time = new List <string>(); timeNow = DateTimeOffset.FromUnixTimeMilliseconds((messages[0].timestamp_ms)); timePrev = DateTimeOffset.FromUnixTimeMilliseconds((messages[0].timestamp_ms)); var currY = timeNow.Year; c1 = 0; c2 = 0; for (i = 1; i < messages.Count; i++) { var thisY = timeNow.Year; if (thisY != currY) { count1.Add(c1); count2.Add(c2); c1 = 0; c2 = 0; time.Add((timePrev.Year.ToString())); currY = thisY; } if (messages[i].sender_name == selectedIdentity) { c2++; } else { c1++; } timePrev = timeNow; timeNow = DateTimeOffset.FromUnixTimeMilliseconds((messages[i].timestamp_ms)); } jsonForCharts[3] = JsonConvert.SerializeObject(new GraphData { count1 = count1, count2 = count2, dates = time }); Console.WriteLine("{0}ms got messages per year count", stopwatch.ElapsedMilliseconds); info.firstTime = DateTimeOffset.FromUnixTimeMilliseconds((messages[0].timestamp_ms)).ToString("dd. MM. yyyy HH:mm:ss"); info.lastTime = DateTimeOffset.FromUnixTimeMilliseconds((messages[messages.Count() - 1].timestamp_ms)).ToString("dd. MM. yyyy HH:mm:ss"); jsonForCharts[8] = JsonConvert.SerializeObject(info); preparedMessageFile = messFilePath; var wordList1 = await countTask1; var wordList2 = await countTask2; Console.WriteLine("{0}ms got word counts {1}", stopwatch.ElapsedMilliseconds, wordList1.Count); var counts1_2 = new List <int>(); //matching counts from counts 2 var counts2_1 = new List <int>(); //matching counts from counts 1 var counts1 = wordList1.Select(x => x.count).ToList(); var texts1 = wordList1.Select(x => x.text).ToList(); var counts2 = wordList2.Select(x => x.count).ToList(); var texts2 = wordList2.Select(x => x.text).ToList(); for (i = 0; i < texts1.Count; i++) { int index = texts2.FindIndex(x => x == texts1[i]); if (index == -1) { counts1_2.Add(0); } else { counts1_2.Add(counts2[index]); } } for (i = 0; i < texts2.Count; i++) { int index = texts1.FindIndex(x => x == texts2[i]); if (index == -1) { counts2_1.Add(0); } else { counts2_1.Add(counts1[index]); } } Console.WriteLine("{0}ms got word counts relatives", stopwatch.ElapsedMilliseconds); jsonForCharts[4] = JsonConvert.SerializeObject(new GraphData { count1 = counts1, count2 = new List <int>(), dates = texts1 }); jsonForCharts[5] = JsonConvert.SerializeObject(new GraphData { count1 = counts2, count2 = new List <int>(), dates = texts2 }); jsonForCharts[6] = JsonConvert.SerializeObject(new GraphData { count1 = counts1, count2 = counts1_2, dates = texts1 }); jsonForCharts[7] = JsonConvert.SerializeObject(new GraphData { count1 = counts2, count2 = counts2_1, dates = texts2 }); Console.WriteLine("{0}ms serialized all jsons", stopwatch.ElapsedMilliseconds); }
// Use this for initialization void Start() { current = this; highScore.text = GeneralStats.fromStorage().highScore.ToString(); }
// This function is implemented should the behaviour wants to change the command. public virtual AIStats.Command SetCommand(GeneralStats stats) { return(AIStats.Command.Idle); }
public static GeneralStats DeserializeGeneralStatsFor(this JObject jObject, string guid) { // try to get the user but if there is nothing return null var json = jObject[Misc.Results]?[guid] as JObject; if (json == null) { return(null); } var result = new GeneralStats { Guid = guid, #region Playlists Casual = new PlaylistStatsContainer { Kills = json.GetUInt(GeneralCasual.Kills.ToStatsKey()), Deaths = json.GetUInt(GeneralCasual.Deaths.ToStatsKey()), Wins = json.GetUInt(GeneralCasual.Wins.ToStatsKey()), Losses = json.GetUInt(GeneralCasual.Losses.ToStatsKey()), MatchesPlayed = json.GetUInt(GeneralCasual.MatchesPlayed.ToStatsKey()), Duration = json.GetUInt(GeneralCasual.Time.ToStatsKey()) }, Training = new PlaylistStatsContainer { Kills = json.GetUInt(GeneralTraining.Kills.ToStatsKey()), Deaths = json.GetUInt(GeneralTraining.Deaths.ToStatsKey()), Wins = json.GetUInt(GeneralTraining.Wins.ToStatsKey()), Losses = json.GetUInt(GeneralTraining.Losses.ToStatsKey()), Duration = json.GetUInt(GeneralTraining.Time.ToStatsKey()), MatchesPlayed = json.GetUInt(GeneralTraining.MatchesPlayed.ToStatsKey()) }, Ranked = new PlaylistStatsContainer { Kills = json.GetUInt(GeneralRanked.Kills.ToStatsKey()), Deaths = json.GetUInt(GeneralRanked.Deaths.ToStatsKey()), Wins = json.GetUInt(GeneralRanked.Wins.ToStatsKey()), Losses = json.GetUInt(GeneralRanked.Losses.ToStatsKey()), Duration = json.GetUInt(GeneralRanked.Time.ToStatsKey()), MatchesPlayed = json.GetUInt(GeneralRanked.MatchesPlayed.ToStatsKey()), }, Overall = new PlaylistStatsContainer { Kills = json.GetUInt(General.Kills.ToStatsKey()), Deaths = json.GetUInt(General.Deaths.ToStatsKey()), Wins = json.GetUInt(General.Wins.ToStatsKey()), Losses = json.GetUInt(General.Losses.ToStatsKey()), Duration = json.GetUInt(General.Time.ToStatsKey()), MatchesPlayed = json.GetUInt(General.MatchesPlayed.ToStatsKey()) }, #endregion #region Modes Bomb = new BombModeStats { Wins = json.GetUInt(Modes.Bomb.Wins.ToStatsKey()), Losses = json.GetUInt(Modes.Bomb.Losses.ToStatsKey()), Highscore = json.GetUInt(Modes.Bomb.Highscore.ToStatsKey()), Duration = json.GetUInt(Modes.Bomb.Time.ToStatsKey()), MatchesPlayed = json.GetUInt(Modes.Bomb.MatchesPlayed.ToStatsKey()) }, Hostage = new HostageModeStats { Wins = json.GetUInt(Modes.Hostage.Wins.ToStatsKey()), Losses = json.GetUInt(Modes.Hostage.Losses.ToStatsKey()), Highscore = json.GetUInt(Modes.Hostage.Highscore.ToStatsKey()), Duration = json.GetUInt(Modes.Hostage.Time.ToStatsKey()), MatchesPlayed = json.GetUInt(Modes.Hostage.MatchesPlayed.ToStatsKey()), Rescues = json.GetUInt(Modes.Hostage.Rescues.ToStatsKey()), Defenses = json.GetUInt(Modes.Hostage.Defenses.ToStatsKey()) }, Secure = new SecureModeStats { Wins = json.GetUInt(Modes.Secure.Wins.ToStatsKey()), Losses = json.GetUInt(Modes.Secure.Losses.ToStatsKey()), Highscore = json.GetUInt(Modes.Secure.Highscore.ToStatsKey()), Duration = json.GetUInt(Modes.Secure.Time.ToStatsKey()), MatchesPlayed = json.GetUInt(Modes.Secure.MatchesPlayed.ToStatsKey()), Aggressions = json.GetUInt(Modes.Secure.Aggressions.ToStatsKey()), Defenses = json.GetUInt(Modes.Secure.Defenses.ToStatsKey()), Captures = json.GetUInt(Modes.Secure.Captures.ToStatsKey()) }, #endregion // non-containerised stats Barricades = json.GetUInt(General.Barricades.ToStatsKey()), Reinforcements = json.GetUInt(General.Reinforcements.ToStatsKey()), GadgetsDestroyed = json.GetUInt(General.GadgetsDestroyed.ToStatsKey()), Downs = json.GetUInt(General.Downs.ToStatsKey()), Revives = json.GetUInt(General.Revives.ToStatsKey()), // todo move to killtypes class? Penetrations = json.GetUInt(General.Penetrations.ToStatsKey()), Headshots = json.GetUInt(General.Headshots.ToStatsKey()), Knifes = json.GetUInt(General.Knives.ToStatsKey()), BlindKills = json.GetUInt(General.BlindKills.ToStatsKey()), Assists = json.GetUInt(General.Assists.ToStatsKey()), DownAssists = json.GetUInt(General.DownAssists.ToStatsKey()), Suicides = json.GetUInt(General.Suicides.ToStatsKey()), ShotsFired = json.GetULong(General.BulletFired.ToStatsKey()), ShotsConnected = json.GetULong(General.BulletHit.ToStatsKey()), Experience = json.GetULong(General.Experience.ToStatsKey()), DistanceTravelled = json.GetULong(General.DistanceTravelled.ToStatsKey()) }; return(result); }
public override void RunIt() { base.RunIt(); StartSteps: #region 1 Start if (step == 1) { if (needsToBeFinished) { SetStep(2); goto StartSteps; } if (controlledSoldier != null) { AddMachineGunActToSoldier(controlledSoldier); } SetStep(1.1f); } #endregion #region 1.1 Run if (step == 1.1f) { if (needsToBeFinished) { SetStep(2); goto StartSteps; } if (respawnPointCollection != null) { if (IsCreatingSoldiersStoppedAndAllSoldsDead()) { SetFinished(true); return; } if (respawnPointCollection.IsReady()) { CreateAndInitSoldier(); } } } #endregion #region 2 Start Finishing if (step == 2) //StartFinishing { StopCreatingMoreSoldiers(); if (!GeneralStats.IsCharacterAlive(controlledSoldier)) { SetFinished(true); return; } if (actMachineGun == null) { SetFinished(true); return; } actMachineGun.SetNeedsToBeFinished(evenStopMovingForFinish); SetStep(2.1f); } #endregion #region 2.1 Check Finished if (step == 2.1f) //Check Finished { if (!GeneralStats.IsCharacterAlive(controlledSoldier)) { SetFinished(true); return; } else { //<Alpha> if (needsToBeFinished) { actMachineGun.SetNeedsToBeFinished(evenStopMovingForFinish); } //</Alpha> if (actMachineGun.status == SoldierAction.ActionStatusEnum.Finished) { SetFinished(true); return; } } } #endregion }