public Cell GetLeftWithType(CellTypes type = CellTypes.Usual) { var left = Left; while (left != null) { if (left.Type == type ) { return left; } left = left.Left; } return null; }
public Cell GetBottomWithType(CellTypes type = CellTypes.Usual) { var bottom = Bottom; while (bottom != null) { if (bottom.Type == type) { return bottom; } bottom = bottom.Bottom; } return null; }
public Cell GetRightWithType(CellTypes type = CellTypes.Usual) { var right = Right; while (right != null) { //Debug.Log("Right" + right.ToString()); if (right.Type == type) { return right; } right = right.Right; } return null; }
public LabirintVertex(CellTypes type) { NodeType = type; Neighbours = new List <LabirintVertex>(); }
// ckeck for chain=|winSize cells of same type in a row| in 4 possible directions // for every valid starting point on the field private void CheckGame() { // check rows for (int i = 0; i < GameSettings.yDim; i++) { for (int j = 0; j < GameSettings.xDim - GameSettings.winSize + 1; j++) { CellTypes start = Cells[i * GameSettings.xDim + j]; if (start != CellTypes.Clear) { bool foundChain = true; for (int k = 1; k < GameSettings.winSize; k++) { if (Cells[i * GameSettings.xDim + (j + k)] != start) { foundChain = false; } } if (foundChain) { Winner = CalculateWinner(); GameOver = true; GameOverConditions = new Conditions { winner = Winner, direction = "right", i = i, j = j }; return; } } } } // check columns for (int i = 0; i < GameSettings.yDim - GameSettings.winSize + 1; i++) { for (int j = 0; j < GameSettings.xDim; j++) { CellTypes start = Cells[i * GameSettings.xDim + j]; if (start != CellTypes.Clear) { bool foundChain = true; for (int k = 1; k < GameSettings.winSize; k++) { if (Cells[(i + k) * GameSettings.xDim + j] != start) { foundChain = false; } } if (foundChain) { Winner = CalculateWinner(); GameOver = true; GameOverConditions = new Conditions { winner = Winner, direction = "down", i = i, j = j }; return; } } } } // check dioganal right+down for (int i = 0; i < GameSettings.yDim - GameSettings.winSize + 1; i++) { for (int j = 0; j < GameSettings.xDim - GameSettings.winSize + 1; j++) { CellTypes start = Cells[i * GameSettings.xDim + j]; if (start != CellTypes.Clear) { bool foundChain = true; for (int k = 1; k < GameSettings.winSize; k++) { if (Cells[(i + k) * GameSettings.xDim + (j + k)] != start) { foundChain = false; } } if (foundChain) { Winner = CalculateWinner(); GameOver = true; GameOverConditions = new Conditions { winner = Winner, direction = "right+down", i = i, j = j }; return; } } } } // check dioganal left+down for (int i = 0; i < GameSettings.yDim - GameSettings.winSize + 1; i++) { for (int j = GameSettings.winSize - 1; j < GameSettings.xDim; j++) { CellTypes start = Cells[i * GameSettings.xDim + j]; if (start != CellTypes.Clear) { bool foundChain = true; for (int k = 1; k < GameSettings.winSize; k++) { if (Cells[(i + k) * GameSettings.xDim + (j - k)] != start) { foundChain = false; } } if (foundChain) { Winner = CalculateWinner(); GameOver = true; GameOverConditions = new Conditions { winner = Winner, direction = "left+down", i = i, j = j }; return; } } } } if (MovesCount == GameSettings.xDim * GameSettings.yDim) { Winner = "draw"; GameOver = true; GameOverConditions = new Conditions { winner = Winner, direction = "none", i = -1, j = -1 }; return; } }
private void DecodeNUMBER(Bytes data) { _value = BitConverter.ToDouble(data.ByteArray, 0); _type = CellTypes.Float; }
// Use this for initialization void Start() { Type = CellTypes.Empty; }
private void UpdateMaterial() { switch (RoadType) { case CellTypes.Empty: currentCell.GetComponent <MeshRenderer>().sharedMaterial = Empty; currentCell.transform.localEulerAngles = Vector3.zero; gameObject.isStatic = false; Checker = RoadType; break; case CellTypes.FourRoad: currentCell.GetComponent <MeshRenderer>().sharedMaterial = FourRoad; currentCell.transform.localEulerAngles = Vector3.zero; gameObject.isStatic = true; Checker = RoadType; break; case CellTypes.HorRoad: currentCell.GetComponent <MeshRenderer>().sharedMaterial = StrRoad; currentCell.transform.localEulerAngles = Vector3.zero; gameObject.isStatic = true; Checker = RoadType; break; case CellTypes.VertRoad: currentCell.GetComponent <MeshRenderer>().sharedMaterial = StrRoad; currentCell.transform.localEulerAngles = RotValue; gameObject.isStatic = true; Checker = RoadType; break; case CellTypes.ThreeBotRoad: currentCell.GetComponent <MeshRenderer>().sharedMaterial = ThreeRoad; currentCell.transform.localEulerAngles = RotValue * 2; gameObject.isStatic = true; Checker = RoadType; break; case CellTypes.ThreeLeftRoad: currentCell.GetComponent <MeshRenderer>().sharedMaterial = ThreeRoad; currentCell.transform.localEulerAngles = -RotValue; gameObject.isStatic = true; Checker = RoadType; break; case CellTypes.ThreeRightRoad: currentCell.GetComponent <MeshRenderer>().sharedMaterial = ThreeRoad; currentCell.transform.localEulerAngles = RotValue; gameObject.isStatic = true; Checker = RoadType; break; case CellTypes.ThreeTopRoad: currentCell.GetComponent <MeshRenderer>().sharedMaterial = ThreeRoad; currentCell.transform.localEulerAngles = Vector3.zero; gameObject.isStatic = true; Checker = RoadType; break; case CellTypes.LeftToBotRoad: currentCell.GetComponent <MeshRenderer>().sharedMaterial = LTRoad; currentCell.transform.localEulerAngles = RotValue * 2; gameObject.isStatic = true; Checker = RoadType; break; case CellTypes.LeftToTopRoad: currentCell.GetComponent <MeshRenderer>().sharedMaterial = LTRoad; currentCell.transform.localEulerAngles = -RotValue; gameObject.isStatic = true; Checker = RoadType; break; case CellTypes.RightToBotRoad: currentCell.GetComponent <MeshRenderer>().sharedMaterial = RTRoad; currentCell.transform.localEulerAngles = RotValue * 2; gameObject.isStatic = true; Checker = RoadType; break; case CellTypes.RightToTopRoad: currentCell.GetComponent <MeshRenderer>().sharedMaterial = RTRoad; currentCell.transform.localEulerAngles = RotValue; gameObject.isStatic = true; Checker = RoadType; break; } }
public SpecialCell(CellTypes celltype) { m_cellType = celltype; if (celltype == CellTypes.Transparent) m_color = System.Drawing.Color.Transparent; }
public Cell(int x, int y, CellTypes type = CellTypes.Usual) { this.x = x; this.y = y; this.Type = type; }
private void DecodeFORMULA(Bytes data, Record stringRecord) { //TODO: Read in formula properties if (stringRecord != null) _value = UnicodeBytes.Read(stringRecord.Data, 16); _type = CellTypes.Formula; }
private void DecodeLABEL(Bytes data) { _value = UnicodeBytes.Read(data, 16); _type = CellTypes.Text; }
public string GetCell(CellTypes types) { return(_inner.GetCell(types)); }
private static Func <CellInfo, bool> IsCellType(CellTypes t) => (c) => c.CellType == t;
public override Map Generate(int x, int y) { var map = new Map(x, y, this); map.Cells.Clear(); //var tileSet = BuildTileSet(); var topCells = CellTypes.Where(ct => !ct.Name.ToLower().Contains("up")).ToList(); var downCells = CellTypes.Where(ct => !ct.Name.ToLower().Contains("down")).ToList(); var leftCells = CellTypes.Where(ct => !ct.Name.ToLower().Contains("left")).ToList(); var rightCells = CellTypes.Where(ct => !ct.Name.ToLower().Contains("right")).ToList(); map.Cells.Add(new CornerRightDown(map, false) { Position = new Point(0, 0) }); map.Cells.Add(new CornerLeftDown(map, false) { Position = new Point(x, 0) }); map.Cells.Add(new CornerRightUp(map, false) { Position = new Point(0, y) }); map.Cells.Add(new CornerLeftUp(map, false) { Position = new Point(x, y) }); //Todo should be more generic for (int i = 1; i < x; i++) { var cell = (Cell)Activator.CreateInstance(topCells[random.Next(0, topCells.Count)], map, false); cell.Position = new Point(i, 0); map.Cells.Add(cell); } for (int i = 1; i < y; i++) { var cell = (Cell)Activator.CreateInstance(leftCells[random.Next(0, topCells.Count)], map, false); cell.Position = new Point(0, i); cell.Movable = false; map.Cells.Add(cell); } for (int i = 1; i < x; i++) { var cell = (Cell)Activator.CreateInstance(downCells[random.Next(0, topCells.Count)], map, false); cell.Position = new Point(i, y); cell.Movable = false; map.Cells.Add(cell); } for (int i = 1; i < y; i++) { var cell = (Cell)Activator.CreateInstance(rightCells[random.Next(0, topCells.Count)], map, false); cell.Position = new Point(x, i); cell.Movable = false; map.Cells.Add(cell); } //x + 1 bis x - 1 //y + 1 bis y - 1 for (int tempX = 1; tempX < x; tempX++) { for (int tempY = 1; tempY < y; tempY++) { var nTopCell = map.Cells.FirstOrDefault(c => c.Position.X == tempX && c.Position.Y == tempY - 1); var nDownCell = map.Cells.FirstOrDefault(c => c.Position.X == tempX && c.Position.Y == tempY + 1); var nLeftCell = map.Cells.FirstOrDefault(c => c.Position.X == tempX - 1 && c.Position.Y == tempY); var nRightCell = map.Cells.FirstOrDefault(c => c.Position.X == tempX + 1 && c.Position.Y == tempY); var possibleCells = CellTypes.Where(cellType => ((nTopCell != null && nTopCell.GetType().Name.ToLower().Contains("down")) ? (cellType.Name.ToLower().Contains("up") ? true : false) : true) && ((nDownCell != null && nDownCell.GetType().Name.ToLower().Contains("up")) ? (cellType.Name.ToLower().Contains("down") ? true : false) : true) && ((nLeftCell != null && nLeftCell.GetType().Name.ToLower().Contains("right")) ? (cellType.Name.ToLower().Contains("left") ? true : false) : true) && ((nRightCell != null && nLeftCell.GetType().Name.ToLower().Contains("left")) ? (cellType.Name.ToLower().Contains("right") ? true : false) : true)).ToArray(); var cell = (Cell)Activator.CreateInstance(possibleCells[random.Next(0, possibleCells.Length)], map, true); cell.Position = new Point(tempX, tempY); map.Cells.Add(cell); } } foreach (MapCell ourCell in map.Cells) { ourCell.NormalizeLayering(); } //Default coin stack var r = new Random(); map.Cells.Add(new CoinStack(map) { Position = new Point(5 * r.Next(1, map.Width - 2) - 3, 3 * r.Next(1, map.Height - 2) - 2) }); return(map); }
public Currency GetCost(CellTypes type) { return(GetPrefab(type).Cost); }
/// <summary> /// Creates a map cell /// </summary> /// <param name="type">The cell type</param> public Cell(CellTypes type) { Type = type; }
// Constructor public Player(ulong playerId, CellTypes type) { PlayerId = playerId; Type = type; Score = 0; }
public CellDescription(int x, int y, CellTypes type) : this(x,y) { Type = type; }
// Update cells models to display when entering a new room void UpdateCellsModels() { OneCellClass current = GetCurrentCell(); CellTypes curType = current.cellType; int curId = current.cellId; m_CentreModels.SetActiveModel(curType); m_NorthModels.SetActiveModel(GetNorthType(curId)); m_EastModels.SetActiveModel(GetEastType(curId)); m_SouthModels.SetActiveModel(GetSouthType(curId)); m_WestModels.SetActiveModel(GetWestType(curId)); if (curType == CellTypes.Exit) { float light_range = 4.0f; Color light_colour = new Color(0.9f, 1.0f, 0.9f, 1.0f); SetupLights(m_CentreModels, light_range, light_colour); //remove the north wall "Trap_1" from south_cell... GameObject southModel = m_SouthModels.GetActiveModel(); if (southModel) { GameObject northWall = southModel.transform.Find("Trap_1").gameObject; //Debug.Log($"[GameMgr][{Time.fixedTime - startingTime}s] {m_SouthModels.transform.name}, model: {northWall.name}"); if (northWall != null) { northWall.SetActive(false); } } } else if (curType == CellTypes.Deadly) { SetupLightsBySubType(m_CentreModels, current.cellSubType); } // Activate levers for centre model only if (m_CentreModels.m_GenCellA.activeSelf == true) { //Debug.Log($"[GameMgr][{Time.fixedTime - startingTime}s] {m_CentreModels.m_GenCellA.name}, MechanismNorth= {current.cellId}"); /* * GameObject genAModel = m_CentreModels.m_GenCellA.gameObject; * GameObject h1 = genAModel.transform.Find("Trap_1").gameObject; * GameObject h2 = h1.transform.Find("manche_base").gameObject; * GameObject h3 = h2.transform.Find("manche").gameObject; * h3.SetActive(true); * OneCellClass toto = GetCurrentCell(); * MechanismMove mec = h3.GetComponentInChildren<MechanismMove>(); * toto.MechanismNorth = mec; */ if (current.MechanismNorth.m_modelSet == false) { MechanismMove[] mecs = m_CentreModels.m_GenCellA.GetComponentsInChildren <MechanismMove>(); foreach (MechanismMove mec in mecs) { mec.enabled = true; switch (mec.cardinal) { case CardinalPoint.North: current.MechanismNorth = mec; current.MechanismNorth.m_modelSet = true; break; case CardinalPoint.East: current.MechanismEast = mec; current.MechanismEast.m_modelSet = true; break; case CardinalPoint.South: current.MechanismSouth = mec; current.MechanismSouth.m_modelSet = true; break; case CardinalPoint.West: current.MechanismWest = mec; current.MechanismWest.m_modelSet = true; break; default: Debug.LogWarning($"Wrong cardinal {mec.cardinal} for MechanismMove"); break; } } } } SetupAdjacentLights(null, 0.0f, Color.red); }
public Cell GetTopWithType(CellTypes type = CellTypes.Usual) { var top = Top; while (top != null && !top.IsTemporary) { if (top.Type == type) { return top; } top = top.Top; } return null; }
public virtual string GetCell(CellTypes types) { return(BasePath + "/TableCells/" + types.ToString() + ".cshtml"); }
private void DecodeLABELSST(Bytes data) { _value = BitConverter.ToUInt32(data.ByteArray, 0); _type = CellTypes.Text; }
public CellDescription(int x, int y, CellTypes type, CreationType creationType) : this(x,y,type) { CreationType = creationType; }
private void DecodeRK(Bytes bytes) { Bytes.Bits bits = bytes.GetBits(); bool div100 = bits.Values[0]; bool isInt = bits.Values[1]; if (isInt) { Value = DecodeRKInt(bits, div100); _type = (Value is Int32) ? CellTypes.Integer : CellTypes.Float; } else { Value = DecodeRKFloat(bits, div100); _type = CellTypes.Float; } }
private int MinimaxValue(GameLogic logic, int depth, CellTypes originalTurn, CellTypes currentTurn) { logic.DetermineUsableCells(currentTurn, (currentTurn == CellTypes.Player1) ? CellTypes.Player2 : CellTypes.Player1); if (depth == 7 || logic.IsGameWinnable(currentTurn) == -1) { return(Heruistic(originalTurn, logic)); } GetPossibleMoves(logic.GameBoard, ref PossibleMoves); CellTypes opponent = CellTypes.Player1; if (currentTurn == CellTypes.Player1) { opponent = CellTypes.Player2; } // If no moves are available, pass the turn to the other player if (PossibleMoves.Count == 0) { return(MinimaxValue(logic, depth + 1, originalTurn, opponent)); } else { int bestValue = -99999; // for finding max if (originalTurn != currentTurn) { bestValue = 99999; } // Try every single move for (int i = 0; i < PossibleMoves.Count; i++) { GameLogic tempLogic = new GameLogic(logic.boardSize); tempLogic.GameBoard = GetBoardCopy(tempLogic, logic.GameBoard); // Make move tempLogic.GameBoard[PossibleMoves[i].Y, PossibleMoves[i].X].Type = currentTurn; // Exact recursive call int newValue = MinimaxValue(tempLogic, depth + 1, originalTurn, currentTurn); // Remember the best move if (originalTurn == currentTurn) { // Remember Max if it's the originator's turn if (newValue > bestValue) { bestValue = newValue; } } else { // Remember Min if it's the opponent turn if (newValue < bestValue) { bestValue = newValue; } } } return(bestValue); } }
public Cell(CellTypes _type, Rectangle _spacePos) { type = _type; contains = null; spacePos = _spacePos; }
public bool IsWon(int startX, int startY, CellTypes type, Directions direction) { if (direction == Directions.HORIZONTAL) { for (int y = 0; y < Size; y++) { if (cells[startX, y] != type) { return(false); } } } else if (direction == Directions.VERTICAL) { for (int x = 0; x < Size; x++) { if (cells[x, startY] != type) { return(false); } } } else // Diagonal { int count = 1; int x, y; // Up_Left x = startX - 1; y = startY - 1; while (x >= 0 && y >= 0) { if (cells[x, y] != type) { break; } count++; x--; y--; } // Down_Right x = startX + 1; y = startY + 1; while (x < Size && y < Size) { if (cells[x, y] != type) { break; } count++; x++; y++; } if (count == Size) { return(true); } count = 1; // Up_Right x = startX - 1; y = startY + 1; while (x >= 0 && y < Size) { if (cells[x, y] != type) { break; } count++; x--; y++; } // Down_Left x = startX + 1; y = startY - 1; while (x < Size && y >= 0) { if (cells[x, y] != type) { break; } count++; x++; y--; } return(count == Size); } return(true); }
// Получение фигуры противника private CellTypes GetCellTypeEnemy(CellTypes cellTypePlayer) => cellTypePlayer == CellTypes.o ? CellTypes.x : CellTypes.o;
public Cell(CellTypes CellType, Vector3 GlobalPosition, int Cost) { this.CellType = CellType; this.GlobalPosition = GlobalPosition; this.Cost = Cost; }
/// <summary> /// 列类型 /// </summary> /// <param name="col"></param> /// <param name="cellType"></param> /// <returns></returns> public static GridColumn CellType(this GridColumn col, CellTypes cellType = CellTypes.String) { col.sType = cellType.ToString().ToLower(); return(col); }
public static Cell CreateCell(CellTypes type, string name, string colour, Figures figure, string figureColour, bool fill, bool hasDialogue, Effect[] enterEffects, Effect[] glanceEffects, string desc) { switch (type) { case CellTypes.ErrType: Task.Run(() => Logger.Log("Could not get cell type - it's been set to Empty")).Wait(); return(new EmptyCell(name: name, colour: colour, figure: figure, figureColour: figureColour, fill: fill, hasDialogue: hasDialogue, enterEffects: enterEffects, glanceEffects: glanceEffects, desc: desc)); case CellTypes.Empty: return(new EmptyCell(name: name, colour: colour, figure: figure, figureColour: figureColour, fill: fill, hasDialogue: hasDialogue, enterEffects: enterEffects, glanceEffects: glanceEffects, desc: desc)); case CellTypes.GlanceTrap: return(new GlanceTrapCell(name: name, colour: colour, figure: figure, figureColour: figureColour, fill: fill, hasDialogue: hasDialogue, enterEffects: enterEffects, glanceEffects: glanceEffects, desc: desc)); case CellTypes.EnterTrap: return(new EnterTrapCell(name: name, colour: colour, figure: figure, figureColour: figureColour, fill: fill, hasDialogue: hasDialogue, enterEffects: enterEffects, glanceEffects: glanceEffects, desc: desc)); case CellTypes.Char: return(new CharCell(name: name, colour: colour, figure: figure, figureColour: figureColour, fill: fill, hasDialogue: hasDialogue, enterEffects: enterEffects, glanceEffects: glanceEffects, desc: desc)); case CellTypes.Player: return(new PlayerCell(name: name, colour: colour, figure: figure, figureColour: figureColour, fill: fill, hasDialogue: hasDialogue, enterEffects: enterEffects, glanceEffects: glanceEffects, desc: desc)); case CellTypes.Darkness: return(new DarknessCell(name: name, colour: colour, figure: figure, figureColour: figureColour, fill: fill, hasDialogue: hasDialogue, enterEffects: enterEffects, glanceEffects: glanceEffects, desc: desc)); case CellTypes.Exit: return(new ExitCell(name: name, colour: colour, figure: figure, figureColour: figureColour, fill: fill, hasDialogue: hasDialogue, enterEffects: enterEffects, glanceEffects: glanceEffects, desc: desc)); default: Task.Run(() => Logger.Log("Unrecognizable cell type - it's been set to Empty")).Wait(); return(new EmptyCell(name: name, colour: colour, figure: figure, figureColour: figureColour, fill: fill, hasDialogue: hasDialogue, enterEffects: enterEffects, glanceEffects: glanceEffects, desc: desc)); } }
public CellModel(CellTypes cellType, int digit, int fileLine) { FileLine = fileLine; CellType = cellType; Digit = digit; }