public static void AddDocumentAnnotation(DataPool pool, string annotationName, string value = null) { foreach (Document doc in pool.RootNode.Documents) { Annotation a = new Annotation(pool, annotationName); if (value != null) { a.Value = value; } doc.Annotations.Add(a); } }
public static void RemoveUncertainRows(DataPool pool, string tableFieldname, UncertainRowsDefinition ucrd = null) { if (ucrd == null) { ucrd = new UncertainRowsDefinition() { Bottom = true } } ; foreach (Document doc in pool.RootNode.Documents) { List <TableRow> topRows = new List <TableRow>(); List <TableRow> bottomRows = new List <TableRow>(); bool certainRowFound = false; if (doc.Fields[tableFieldname] == null) { throw new Exception("Field " + tableFieldname + " not found in document"); } Table table = doc.Fields[tableFieldname] as Table; int nofRows = table.Rows.Count; foreach (TableRow tr in table.Rows) { if (tr.State != DataState.Uncertain) { certainRowFound = true; bottomRows.Clear(); continue; } if (!certainRowFound) { topRows.Add(tr); } else { bottomRows.Add(tr); } } if (ucrd.Top) { removeRows(table, topRows, ucrd.TopFields); } if (ucrd.Bottom) { removeRows(table, bottomRows, ucrd.BottomFields); } } }
/// <summary> /// 回池 /// </summary> protected override void toRelease(DataPool pool) { base.toRelease(pool); this.type = 0; if (this.nowPos != null) { this.nowPos.release(pool); this.nowPos = null; } this.targetPos.release(pool); this.targetPos = null; }
public void train(ref DataPool worldData) { ManagerProtocol.FacilityShortcut training = chooseTraining(); if (atSea) { ship.train(ref worldData, boxerIndex, training); } else { homebase.train(ref worldData, boxerIndex, training); } }
public static List <Boxer> generateBoxerRecruits(ref DataPool worldData, int townIndex, float elo) { List <WeightClass.WClass> boxersToCreate = generateBoxersToCreate(elo); List <Boxer> boxers = new List <Boxer> (); foreach (WeightClass.WClass wClass in boxersToCreate) { boxers.Add(createBoxerBasedOnFame(worldData.generateFirstName(), worldData.generateLastName(), townIndex, elo, wClass)); } return(boxers); }
private IEnumerator ScreenShot() { //开始截图 yield return(new WaitForEndOfFrame()); Texture2D tex = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); tex.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0); TextureScale.Bilinear(tex, 240, 135); byte[] imagebytes = tex.EncodeToPNG(); DataPool.GetInstance().WriteSystemVar("缩略图", imagebytes); Destroy(tex); }
/// <summary> /// 回池 /// </summary> protected override void toRelease(DataPool pool) { this.instanceID = 0; this.identity = null; this.normal = null; this.pos = null; this.avatar = null; this.move = null; this.fight = null; this.fightEx = null; this.ai = null; this.func = null; }
private void handleFreeMovement(ref DataPool worldData, InfoLayerJob.InfoJob infoJob) { if (listController.State.Equals(ListController.ListState.None)) { if (Input.GetKeyDown(KeyCode.Space)) { if (mapState.Equals(MapState.World)) { loadRegion(ref worldData); } } } }
/// <summary> /// 回池 /// </summary> protected override void toRelease(DataPool pool) { this.baseMoveState = 0; this.moveType = 0; this.baseMovePos = null; this.moveList = null; this.specialMoveID = 0; this.specialMoveArgs = null; this.specialMoveLastTime = 0; this.vehicleInstanceID = 0; this.driveData = null; this.realMoveDir = null; this.realMoveSpeedRatio = 0; }
private XmlDocument tableColumnWise(DataPool pool) { loadSchema(pool); foreach (Document doc in pool.RootNode.Documents) { Annotation tcwAnnoation = doc.Annotations[ScriptingUtilities.TableColumnWise_AnnotationName]; if (tcwAnnoation == null) { continue; } string tableName = tcwAnnoation.Value; List <KeyValuePair <string, string> > mapping = null; Annotation tcwMappingAnnoation = doc.Annotations[ScriptingUtilities.TableColumnWiseMapping_AnnotationName]; if (tcwMappingAnnoation != null) { mapping = (List <KeyValuePair <string, string> >)SIEESerializer.StringToObject(tcwMappingAnnoation.Value); } Table table = doc.Fields[tableName] as Table; table.Rows.Add("row"); int nofRows = getNofRows(doc, table, mapping); for (int i = 0; i < nofRows - 1; i++) { table.Rows.Add("row"); } foreach (string column in getColumnNames(table.Rows[0] as TableRow)) { string fieldName = tcwMap(column, mapping); if (fieldName == null) { continue; } int i = 0; foreach (Field f in getFieldAlternatives(doc, fieldName)) { if (i++ < nofRows) { Field newField = f.Clone() as Field; newField.Rename(column); table.Rows[i - 1].Fields[column] = newField; } } } } return(pool.XmlDocument); }
void Start() { worldData = new DataPool(); WorldBuilderProtocol.createWorld(ref worldData, 220, 220); worldData.updateBoxerDistribution(); thisWeeksTournaments = new List <int>(); //foreach (ManagerProtocol mp in worldData.ManagerProtocols){ // worldData.Boxers[mp.BoxerIndex].logBoxerStats(mp.Rank); //} weeklyTest(); }
public static void ExportAttachments(DataPool pool, int masterDocument) { if (masterDocument >= pool.RootNode.Documents.Count) { return; } foreach (Source s in pool.RootNode.Sources) { Document doc = pool.RootNode.Documents[masterDocument].Clone() as Document; doc.SetExportPdfSource(s.Clone() as Source); pool.RootNode.Documents.Add(doc); } }
public static bool doesRegionExistAt(ref DataPool worldData, Vector2Int position) { bool regionExists = false; foreach (Region region in worldData.Regions) { if (region.Position.Equals(position)) { regionExists = true; } } return(regionExists); }
private void handleListControllers(ref DataPool worldData) { if (listController.State.Equals(ListController.ListState.Clicked)) { RowInfoInitializer rowInfo = listController.getSelectedRow(); if (rowInfo.ID >= 0) { rowClick(ref worldData, rowInfo); } listController.acknowledgeClick(); } listController.resolveSelection(); }
public static void initExercises(ref DataPool worldData) { string strengthExercise = "Punching Bag"; string speedExercise = "Sprints"; string enduranceExercise = "Punch Glove"; string accuracyExercise = "Double End Bag"; string healthExercise = "Laps"; worldData.addExerciseDescription(strengthExercise, "Strength Training"); worldData.addExerciseDescription(speedExercise, "Speed Training"); worldData.addExerciseDescription(enduranceExercise, "Endurance Training"); worldData.addExerciseDescription(accuracyExercise, "Accuracy Training"); worldData.addExerciseDescription(healthExercise, "Health Training"); worldData.addExerciseProgress(strengthExercise, new List <int>(new int[] { 0, 0, 0, 0, 1 })); worldData.addExerciseProgress(strengthExercise, new List <int>(new int[] { 0, 0, 0, 0, 1 })); worldData.addExerciseProgress(strengthExercise, new List <int>(new int[] { 0, 0, 0, 0, 2 })); worldData.addExerciseProgress(strengthExercise, new List <int>(new int[] { 0, 0, 0, 0, 2 })); worldData.addExerciseProgress(strengthExercise, new List <int>(new int[] { 0, 0, 0, 0, 3 })); worldData.addExerciseProgress(strengthExercise, new List <int>(new int[] { 0, 0, 0, 0, 3 })); worldData.addExerciseProgress(speedExercise, new List <int>(new int[] { 0, 0, 0, 1, 0 })); worldData.addExerciseProgress(speedExercise, new List <int>(new int[] { 0, 0, 0, 1, 0 })); worldData.addExerciseProgress(speedExercise, new List <int>(new int[] { 0, 0, 0, 2, 0 })); worldData.addExerciseProgress(speedExercise, new List <int>(new int[] { 0, 0, 0, 2, 0 })); worldData.addExerciseProgress(speedExercise, new List <int>(new int[] { 0, 0, 0, 3, 0 })); worldData.addExerciseProgress(speedExercise, new List <int>(new int[] { 0, 0, 0, 3, 0 })); worldData.addExerciseProgress(enduranceExercise, new List <int>(new int[] { 0, 1, 0, 0, 0 })); worldData.addExerciseProgress(enduranceExercise, new List <int>(new int[] { 0, 1, 0, 0, 0 })); worldData.addExerciseProgress(enduranceExercise, new List <int>(new int[] { 0, 2, 0, 0, 0 })); worldData.addExerciseProgress(enduranceExercise, new List <int>(new int[] { 0, 2, 0, 0, 0 })); worldData.addExerciseProgress(enduranceExercise, new List <int>(new int[] { 0, 3, 0, 0, 0 })); worldData.addExerciseProgress(enduranceExercise, new List <int>(new int[] { 0, 3, 0, 0, 0 })); worldData.addExerciseProgress(accuracyExercise, new List <int>(new int[] { 1, 0, 0, 0, 0 })); worldData.addExerciseProgress(accuracyExercise, new List <int>(new int[] { 1, 0, 0, 0, 0 })); worldData.addExerciseProgress(accuracyExercise, new List <int>(new int[] { 2, 0, 0, 0, 0 })); worldData.addExerciseProgress(accuracyExercise, new List <int>(new int[] { 2, 0, 0, 0, 0 })); worldData.addExerciseProgress(accuracyExercise, new List <int>(new int[] { 3, 0, 0, 0, 0 })); worldData.addExerciseProgress(accuracyExercise, new List <int>(new int[] { 3, 0, 0, 0, 0 })); worldData.addExerciseProgress(healthExercise, new List <int>(new int[] { 0, 0, 1, 0, 0 })); worldData.addExerciseProgress(healthExercise, new List <int>(new int[] { 0, 0, 1, 0, 0 })); worldData.addExerciseProgress(healthExercise, new List <int>(new int[] { 0, 0, 2, 0, 0 })); worldData.addExerciseProgress(healthExercise, new List <int>(new int[] { 0, 0, 2, 0, 0 })); worldData.addExerciseProgress(healthExercise, new List <int>(new int[] { 0, 0, 3, 0, 0 })); worldData.addExerciseProgress(healthExercise, new List <int>(new int[] { 0, 0, 3, 0, 0 })); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Use this for initialization void Start() { size = GameSettings.size; panelBlocks = new Vector2[size, size]; blocks = new Vector2[size, size]; map = new int[size, size]; queueX = new int[size * size + 1]; queueY = new int[size * size + 1]; trace = new int[size * size + 1]; moves = new int[size * size + 1]; moveMap = new int[size * size + 1]; avail = new bool[size, size]; scoreRateBall = new float[size * size + 1]; preBalls = new Vector2[size, size]; genList = new Vector3[size * size + 1]; maxCount = size * size; pool = Camera.main.GetComponent<DataPool>(); nullVector2 = new Vector2(-1, -1); levelTracking = new LevelTracking(); initPreBalls(); initScoreRate(); initPool(); initPanelBoard (); startLevel(GameSettings.TESTMODE); }
/// <summary> /// Map discovery phase /// </summary> /// <returns>action for robot to perform</returns> private ActionType Phase1Iteration() { Tile[,] hugeMap = HugeMap; Point currentPos = CurrentPos; bool followPath = false; //If it's first iteration in the phase if (Phase1Preparing) { //set all tiles as black (unexplored) TileStates black = TileStates.TopNV | TileStates.RightNV | TileStates.BottomNV | TileStates.LeftNV; for (int i = 0; i < hugeMap.GetLength(0); ++i) for (int j = 0; j < hugeMap.GetLength(1); ++j) { hugeMap[i, j] = new Tile(black, -1, -1); } //set initial tile as grey tile hugeMap[currentPos.Row - 1, currentPos.Col].State &= ~TileStates.BottomNV; hugeMap[currentPos.Row, currentPos.Col + 1].State &= ~TileStates.LeftNV; hugeMap[currentPos.Row + 1, currentPos.Col].State &= ~TileStates.TopNV; hugeMap[currentPos.Row, currentPos.Col - 1].State &= ~TileStates.RightNV; hugeMap[currentPos.Row, currentPos.Col].State |= TileStates.Visited; Phase1Preparing = false; } Tile currentTile = hugeMap[currentPos.Row, currentPos.Col]; ActionType action = ActionType.actIDLE; //if we are not following path to nearest grey tile generated by A* if (GoingToGrey == null) { //if current tile is grey (has unexplored neighbours) if ((currentTile.State & GreyTileSign) != 0) { if ((currentTile.State & TileStates.TopNV) != 0) { --currentPos.Row; action = ActionType.actUP; } else if ((currentTile.State & TileStates.RightNV) != 0) { ++currentPos.Col; action = ActionType.actRIGHT; } else if ((currentTile.State & TileStates.BottomNV) != 0) { ++currentPos.Row; action = ActionType.actDOWN; } else if ((currentTile.State & TileStates.LeftNV) != 0) { --currentPos.Col; action = ActionType.actLEFT; } hugeMap[currentPos.Row - 1, currentPos.Col].State &= ~TileStates.BottomNV; hugeMap[currentPos.Row, currentPos.Col + 1].State &= ~TileStates.LeftNV; hugeMap[currentPos.Row + 1, currentPos.Col].State &= ~TileStates.TopNV; hugeMap[currentPos.Row, currentPos.Col - 1].State &= ~TileStates.RightNV; hugeMap[currentPos.Row, currentPos.Col].State |= TileStates.Visited; PossiblePos = currentPos; return action; } else { //if no current tile has no unexplored neighbours and there are still grey tiles on map if (GreyExists()) { //A* to search for nearest grey GetPathToGrey(); followPath = true; } else { //Finishing phase 1 //Rewrting HugeMap contents to SmallMap int minRow = int.MaxValue, minCol = int.MaxValue; for (int row = 0; row < hugeMap.GetLength(0); ++row) { for (int col = 0; col < hugeMap.GetLength(1); ++col) { if ((hugeMap[row, col].State & TileStates.Visited) != 0) { minRow = System.Math.Min(minRow, row); minCol = System.Math.Min(minCol, col); } else { hugeMap[row, col].State |= TileStates.Wall; } } } Tile[,] smallMap = SmallMap; for (int row = 0; row < Environment.mazeSize_; ++row) for (int col = 0; col < Environment.mazeSize_; ++col) smallMap[row, col] = hugeMap[row + minRow, col + minCol]; CurrentPos.Row -= minRow; CurrentPos.Col -= minCol; HugeMap = null; Fringe = null; Phase1Running = false; } } } else followPath = true; if (followPath) { //Following path generated by A* on some previous step Point dest = GoingToGrey.Value; GoingToGrey = GoingToGrey.Parent; PossiblePos = dest; if (dest.Row < currentPos.Row) return ActionType.actUP; if (dest.Col > currentPos.Col) return ActionType.actRIGHT; if (dest.Row > currentPos.Row) return ActionType.actDOWN; if (dest.Col < currentPos.Col) return ActionType.actLEFT; } return ActionType.actIDLE; }