Exemplo n.º 1
0
    void EndDrag()
    {
        OnEndDrag.Invoke();
        Dragging = false;
        FieldMapController fieldMapColtroller = FieldMap.GetComponent <FieldMapController>();
        Vector2            pos = fieldMapColtroller.GetCellPosFromShipPos(transform.position);
        bool isValid           = fieldMapColtroller.CheckValidShipPos(gameObject, pos);

        if (!isValid)
        {
            ResetShip();
        }
        else
        {
            GameObject cell     = fieldMapColtroller.GetCellByPos(pos);
            Vector3    position = new Vector3(
                Camera.main.WorldToScreenPoint(cell.transform.position).x,
                Camera.main.WorldToScreenPoint(cell.transform.position).y,
                ZPosition
                );
            transform.position = Camera.main.ScreenToWorldPoint(position);
            fieldMapColtroller.SetShipIntoArray(gameObject);
            RotateButton.gameObject.SetActive(false);
        }
        fieldMapColtroller.ResetCellStatus();
        SoundManager.Instance.PlaySound(SoundManager.Sound.BOAT_TO_WATER);
    }
Exemplo n.º 2
0
    public void SetShipToMap(int row, int col, int dir)
    {
        FieldMapController fieldMapColtroller = FieldMap.GetComponent <FieldMapController>();
        GameObject         cell = fieldMapColtroller.GetCellByPos(row, col);

        transform.position = new Vector3(
            cell.transform.position.x,
            transform.position.y,
            cell.transform.position.z
            );
        SetDirection(dir);
        root = cell;
        fieldMapColtroller.SetShipIntoArray(gameObject);
        RotateButton.gameObject.SetActive(false);
    }