void Start()
 {
     turnManager        = GameObject.Find("turnManager").GetComponent <turnHandler>();
     gridManager        = GameObject.Find("gridManager").GetComponent <gridHandler>();
     playerPos          = new Vector3Int(0, gridManager.board_height / 2, 0);
     transform.position = gridManager.matrixPosToWorld(playerPos);
 }
Пример #2
0
 void Start()
 {
     //playerScript = GameObject.Find("Player").GetComponent<playerMovement>();
     gridManager        = GameObject.Find("gridManager").GetComponent <gridHandler>();
     turnManager        = GameObject.Find("turnManager").GetComponent <turnHandler>();
     enemyPos           = new Vector3Int(gridManager.board_width - 1, gridManager.board_height / 2, 0);
     transform.position = gridManager.matrixPosToWorld(enemyPos);
 }
    public void selectMove(movementSystemObject object_to_move)
    {
        if (last_object != null && last_object != object_to_move)
        {
            last_object.released_after_selected = false;
            last_object.selected = false;
        }
        last_object = object_to_move;
        if (Input.GetMouseButton(0) && !select_started && gridManager.matrixPosToWorld(object_to_move.posOnMatrix) == gridManager.mousePositionToTileMapPosition(Input.mousePosition))
        {
            gridManager.possible_moves(last_object.posOnMatrix, last_object.player_moves);
            mousePressed = true;
            Vector3Int next = gridManager.mousePositionToTileMapPosition(Input.mousePosition);
            last_position = gridManager.tilemapGridToMatrixPos(next);
            gridManager.board_tilemap.SetTile(next, gridManager.red_tile);
            select_started = true;
        }

        if (Input.GetMouseButton(0) && select_started && spaces_selected < object_to_move.player_moves)
        {
            Vector3Int next      = gridManager.mousePositionToTileMapPosition(Input.mousePosition);
            Vector3Int nextCoord = gridManager.tilemapGridToMatrixPos(next);
            if (gridManager.are_adjacent(last_position, nextCoord) && gridManager.validMatrixPos(nextCoord))
            {
                gridManager.board_tilemap.SetTile(next, gridManager.red_tile);
                move_queue.Enqueue(nextCoord);
                last_position = nextCoord;
                spaces_selected++;
            }
            else if (last_position != nextCoord)
            {
                select_started  = false;
                mousePressed    = false;
                spaces_selected = 0;
                //gridManager.clearPaths();
                move_queue.Clear();
            }
        }

        if (mousePressed && !Input.GetMouseButton(0))
        {
            turnDone              = true;
            mousePressed          = false;
            select_started        = false;
            spaces_selected       = 0;
            last_object.move_done = true;
            //turnManager.nextTurn();
        }
    }
    void selectMove()
    {
        if (Input.GetMouseButton(0) && !select_started && gridManager.matrixPosToWorld(playerPos) == gridManager.mousePositionToTileMapPosition(Input.mousePosition))
        {
            mousePressed = true;
            Vector3Int next = gridManager.mousePositionToTileMapPosition(Input.mousePosition);
            last_position = gridManager.tilemapGridToMatrixPos(next);
            gridManager.board_tilemap.SetTile(next, gridManager.red_tile);
            select_started = true;
        }

        if (Input.GetMouseButton(0) && select_started && spaces_selected < player_moves)
        {
            Vector3Int next      = gridManager.mousePositionToTileMapPosition(Input.mousePosition);
            Vector3Int nextCoord = gridManager.tilemapGridToMatrixPos(next);
            if (gridManager.are_adjacent(last_position, nextCoord))
            {
                gridManager.board_tilemap.SetTile(next, gridManager.red_tile);
                move_queue.Enqueue(nextCoord);
                last_position = nextCoord;
                spaces_selected++;
            }
            else if (last_position != nextCoord)
            {
                select_started  = false;
                mousePressed    = false;
                spaces_selected = 0;
                gridManager.clearPaths();
                move_queue.Clear();
            }
        }

        if (mousePressed && !Input.GetMouseButton(0))
        {
            turnDone        = true;
            mousePressed    = false;
            select_started  = false;
            spaces_selected = 0;
            turnManager.nextTurn();
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     movementScript     = GameObject.Find("movementSystem").GetComponent <movementSystem>();
     gridManager        = GameObject.Find("gridManager").GetComponent <gridHandler>();
     transform.position = gridManager.matrixPosToWorld(posOnMatrix);
 }