Ejemplo n.º 1
0
    public void copySide(bool white)
    {
        List <GeneratedTile> toCopy = new List <GeneratedTile>();

        foreach (List <GeneratedTile> item in GenerateGame.instance.board)
        {
            if (item.Count != 0 && item[0].isWhite == white)
            {
                toCopy.AddRange(item);
            }
        }

        int row = 0;

        foreach (GeneratedTile item in toCopy)
        {
            if (white)
            {
                row = GenerateGame.instance.boardSize - (int)item.pos.x - 1;
            }
            else
            {
                row = Mathf.Abs((int)item.pos.x - GenerateGame.instance.boardSize) - 1;
            }
            //Debug.Log(row);
            if (GenerateGame.instance.board[row][Mathf.FloorToInt(item.pos.y)].occupied)
            {
                RemovePiece.removePiece(GenerateGame.instance.board[row][Mathf.FloorToInt(item.pos.y)].occupiedBy);
            }
            if (item.occupied)
            {
                PlacePiece.placePiece(item.occupiedBy, GenerateGame.instance.board[row][Mathf.FloorToInt(item.pos.y)]);
            }
        }
    }
Ejemplo n.º 2
0
 public void clearSide(bool white)
 {
     foreach (List <GeneratedTile> item in GenerateGame.instance.board)
     {
         foreach (GeneratedTile gt in item)
         {
             if (gt.isWhite == white && gt.occupied)
             {
                 RemovePiece.removePiece(gt.occupiedBy);
             }
         }
     }
 }
Ejemplo n.º 3
0
 public void clear()
 {
     foreach (List <GeneratedTile> item in board)
     {
         foreach (GeneratedTile g in item)
         {
             if (g.gameObject != null)
             {
                 if (g.occupied)
                 {
                     RemovePiece.removePiece(g.occupiedBy);
                 }
                 Destroy(g.gameObject);
             }
         }
     }
     board.Clear();
 }
Ejemplo n.º 4
0
    public void fillRow()
    {
        GeneratedTile lc = GenerateGame.instance.selected;

        //Debug.Log(Mathf.FloorToInt(lc.pos.x));
        if (lc != null)
        {
            if (GameObject.Find("Pieces").GetComponent <Dropdown>().options[GameObject.Find("Pieces").GetComponent <Dropdown>().value].text.Contains("King"))
            {
                return;
            }
            for (int i = 0; i < GenerateGame.instance.boardSize; i++)
            {
                GameObject g;
                if (GenerateGame.instance.selected.isWhite)
                {
                    g = GameObject.Find("White Points");
                }
                else
                {
                    g = GameObject.Find("Black Points");
                }
                int v = int.Parse(g.GetComponent <Text>().text);
                int c = GlobalVariables.pieces[GameObject.Find("Pieces").GetComponent <Dropdown>().value].cost;
                if (v - c < 0)
                {
                    return;
                }
                g.GetComponent <Text>().text = (v - c).ToString();
                if (GenerateGame.instance.board[Mathf.FloorToInt(lc.pos.x)][i].occupied)
                {
                    RemovePiece.removePiece(GenerateGame.instance.board[Mathf.FloorToInt(lc.pos.x)][i].occupiedBy);
                }
                //Debug.Log(Mathf.FloorToInt(lc.pos.x));
                int p = Mathf.FloorToInt(lc.pos.x);
                GenerateGame.instance.spawnPiece(GameObject.Find("Pieces").GetComponent <Dropdown>().value, GenerateGame.instance.board[p][i]);
            }
        }
    }