Exemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     winConditions = gameObject.GetComponent <ThreatCheckScript>();
     board         = gameObject.GetComponent <DrawBoardScript>();
     utility       = gameObject.GetComponent <UtilityScripts>();
     placePiece    = gameObject.GetComponent <GamePieceScript>();
     eval          = gameObject.GetComponent <EvaluateBoardScript>();
 }
Exemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     placePiece     = gameObject.GetComponent <GamePieceScript>();
     gameBoard      = gameObject.GetComponent <DrawBoardScript>().drawnGameBoard;
     utility        = gameObject.GetComponent <UtilityScripts>();
     gameData       = gameObject.GetComponent <GameController>();
     gameBoardState = gameObject.GetComponent <DrawBoardScript>().gameBoardState;
 }
Exemplo n.º 3
0
    public void removePiece(int x, int y)
    {
        GamePieceScript piece = getPiece(x, y);

        if (piece != null)
        {
            piecesRemaining[piece.pieceType] += 1;
            pieces.Remove(piece);
            updateRemainder(piece.pieceType, piecesRemaining[piece.pieceType]);
            Object.Destroy(piece.gameObject);
            roundController.tileEdited();
        }
    }
Exemplo n.º 4
0
    public void place(PieceType pieceType, int x, int y)
    {
        if (piecesRemaining[pieceType] == 0 || !canPlace(x, y))
        {
            return;
        }

        piecesRemaining[pieceType] -= 1;
        updateRemainder(pieceType, piecesRemaining[pieceType]);

        GameObject gameObject;

        if (pieceType == PieceType.Mine)
        {
            gameObject = Instantiate(MineGameObject);
        }
        else if (pieceType == PieceType.Port)
        {
            gameObject = Instantiate(PortGameObject);
        }
        else
        {
            gameObject = Instantiate(MineGameObject);
        }

        float   tileSize   = levelManager.getTileSize();
        Vector3 tileOrigin = map.transform.position + new Vector3(-0.5f * levelManager.gridResolution * tileSize + tileSize, 0.5f * levelManager.gridResolution * tileSize - tileSize, 0);

        gameObject.transform.position = tileOrigin + new Vector3(x * tileSize, -1 * y * tileSize, -1.5f);
        gameObject.transform.SetParent(map.transform);

        GamePieceScript pieceScript = gameObject.GetComponent <GamePieceScript>();

        pieceScript.setup(x, y);

        pieces.Add(pieceScript);
        roundController.tileEdited();
    }