Ejemplo n.º 1
0
    void Update()
    {
        /*
         *
         * if (Input.GetKeyDown(KeyCode.K)){
         *  for (int i = 0; i < 5; ++i)
         *  {
         *      Map._Instances[i, 0, 0] = Instantiate(_water, new Vector3(i+1 * 20, 0, 0), Quaternion.identity);
         *  }
         *
         * }
         * if (Input.GetKeyDown(KeyCode.L))
         * {
         *  for (int i = 0; i < 5; ++i)
         *  {
         *      Destroy(Map._Instances[i, 0, 0]);
         *  }
         *
         * }
         */

        if (_boat.transform.position.z > (_currentTile.z + _pieceZ / 2 + 1))
        {
            DrawMap.DrawMapUp(_size, _water, _currentTile, _islands, _pieceX, _pieceZ);
            _currentTile.z = _currentTile.z + _pieceZ;
        }
        if (_boat.transform.position.x > (_currentTile.x + _pieceX / 2 + 1))
        {
            DrawMap.DrawMapRight(_size, _water, _currentTile, _islands, _pieceX, _pieceZ);
            _currentTile.x = _currentTile.x + _pieceX;
        }
        if (_boat.transform.position.x < (_currentTile.x - _pieceX / 2 - 1))
        {
            DrawMap.DrawMapLeft(_size, _water, _currentTile, _islands, _pieceX, _pieceZ);
            _currentTile.x = _currentTile.x - _pieceX;
        }
        if (_boat.transform.position.z < (_currentTile.z - _pieceZ / 2 - 1))
        {
            DrawMap.DrawMapDown(_size, _water, _currentTile, _islands, _pieceX, _pieceZ);
            _currentTile.z = _currentTile.z - _pieceZ;
        }
    }
Ejemplo n.º 2
0
    void FixedUpdate()
    {
        /*
         *
         * if (Input.GetKeyDown(KeyCode.K)){
         *  for (int i = 0; i < 5; ++i)
         *  {
         *      Map._Instances[i, 0, 0] = Instantiate(_water, new Vector3(i+1 * 20, 0, 0), Quaternion.identity);
         *  }
         *
         * }
         * if (Input.GetKeyDown(KeyCode.L))
         * {
         *  for (int i = 0; i < 5; ++i)
         *  {
         *      Destroy(Map._Instances[i, 0, 0]);
         *  }
         *
         * }
         */

        if (_boat.transform.position.z > (_currentTile.z + _pieceZ / 2 + 1))
        {
            //Debug.Log(_mapX + "   " + _mapZ + " x and Y before up ");
            DrawMap.DrawMapUp(_size, _water, _currentTile, _mapX, _mapZ, _islands, _pieceX, _pieceZ, _objective);
            ++_mapZ;
            if (_mapZ == _size)
            {
                _mapZ = 0;
            }
            _currentTile.z = _currentTile.z + _pieceZ;
            //Debug.Log(_mapX + "   " + _mapZ + " x and Y after up ");
        }
        if (_boat.transform.position.x > (_currentTile.x + _pieceX / 2 + 1))
        {
            DrawMap.DrawMapRight(_size, _water, _currentTile, _mapX, _mapZ, _islands, _pieceX, _pieceZ, _objective);
            ++_mapX;
            if (_mapX == _size)
            {
                _mapX = 0;
            }
            _currentTile.x = _currentTile.x + _pieceX;
        }
        if (_boat.transform.position.x < (_currentTile.x - _pieceX / 2 - 1))
        {
            DrawMap.DrawMapLeft(_size, _water, _currentTile, _mapX, _mapZ, _islands, _pieceX, _pieceZ, _objective);
            --_mapX;
            if (_mapX == -1)
            {
                _mapX = _size + _mapX;
            }
            _currentTile.x = _currentTile.x - _pieceX;
        }
        if (_boat.transform.position.z < (_currentTile.z - _pieceZ / 2 - 1))
        {
            //Debug.Log(_mapX + "   " + _mapZ + " x and Y before down ");
            DrawMap.DrawMapDown(_size, _water, _currentTile, _mapX, _mapZ, _islands, _pieceX, _pieceZ, _objective);
            --_mapZ;
            if (_mapZ < 0)
            {
                _mapZ = _size + _mapZ;
            }
            _currentTile.z = _currentTile.z - _pieceZ;
            //Debug.Log(_mapX + "   " + _mapZ + " x and Y after down ");
        }
    }