private bool CreateSpecialTile(out Tile toAdd) { toAdd = new SpecialTile(int.Parse(tsLblSelX.Text), int.Parse(tsLblSelY.Text)); if (cmbSpecialType.SelectedIndex < 0 || cmbWarpAnim.SelectedIndex < 0 || lvTiles2.SelectedIndices.Count == 0) { return(false); } SpecialTileSpec type = (SpecialTileSpec)cmbSpecialType.SelectedIndex; object[] paramList; if (type == SpecialTileSpec.WARP) { int outID, outX, outY; WarpAnim add = (WarpAnim)cmbWarpAnim.SelectedIndex; if (!int.TryParse(txtDestWarpX.Text, out outX) || !int.TryParse(txtDestWarpY.Text, out outY) || !int.TryParse(txtDestWarpMap.Text, out outID)) { MessageBox.Show("Error: please enter valid values for X, Y, and Dest"); return(false); } paramList = new object[4]; paramList[0] = outID; paramList[1] = outX; paramList[2] = outY; paramList[3] = add; } else { paramList = null; } (toAdd as SpecialTile).SetType(type, paramList); (toAdd as SpecialTile).Graphic = lvTiles2.SelectedIndices[0]; return(true); }
private void btnAddTile_Click(object sender, EventArgs e) { if (GraphicTileGraphic == null) { return; } switch (tileType) { case TileType.Animated: case TileType.Graphic: // Graphic Tile Tileset.Images.Images.Add(GraphicTileGraphic); Tileset.Tiles.Add(new GraphicTile(Tileset.Images.Images.Count - 1)); Close(); break; case TileType.Special: // Special Tile Tileset.Images.Images.Add(GraphicTileGraphic); SpecialTile tile = new SpecialTile(-1, -1); tile.Graphic = Tileset.Images.Images.Count - 1; Tileset.Tiles.Add(tile); Close(); break; } }
private void OnTriggerEnter(Collider col) { if (col.CompareTag("Tile")) { currentTile = col.GetComponent <Tile>(); } else if (col.CompareTag("SpecialTile")) { currentSpecialTile = col.GetComponent <SpecialTile>(); } }
private void OnTriggerExit(Collider col) { if (currentTile != null) { if (col.gameObject.GetInstanceID() == currentTile.gameObject.GetInstanceID()) { currentTile = null; } } else if (currentSpecialTile != null) { if (col.gameObject.GetInstanceID() == currentSpecialTile.gameObject.GetInstanceID()) { currentSpecialTile = null; } } }
private void FillTileSpecial(Tile tileToFill, Tile fillTile) { SpecialTile destTile = tileToFill as SpecialTile, sourceTile = fillTile as SpecialTile; if (destTile.Type == sourceTile.Type) { return; } SpecialTileSpec graphicToMatch = destTile.Type; Stack <Tile> tileStack = new Stack <Tile>(); tileStack.Push(tileToFill); while (tileStack.Count != 0) { SpecialTile currentTile = tileStack.Pop() as SpecialTile; if (currentTile.Type == graphicToMatch) { currentTile.CopyTypeFrom(sourceTile); if (currentTile.X > 0) { tileStack.Push(m_openMap.GetTile(currentTile.X - 1, currentTile.Y, LAYERS.Special)); } if (currentTile.Y > 0) { tileStack.Push(m_openMap.GetTile(currentTile.X, currentTile.Y - 1, LAYERS.Special)); } if (currentTile.X < m_openMap.Width - 1) { tileStack.Push(m_openMap.GetTile(currentTile.X + 1, currentTile.Y, LAYERS.Special)); } if (currentTile.Y < m_openMap.Height - 1) { tileStack.Push(m_openMap.GetTile(currentTile.X, currentTile.Y + 1, LAYERS.Special)); } } } }
//tests the tile for specialty void TestTile() { RaycastHit2D hit = Physics2D.Raycast(feetCollider.bounds.center, Vector2.down, feetCollider.bounds.extents.y + 0.1f, groundLayer); /***** Debugging ****/ Debug.DrawRay(feetCollider.bounds.center, Vector2.down * (feetCollider.bounds.extents.y + 0.1f), Color.green); /***** Debugging ****/ if (hit.collider != null) { try { SpecialTile st = hit.collider.GetComponent <SpecialTile>(); st.ActivateSpecial(); DropDown(); }catch { } } }
// Set the special tile to the rectangle private Rectangle setGivenSpecialTile(Rectangle rectangle, int x, int y, SpecialTile SpecialTile) { if (SpecialTile == SpecialTile.HEATZONE) { rectangle.Name = SpecialTile.HEATZONE.ToString(); rectangle.Stroke = new SolidColorBrush(Colors.Orange); rectangle.StrokeThickness = 2; globalMap[x, y].heatZone = true; } if (SpecialTile == SpecialTile.NON_COLLIDABLE) { rectangle.Name = SpecialTile.NON_COLLIDABLE.ToString(); rectangle.Stroke = new SolidColorBrush(Colors.DarkGray); rectangle.StrokeThickness = 3; globalMap[x, y].collidable = false; } return (rectangle); }
public static void CreateSpecialTiles(List <Vector3Int> positions, SpecialTile tile, Unit creator, int duration) { }
/// IMPORTANT FUNCTION /// Called when the player finished moving. /// We check what is the type of the destination tile and act accordingly. /// If we reached a property tile, we also need to check who owns it and act accordingly. /// This function also updates the players amount of money and properties ownership (if needed). /// Just to mention that the 'visual update' will occur after clicking on log window button void ReachedFinalTile() { MainGameData.isCurrentPlayerCouldNotBuyProperty = false;//resets the variable Tile tempTile = MainGameData.gameTileMap[MainGameData.players[MainGameData.whosTurnIsIt].GetCurrentPosition()]; MainGameData.MoneyAtStartOfTurn = MainGameData.players[MainGameData.whosTurnIsIt].GetMoney(); if (tempTile.GetType() == typeof(Property)) { Property currentProperty = (Property)tempTile; if (currentProperty.GetOwnedByPlayerIndex() == MainGameData.whosTurnIsIt) // This property is already yours //Enters only in games with upgrades { if (MainGameData.gameType == GameData.GameType.Upgrades) { int upgradeCost = (int)(currentProperty.GetCostPrice() * MainGameData.UPGRADE_COST_RATIO); if (MainGameData.players[MainGameData.whosTurnIsIt].GetMoney() - upgradeCost > 0) //Player has enough money to upgrade the property { MainGameData.players[MainGameData.whosTurnIsIt].DecreaseMoney(upgradeCost); UpgradeProperty(currentProperty); ViewerHandler.UpdateLogWindow(MainGameData, upgradeCost, GameData.LogType.Upgrade); } else //Player did not have enough money to buy the property { MainGameData.isCurrentPlayerCouldNotBuyProperty = true; ViewerHandler.UpdateLogWindow(MainGameData, -1, GameData.LogType.AlreadyBoughtIt); } } else //Enters only in classic games. This property is already yours { MainGameData.isCurrentPlayerCouldNotBuyProperty = true; ViewerHandler.UpdateLogWindow(MainGameData, -1, GameData.LogType.AlreadyBoughtIt); } } else if (currentProperty.GetOwnedByPlayerIndex() == -1) //This property is free //make sure the player has enough money to buy the property { if (MainGameData.players[MainGameData.whosTurnIsIt].GetMoney() - currentProperty.GetCostPrice() > 0) //That means the player can afford buying the property { MainGameData.players[MainGameData.whosTurnIsIt].DecreaseMoney(currentProperty.GetCostPrice()); //Takes money from the player currentProperty.SetOwnedByPlayerIndex(MainGameData.whosTurnIsIt); //Make the current property be owned by current player ViewerHandler.UpdateLogWindow(MainGameData, currentProperty.GetCostPrice(), GameData.LogType.BuyProperty); } else //Means the player don't have enought money to buy the property { MainGameData.isCurrentPlayerCouldNotBuyProperty = true; ViewerHandler.UpdateLogWindow(MainGameData, currentProperty.GetCostPrice(), GameData.LogType.NotEnoghtMoney); } } else //Other player already purchased this property { MainGameData.players[(MainGameData.whosTurnIsIt)].DecreaseMoney(currentProperty.GetFinePrice()); //Takes money from the player and gives it to the player owning this property MainGameData.players[currentProperty.GetOwnedByPlayerIndex()].IncreaseMoney(currentProperty.GetFinePrice()); //Takes money from the player and gives it to the player owning this property ViewerHandler.UpdateLogWindow(MainGameData, currentProperty.GetFinePrice(), GameData.LogType.PayFine); } } else //Special tile - Can only earn money { SpecialTile specialTile = (SpecialTile)tempTile; int tempReward = specialTile.GetReward();//Every time we call GetReward() we receive differnet amount, so we keep it for this turn MainGameData.players[(MainGameData.whosTurnIsIt)].IncreaseMoney(tempReward); ViewerHandler.UpdateLogWindow(MainGameData, tempReward, GameData.LogType.ReceiveBonusMoney); } // ViewerHandler.UpdateHUD(MainGameData); ViewerHandler.ShowWindow(ViewerHandler.GAME_LOG_WINDOW); }