public GridModel(int sizeOfSide) { this.grid = new Grid(sizeOfSide); this.countOfEmptyCells = this.grid.numberOfCells; this.winner = ECellType.Empty; this.currentPlayer = ECellType.X; }
public static string CellTypeToText(ECellType cell_type) { if (cell_type == ECellType.LiFePo4) { return("LiFePo4"); } if (cell_type == ECellType.LiFePo4_Full) { return("LiFePo4 Full"); } if (cell_type == ECellType.LiIon) { return("LiIon"); } if (cell_type == ECellType.LiPo) { return("LiPo"); } if (cell_type == ECellType.PbAcid3) { return("Pb Acid 3 cells"); } if (cell_type == ECellType.PbAcid6) { return("Pb Acid 6 cells"); } return("<unknown>"); }
public void CopyFrom(SerializableCell _cell) { cellStatus = (ECellStatus)_cell.cellStatus; cellType = (ECellType)_cell.cellType; if (cellType == CellScript.ECellType.Number) { intCellContent = int.Parse(_cell.cellContent); m_currentColor = LevelEditor.instance.colorConfiguration.numberBlockColor; } else if (cellType == CellScript.ECellType.Operation) { charCellContent = _cell.cellContent.ToCharArray()[0]; CurrentColor = LevelEditor.instance.colorConfiguration.operationBlockColor; } else { CurrentColor = LevelEditor.instance.colorConfiguration.unusedBlockColor; } if (cellStatus == CellScript.ECellStatus.Hidden) { PreviousColor = CurrentColor; CurrentColor = LevelEditor.instance.colorConfiguration.hiddenBlockColor; } }
public void OnPointerClick(PointerEventData eventData) { if (eventData.button != PointerEventData.InputButton.Left && eventData.button != PointerEventData.InputButton.Right) { return; } int CellType = (int)CurrentCellType; if (eventData.button == PointerEventData.InputButton.Left) { CellType += 1; } else if (eventData.button == PointerEventData.InputButton.Right) { CellType -= 1; } if (CellType < 0) { CellType = 4; } else if (CellType > 4) { CellType = 0; } CurrentCellType = (ECellType)CellType; UpdateSprite(); }
/// <summary> /// .ctor /// </summary> /// <param name="iX"></param> /// <param name="iY"></param> /// <param name="enCellType"></param> public CCell(int iX, int iY, ECellType enCellType) { X = iX; Y = iY; CellType = enCellType; IsExit = (enCellType == ECellType.Place); }
public void Clear() { if (_type != ECellType.WALL) { _type = ECellType.EMPTY; } }
private void Update() { if (!_currentPath.Empty) { TargetCell = _currentPath.Nodes.LastOrDefault().CurrentCellType; CurrentCell = MyPosition.CurrentCellType; var rotation = Quaternion.LookRotation(_currentPath.Nodes[0].Position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, rotation, 0.1f); if (_currentPath.Nodes[0].CurrentCellType == ECellType.Busy) { BeginMovementByPath(Pathfinder.FindPathToDestination(MyPosition.GridPosition, _currentPath.Nodes.Last().GridPosition)); if (!_currentPath.Empty) { MoveToTarget(_currentPath.Nodes[0].Position); } else { ToggleAnimationState(EMovableObjectState.Standing); } } else { MoveToTarget(_currentPath.Nodes[0].Position); } DrawDebugPath(); } }
public void SetState(ECellType statue, int mineCount = 0) { if ((statue != ECellType.Number && this.statue == statue) || (statue == ECellType.Number && mineCountInBorder == mineCount)) { //is the same do not need reflash return; } this.statue = statue; switch (statue) { case ECellType.UnOpened: { SetStatus(false, false, true, false, ""); break; } case ECellType.Number: { SetStatus(false, true, false, false, mineCount == 0 ? "" : mineCount.ToString()); break; } case ECellType.Flag: { SetStatus(true, false, true, false, ""); break; } case ECellType.Mine: { SetStatus(false, false, false, true, ""); break; } } }
public MapData(int sizeX, int sizeY, ECellType fullFillCellType = ECellType.Air) { SizeX = sizeX; SizeZ = sizeY; FullFillMapData(fullFillCellType); InitializeBorder(); }
bool checkStep(Cell cell, ECellType type) { if (cell.state == ECellType.Empty && type != ECellType.Empty) { return(true); } return(false); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { ECellType celltype = (ECellType)value; switch (celltype) { case ECellType.Dark: return(new SolidColorBrush(Colors.CadetBlue)); case ECellType.Light: return(new SolidColorBrush(Colors.White)); } throw new ArgumentException("Invalid input, could not convert"); }
private void FullFillMapData(ECellType cellType) { Cells = new ECellType[SizeZ + 2][]; Level = new int[SizeZ + 2][]; for (int j = 0; j < SizeZ + 2; j++) { Cells[j] = new ECellType[SizeX + 2]; Level[j] = new int[SizeX + 2]; for (int i = 0; i < SizeX + 2; i++) { Cells[j][i] = cellType; Level[j][i] = 0; } } }
private GameObject getPrefabType(ECellType cellType) { switch (cellType) { case ECellType.AirWall: return(airWallPrefab); case ECellType.Air: return(null); case ECellType.Ground: return(groundPrefab); case ECellType.Stone: return(stonePrefab); default: return(null); } }
public override void OnInspectorGUI() { map = serializedObject.targetObject as GridMap2D; map.m_GridCustom = EditorGUILayout.ObjectField("自定义网格类型", map.m_GridCustom, typeof(GridCustom), true) as GridCustom; map.m_rowCount = EditorGUILayout.IntField("行数", map.m_rowCount); map.m_colCount = EditorGUILayout.IntField("列数", map.m_colCount); map.m_cellWidth = EditorGUILayout.FloatField("单元格宽度", map.m_cellWidth); map.m_cellHeight = EditorGUILayout.FloatField("单元格高度", map.m_cellHeight); map.m_offsetInWorldSapce = EditorGUILayout.Vector3Field("世界空间偏移", map.m_offsetInWorldSapce); map.Fit(); EditorGUILayout.LabelField("总宽度", map.Length.ToString()); EditorGUILayout.LabelField("总高度", map.Height.ToString()); m_from = EditorGUILayout.Vector2Field("从", m_from); m_to = EditorGUILayout.Vector2Field("到", m_to); if (GUILayout.Button("寻路")) { FindPath(false); } if (GUILayout.Button("寻路(忽略对角)")) { FindPath(true); } if (m_curSelectedPoint != IPoint.Unavailable) { ECellType type = (ECellType)map.GetType(m_curSelectedPoint.X, m_curSelectedPoint.Y); ECellType s = (ECellType)EditorGUILayout.EnumPopup("单元格类型", type); map.SetType(m_curSelectedPoint.X, m_curSelectedPoint.Y, (int)s); } if (m_curOverCellPos != null) { EditorGUILayout.LabelField("当前选中", m_curSelectedPoint.ToString()); } EditorUtility.SetDirty(map); }
public bool Step(int row, int col) { if (row < 0 || row >= this.grid.sizeOfSide || col < 0 || col >= this.grid.sizeOfSide) { OnDisplay("Указана ячейка, не содержащаяся в таблице"); return false; } Cell cell = this.grid.getCell(row, col); ECellType type = this.currentPlayer; if (!checkStep(cell, type)) { OnDisplay("Ячейка не пустая"); return false; } cell.state = type; countOfEmptyCells--; this.winner = checkWinner(row, col); changeCurrentPlayer(); OnDisplay(); return true; }
public bool Step(int row, int col) { if (row < 0 || row >= this.grid.sizeOfSide || col < 0 || col >= this.grid.sizeOfSide) { OnDisplay("Указана ячейка, не содержащаяся в таблице"); return(false); } Cell cell = this.grid.getCell(row, col); ECellType type = this.currentPlayer; if (!checkStep(cell, type)) { OnDisplay("Ячейка не пустая"); return(false); } cell.state = type; countOfEmptyCells--; this.winner = checkWinner(row, col); changeCurrentPlayer(); OnDisplay(); return(true); }
public ECell(int x, int y) { _point = new MPoint(x, y); _type = ECellType.EMPTY; }
public CLayerCell(string eType, string _name, int _ID) { CellType = (ECellType)Enum.Parse(typeof(ECellType), eType); Name = _name; ID = _ID; }
public CLayerCell() { CellType = ECellType.GC_string; }
public Cell(ECellType eCellType, Vector2 gridPos) : this(eCellType) { GridPos = gridPos; }
/// <summary> /// コンストラクタ /// </summary> public Cell(ECellType type, params int [] values) { mCellType = type; mValues = values; }
public CLogEntry(EtaLoggingChargerControl logging_charger_control, CDevice device, uint start_sector, string name, CSample[] samples, ECellType cell_type, bool is_discharging) { LoggingChargerControl = logging_charger_control; Device = device; StartSector = start_sector; Name = name; Samples = samples; IsDischarging = is_discharging; CellType = cell_type; ProcessingTime = new TimeSpan(0, 0, Samples.Length / 2); double _avarage_current = 0, _midpoint_voltage = 0, _amp_hour = 0, _watt = 0; foreach (CSample _sample in Samples) { _amp_hour += _sample.CellCurrent; _midpoint_voltage += _sample.CellVoltage; _watt += (_sample.CellVoltage * _sample.CellCurrent); } AvarageCurrent = _amp_hour / Samples.Length; MidpointVoltage = _midpoint_voltage / Samples.Length; AmpHour = _amp_hour / 7200; Wattage = _watt / 7200; }
public void MarkAsQuestion(Color _questionColor) { cellType = ECellType.Question; m_imageReference.color = _questionColor; m_textReference.enabled = false; }
public void Initialize() { m_SpriteRenderer = GetComponent <SpriteRenderer>(); CurrentCellType = ECellType.Ground; UpdateSprite(); }
public void MarkAsAnswer() { cellType = ECellType.Answer; }
public void MarkAsAnswered(GameplayCell _other) { cellType = ECellType.Hint; m_imageReference.color = _other.CellColor; m_textReference.enabled = true; }
/// <summary> /// デフォルトコンストラクタ /// </summary> public Cell() { mCellType = ECellType.Wall; mValues = null; }
public void SetType(ECellType type) { _type = type; }
/// <summary> /// セルイメージを取得する /// </summary> /// <param name="cellType"></param> /// <param name="ownerPlayer"></param> /// <returns></returns> private Image GetCellImage(ECellType cellType, EPlayerType ownerPlayer) { // 該当するイメージのインデックス ECellImage cellImageIndex = ECellImage.FLOOR_NONE; // セルタイプで分岐 switch (cellType) { // 通常床 case ECellType.FLOOR: // 所有者で分岐 switch (ownerPlayer) { case EPlayerType.NO_PLAYER: cellImageIndex = ECellImage.FLOOR_NONE; break; case EPlayerType.PLAYER1: cellImageIndex = ECellImage.FLOOR_1; break; case EPlayerType.PLAYER2: cellImageIndex = ECellImage.FLOOR_2; break; case EPlayerType.PLAYER3: cellImageIndex = ECellImage.FLOOR_3; break; case EPlayerType.PLAYER4: cellImageIndex = ECellImage.FLOOR_4; break; } break; // スタート台 case ECellType.START: // 所有者で分岐 switch (ownerPlayer) { case EPlayerType.NO_PLAYER: cellImageIndex = ECellImage.START_NONE; break; case EPlayerType.PLAYER1: cellImageIndex = ECellImage.START_1; break; case EPlayerType.PLAYER2: cellImageIndex = ECellImage.START_2; break; case EPlayerType.PLAYER3: cellImageIndex = ECellImage.START_3; break; case EPlayerType.PLAYER4: cellImageIndex = ECellImage.START_4; break; } break; // 壁 case ECellType.WALL: cellImageIndex = ECellImage.WALL; break; // 網床 case ECellType.WIRE_MESH: cellImageIndex = ECellImage.WIRE_MESH; break; } // 結果を返す return(_cellImageList[(int)cellImageIndex]); }
public Cell() { this.state = ECellType.Empty; }
public Cell(ECellType eCellType) { ECellType = eCellType; }
bool checkStep(Cell cell, ECellType type) { if (cell.state == ECellType.Empty && type != ECellType.Empty) return true; return false; }
/// <summary> /// コピー /// </summary> public void CopyFrom(Cell src) { mCellType = src.CellType; mValues = src.Values; }