private void RankGameplayDataMap() { Dictionary currentDataMap; string currentKey; long currentValue; string biggestRankKey = null; long biggestValue = long.MinValue; int iterations = gameplayDataMap.Count < 10 ? gameplayDataMap.Count : 10; SCG.HashSet <string> selectedMapSet = new SCG.HashSet <string>(); rankedGameplayDataMap = new Dictionary(); for (int i = 0; i < 3; i++) { for (int j = 0; j < iterations; j++) { currentKey = j.ToString(); if (gameplayDataMap.Contains(currentKey) && !selectedMapSet.Contains(currentKey)) { currentDataMap = gameplayDataMap[currentKey] as Dictionary; if (this.Call <bool>(gameplayData, this.GetMethodIsValidDataMap(), currentDataMap, gameplayDataKeyList, gameMode)) { currentValue = long.Parse(currentDataMap[rankKey] as string); if (currentValue > biggestValue) { biggestValue = currentValue; biggestRankKey = currentKey; } } } } if (gameplayDataMap.Contains(biggestRankKey) && !selectedMapSet.Contains(biggestRankKey)) { rankedGameplayDataMap.Add(i.ToString(), gameplayDataMap[biggestRankKey]); selectedMapSet.Add(biggestRankKey); } biggestValue = long.MinValue; biggestRankKey = null; } }
public void OnStartButtonPressed() { SCG.HashSet <int> selectedSpecialistKeySet = new SCG.HashSet <int>(); Array slotList; int specialistColorIndex; int autoSelect; string[] skills = new string[] { "", "P", "L", "S" }; globalData.Call(this.GetMethodClear()); // NOTE: This clears all entries inside GlobalData. PutGlobal("specialistAmountIndex", specialistAmountIndex); PutGlobal("firstToIndex", firstToIndex); PutGlobal("levelIndex", locationIndex); PutGlobal("roundTimeIndex", roundTimeIndex); PutGlobal("skillIndex", skillIndex); PutGlobal("sceneToLoad", GetLevelScenePath()); PutGlobal("levelScenePathList", levelScenePathList); PutGlobal("firstTo", firstToIndex + 1); PutGlobal("levelIndex", locationIndex); PutGlobal("battleRound", 1); PutGlobal("specialistAmount", specialistAmountIndex + 2); PutGlobal("battleRoundTime", 180f + (roundTimeIndex * 60f)); PutGlobal("battleStartingSkill", skills[skillIndex]); for (int i = 0; i < specialistControls.Length; i++) { specialistColorIndex = specialistColorIndexes[i]; autoSelect = 0; slotList = new Array(); slotList.Add("S"); slotList.Add("S"); while (selectedSpecialistKeySet.Contains(specialistColorIndex)) { specialistColorIndex = autoSelect++; } selectedSpecialistKeySet.Add(specialistColorIndex); PutGlobal("winsSpecialistIndex" + i, 0); PutGlobal("livesSpecialistIndex" + i, 0); PutGlobal("healthSpecialistIndex" + i, 100); PutGlobal("speedLevelSpecialistIndex" + i, 1); PutGlobal("laserRayLevelSpecialistIndex" + i, 2); PutGlobal("laserDeviceAmountSpecialistIndex" + i, 1); PutGlobal("detonateTimeLevelSpecialistIndex" + i, 1); PutGlobal("slotListSpecialistIndex" + i, slotList); PutGlobal("selectedSlotSpecialistIndex" + i, 0); PutGlobal("skillSpecialistIndex" + i, skills[skillIndex]); PutGlobal("colorSpecialistIndex" + i, specialistColorIndex); } GetTree().ChangeScene(this.GetScenePath(loadScreenScenePath)); }
public void OnStartButtonPressed() { globalData.Call(this.GetMethodClear()); // NOTE: This clears all entries inside GlobalData. PutGlobal("totalTime", totalTime.ToString()); PutGlobal("p1Deaths", p1Deaths); PutGlobal("p2Deaths", p2Deaths); PutGlobal("continues", continues); PutGlobal("levelScenePathList", locationScenePathList); PutGlobal("locationIndex", locationIndex); PutGlobal("specialistAmount", specialistAmountIndex + 1); PutGlobal("gameMode", (specialistAmountIndex + 1) + "P Story Mode"); PutGlobal("sceneToLoad", this.GetScenePath(dialogueScreenScenePath)); SCG.HashSet <int> selectedSpecialistKeySet = new SCG.HashSet <int>(); Array slotList; int specialistColorIndex; int autoSelect; for (int i = 0; i < specialistAmountIndex + 1; i++) { specialistColorIndex = specialistColorIndexes[i]; autoSelect = 0; slotList = new Array(); slotList.Add("S"); slotList.Add("S"); while (selectedSpecialistKeySet.Contains(specialistColorIndex)) { specialistColorIndex = autoSelect++; } selectedSpecialistKeySet.Add(specialistColorIndex); PutGlobal("livesSpecialistIndex" + i, 4); PutGlobal("healthSpecialistIndex" + i, 100); PutGlobal("speedLevelSpecialistIndex" + i, 1); PutGlobal("laserRayLevelSpecialistIndex" + i, 1); PutGlobal("laserDeviceAmountSpecialistIndex" + i, 1); PutGlobal("detonateTimeLevelSpecialistIndex" + i, 1); PutGlobal("slotListSpecialistIndex" + i, slotList); PutGlobal("selectedSlotSpecialistIndex" + i, 0); PutGlobal("skillSpecialistIndex" + i, ""); PutGlobal("colorSpecialistIndex" + i, specialistColorIndex); } GetTree().ChangeScene(this.GetScenePath(loadScreenScenePath)); }
private void InitializeSpecialistsColor() { int specialistColor; int autoSelect; SCG.HashSet <int> selectedSpecialistKeySet = new SCG.HashSet <int>(); for (int i = 0; i < specialistControls.Length; i++) { specialistColor = GetGlobal <int>("colorSpecialistIndex" + i); autoSelect = 0; while (selectedSpecialistKeySet.Contains(specialistColor)) { specialistColor = autoSelect++; } selectedSpecialistKeySet.Add(specialistColor); specialistColorIndexes[i] = specialistColor; } }
public static bool ItemsAreUnique <T>(this SCG.IEnumerable <T> items) { #region Code Contracts // Must not be null Requires(items != null); #endregion // TODO: Replace with C5's HashTable once implemented var set = new SCG.HashSet <T>(); foreach (var item in items) { if (set.Contains(item)) { return(false); } set.Add(item); } return(true); }
private void RecoverAllWays(RecoveryParser rp) { // ReSharper disable once RedundantAssignment int maxPos = rp.MaxPos; var failPositions = new HashSet<int>(); var deleted = new List<Tuple<int, ParsedSequence>>(); do { var tmpDeleted = FindMaxFailPos(rp); if (rp.MaxPos != rp.ParseResult.Text.Length) UpdateParseErrorCount(); if (!CheckUnclosedToken(rp)) deleted.AddRange(tmpDeleted); else { } maxPos = rp.MaxPos; failPositions.Add(maxPos); var records = new SCG.Queue<ParseRecord>(rp.Records[maxPos]); var prevRecords = new SCG.HashSet<ParseRecord>(rp.Records[maxPos]); do { if (_parseResult.TerminateParsing) throw new OperationCanceledException(); while (records.Count > 0) { var record = records.Dequeue(); if (record.IsComplete) { rp.StartParseSubrule(maxPos, record); continue; } if (record.Sequence.IsToken) continue; foreach (var state in record.ParsingState.Next) { var newRecord = new ParseRecord(record.Sequence, state, maxPos); if (!rp.Records[maxPos].Contains(newRecord)) { records.Enqueue(newRecord); prevRecords.Add(newRecord); } } rp.SubruleParsed(maxPos, maxPos, record); rp.PredictionOrScanning(maxPos, record, false); } rp.Parse(); foreach (var record in rp.Records[maxPos]) if (!prevRecords.Contains(record)) records.Enqueue(record); prevRecords.UnionWith(rp.Records[maxPos]); } while (records.Count > 0); } while (rp.MaxPos > maxPos); foreach (var del in deleted) DeleteTokens(rp, del.Item1, del.Item2, NumberOfTokensForSpeculativeDeleting); rp.Parse(); }
private void RecoverAllWays(RecoveryParser rp) { // ReSharper disable once RedundantAssignment int maxPos = rp.MaxPos; var failPositions = new HashSet <int>(); var deleted = new List <Tuple <int, ParsedSequence> >(); do { var tmpDeleted = FindMaxFailPos(rp); if (rp.MaxPos != rp.ParseResult.Text.Length) { UpdateParseErrorCount(); } if (!CheckUnclosedToken(rp)) { deleted.AddRange(tmpDeleted); } else { } maxPos = rp.MaxPos; failPositions.Add(maxPos); var records = new SCG.Queue <ParseRecord>(rp.Records[maxPos]); var prevRecords = new SCG.HashSet <ParseRecord>(rp.Records[maxPos]); do { if (_parseResult.TerminateParsing) { throw new OperationCanceledException(); } while (records.Count > 0) { var record = records.Dequeue(); if (record.IsComplete) { rp.StartParseSubrule(maxPos, record); continue; } if (record.Sequence.IsToken) { continue; } foreach (var state in record.ParsingState.Next) { var newRecord = new ParseRecord(record.Sequence, state, maxPos); if (!rp.Records[maxPos].Contains(newRecord)) { records.Enqueue(newRecord); prevRecords.Add(newRecord); } } rp.SubruleParsed(maxPos, maxPos, record); rp.PredictionOrScanning(maxPos, record, false); } rp.Parse(); foreach (var record in rp.Records[maxPos]) { if (!prevRecords.Contains(record)) { records.Enqueue(record); } } prevRecords.UnionWith(rp.Records[maxPos]); }while (records.Count > 0); }while (rp.MaxPos > maxPos); foreach (var del in deleted) { DeleteTokens(rp, del.Item1, del.Item2, NumberOfTokensForSpeculativeDeleting); } rp.Parse(); }