public void SetColor(TileColor tc, bool force = false) { SpriteRenderer s = gameObject.GetComponent <SpriteRenderer>(); if (tc == TileColor.Gray) { s.color = new Color32((byte)145, (byte)145, (byte)145, (byte)255); } else if (tc == TileColor.White) { s.color = new Color32((byte)255, (byte)255, (byte)255, (byte)255); } else if (board.Options["highlight"] == true || force == true) { switch (tc) { case TileColor.Green: s.color = new Color32((byte)188, (byte)255, (byte)154, (byte)255); break; case TileColor.Red: s.color = new Color32((byte)255, (byte)80, (byte)80, (byte)255); break; default: s.color = new Color32((byte)255, (byte)255, (byte)255, (byte)255); break; } } }
//find all possible plays given the current game state // this takes into consideration whose turn it is public Dictionary <Tuple <int, int>, Play> PossiblePlays(bool otherPlayer = false) { //for all open spots on the board that are adjacent to any tiles List <Tuple <int, int> > possiblePositions = Board.OpenAdjacentSpots(); Dictionary <Tuple <int, int>, Play> results = new Dictionary <Tuple <int, int>, Play>(); TileColor playerColor = IsPlayer1 ? TileColor.BLACK : TileColor.WHITE; // If calcualting potential moves for the other player switch the color if (otherPlayer) { playerColor = IsPlayer1 ? TileColor.WHITE : TileColor.BLACK;; } foreach (Tuple <int, int> coord in possiblePositions) { Play possiblePlay = new Play(Board, playerColor, coord); if (possiblePlay.AffectedTiles != null) { results.Add(coord, possiblePlay); } } return(results); }
void OnKeyCollected(TileColor keyColor) { if (keyColor == m_Color) { Destroy(gameObject); } }
public async Task <TileColor> Update(TileColor color) { var _tileColor = await _repo.Get(color.TileColorId); if (_tileColor == null) { return(_tileColor); } _tileColor.TitleBgColor = color.TitleBgColor; _tileColor.TitleTextColor = color.TitleTextColor; _tileColor.BodyBgColor = color.BodyBgColor; _tileColor.BodyTextColor = color.BodyTextColor; _tileColor.CharacterTileId = color.CharacterTileId; _tileColor.CreatedBy = color.CreatedBy; _tileColor.CreatedDate = DateTime.Now; try { await _repo.Update(_tileColor); } catch (Exception ex) { throw ex; } return(_tileColor); }
private void TapTile() { if (!canSelect) { return; } Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; float raycastDistance = 100f; if (Physics.Raycast(ray, out hit, raycastDistance)) { GameObject collidedGO = hit.collider.gameObject; Selector selector = collidedGO.GetComponent <Selector>(); TileColor tileColor = collidedGO.GetComponent <TileColor>(); if (selector != null && tileColor != null) { GridCoordinates gridCoordinates = selector.gameObject.GetComponent <GridCoordinates>(); if (gridCoordinates != null && freeTileChecker.CanTapTile(gridCoordinates.MyPosition)) { SelectTile(selector, tileColor); } } } }
public void TileHit(Vector2Int HitDirection, TileColor tileColour) { //Check if the light can pass through if (TileColor.ContainColour(tileColour, FilterColour)) { LightPositions = creator.LightBouncePositions(arrayPosition, HitDirection, tileColour); Vector3[] tempArray = new Vector3[LightPositions.Length]; if (bInstantBeam) { lineRenderer.positionCount = tempArray.Length; } for (int i = 0; i < tempArray.Length; i++) { tempArray[i] = (Vector2)LightPositions[i].lightPosition; if (bInstantBeam) { lineRenderer.SetPosition(i, tempArray[i]); if (LightPositions[i].hitTile != null) { LightPositions[i].hitTile.TileHit(Utility.NormalizeVec2Int(LightPositions[i].lightPosition - LightPositions[i - 1].lightPosition), tileColour); } } } if (!bInstantBeam) { StartCoroutine(MoveLightBeam(tempArray)); } } }
List <Match> ExplodeBomb(GameObject bomb, GameObject colorIdentifier) { TileColor c = colorIdentifier.GetComponent <EmojiType>().TC; List <Match> m = new List <Match>(); Match bombtemp = new Match(); bombtemp.objectJoinedTogether.Add(bomb.GetComponent <TileController>().location); m.Add(bombtemp); // explosion sound ExplosionSound.Play(); foreach (GameObject t in board) { if (t != null) { if (t.GetComponent <EmojiType>().TC == c) { Match temp = new Match(); temp.objectJoinedTogether.Add(t.GetComponent <TileController>().location); m.Add(temp); } } } return(m); }
//COLOR FUNCTIONS public void SetTileColor(TileColor color) { switch (color) { case TileColor.standard: SetColor(baseColor); break; case TileColor.move: SetColor(moveRangeColor); break; case TileColor.attack: SetColor(attackRangeColor); break; case TileColor.ally: SetColor(allyColor); break; default: SetColor(baseColor); break; } }
public override Tile GetTile(int row, int column, TileColor tileColor, Texture2D texture) { return(new PawnPromotionTile(row, column, tileColor, texture, new List <Alliance>() { AllianceToPromote }, PromotionFactory)); }
public void InitDummy()//13*4*2 + 2 { Dummy.Clear(); Tile tile; TileColor color = TileColor.RED; var type = Enum.GetValues(color.GetType()); for (int j = 0; j < 2; j++) { foreach (TileColor v in type) { for (int k = 1; k <= 13; k++) { tile = new NumberTile(v, k); Dummy.Add(tile); } } } Dummy.Add(new JokerTile(TileColor.RED)); Dummy.Add(new JokerTile(TileColor.BLACK)); return; }
public static Brush ToBrush(this TileColor color) { Brush brush; switch (color) { case TileColor.Text: brush = Text; break; case TileColor.GrayText: brush = Gray; break; case TileColor.HeadBackground: brush = HeadBackground; break; case TileColor.SuggestionBackground: brush = SuggestionBackground; break; case TileColor.SuggestionPartBackground: brush = SuggestionPartBackground; break; case TileColor.SymbolBackground: brush = SymbolBackground; break; case TileColor.GhostBackground: brush = GhostBackground; break; case TileColor.None: default: Debug.Assert(color == TileColor.None); brush = None; break; } return(brush); }
void SendPaintingColor(TileColor paintingColor) { PaintingColorMessage msg = new PaintingColorMessage(); msg.tileColor = paintingColor; clientConnection.Send(msg.GetMsgType(), msg); }
public static Color32 GetColor(TileColor tileColor) { switch (tileColor) { case TileColor.White: return(Color.white); case TileColor.Red: return(Color.red); case TileColor.Green: return(Color.green); case TileColor.Blue: return(Color.blue); case TileColor.Yellow: return(Color.yellow); case TileColor.Magenta: return(Color.magenta); case TileColor.Cyan: return(Color.cyan); default: throw new ArgumentException(); } }
private void ChangeColor(int change) { if (Lvl.tileObjectPrefab.GetType() != typeof(PaintBucket) && Lvl.tileObjectPrefab.GetType() != typeof(Exit) && Lvl.tileObjectPrefab.GetType() != typeof(Entrance)) { return; } TileColor oldCol = TileColor.None; if (Lvl.tileObjectPrefab.GetType() == typeof(PaintBucket)) { oldCol = ((PaintBucketDefinition)Lvl.tileObjectDefinition).color; } else if (Lvl.tileObjectPrefab.GetType() == typeof(Exit)) { oldCol = ((ExitDefinition)Lvl.tileObjectDefinition).color; } else if (Lvl.tileObjectPrefab.GetType() == typeof(Entrance)) { oldCol = ((EntranceDefinition)Lvl.tileObjectDefinition).color; } TileColor newCol = (TileColor)((((int)oldCol) + 1) % System.Enum.GetValues(typeof(TileColor)).Length); if (change == 1) { newCol = (TileColor)((((int)oldCol) + 1) % System.Enum.GetValues(typeof(TileColor)).Length); } else if (change == -1) { newCol = (TileColor)(((int)oldCol) - 1 < 0 ? System.Enum.GetValues(typeof(TileColor)).Length - 1 : ((int)oldCol) - 1); } SetColor(newCol); }
/// <summary> /// Calculates a heuristic based on how many moves a player has relative to how many moves the opponent has /// </summary> /// <param name="game"></param> /// <param name="color"></param> /// <returns></returns> public static int ActualMobilityHeuristic(Game game, TileColor color) { TileColor currentPlayer = game.IsPlayer1 ? TileColor.BLACK : TileColor.WHITE; TileColor maxPlayer = color; TileColor minPlayer = color == TileColor.BLACK ? TileColor.WHITE : TileColor.BLACK; int maxMobility = 0; int minMobility = 0; // Sets the max and min mobilities if (currentPlayer == maxPlayer) { maxMobility = game.PossiblePlays().Count; minMobility = game.PossiblePlays(true).Count; } else { maxMobility = game.PossiblePlays(true).Count; minMobility = game.PossiblePlays().Count; } // Return the normalized difference between the mobilities if ((maxMobility + minMobility) > 0) { return(100 * (maxMobility - minMobility) / (maxMobility + minMobility)); } else { return(0); } }
//Returns list of rows in which the player can legally place a tile of a given color public IEnumerable <int> LegalRowsForColor(TileColor c) { Debug.Assert(c != TileColor.FirstPlayer); for (int row = 0; row < 5; row++) { bool canMatchInRow = true; //Check wall to see if tile of color c is already placed on this row if (PatternLines[row].IsEmpty) { var col = Wall.ColumnOfTileColor(row, c); if (Wall[row, col] != null) { canMatchInRow = false; } } //Check if there is space remaining in pattern lines containing tiles of color c else if (PatternLines[row].Color == c) { canMatchInRow = !PatternLines[row].IsFull; } //Full rows or empty rows with appropriate wall space cannot recieve tiles of color c else { canMatchInRow = false; } if (canMatchInRow) { yield return(row); } } }
public Bitmap GetTileResource(TileState state, TileColor color) { TILE tileAdapt = TILE.NormalBlackTile; if (color == TileColor.Black) { switch (state) { case TileState.Normal: tileAdapt = TILE.NormalBlackTile; break; case TileState.Selected: tileAdapt = TILE.SelectBlackTile; break; case TileState.LastMove: tileAdapt = TILE.LastMoveBlackTile; break; case TileState.AvalableMove: tileAdapt = TILE.AvalBlackTile; break; } } else { switch (state) { case TileState.Normal: tileAdapt = TILE.NormalWhiteTile; break; case TileState.Selected: tileAdapt = TILE.SelectWhiteTile; break; case TileState.LastMove: tileAdapt = TILE.LastMoveWhiteTile; break; case TileState.AvalableMove: tileAdapt = TILE.AvalWhiteTile; break; } } return(this.tileStrategy.GetTile(tileAdapt)); }
public void Paint(IEnumerable <long> instruction) { var inputBuffer = new BufferBlock <long>(); var outputBuffer = new BufferBlock <long>(); inputBuffer.Post((long)colorUnderCamera); // first is black var vm = new IntCodeVm(instruction, inputBuffer, outputBuffer); var tokenSource = new CancellationTokenSource(); var ctoken = tokenSource.Token; var runningProgram = Task.Run(() => vm.RunProgram(ctoken), ctoken); var paintJob = Task.Run(async() => { var endOperation = false; while (!endOperation) { try { var outputColor = await outputBuffer.ReceiveAsync(ctoken); // paint painting[location] = (TileColor)outputColor; var outputTurn = await outputBuffer.ReceiveAsync(ctoken); // turn an move directionAngle = (directionAngle + (90 * (outputTurn == 0 ? -1 : 1) + 360)) % 360; // (directionAngle + (90 * outputTurn == 0 ? -1 : 1) + 360) % 360; location = directionAngle switch { 0 => location.MoveRight(), 90 => location.MoveDown(), 180 => location.MoveLeft(), 270 => location.MoveUp(), _ => throw new Exception("Unknown direction angle"), }; if (!painting.TryGetValue(location, out colorUnderCamera)) { colorUnderCamera = TileColor.Black; painting.Add(location, colorUnderCamera); } inputBuffer.Post((long)colorUnderCamera); } catch (OperationCanceledException) { endOperation = true; } } }, ctoken); runningProgram.Wait(); try { tokenSource.Cancel(); paintJob.Wait(); } catch (OperationCanceledException) { } }
public Tile(TileLocation tileLocation, Material material, TileColor tileColor, GameObject tileObject) { this.tileMaterial = material; this.colorOfTile = tileColor; this.locationOfTile = tileLocation; this.tileObj = tileObject; }
public void TileHit(Vector2Int HitDirection, TileColor hitColour) { if (CanPass(hitColour)) { Debug.Log("Trigger Been Hit", gameObject); } }
public Painter(TileColor startingColor) { location = new Point(0, 0); directionAngle = 360 - 90; // up colorUnderCamera = startingColor; painting.Add(location, colorUnderCamera); }
public Tile(int score, TileColor color, TileAction tileAction, int tileIndex, int imageVariation) { Score = score; TileAction = tileAction; Color = color; TileIndex = tileIndex; Image = score + (color == TileColor.Blue ? "B" : "R") + imageVariation; }
private void SwapTiles(Tile first, Tile second) { //Much better than phisical swap tiles, but if there is no need animation, just swap color values and sprites TileColor tmpColor = first.tileColor; first.ResetColor(second.tileColor); second.ResetColor(tmpColor); }
//construct manager for human vs computer play public GameManager(Func <Game, TileColor, int> heuristic, int ply, TileColor color, uint size = 8) { game = new Game(size); int index = color == TileColor.BLACK ? 0 : 1; Agents[index] = new ReversiSolver(color, heuristic, ply); play = 0; }
public TileRow(Game game, TileColor rowColor) : base(game) { UpdateOrder = BrickInvaders.TileRowPriority; Game.Components.Add(this); tiles = new Tile[TilesPerRow]; this.rowColor = rowColor; }
public void DepaintTiles(List <GameObject> tiles, TileColor color) { foreach (var tile in tiles) { tile.GetComponent <Tile>().DepaintTile(color); tile.GetComponent <Tile>().SetPreSelected(false); } }
public Tile(int row, int column, TileColor tilecolor, Texture2D texture) { Row = row; Column = column; tileColor = tilecolor; Texture = texture; Tint = Color.White; }
void Awake() { TT = GetComponent <EmojiType>().TT; color = GetComponent <EmojiType>().TC; tileFallSpeed = 50; scannedHorizontally = false; scannedVertically = false; }
public List <Tile> TakeAll(TileColor tileColor) { var takenTiles = tiles.FindAll(t => t.TileColor.Equals(tileColor) || t.TileColor.Equals(TileColor.FirstPlayer)); tiles = tiles.Except(takenTiles).ToList(); return(takenTiles); }
} //Value of true indicates this is the first move to pull from the center this round public Move(int factoryIndex, int targetRow, TileColor colorToTake, int count, bool hasFirstPlayerPenalty) { FactoryIdx = factoryIndex; RowIdx = targetRow; Color = colorToTake; Count = count; HasFirstPlayerPenalty = hasFirstPlayerPenalty; }
public Tile(Game game, TileRow row, TileColor color) : base(game) { UpdateOrder = BrickInvaders.TilePriority; Game.Components.Add(this); Cleared = false; this.containingRow = row; this.color = color; }
public void handleMessage(Message msg) { // collect data for enchantments (or units who buff) if (msg is CardTypesMessage) { JsonReader jsonReader = new JsonReader(); Dictionary<string, object> dictionary = (Dictionary<string, object>)jsonReader.Read(msg.getRawText()); Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["cardTypes"]; this.cardids = new int[d.GetLength(0)]; this.cardnames = new string[d.GetLength(0)]; this.cardImageid = new int[d.GetLength(0)]; for (int i = 0; i < d.GetLength(0); i++) { cardids[i] = Convert.ToInt32(d[i]["id"]); cardnames[i] = d[i]["name"].ToString(); cardImageid[i] = Convert.ToInt32(d[i]["cardImage"]); } //App.Communicator.removeListener(this);//dont need the listener anymore } if(msg is AbilityInfoMessage) { AbilityInfoMessage aim = (AbilityInfoMessage)msg; if (aim.abilityId == "Move")//aim.isPlayable && { this.showLobbers = TileColor.white; if (aim.unitPosition.color == TileColor.white) this.showLobbers = TileColor.black; this.calculateEnemyLobbers(this.showLobbers); } this.showLobbers = TileColor.unknown; } if (msg is CardInfoMessage) { CardInfoMessage aim = (CardInfoMessage)msg; //Console.WriteLine("cardinfo"); if (aim.card.getPieceKind() == CardType.Kind.CREATURE || aim.card.getPieceKind() == CardType.Kind.STRUCTURE)//aim.isPlayable && { this.mark =true; if (aim.data.selectableTiles.Count >= 1) { //Console.WriteLine("cardinfo " + aim.data.selectableTiles.tileSets[0][0].color); this.showLobbers = aim.data.selectableTiles.tileSets[0][0].color.otherColor(); this.calculateEnemyLobbers(this.showLobbers); } } this.showLobbers = TileColor.unknown; } return; }
public void printMove(TileColor tc) { foreach (KeyValuePair<long, moveunit> kvp in this.moveCounter) { if (kvp.Value.tp != tc) continue; Console.WriteLine(kvp.Key + " move: " + kvp.Value.movesdone + " " +kvp.Value.move + " " + kvp.Value.tp.ToString()); } }
public moveunit(int m, TilePosition p) { this.move = m; this.tp = p.color; }
private void calculateEnemyLobbers(TileColor tc) { this.enemyLobbers.Clear(); //this.bm.getTileList(tc); //Console.WriteLine("##"); for (int i = 0; i < 5; i++) { for (int j = 0; j < 3; j++) { Unit unitFromTile = this.bm.getUnit(tc, i, j); if (unitFromTile == null) continue; /*int movecount = 0; foreach (ActiveAbility aa in unitFromTile.getActiveAbilities()) { Console.WriteLine(aa.name); if (aa.isMoveLike()) movecount++; } Console.WriteLine("-");*/ TilePosition tp2 = new TilePosition(tc.otherColor(), i, 2 - j); if (unitFromTile.getTargetArea() == TargetArea.RADIUS_4) { selectTargetMethod.Invoke(this.bm, new object[]{TargetArea.RADIUS_4, tp2}); selectTargetArea(TargetArea.RADIUS_4, tp2); } if (unitFromTile.getTargetArea() == TargetArea.RADIUS_3) { selectTargetMethod.Invoke(this.bm, new object[] { TargetArea.RADIUS_3, tp2 }); selectTargetArea(TargetArea.RADIUS_3, tp2); } /*if (unitFromTile.getTargetArea() == TargetArea.RADIUS_7) { TilePosition tp2 = new TilePosition(tc.otherColor(), i, 2 - j); selectTargetMethod.Invoke(this.bm, new object[] { TargetArea.RADIUS_7, tp2 }); }*/ } } }
public Tile(TileColor color) { Color = color; }
public Color TypeToColor(TileColor type) { var palette = Model.Instance.Palette; return palette.ColorForIndex(type); }