Beispiel #1
0
        private Vector3 vert0;  // lower left most vertex of Tile

        public void CreateCells(GOTile tile)
        {
            vert0 = tile.vertices[0] + tile.tileCenter.convertCoordinateToVector(0); // verts[0] relative to world coords

            tile_edge_x = tile.vertices[2].x - tile.vertices[1].x;
            tile_edge_z = tile.vertices[1].z - tile.vertices[0].z;

            cell_edge_x = tile_edge_x / Mathf.Sqrt(CELLS_PER_TILE);
            cell_edge_z = tile_edge_z / Mathf.Sqrt(CELLS_PER_TILE);

            GameObject markerPrefab = (GameObject)Resources.Load("Prefabs/pref_NodeMarker", typeof(GameObject));

            for (int x = 0; x < Mathf.Sqrt(CELLS_PER_TILE); x++)     // column
            {
                for (int z = 0; z < Mathf.Sqrt(CELLS_PER_TILE); z++) // row
                {
                    float center_x = tile.vertices[1].x + ((x * cell_edge_x) + (cell_edge_x / 2)) + this.transform.position.x;
                    float center_z = tile.vertices[0].z + ((z * cell_edge_z) + (cell_edge_z / 2)) + this.transform.position.z;

                    // visualize -- place marker
                    GameObject marker = GameObject.Instantiate(markerPrefab, new Vector3(), new Quaternion());
                    marker.transform.parent = this.gameObject.transform;
                    marker.layer            = LayerMask.NameToLayer("Debug");
                    ///marker.transform.localPosition = new Vector3(center_x, 1.5f, center_z);

                    // fill array element
                    cells[x, z] = new GOTileCell(new Vector3(center_x, 0, center_z), marker, new Vector2(x, z), cell_edge_x, cell_edge_z);

                    marker.GetComponent <NodeMarker>().Init(cells[x, z]);
                }
            }
        }
Beispiel #2
0
    public void OnTileLoad(GOTile tile)
    {
        Vector3 currentLocation = goMap.locationManager.currentLocation.convertCoordinateToVector();

        if (tile.goTile.vectorIsInTile(currentLocation))
        {
//
            Debug.Log("FIX Start");
//
            currentLocation    = GOMap.AltitudeToPoint(currentLocation);
            transform.position = currentLocation;
        }
    }
Beispiel #3
0
    public void OnTileLoad(GOTile tile)
    {
        Vector3 currentLocation = goMap.locationManager.currentLocation.convertCoordinateToVector();

        if (tile.goTile.vectorIsInTile(currentLocation))
        {
            if (goMap.useElevation)
            {
                currentLocation = GOMap.AltitudeToPoint(currentLocation);
            }

            transform.position = currentLocation;
        }
    }