bool[] getAdjacentSprites() { bool[] total = new bool[4]; BoardTile adjacent = board.getBoardTile(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y + 1)); //up if (adjacent != null && adjacent.getLandHeight() == tile.getLandHeight()) { total[0] = true; } adjacent = board.getBoardTile(Mathf.RoundToInt(transform.position.x - 1), Mathf.RoundToInt(transform.position.y)); //left if (adjacent != null && adjacent.getLandHeight() == tile.getLandHeight()) { total[1] = true; } adjacent = board.getBoardTile(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y - 1)); //down if (adjacent != null && adjacent.getLandHeight() == tile.getLandHeight()) { total[2] = true; } adjacent = board.getBoardTile(Mathf.RoundToInt(transform.position.x + 1), Mathf.RoundToInt(transform.position.y)); //right if (adjacent != null && adjacent.getLandHeight() == tile.getLandHeight()) { total[3] = true; } return(total); }
public void MoveAttempt(BoardTile tile) { //Ensure all existing pieces are stable for (int i = 0; i < 64; i++) { if ((board.GetTileAt(i).piece != null) && (!board.GetTileAt(i).piece.Stable)) { return; } } List <int> tilesAffected = getTilesAffected(board.GetUpdatedBoardModel(), Turn, board.IndexOfTile(tile)); if (tilesAffected.Count > 0) { tile.SetOwner(Turn); foreach (int tileIndex in tilesAffected) { board.GetTileAt(tileIndex).SetOwner(Turn); } //Swap turns SetTurn(Turn == Player.PLAYER_ONE ? Player.PLAYER_TWO : Player.PLAYER_ONE); TextManager.RefreshText(); } }
void updateAdjacentSprites() { BoardTile b = board.getBoardTile(Mathf.RoundToInt(transform.position.x + 1), Mathf.RoundToInt(transform.position.y)); if (b != null && b.structure != null && b.structure.GetComponent <Wall>() != null) { b.structure.GetComponent <Wall>().updateSprite(); } b = board.getBoardTile(Mathf.RoundToInt(transform.position.x - 1), Mathf.RoundToInt(transform.position.y)); if (b != null && b.structure != null && b.structure.GetComponent <Wall>() != null) { b.structure.GetComponent <Wall>().updateSprite(); } b = board.getBoardTile(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y + 1)); if (b != null && b.structure != null && b.structure.GetComponent <Wall>() != null) { b.structure.GetComponent <Wall>().updateSprite(); } b = board.getBoardTile(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y - 1)); if (b != null && b.structure != null && b.structure.GetComponent <Wall>() != null) { b.structure.GetComponent <Wall>().updateSprite(); } }
protected override void Awake() { base.Awake(); if (this.SkipRegen) { this.Tiles = new BoardTile[this.width, this.height]; List <GameObject> children = this.gameObject.transform.GetChildren(); Debug.Log("Found " + children.Count + " children"); foreach (GameObject d in children) { BoardTile bt = d.GetComponent <BoardTile>(); if (bt) { bt.ColorManager.ChangeColor(Color.black); this.Tiles[bt.x, bt.y] = bt; } else { Debug.Log("Non-BT child found."); } } return; } this.DeleteAllChildren(); this.GenerateBoard(); }
void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] hits = Physics.RaycastAll(ray); Transform[] transforms = new Transform[hits.Length]; for (int i = 0; i < hits.Length; i++) { transforms[i] = hits[i].transform; } Array.Sort(transforms, new ProximityPositionComparer(Camera.main.transform)); foreach (Transform hit in transforms) { BoardTile btCandidate = hit.transform.gameObject.GetComponent <BoardTile>(); if (btCandidate) { if (this.TargetOnClick) { Vector3 newPos = new Vector3(btCandidate.transform.position.x, this.TargetGobj.transform.position.y, btCandidate.transform.position.z); this.TargetGobj.transform.position = newPos; } this.Callback.HandleTile(btCandidate); return; } } } }
private bool _checkLeftDiagonal(BoardTile type, BoardPosition pos) { var streak = 0; var dx = (_columns - 1) - pos.Column; var dy = pos.Cell; var lowest = dx < dy ? dx : dy; var origin = new BoardPosition() { Cell = pos.Cell - lowest, Column = pos.Column + lowest }; var colIdx = origin.Column; var cellIdx = origin.Cell; for (; colIdx >= 0 && cellIdx < _columnSize; colIdx--, cellIdx++) { var cell = _board[colIdx][cellIdx]; if (cell == type) { streak++; } else { streak = 0; } if (streak == 4) { return(true); } } return(false); }
// This is the function that we will use to subscribe to the "OnTilePressed" event from the BoardTiles void OnTilePressed(BoardTile tile) { if (gameOver) { return; } // Update the tile to show the sprite of the player. tile.UpdatePlayerSprite(GameController.GetCurrentPlayerSprite()); // Append this move to the gameMoves list gameMoves.Add(new GameMove(tile.row, tile.column, GameController.playerTurn)); if (CheckWins(tile)) { GameController.UpdateGameState(GameState.GameOver, true); gameOver = true; } else if (CheckTie()) { GameController.UpdateGameState(GameState.GameOver, false); gameOver = true; } else { GameController.NextTurn(); } }
private bool _checkRow(BoardTile type, BoardPosition pos) { var streak = 0; for (var colIdx = 0; colIdx < _columns && (4 - streak) <= (_columns - colIdx); colIdx++) { var cell = _board[colIdx][pos.Cell]; if (cell == type) { streak++; } else { streak = 0; } if (streak == 4) { return(true); } } return(false); }
private bool canMove(string dir, Vector2 src, Vector2 dest) { // Check OOB if ((int)dest.x >= board.GetLength(0) || (int)dest.y >= board.GetLength(1) || (int)dest.x < 0 || (int)dest.y < 0) { return(false); } // Check board layout BoardTile srcTile = board[(int)src.x, (int)src.y]; BoardTile destTile = board[(int)dest.x, (int)dest.y]; if (destTile.type == BoardTileType.Empty) { return(false); } //Check if connected if (dir == "up") { if (!srcTile.upPath) { return(false); } } else if (dir == "down") { if (!destTile.upPath) { return(false); } } else if (dir == "left") { if (!destTile.rightPath) { return(false); } } else if (dir == "right") { if (!srcTile.rightPath) { return(false);; } } //Check other pillars foreach (BoardPillar pillar in pillars) { if (pillar.pos == dest) { return(false); } } return(true); }
public override void OnLandedOnUnownedTile(BoardTile landedTile){ // try and buy the tile Debug.Log (playerName+": Trying to buy unowned tile"); BuyTile(landedTile); DoneProcessingUnOwnedTile(); }
/// <summary> /// Fires the guns of all living ships of the attacking player at the target tile. /// </summary> /// <param name="targetTile">The position of the tile to target.</param> /// <returns>The time it will take for the shells to arrive.</returns> public float FireGunsAtTargetTile(BoardTile targetTile) { float highestTravelTime = 0f; foreach (Ship ship in attackingPlayer.livingShips) { Vector3 targetPosition = targetTile.transform.position; targetPosition.y = 0f; float travelTime = ship.PrepareToFireAt(targetPosition, targetTile.containedShip); ship.Fire(); if (travelTime > highestTravelTime) { highestTravelTime = travelTime; } //ship.FireAt(defendingPlayer.board.tiles[(int)tile.x, (int)tile.y].worldPosition + Vector3.down * (GameController.playerBoardElevation - 0.4f)); } // if (defendingPlayer.board.tiles[(int)targetTile.x, (int)targetTile.y].containedShip) // { // defendingPlayer.board.tiles[(int)targetTile.x, (int)targetTile.y].containedShip.InformAboutIncomingProjectile(highestTravelTime, ProjectileType.SHELL); // } return(highestTravelTime); }
/// <summary> /// Registers that a tile has been hit. /// </summary> /// <param name="tile">The tile that has been hit.</param> public void RegisterHitOnTile(BoardTile tile) { if (tile.containedShip) { if (!tile.containedShip.eliminated) { attackingPlayer.hits[defendingPlayer.ID].Add(tile); if (!recentTurnInformation.hitShips.Contains(tile.containedShip)) { recentTurnInformation.hitShips.Add(tile.containedShip); } if (!tile.hit) { tile.containedShip.RegisterHit(); if (tile.containedShip.eliminated) { recentTurnInformation.sunkShips.Add(tile.containedShip); } } } else { attackingPlayer.misses[defendingPlayer.ID].Add(tile); } } else { attackingPlayer.misses[defendingPlayer.ID].Add(tile); } tile.hit = true; recentTurnInformation.hitTiles.Add(tile); }
private void CreateBoard(Vector2 offset, Vector2 baseSpaw) { board = new BoardTile[rows, columns]; //Create frame if (framePrefab != null) { SpriteRenderer frame = Instantiate(framePrefab, new Vector3(transform.position.x, transform.position.y, 0f), framePrefab.transform.rotation); frame.transform.SetParent(tilesParent.transform); frame.transform.localScale = new Vector2(columns + 0.3f, rows + 0.3f); } for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { BoardTile tile = Instantiate(tilePrefab, new Vector3(baseSpaw.x + (offset.x * j), baseSpaw.y + (offset.y * i), 0f), tilePrefab.transform.rotation); tile.transform.SetParent(tilesParent.transform); board[i, j] = tile; board[i, j].InitializeBoardTile(i, j); } } }
private int _evalHorizontalScore(BoardTile player) { var points = 0; for (var cellIdx = 0; cellIdx < _columnSize; cellIdx++) { for (var colIdx = 0; colIdx < _columns - 3; colIdx++) { for (var i = 0; i < 4; i++) { var cell = _board[colIdx + i][cellIdx]; if (cell == player) { points++; } else if (cell != BoardTile.Empty) { points = 0; break; } } } } return(points); }
private void InitializeBoard() { boardTiles = new BoardTile[width, height]; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { bool isWalkable = true; if (j == 0 || j == height - 1 || Random.Range(0, 3) == 0) { isWalkable = false; } boardTiles[i, j] = new BoardTile(i, j, isWalkable); if (i > 0) { boardTiles[i, j].Neighbors.Add(boardTiles[i - 1, j]); boardTiles[i - 1, j].Neighbors.Add(boardTiles[i, j]); } if (j > 0) { boardTiles[i, j].Neighbors.Add(boardTiles[i, j - 1]); boardTiles[i, j - 1].Neighbors.Add(boardTiles[i, j]); } } } Player.Instance.currentTile = boardTiles[0, 1]; }
private void ResolveDeselect() { if (globalLastTileSelected.numInChain > 2) { Score(globalLastTileSelected); float timerSet = 0.0f; if (numInChain == 3) { timerSet = 7.0f; } else if (numInChain < 6) { timerSet = 5.0f; } else { timerSet = 7.0f / numInChain; } AudioManager.instance.PlayPitch("Disappear", 0.7f + 0.1f * numInChain); RandomizingChainBackwards(globalLastTileSelected, timerSet); } else { DeselectChainBackwards(globalLastTileSelected); } globalLastTileSelected = null; }
public BoardTile CalculateTileWeight(BoardTile boardTile, ItemData[] itemData) { int[] coordX = { 1, 1, 0, -1, -1, 0 }; int[] coordZ = { 0, -1, -1, 0, 1, 1 }; BoardTile targetBoardTile = null; for (int i = 0; i < 6; i++) { BoardTile comparerTile = TileManager.Instance.BoardTileGrid[boardTile.TileCoordinate.x + coordX[i], boardTile.TileCoordinate.z + coordZ[i]].GetComponent <BoardTile>(); if (comparerTile.tileOwner != TileOwner.None) { continue; } comparerTile.CalculateTileWeight(itemData); if (targetBoardTile == null) { targetBoardTile = comparerTile; } else { targetBoardTile = (targetBoardTile.tileWeight <= comparerTile.tileWeight) ? targetBoardTile : comparerTile; } } return(targetBoardTile); }
private void AddBoardTile(int row, int i) { if (i <= m_Bounds.Left) { m_Bounds.Left = i - 1; BoardTile.XOffset = m_Bounds.Left; } if (i > m_Bounds.Right) { m_Bounds.Right = i; } if (row <= m_Bounds.Top) { m_Bounds.Top = row - 1; BoardTile.YOffset = m_Bounds.Top; } if (row > m_Bounds.Bottom) { m_Bounds.Bottom = row; } var bt = new BoardTile(this, i, row); Board.Add(bt); BoardMatrix[i, row] = bt; }
public Move(BoardTile to, Piece owningPiece) { To = to; From = owningPiece._board[owningPiece.CurrentPosition]; OwningPiece = owningPiece; _pieceTaken = To.OccupyingPiece; }
private bool _checkColumn(BoardTile type, BoardPosition pos) { var column = _board[pos.Column]; var streak = 0; for (var cellIdx = 0; cellIdx < _columnSize && (4 - streak) <= (_columnSize - cellIdx); cellIdx++) { var cell = column[cellIdx]; if (cell == type) { streak++; } else { streak = 0; } if (streak == 4) { return(true); } } return(false); }
public TradeOffer (GamePlayer _sender,GamePlayer _reciever, BoardTile _senderProperty, BoardTile _recieverProperty, int _senderFunds, int _recieverFunds){ senderPlayerId = _sender.playerIndex; recieverPlayerId = _reciever.playerIndex; // find the sender property ID senderPropertyId = -1; for(int i=0;i<_sender.ownedProperties.Count;i++){ // find the property if(_sender.ownedProperties[i] == _senderProperty){ // set the property ID senderPropertyId = i; // end the loop i = _sender.ownedProperties.Count; } } // find the reciever property ID recieverPropertyId = -1; for(int i=0;i<_reciever.ownedProperties.Count;i++){ // find the property if(_reciever.ownedProperties[i] == _recieverProperty){ // set the property ID recieverPropertyId = i; // end the loop i = _reciever.ownedProperties.Count; } } senderFunds = _senderFunds; recieverFunds = _recieverFunds; }
private int _evalLeftDiagonalScore(BoardTile player) { var points = 0; for (var cellIdx = 3; cellIdx < _columnSize; cellIdx++) { for (var colIdx = 0; colIdx <= _columns - 4; colIdx++) { for (var i = 0; i < 4; i++) { var cell = _board[colIdx + 1][cellIdx - 1]; if (cell == player) { points++; } else if (cell != BoardTile.Empty) { points = 0; break; } } } } return(points); }
public void MoveToTargetTile(BoardTile targetTile) { PossessingTile.Add(targetTile); inventory[(int)(targetTile.TileType)].Count++; transform.position = new Vector3(targetTile.transform.position.x, transform.position.y, targetTile.transform.position.z); int[] coordX = { 1, 0, -1, -1, 0, 1 }; int[] coordZ = { 0, 1, 1, 0, -1, -1 }; for (int i = 0; i < 6; i++) { BoardTile targetBoardTile; if (TileManager.Instance.BoardTileGrid[targetTile.TileCoordinate.x + coordX[i], targetTile.TileCoordinate.z + coordZ[i]] != null) { targetBoardTile = TileManager.Instance.BoardTileGrid[targetTile.TileCoordinate.x + coordX[i], targetTile.TileCoordinate.z + coordZ[i]].GetComponent <BoardTile>(); } else { continue; } if (targetBoardTile.tileOwner == tileOwner) { targetTile.TileBorder[i].SetActive(false); targetBoardTile.TileBorder[(i + 3) % 6].SetActive(false); } else { targetTile.TileBorder[i].SetActive(true); } } }
public Connect4Board GetNewState(BoardTile type, int col) { var board = Clone(); board.DropChip(type, col); return(board); }
void calcAndApplyChange(BoardTile b, int x, int y) { double change = ChangeAdjacentTile(b, tileBoard[y, x]); tileBoard[y, x].addGooChange(change); b.addGooChange(-change); }
void LateUpdate() { foreach (BoardTile tile in this.Tiles) { if (tile.Expired()) { //tile.ColorManager.ChangeColor(Color.black); tile.Action = new BaseTileAction(); tile.Action.Init(); } } foreach (TileTask task in this.ColorTasks) { if (this.IsValidTask(task)) { BoardTile tile = this.Tiles[task.x, task.y]; tile.ColorManager.ChangeColor(task.toColor); if (task.PresetAction != TileAction.Actions.NONE) { tile.Action = TileAction.Create(task.PresetAction, tile); } else { tile.Action = task.action; } tile.Action.Init(); tile.TimeActive = task.time; tile.Tick(); } } this.ColorTasks.Clear(); }
//how should b change based on a? double getChangeToOtherTile(BoardTile a, BoardTile b) { double returnVal; if (a.getTotalHeight() < b.getLandHeight()) { returnVal = System.Math.Round((-1 * b.gooHeight) * gooRatio, 2); // a is shorter than b, goo runs downhill. } else if (b.getTotalHeight() < a.getLandHeight()) { returnVal = System.Math.Round(a.gooHeight * gooRatio, 2); } else //a is taller than or equal to b, b will need to look at a. { //get difference in goo //a.getTotalHeight() - b.getTotalHeight() returnVal = System.Math.Round((a.getTotalHeight() - b.getTotalHeight()) * gooRatio, 2); //function like most goo } if (Mathf.Abs((float)returnVal) < spreadThreshold) { return(0); } return(returnVal); }
/// <summary> /// Processes actions for AI players. /// </summary> void AIPlayerActions() { if (switchTime <= -0.1f) { switch (state) { case BattleState.CHOOSING_TARGET: int randomTargetID = Random.Range(0, players.Length); while (randomTargetID == attackingPlayerID) { randomTargetID = Random.Range(0, players.Length); } if (SelectTarget(players[randomTargetID])) { ChangeState(BattleState.CHOOSING_TILE_TO_SHOOT, 0.2f); } break; case BattleState.CHOOSING_TILE_TO_SHOOT: BoardTile tileToShoot = ChooseTileToAttackForAIPlayer(); Debug.Log(ArtilleryAttack(tileToShoot)); ChangeState(BattleState.TURN_FINISHED, 0.2f); break; } } }
//How should both a and b changed based on a double ChangeAdjacentTile(BoardTile a, BoardTile b) { double returnVal = 0; if (a.getTotalHeight() <= b.getTotalHeight() || a.gooHeight == 0) { return(0); //a is shorter than or equal to b, goo does not run uphill } else if (b.getTotalHeight() < a.getLandHeight()) { returnVal = System.Math.Round(a.gooHeight * gooRatio, 2); } else //a is taller than or equal to b, b will need to look at a. { //get difference in goo //a.getTotalHeight() - b.getTotalHeight() returnVal = System.Math.Round((a.getTotalHeight() - b.getTotalHeight()) * gooRatio, 2); //a goo higher than b goo } if (Mathf.Abs((float)returnVal) < spreadThreshold) { return(0); } return(returnVal); }
public void TileInfo() { if (boardCamera == null) { boardCamera = GameObject.FindWithTag("BoardCamera").GetComponentInChildren <Camera>(); } if (Input.GetMouseButtonUp(0)) { Ray rayPoint = boardCamera.ScreenPointToRay(Input.mousePosition); RaycastHit hitPoint; if (Physics.Raycast(rayPoint, out hitPoint, Mathf.Infinity)) { if (hitPoint.collider.CompareTag("Tile")) { tileInformation = hitPoint.collider.gameObject.GetComponent <BoardTile>(); GameManager.Instance.GetClickedTile(tileInformation); } else if (!hitPoint.collider.CompareTag("Tile")) { LogManager.Instance.UserDebug(LogColor.Blue, GetType().Name, "타일 정보를 찾을 수 없습니다."); } } } }
private bool _checkRightDiagonal(BoardTile type, BoardPosition pos) { var streak = 0; var lowest = pos.Cell < pos.Column ? pos.Cell : pos.Column; var origin = new BoardPosition() { Cell = pos.Cell - lowest, Column = pos.Column - lowest }; var colIdx = origin.Column; var cellIdx = origin.Cell; for (; colIdx < _columns && cellIdx < _columnSize; colIdx++, cellIdx++) { var cell = _board[colIdx][cellIdx]; if (cell == type) { streak++; } else { streak = 0; } if (streak == 4) { return(true); } } return(false); }
/// <summary> /// Prepares the torpedo launcher for firing. /// </summary> public void PrepareTorpedoLaunchers(Vector3 targetPosition) { Vector3 launchPoint = owner.battle.GetTorpedoLaunchPosition(); foreach (Turret launcher in torpedoLaunchers) { launcher.PrepareToFireAt(targetPosition); int id = 0; foreach (TorpedoLauncher tube in launcher.weapons) { if (owner.battle.recentTurnInformation.torpedoInfo.impacts.Count > 0) { BoardTile hitTile = owner.battle.recentTurnInformation.torpedoInfo.impacts[id]; Vector3 hitPosition = hitTile.transform.position; hitPosition.y = 0; if (id + 1 < owner.battle.recentTurnInformation.torpedoInfo.impacts.Count) { id++; } tube.torpedo.targetShip = hitTile.containedShip; tube.torpedo.targetDistance = Vector3.Distance(launchPoint, hitPosition); } else { tube.torpedo.targetShip = null; } tube.torpedo.launchDirection = new Vector3(owner.battle.recentTurnInformation.target.x, 0, owner.battle.recentTurnInformation.target.y); } } }
//Updates a mark on the tile, marking it as Good if it's empty, as Bad otherwise public void MarkMovementRangeOnTile(BoardTile tile) { if (tile != null) //If pos is not outside of the board, hence theres a tile { if (tile.IsEmpty()) tile.SetPermanentMarkType(BoardMark.MarkType.Good); else tile.SetPermanentMarkType(BoardMark.MarkType.Bad); } }
public Battlefield(int boardWidth, int boardHeight) { Bots = new List<TankBlasterBot>(); Bombs = new List<Bomb>(); Explosions = new List<Explosion>(); Missiles = new List<Missile>(); Board = new BoardTile[boardWidth, boardHeight]; }
public static IEnumerable<BoardTile> GetAdjacentTiles(BoardTile tile) { switch (tile) { case BoardTile.TopLeft: return new[] { BoardTile.TopCenter, BoardTile.CenterLeft }; case BoardTile.TopCenter: return new[] { BoardTile.TopLeft, BoardTile.TopRight, BoardTile.Center }; case BoardTile.TopRight: return new[] { BoardTile.TopCenter, BoardTile.CenterRight }; case BoardTile.CenterLeft: return new[] { BoardTile.TopLeft, BoardTile.Center, BoardTile.BottomLeft }; case BoardTile.Center: return new[] { BoardTile.TopCenter, BoardTile.CenterLeft, BoardTile.CenterRight, BoardTile.BottomCenter }; case BoardTile.CenterRight: return new[] { BoardTile.TopRight, BoardTile.Center, BoardTile.BottomRight }; case BoardTile.BottomLeft: return new[] { BoardTile.BottomCenter, BoardTile.CenterLeft }; case BoardTile.BottomCenter: return new[] { BoardTile.BottomLeft, BoardTile.BottomRight, BoardTile.Center }; case BoardTile.BottomRight: return new[] { BoardTile.BottomCenter, BoardTile.CenterRight }; default: return new BoardTile[] {}; } }
public static Tuple<CardBorder, CardBorder> GetCardBorders(BoardTile tile1, BoardTile tile2) { var pos1 = (int)tile1; var pos2 = (int)tile2; if (pos1 - pos2 == 1) { return Tuple.Create(CardBorder.Left, CardBorder.Right); } else if (pos1 - pos2 == -1) { return Tuple.Create(CardBorder.Right, CardBorder.Left); } else if (pos1 - pos2 == 3) { return Tuple.Create(CardBorder.Top, CardBorder.Bottom); } else if (pos1 - pos2 == -3) { return Tuple.Create(CardBorder.Bottom, CardBorder.Top); } throw new InvalidOperationException("Not adjacent tiles"); }
public void OnTileUnSelected(BoardTile tile) { HideAllButtons(); }
IEnumerator PayRentForProperty (BoardTile propertyTile){ // we haven't paid all the rent yet allPropertyRentPaid = false; // keep going until we have paid all the rent. Debug.Log ("Paying Funds..."); StartCoroutine(PayFunds(propertyTile.currentRentCost)); while(hasPaidAllFunds == false){ yield return new WaitForEndOfFrame(); } // check for bankruptcy if(isBankrupt == true){ BankruptOnPlayer(propertyTile.owningPlayer); } // pay the other player GameController.singleton.AddMoneyToPlayer(amountOfFundsPaid, propertyTile.owner); // we have just paid all the rent allPropertyRentPaid = true; // end the function yield return 0; }
public IEnumerator ProcessUnownedPropertyTile(BoardTile tile){ // woohoo unowned tile // we are now processing an unowned tile... isProcessingUnOwnedPropertyTile = true; // call the function OnLandedOnUnownedTile(tile); Debug.Log (playerName+": Landed on unowned tile"); // wait for buying tile feedback while(isProcessingUnOwnedPropertyTile == true){ Debug.Log (playerName+": Waiting for unowned tile to be processed"); yield return new WaitForEndOfFrame(); } // did we buy that tile? if(didBuyTile == false){ // if not, AUCTION TIME WOOOT! Debug.Log (playerName+": AUCTIONING"); auctionDone = false; GameController.singleton.AuctionProperty(tile, this); // wait for the auction to complete before continuing while(auctionDone == false){ yield return new WaitForEndOfFrame(); } } // done with the result of the move action DoneMoveAction(); }
public IEnumerator ProcessOwnedPropertyTile (BoardTile tile){ if(tile.owner != playerIndex){ // ah damn, we landed on a tile that was owned Debug.Log (playerName+": Paying Rent For Property"); StartCoroutine(PayRentForProperty(tile)); while(allPropertyRentPaid == false){ yield return new WaitForEndOfFrame(); } } else{ Debug.Log ("We landed on our own tile... phew"); } // done with the result of the move action DoneMoveAction(); }
public virtual void OnLandedOnUnownedTile(BoardTile landedTile){ DoneProcessingUnOwnedTile(); }
public bool BuyTile (BoardTile tileToBuy) { // check if we have enough money if(tileToBuy.isOwned == false && tileToBuy.tileType == TileType.property){ if(money > tileToBuy.buyPrice){ money -= (int)tileToBuy.buyPrice; didBuyTile = true; // add it to our list ownedProperties.Add (tileToBuy); // set ownership of the tile tileToBuy.SetOwner(this); // reduce the number of remaining properties GameController.remainingProperties -=1; // update our property values UpdateOwnedProperties(); } } return didBuyTile; }
void AddProperty (BoardTile property){ // add it to our list ownedProperties.Add (property); // set ownership of the tile property.SetOwner(this); // update our property values UpdateOwnedProperties(); }
void RemoveProperty(BoardTile property){ if(ownedProperties.Contains(property) == false){ //Debug.LogError ("PLAYER NEVER OWNED PROPERTY, ERROR"); } ownedProperties.Remove (property); if(ownedProperties.Contains(property) == true){ //Debug.LogError ("STILL OWNS PROPERTY AFTER TRADE, ERROR"); } UpdateOwnedProperties(); }
public void OnTileSelected(BoardTile tile) { if(!tile.IsEmpty()) { GoToMainActionMenu(); //Change the menu to Move, Attack, Defense, etc Bug selectedBug = tile.GetBug(); PopulateStatsTexts(selectedBug); //Populate the texts on the StatsPanel } else { HideAllButtons(); } }
public void SellPropertyToBank (BoardTile property) { Debug.Log (playerName+": Selling property to bank "+property.actualTileName); // remove the property from us RemoveProperty(property); // remove property property.ResetProperty(); // add the money for that property back on money += (int)(property.buyPrice/2); // add 1 to the number of properties remaining GameController.remainingProperties +=1; }
public void AuctionProperty (BoardTile tile, GamePlayer hostPlayer){ // TODO actually do an auction // notify the player that the auction is complete hostPlayer.DoneAuction(); }
private bool TestBorder(Card currentCard, BoardTile currentTile, BoardTile targetTile, int chainStep) { var currentRow = currentTile.Row(); var currentCol = currentTile.Col(); var targetRow = targetTile.Row(); var targetCol = targetTile.Col(); var targetCard = Board[targetRow, targetCol]; if (targetCard == null) { return true; } var borders = System.Board.GetCardBorders(currentTile, targetTile); var currentStr = GetElemStrength(currentCard.Strength.GetBorderStrength(borders.Item1), currentCard.Elemental, currentRow, currentCol); var targetStr = GetElemStrength(targetCard.Strength.GetBorderStrength(borders.Item2), targetCard.Elemental, targetRow, targetCol); if (currentStr > targetStr) { if (TakeCard(targetCard, currentCard.OwnedBy, chainStep) && Rules.HasFlag(Rules.Combo)) { ProcessInternal(targetCard, targetRow, targetCol, chainStep); return true; } } return false; }
//Fill the tiles matrix with new BoardTiles() void FillTiles() { tiles = new List<List<BoardTile>>(); for (int i = 0; i < HeightInTiles; ++i) { List<BoardTile> tileRow = new List<BoardTile>(); for (int j = 0; j < WidthInTiles; ++j) { Vector2 tilePos = new Vector2(j, i); BoardTile tile = new BoardTile(tilePos, GetWorldPos(tilePos)); tileRow.Add(tile); if (UnityEngine.Random.Range(1, 11) > 7) tile.CreateBug(); //Put some random bugs around } tiles.Add(tileRow); } }
///////////////////////////////////////////////////////////////////////////////////////////////// // UTILS //////////////////////////////////////////////////////////// public void ResetEverything() { if (selectedTile != null) selectedTile.OnUnSelected(); if (selectedBug != null) selectedBug.OnUnSelected(); selectedBug = null; selectedTile = null; actionBug = null; board.GetMarkManager().ClearBoardMarks(); currentGameState = BoardGameState.Pointing; }
public void Reset() { Bots.Clear(); Bombs.Clear(); Missiles.Clear(); Explosions.Clear(); Board = new BoardTile[Board.GetLength(0), Board.GetLength(1)]; OnArenaChanged(); }
public bool BuyHouse (BoardTile property){ // check if it can be upgraded if(property.tileType != TileType.property || property.tileGroup == TileGroup.other || property.tileGroup == TileGroup.station || property.tileGroup == TileGroup.utility){ Debug.Log ("House cannot be bought here, invalid property"); return false; } if(property.improvement == HouseImprovement.Hotel){ return false; Debug.Log ("Property cannot be improved any more"); } // check if we have the funds if(money < property.houseBuyCost){ Debug.Log ("Don't have enough funds to buy a house there"); return false; } int minHouseUpgradeStatus = 9; // get all the properties of this color for(int i=0;i<ownedProperties.Count;i++){ // check if it is part of our group we are upgrading if(ownedProperties[i].tileGroup == property.tileGroup){ // get the current house upgrade status int houseUpgradeStatus = (int)ownedProperties[i].improvement; // check if it is below the current minimum upgrade if(houseUpgradeStatus < minHouseUpgradeStatus){ minHouseUpgradeStatus = houseUpgradeStatus; } } } // check if our improvement is the same as the minimum house upgrade status if((int)property.improvement == minHouseUpgradeStatus){ property.AddHouseUpgrade(); money -= property.houseBuyCost; return true; } else{ Debug.Log ("Cannot upgrade property, properties must be upgraded evenly."); return false; } }
public override void OnLandedOnUnownedTile(BoardTile landedTile){ DoneProcessingUnOwnedTile(); }
public void SellHouse (BoardTile property,int numOfHouses){ if(property.owner == playerIndex){ // determine how many houses can be sold back if(numOfHouses > (int)property.improvement){ numOfHouses = (int)property.improvement; } // calculate money back from selling houses int moneyBack = (property.houseBuyCost/2)*numOfHouses; property.RemoveHouseUpgrade(numOfHouses); } }
//Called when the tile 'tile' is selected. This method spreads the event to all the ITileListeners public void OnTileSelected(BoardTile tile) { if (selectedTile == tile) //When clicking on a selected tile, unselect it { selectedTile.OnUnSelected(); selectedTile = null; board.GetCanvasManager().OnTileUnSelected(tile); } else //Tile selected for the first time { if (selectedTile != null) selectedTile.OnUnSelected(); //Tell the last selected tile that its not selected anymore selectedTile = tile; selectedTile.OnSelected(); //Tell the selected tile that its been selected selectedBug = selectedTile.GetBug(); if (selectedBug != null) //If the tile isnt empty, do something with the bug { if(currentGameState == BoardGameState.Pointing) { /*Just mark the selected tile, i.e., do nothing here*/ } else if(currentGameState == BoardGameState.MovingBug) { //When a tile is selected and the player is moving } } board.GetCanvasManager().OnTileSelected(tile); } }