private string GetRequiredValueFromRowOrNull( ISheet worksheet, int row, int column, string columnName, StringBuilder exceptionMessage, CellType?cellType = null) { var cell = worksheet.GetRow(row).GetCell(column); if (cellType.HasValue) { cell.SetCellType(cellType.Value); } var cellValue = cell.StringCellValue; if (cellValue != null && !string.IsNullOrWhiteSpace(cellValue)) { return(cellValue); } exceptionMessage.Append(GetLocalizedExceptionMessagePart(columnName)); return(null); }
/// <summary> /// Digunakan untuk mengambil nilai dari cell di excel /// </summary> /// <param name="cell">cell</param> /// <param name="type">tipe data (jika tidak ditentukan, akan dicari otomatis)</param> /// <returns>string</returns> private static string GetCellValue(ICell cell, CellType?type = null) { string output; if (!type.HasValue) { type = cell.CellType; } switch (type.Value) { case CellType.NUMERIC: output = cell.NumericCellValue.To <string>(); break; case CellType.FORMULA: output = GetCellValue(cell, cell.CachedFormulaResultType); break; case CellType.BOOLEAN: output = cell.BooleanCellValue.To <string>(); break; case CellType.STRING: output = cell.StringCellValue; break; default: output = cell.StringCellValue; break; } return(output); }
public static string SValueOneline(this ICell self, CellType?FormulaResultType = null) { return(self.SValue() .Replace("\n", "\\n") .Replace("\t", "\\t") .Replace("\"", "\\\"")); }
public void Draw(CellType?otherType, Camera camera) { GL.PushMatrix(); GL.modelview = camera.worldToCameraMatrix * modelMatrix; material.SetPass((int)(otherType ?? type)); Graphics.DrawProcedural(MeshTopology.Points, count, 1); GL.PopMatrix(); }
public Actions DecideAction(List <Vector3> currentPath, ref int nextPathIndex) { //Move to target if you can float[] actions = new float[Actions.actionTableLength]; updateCellIndex(currentPath, ref nextPathIndex); //TODO: 1) Make sure that the obstacle is crossed correctly: try to jump faster to avoid loosing time (1 cell ahead) //TODO: 2) Try to slide ahead and stop sliding afterwards //TODO: 3) Also, algorithm does not know that you can't change direction while sliding/jumping Vector3? previousCellIndex = null; CellType?previousCellType = null; if (nextPathIndex > 0) { previousCellIndex = BoardManager.ConvertPositionToGridIndex(currentPath[nextPathIndex - 1]); previousCellType = BoardManager.Instance.board[(int)previousCellIndex.Value.x][(int)previousCellIndex.Value.z]; } Vector3 targetCellIndex = BoardManager.ConvertPositionToGridIndex(currentPath[nextPathIndex]); CellType nextCellType = BoardManager.Instance.board[(int)targetCellIndex.x][(int)targetCellIndex.z]; Vector3 direction = (currentPath[nextPathIndex] - GameMainManager.Instance.mouse.transform.position).normalized; actions[0] = direction.x; actions[1] = direction.z; bool shouldSlide = false; //if (previousCellType != null) //shouldSlide = previousCellType == CellType.BAR || (previousCellType == CellType.STEP_BAR); shouldSlide = shouldSlide || (nextCellType == CellType.BAR || (nextCellType == CellType.STEP_BAR)); bool isSliding = animator.GetCurrentAnimatorStateInfo(0).IsName("Base.slide"); if (shouldSlide) { if (!isSliding) { startSlideTime = Time.time; } if ((Time.time - startSlideTime) < MAX_SLIDE_TIME) { actions[2] = 1; } } if (nextCellType == CellType.STEP) { actions[3] = 1; } //TODO: when to dash? return(new Actions(actions)); }
private void RenderThermalData() { CellType?type = useCellType ? (CellType?)thermalCellType : null; foreach (var drawer in thermalDrawers) { if (drawer.Enabled) { drawer.Draw(type, GetComponent <Camera>()); } } }
/// <summary> /// Get all cells adjacent in the cardinal (and intercardinal) directions of the given cell /// </summary> /// <param name="cell"></param> /// <param name="includeIntercardinals"></param> /// <returns></returns> private List <CellMetadata> GetAdjacentCells( CellMetadata cell, bool includeIntercardinals, CellType?typeFilter = null ) { List <CellMetadata> adjacencyList = new List <CellMetadata>(); CellMetadata adjacent; IntVector2 position; // Grab cells in all cardinal directions foreach (IntVector2 direction in IntVector2.Cardinals) { position = cell.Position + direction; if (Contains(position)) { adjacent = GetCell(position); if (!typeFilter.HasValue || adjacent.Type == typeFilter.Value) { adjacencyList.Add(adjacent); } } } // If they ask for intercardinals, grab those too if (includeIntercardinals) { foreach (IntVector2 direction in IntVector2.Intercardinals) { position = cell.Position + direction; if (Contains(position)) { adjacent = GetCell(position); if (!typeFilter.HasValue || adjacent.Type == typeFilter.Value) { adjacencyList.Add(adjacent); } } } } return(adjacencyList); }
public static string SValue(this ICell cell, CellType?FormulaResultType = null) { string svalue = "nil"; var cellType = FormulaResultType ?? cell.CellType; switch (cellType) { case CellType.Unknown: //svalue = "nil"; break; case CellType.Numeric: svalue = cell.NumericCellValue.ToString(); break; case CellType.String: svalue = cell.StringCellValue //.Replace("\n", "\\n") //.Replace("\t", "\\t") //.Replace("\"", "\\\"") ; break; case CellType.Formula: svalue = cell.SValue(cell.CachedFormulaResultType); break; case CellType.Blank: //svalue = "nil"; break; case CellType.Boolean: svalue = cell.BooleanCellValue.ToString(); break; case CellType.Error: //svalue = "nil"; break; default: break; } return(svalue); }
public Tuple <int, object> ValueCell(ICell cell, CellType?type) { object valueCell = null; var iCellNumber = cell.ColumnIndex; if (type != null) { switch (type.Value) { case CellType.Blank: valueCell = null; break; case CellType.Boolean: valueCell = cell.BooleanCellValue.ToString(); break; case CellType.Error: valueCell = "ERROR"; break; case CellType.Formula: valueCell = ValueCell(cell, cell.CachedFormulaResultType).Item2; break; case CellType.Numeric: valueCell = cell.NumericCellValue; break; case CellType.String: valueCell = cell.StringCellValue; break; case CellType.Unknown: valueCell = null; break; default: throw new ArgumentException($"cannot find cell value for ${type}"); } } return(new Tuple <int, object>(iCellNumber, valueCell)); }
public static string SValue(this ICell cell, CellType?FormulaResultType = null) { string svalue = ""; var cellType = FormulaResultType ?? cell.CellType; switch (cellType) { case CellType.Unknown: svalue = "Unknown"; break; case CellType.Numeric: svalue = cell.NumericCellValue.ToString(); break; case CellType.String: svalue = cell.StringCellValue; break; case CellType.Formula: svalue = cell.SValue(cell.CachedFormulaResultType); break; case CellType.Blank: svalue = ""; break; case CellType.Boolean: svalue = cell.BooleanCellValue.ToString(); break; case CellType.Error: svalue = "Error"; break; default: break; } return(svalue); }
public static void Draw(this ICell self, CellType?FormulaResultType = null, GUILayoutOption[] guiOpts = null) { #if UNITY_EDITOR var cellType = FormulaResultType ?? self.CellType; switch (cellType) { case CellType.Unknown: self.SetCellValue(EditorGUILayout.DelayedTextField(self.SValueOneline(), guiOpts)); break; case CellType.Numeric: self.SetCellValue(EditorGUILayout.DelayedDoubleField(self.NumericCellValue, guiOpts)); break; case CellType.String: self.SetCellValue(EditorGUILayout.DelayedTextField(self.StringCellValue, guiOpts)); break; case CellType.Formula: EditorGUILayout.LabelField(self.SValue() + "=" + self.CellFormula, guiOpts); break; case CellType.Blank: self.SetCellValue(EditorGUILayout.DelayedTextField(self.StringCellValue, guiOpts)); break; case CellType.Boolean: self.SetCellValue(EditorGUILayout.Toggle(self.BooleanCellValue, guiOpts)); break; case CellType.Error: self.SetCellValue(EditorGUILayout.DelayedTextField(self.SValueOneline(), guiOpts)); break; default: break; } #endif }
void InstantiateCell(char value, int x, int y) { GameObject cellToInstantiate = null; CellType? instantiatedType = null; GameObject instantiatedBox = null; switch (value) { case '.': { cellToInstantiate = Instantiate(Floor, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); instantiatedType = CellType.Floor; break; } case 'g': { cellToInstantiate = Instantiate(Gate, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); Gate = cellToInstantiate; EyesCell = new Cell { XCoordinate = y, YCoordinate = x - 1 }; instantiatedType = CellType.Gate; break; } case 'w': { cellToInstantiate = Instantiate(Wall, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); instantiatedType = CellType.Wall; break; } case 'b': { cellToInstantiate = Instantiate(Floor, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); blinky = Instantiate(blinky, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); instantiatedType = CellType.Floor; mapData[y, x] = new Cell { Item = cellToInstantiate, Type = instantiatedType.Value, XCoordinate = y, YCoordinate = x }; blinky.currentCell = mapData[y, x]; break; } case 'p': { cellToInstantiate = Instantiate(Floor, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); instantiatedType = CellType.Floor; pinky = Instantiate(pinky, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); mapData[y, x] = new Cell { Item = cellToInstantiate, Type = instantiatedType.Value, XCoordinate = y, YCoordinate = x }; pinky.currentCell = mapData[y, x]; break; } case 'i': { cellToInstantiate = Instantiate(Floor, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); instantiatedType = CellType.Floor; inky = Instantiate(inky, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); mapData[y, x] = new Cell { Item = cellToInstantiate, Type = instantiatedType.Value, XCoordinate = y, YCoordinate = x }; inky.currentCell = mapData[y, x]; break; } case 'c': { cellToInstantiate = Instantiate(Floor, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); instantiatedType = CellType.Floor; clyde = Instantiate(clyde, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); mapData[y, x] = new Cell { Item = cellToInstantiate, Type = instantiatedType.Value, XCoordinate = y, YCoordinate = x }; clyde.currentCell = mapData[y, x]; break; } case 'P': { cellToInstantiate = Instantiate(Floor, new Vector3(1 * x, 0, 1 * y), Quaternion.identity, SuperParentContainer.transform); var playerGameobject = Instantiate(Player, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); mainPlayer = playerGameobject.GetComponent <PackManPlayer>(); instantiatedType = CellType.Floor; mainPlayer.ScoreText = ScoreText; mainPlayer.RestartButton = RestartButton; mainPlayer.DeadText = YouAreDead; mapData[y, x] = new Cell { Item = cellToInstantiate, Type = instantiatedType.Value, XCoordinate = y, YCoordinate = x }; mainPlayer.CellPosition = mapData[y, x]; Debug.Log(mainPlayer.CellPosition); break; } default: { Debug.Log("Can't instantiate"); break; } } mapData[y, x] = new Cell { Item = instantiatedBox, Type = instantiatedType.Value, XCoordinate = y, YCoordinate = x }; cellToInstantiate.transform.SetParent(SuperParentContainer.transform); }
/// <summary> /// 셀 타입에 해당하는 Value를 반환한다. /// </summary> private IExcelCellValue GetCellValue(ICell cell, Func <IExcelCellValue> valueCreator, CellType?preferredType = null) { var value = valueCreator(); value.Column = ConvertToColumnName(cell.ColumnIndex + 1); value.Row = cell.RowIndex + 1; value.ValueType = ConvertCellValueType(preferredType.HasValue ? preferredType.Value : cell.CellType); switch (value.ValueType) { case ExcelCellValueType.Blank: value.ValueType = ExcelCellValueType.String; value.Value = string.Empty; break; case ExcelCellValueType.Numeric: value.Value = cell.NumericCellValue; break; case ExcelCellValueType.String: value.Value = cell.StringCellValue; break; case ExcelCellValueType.Boolean: value.Value = cell.BooleanCellValue; break; case ExcelCellValueType.Formula: value = GetCellValue(cell, valueCreator, cell.CachedFormulaResultType); // 재귀로 처리 break; default: value.ValueType = ExcelCellValueType.Unknown; value.Value = $"Unknown value"; logger.Warn($"Not supported type of cell. SheetName: '{value.SheetName}', Location: '{value.Location}', Type: '{value.ValueType}'"); break; } return(value); }
public char this[CellType? index] => CellMap[index ?? CellType.Empty];
private string GetOptionalValueFromRowOrNull(ISheet worksheet, int row, int column, StringBuilder exceptionMessage, CellType?cellType = null) { var cell = worksheet.GetRow(row).GetCell(column); if (cell == null) { return(string.Empty); } if (cellType != null) { cell.SetCellType(cellType.Value); } var cellValue = worksheet.GetRow(row).GetCell(column).StringCellValue; if (cellValue != null && !string.IsNullOrWhiteSpace(cellValue)) { return(cellValue); } return(String.Empty); }
public static Texture2D LogDungeonToTexture2D() { int width = GameManager.Instance.Dungeon.data.Height; int height = GameManager.Instance.Dungeon.data.Width; // int width = 1000; // int height = 1000; Texture2D m_NewImage = new Texture2D(width, height, TextureFormat.RGBA32, false); m_NewImage.name = GameManager.Instance.Dungeon.gameObject.name; Color WhitePixel = new Color32(255, 255, 255, 255); // Wall Cell Color PinkPixel = new Color32(255, 0, 255, 255); // Diagonal Wall Cell (North East) Color YellowPixel = new Color32(255, 255, 0, 255); // Diagonal Wall Cell (North West) Color HalfPinkPixel = new Color32(127, 0, 127, 255); // Diagonal Wall Cell (South East) Color HalfYellowPixel = new Color32(127, 127, 0, 255); // Diagonal Wall Cell (South West) Color BluePixel = new Color32(0, 0, 255, 255); // Floor Cell Color BlueHalfGreenPixel = new Color32(0, 127, 255, 255); // Floor Cell (Ice Override) Color HalfBluePixel = new Color32(0, 0, 127, 255); // Floor Cell (Water Override) Color HalfRedPixel = new Color32(0, 0, 127, 255); // Floor Cell (Carpet Override) Color GreenHalfRBPixel = new Color32(127, 255, 127, 255); // Floor Cell (Grass Override) Color HalfWhitePixel = new Color32(127, 127, 127, 255); // Floor Cell (Bone Override) Color OrangePixel = new Color32(255, 127, 0, 255); // Floor Cell (Flesh Override) Color RedHalfGBPixel = new Color32(255, 127, 127, 255); // Floor Cell (ThickGoop Override) Color GreenPixel = new Color32(0, 255, 0, 255); // Damage Floor Cell Color RedPixel = new Color32(255, 0, 0, 255); // Pit Cell Color BlackPixel = new Color32(0, 0, 0, 255); // NULL Cell for (int X = 0; X < width; X++) { for (int Y = 0; Y < height; Y++) { if (GameManager.Instance.Dungeon.data.CheckInBoundsAndValid(X, Y)) { IntVector2 m_CellPosition = new IntVector2(X, Y); CellType? cellData = GameManager.Instance.Dungeon.data[m_CellPosition].type; CellData localDungeonData = GameManager.Instance.Dungeon.data[m_CellPosition]; bool DamageCell = false; DiagonalWallType diagonalWallType = DiagonalWallType.NONE; if (localDungeonData != null) { DamageCell = localDungeonData.doesDamage; diagonalWallType = localDungeonData.diagonalWallType; } if (localDungeonData == null | !cellData.HasValue) { m_NewImage.SetPixel(X, Y, BlackPixel); } else if (cellData.Value == CellType.FLOOR) { if (DamageCell) { m_NewImage.SetPixel(X, Y, GreenPixel); } else { CellVisualData.CellFloorType overrideFloorType = localDungeonData.cellVisualData.floorType; if (overrideFloorType == CellVisualData.CellFloorType.Stone) { m_NewImage.SetPixel(X, Y, BluePixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Ice) { m_NewImage.SetPixel(X, Y, BlueHalfGreenPixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Water) { m_NewImage.SetPixel(X, Y, HalfBluePixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Carpet) { m_NewImage.SetPixel(X, Y, HalfRedPixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Grass) { m_NewImage.SetPixel(X, Y, GreenHalfRBPixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Bone) { m_NewImage.SetPixel(X, Y, HalfWhitePixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Flesh) { m_NewImage.SetPixel(X, Y, OrangePixel); } else if (overrideFloorType == CellVisualData.CellFloorType.ThickGoop) { m_NewImage.SetPixel(X, Y, RedHalfGBPixel); } else { m_NewImage.SetPixel(X, Y, BluePixel); } } } else if (cellData.Value == CellType.WALL) { if (diagonalWallType == DiagonalWallType.NORTHEAST) { m_NewImage.SetPixel(X, Y, PinkPixel); } else if (diagonalWallType == DiagonalWallType.NORTHWEST) { m_NewImage.SetPixel(X, Y, YellowPixel); } else if (diagonalWallType == DiagonalWallType.SOUTHEAST) { m_NewImage.SetPixel(X, Y, HalfPinkPixel); } else if (diagonalWallType == DiagonalWallType.SOUTHWEST) { m_NewImage.SetPixel(X, Y, HalfYellowPixel); } else { m_NewImage.SetPixel(X, Y, WhitePixel); } } else if (cellData.Value == CellType.PIT) { m_NewImage.SetPixel(X, Y, RedPixel); } } else { m_NewImage.SetPixel(X, Y, BlackPixel); } } } m_NewImage.Apply(); return(m_NewImage); }
public static void LogDungeonToPNGFile() { // int width = GameManager.Instance.Dungeon.data.Height; // int height = GameManager.Instance.Dungeon.data.Width; int width = 1000; int height = 1000; Texture2D m_NewImage = new Texture2D(width, height, TextureFormat.RGBA32, false); m_NewImage.name = GameManager.Instance.Dungeon.gameObject.name; Color WhitePixel = new Color32(255, 255, 255, 255); // Wall Cell Color PinkPixel = new Color32(255, 0, 255, 255); // Diagonal Wall Cell (North East) Color YellowPixel = new Color32(255, 255, 0, 255); // Diagonal Wall Cell (North West) Color HalfPinkPixel = new Color32(127, 0, 127, 255); // Diagonal Wall Cell (South East) Color HalfYellowPixel = new Color32(127, 127, 0, 255); // Diagonal Wall Cell (South West) Color BluePixel = new Color32(0, 0, 255, 255); // Floor Cell Color BlueHalfGreenPixel = new Color32(0, 127, 255, 255); // Floor Cell (Ice Override) Color HalfBluePixel = new Color32(0, 0, 127, 255); // Floor Cell (Water Override) Color HalfRedPixel = new Color32(0, 0, 127, 255); // Floor Cell (Carpet Override) Color GreenHalfRBPixel = new Color32(127, 255, 127, 255); // Floor Cell (Grass Override) Color HalfWhitePixel = new Color32(127, 127, 127, 255); // Floor Cell (Bone Override) Color OrangePixel = new Color32(255, 127, 0, 255); // Floor Cell (Flesh Override) Color RedHalfGBPixel = new Color32(255, 127, 127, 255); // Floor Cell (ThickGoop Override) Color GreenPixel = new Color32(0, 255, 0, 255); // Damage Floor Cell Color RedPixel = new Color32(255, 0, 0, 255); // Pit Cell Color BlackPixel = new Color32(0, 0, 0, 255); // NULL Cell for (int X = 0; X < width; X++) { for (int Y = 0; Y < height; Y++) { if (GameManager.Instance.Dungeon.data.CheckInBoundsAndValid(X, Y)) { IntVector2 m_CellPosition = new IntVector2(X, Y); CellType? cellData = GameManager.Instance.Dungeon.data[m_CellPosition].type; CellData localDungeonData = GameManager.Instance.Dungeon.data[m_CellPosition]; bool DamageCell = false; DiagonalWallType diagonalWallType = DiagonalWallType.NONE; if (localDungeonData != null) { DamageCell = localDungeonData.doesDamage; diagonalWallType = localDungeonData.diagonalWallType; } if (localDungeonData == null | !cellData.HasValue) { m_NewImage.SetPixel(X, Y, BlackPixel); } else if (cellData.Value == CellType.FLOOR) { if (DamageCell) { m_NewImage.SetPixel(X, Y, GreenPixel); } else { CellVisualData.CellFloorType overrideFloorType = localDungeonData.cellVisualData.floorType; if (overrideFloorType == CellVisualData.CellFloorType.Stone) { m_NewImage.SetPixel(X, Y, BluePixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Ice) { m_NewImage.SetPixel(X, Y, BlueHalfGreenPixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Water) { m_NewImage.SetPixel(X, Y, HalfBluePixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Carpet) { m_NewImage.SetPixel(X, Y, HalfRedPixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Grass) { m_NewImage.SetPixel(X, Y, GreenHalfRBPixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Bone) { m_NewImage.SetPixel(X, Y, HalfWhitePixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Flesh) { m_NewImage.SetPixel(X, Y, OrangePixel); } else if (overrideFloorType == CellVisualData.CellFloorType.ThickGoop) { m_NewImage.SetPixel(X, Y, RedHalfGBPixel); } else { m_NewImage.SetPixel(X, Y, BluePixel); } } } else if (cellData.Value == CellType.WALL) { if (diagonalWallType == DiagonalWallType.NORTHEAST) { m_NewImage.SetPixel(X, Y, PinkPixel); } else if (diagonalWallType == DiagonalWallType.NORTHWEST) { m_NewImage.SetPixel(X, Y, YellowPixel); } else if (diagonalWallType == DiagonalWallType.SOUTHEAST) { m_NewImage.SetPixel(X, Y, HalfPinkPixel); } else if (diagonalWallType == DiagonalWallType.SOUTHWEST) { m_NewImage.SetPixel(X, Y, HalfYellowPixel); } else { m_NewImage.SetPixel(X, Y, WhitePixel); } } else if (cellData.Value == CellType.PIT) { m_NewImage.SetPixel(X, Y, RedPixel); } } else { m_NewImage.SetPixel(X, Y, BlackPixel); } } } m_NewImage.Apply(); string basePath = "DumpedDungeonLayouts/"; string fileName = (basePath + m_NewImage.name); if (string.IsNullOrEmpty(m_NewImage.name)) { fileName += ("DungeonLayout_" + Guid.NewGuid().ToString()); } fileName += "_Layout"; string path = Path.Combine(ETGMod.ResourcesDirectory, fileName.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar) + ".png"); if (!File.Exists(path)) { Directory.GetParent(path).Create(); } File.WriteAllBytes(path, ImageConversion.EncodeToPNG(m_NewImage)); }
public static void LogRoomToPNGFile(PrototypeDungeonRoom room) { int width = room.Width; int height = room.Height; Texture2D m_NewImage = new Texture2D(width, height, TextureFormat.RGBA32, false); if (!string.IsNullOrEmpty(room.name)) { m_NewImage.name = room.name; } Color WhitePixel = new Color32(255, 255, 255, 255); // Wall Cell Color PinkPixel = new Color32(255, 0, 255, 255); // Diagonal Wall Cell (North East) Color YellowPixel = new Color32(255, 255, 0, 255); // Diagonal Wall Cell (North West) Color HalfPinkPixel = new Color32(127, 0, 127, 255); // Diagonal Wall Cell (South East) Color HalfYellowPixel = new Color32(127, 127, 0, 255); // Diagonal Wall Cell (South West) Color BluePixel = new Color32(0, 0, 255, 255); // Floor Cell Color BlueHalfGreenPixel = new Color32(0, 127, 255, 255); // Floor Cell (Ice Override) Color HalfBluePixel = new Color32(0, 0, 127, 255); // Floor Cell (Water Override) Color HalfRedPixel = new Color32(0, 0, 127, 255); // Floor Cell (Carpet Override) Color GreenHalfRBPixel = new Color32(127, 255, 127, 255); // Floor Cell (Grass Override) Color HalfWhitePixel = new Color32(127, 127, 127, 255); // Floor Cell (Bone Override) Color OrangePixel = new Color32(255, 127, 0, 255); // Floor Cell (Flesh Override) Color RedHalfGBPixel = new Color32(255, 127, 127, 255); // Floor Cell (ThickGoop Override) Color GreenPixel = new Color32(0, 255, 0, 255); // Damage Floor Cell Color RedPixel = new Color32(255, 0, 0, 255); // Pit Cell Color BlackPixel = new Color32(0, 0, 0, 255); // NULL Cell for (int X = 0; X < width; X++) { for (int Y = 0; Y < height; Y++) { CellType? cellData = room.GetCellDataAtPoint(X, Y).state; bool DamageCell = false; DiagonalWallType diagonalWallType = DiagonalWallType.NONE; if (room.GetCellDataAtPoint(X, Y) != null && cellData.HasValue) { DamageCell = room.GetCellDataAtPoint(X, Y).doesDamage; diagonalWallType = room.GetCellDataAtPoint(X, Y).diagonalWallType; } if (room.GetCellDataAtPoint(X, Y) == null | !cellData.HasValue) { m_NewImage.SetPixel(X, Y, BlackPixel); } else if (cellData.Value == CellType.FLOOR) { if (DamageCell) { m_NewImage.SetPixel(X, Y, GreenPixel); } else if (room.GetCellDataAtPoint(X, Y).appearance != null) { CellVisualData.CellFloorType overrideFloorType = room.GetCellDataAtPoint(X, Y).appearance.OverrideFloorType; if (overrideFloorType == CellVisualData.CellFloorType.Stone) { m_NewImage.SetPixel(X, Y, BluePixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Ice) { m_NewImage.SetPixel(X, Y, BlueHalfGreenPixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Water) { m_NewImage.SetPixel(X, Y, HalfBluePixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Carpet) { m_NewImage.SetPixel(X, Y, HalfRedPixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Grass) { m_NewImage.SetPixel(X, Y, GreenHalfRBPixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Bone) { m_NewImage.SetPixel(X, Y, HalfWhitePixel); } else if (overrideFloorType == CellVisualData.CellFloorType.Flesh) { m_NewImage.SetPixel(X, Y, OrangePixel); } else if (overrideFloorType == CellVisualData.CellFloorType.ThickGoop) { m_NewImage.SetPixel(X, Y, RedHalfGBPixel); } else { m_NewImage.SetPixel(X, Y, BluePixel); } } else { m_NewImage.SetPixel(X, Y, BluePixel); } } else if (cellData.Value == CellType.WALL) { if (diagonalWallType == DiagonalWallType.NORTHEAST) { m_NewImage.SetPixel(X, Y, PinkPixel); } else if (diagonalWallType == DiagonalWallType.NORTHWEST) { m_NewImage.SetPixel(X, Y, YellowPixel); } else if (diagonalWallType == DiagonalWallType.SOUTHEAST) { m_NewImage.SetPixel(X, Y, HalfPinkPixel); } else if (diagonalWallType == DiagonalWallType.SOUTHWEST) { m_NewImage.SetPixel(X, Y, HalfYellowPixel); } else { m_NewImage.SetPixel(X, Y, WhitePixel); } } else if (cellData.Value == CellType.PIT) { m_NewImage.SetPixel(X, Y, RedPixel); } } } m_NewImage.Apply(); string basePath = "DumpedRoomLayouts/"; string fileName = (basePath + m_NewImage.name); if (string.IsNullOrEmpty(m_NewImage.name)) { fileName += ("RoomLayout_" + Guid.NewGuid().ToString()); } fileName += "_Layout"; string path = Path.Combine(ETGMod.ResourcesDirectory, fileName.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar) + ".png"); if (!File.Exists(path)) { Directory.GetParent(path).Create(); } File.WriteAllBytes(path, ImageConversion.EncodeToPNG(m_NewImage)); }
void InstantiateCell(char value, int x, int y) { GameObject cellToInstantiate = null; CellType? instantiatedType = null; GameObject instantiatedBox = null; switch (value) { case '.': { cellToInstantiate = Instantiate(Floor, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); instantiatedType = CellType.Floor; break; } case 'w': { cellToInstantiate = Instantiate(Wall, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); instantiatedType = CellType.Wall; break; } case 'b': { cellToInstantiate = Instantiate(Floor, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); instantiatedBox = Instantiate(Box, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); instantiatedType = CellType.Box; break; } case 'e': { cellToInstantiate = Instantiate(Exit, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); instantiatedType = CellType.TargetSpot; break; } case 'p': { cellToInstantiate = Instantiate(Floor, new Vector3(1 * x, 0, 1 * y), Quaternion.identity, SuperParentContainer.transform); var playerGameobject = Instantiate(Player, new Vector3(1 * x, 0, 1 * y), Quaternion.identity); mainPlayer = playerGameobject.GetComponent <MainPlayer>(); instantiatedType = CellType.Floor; mainPlayer.PlayerMovementText = PlayerMovementText; mainPlayer.PlayerPushText = PlayerPushText; mapData[y, x] = new Cell { Item = cellToInstantiate, Type = instantiatedType.Value, XCoordinate = y, YCoordinate = x }; mainPlayer.CellPosition = mapData[y, x]; Debug.Log(mainPlayer.CellPosition); break; } default: { Debug.Log("Can't instantiate"); break; } } mapData[y, x] = new Cell { Item = instantiatedBox, Type = instantiatedType.Value, XCoordinate = y, YCoordinate = x }; cellToInstantiate.transform.SetParent(SuperParentContainer.transform); }
/// <summary> /// 根据单元格的类型获取单元格的值 /// </summary> /// <param name="rowCell"></param> /// <param name="type"></param> /// <returns></returns> public static string GetValueByCellStyle(ICell rowCell, CellType?type) { string value = null; switch (type) { case CellType.String: value = rowCell.StringCellValue; break; case CellType.Numeric: if (DateUtil.IsCellInternalDateFormatted(rowCell)) { value = DateTime.FromOADate(rowCell.NumericCellValue).ToString(); } else if (DateUtil.IsCellDateFormatted(rowCell)) { value = DateTime.FromOADate(rowCell.NumericCellValue).ToString(); } //有些情况,时间搓?数字格式化显示为时间,不属于上面两种时间格式 else if (rowCell.CellStyle.GetDataFormatString() == null) { value = DateTime.FromOADate(rowCell.NumericCellValue).ToString(); } else if (rowCell.CellStyle.GetDataFormatString().Contains("$")) { value = "$" + rowCell.NumericCellValue.ToString(); } else if (rowCell.CellStyle.GetDataFormatString().Contains("¥")) { value = "¥" + rowCell.NumericCellValue.ToString(); } else if (rowCell.CellStyle.GetDataFormatString().Contains("¥")) { value = "¥" + rowCell.NumericCellValue.ToString(); } else if (rowCell.CellStyle.GetDataFormatString().Contains("€")) { value = "€" + rowCell.NumericCellValue.ToString(); } else { value = rowCell.NumericCellValue.ToString(); } break; case CellType.Boolean: value = rowCell.BooleanCellValue.ToString(); break; case CellType.Error: value = ErrorEval.GetText(rowCell.ErrorCellValue); break; case CellType.Formula: // TODO: 是否存在 嵌套 公式类型 value = GetValueByCellStyle(rowCell, rowCell?.CachedFormulaResultType); break; } return(value); }