예제 #1
0
    // Highlights the area where the unit can attack/interact with other units.
    public void HighlightAttackRange(TileManagement tile, int attackRange, object[] pieces, GameObject prevPiece)
    {
        TileManagement[] adjacentTiles = tile.GetComponent <TileManagement>().AdjacentTiles;

        foreach (TileManagement adjacentTile in adjacentTiles)
        {
            if (adjacentTile == null)
            {
                break;
            }
            else if (attackRange > 1)
            {
                adjacentTile.GetComponent <Renderer>().material.color = colourManager.turqoise;

                foreach (GameObject piece in pieces)
                {
                    if (adjacentTile.name == piece.GetComponent <Properties>().CurrentTile.name)
                    {
                        if (piece.GetComponent <Player_Piece_Properties>().belongsTo == prevPiece.GetComponent <Player_Piece_Properties>().belongsTo)
                        {
                            adjacentTile.GetComponent <Renderer>().material.color = colourManager.lightGreen;
                        }
                        else if (prevPiece.GetComponent <Player_Piece_Properties>().belongsTo == "Traitor")
                        {
                            break;
                        }
                        else
                        {
                            adjacentTile.GetComponent <Renderer>().material.color = Color.red;
                        }
                    }
                }
                attackRange -= 1;
                HighlightAttackRange(adjacentTile, attackRange, pieces, prevPiece);
                attackRange += 1;
            }
            else
            {
                adjacentTile.GetComponent <Renderer>().material.color = colourManager.turqoise;
                foreach (GameObject piece in pieces)
                {
                    if (adjacentTile.name == piece.GetComponent <Properties>().CurrentTile.name)
                    {
                        if (piece.GetComponent <Player_Piece_Properties>().belongsTo == prevPiece.GetComponent <Player_Piece_Properties>().belongsTo)
                        {
                            adjacentTile.GetComponent <Renderer>().material.color = colourManager.lightGreen;
                        }
                        else if (prevPiece.GetComponent <Player_Piece_Properties>().belongsTo == "Traitor")
                        {
                            break;
                        }
                        else
                        {
                            adjacentTile.GetComponent <Renderer>().material.color = Color.red;
                        }
                    }
                }
            }
        }
    }
예제 #2
0
 // Dodaje kafelek i zamyka stronę
 private void btnOk_Click(object sender, EventArgs e)
 {
     // Dodaj kafelek
     TileManagement.GenerateTile(stpTilePanel, _citations.ViewCitation.Id.ToString());
     // Opuść stronę
     if (NavigationService.CanGoBack)
     {
         NavigationService.GoBack();
     }
 }
예제 #3
0
 //
 // Przycisk dodaj kafelek
 //
 private void btnAddTile_click(object sender, EventArgs e)
 {
     // Sprawdź czy kafelek istnieje
     if (TileManagement.CheckIfTileExist(_citations.ViewCitation.Id.ToString()))
     {
         // Wyświetl komunikat
         MessageBox.Show("Nie mogę go dodać ponownie", "Kafelek z wyranym cytatem już istnieje", MessageBoxButton.OK);
     }
     else
     {
         // Przejdź do strony dodawania kafelka
         NavigationService.Navigate(new Uri("/Pages/TilePage.xaml", UriKind.Relative));
     }
 }
예제 #4
0
 // Similar to HighlightReposition, this function instead highlight the adjacent tiles to allow for the player to spawn in a new unit.
 public void HighlightSpawn(TileManagement tile)
 {
     TileManagement[] adjacentTiles = tile.GetComponent <TileManagement>().AdjacentTiles;
     foreach (TileManagement adjacentTile in adjacentTiles)
     {
         if (adjacentTile == null)
         {
             break;
         }
         else if (adjacentTile.GetComponent <TileManagement>().CurrentPiece != null || adjacentTile.GetComponent <TileProperties>().isWaterTile)
         {
         }
         else
         {
             adjacentTile.GetComponent <Renderer>().material.color = Color.yellow;
         }
     }
 }
예제 #5
0
    //Highlights the adjacent tiles around the unit in question to allow for repositioning of a friendly unit.
    public void HighlightReposition(TileManagement tile)
    {
        TileManagement[] adjacentTiles = tile.GetComponent <TileManagement>().AdjacentTiles;

        foreach (TileManagement adjacentTile in adjacentTiles)
        {
            if (adjacentTile == null)
            {
                break;
            }
            else if (adjacentTile.GetComponent <TileManagement>().CurrentPiece != null || adjacentTile.GetComponent <TileProperties>().isWaterTile)
            {
                adjacentTile.GetComponent <Renderer>().material = tile.GetComponent <Properties>().colour;
            }
            else
            {
                adjacentTile.GetComponent <Renderer>().material.color = colourManager.babyBlue;
            }
        }
    }
예제 #6
0
    // The highlightMovement function displays the current available moves to the user when they select an object. The method is called recursively up to allow for pieces to
    // move cardinally up to their movement speed.
    public void HighlightMovement(TileManagement tile, int speed, GameObject piece)
    {
        TileManagement[] adjacentTiles = tile.GetComponent <TileManagement>().AdjacentTiles;

        foreach (TileManagement adjacentTile in adjacentTiles)
        {
            if (adjacentTile == null)
            {
                break;
            }
            else if (adjacentTile.GetComponent <TileManagement>().CurrentPiece != piece && adjacentTile.GetComponent <TileManagement>().CurrentPiece != null || adjacentTile.GetComponent <TileProperties>().isWaterTile)
            {
                if (piece.GetComponent <Properties>().description == "Player_Piece_Dragon" && adjacentTile.GetComponent <TileProperties>().isWaterTile)
                {
                    adjacentTile.GetComponent <Renderer>().material.color = Color.green;
                }
            }
            else if (adjacentTile.GetComponent <TileProperties>().isForestTile&& piece.GetComponent <Properties>().description != "Player_Piece_Dragon")
            {
                if (speed > 1)
                {
                    adjacentTile.GetComponent <Renderer>().material.color = Color.green;
                }
            }
            else if (speed > 1)
            {
                adjacentTile.GetComponent <Renderer>().material.color = Color.green;
                speed -= 1;
                HighlightMovement(adjacentTile, speed, piece);
                speed += 1;
            }
            else
            {
                adjacentTile.GetComponent <Renderer>().material.color = Color.green;
            }
        }
    }
예제 #7
0
 // Use this for initialization
 void Start()
 {
     this.tm = transform.parent.GetComponent <TileManagement>();
 }