コード例 #1
0
    void OnMouseDown()
    {
        Vector3    pos        = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector3Int coordinate = grid.WorldToCell(pos);

        coordinate.Clamp(minCoordinate, maxCoordinate);

        if (mode == "place")
        {
            controller.PlaceShip(coordinate);
        }
        else if (mode == "attack")
        {
            // outside code thinks coordinates are 0, 0 based
            controller.TakeTurn(coordinate - new Vector3Int(0, size, 0));
        }
    }