Ejemplo n.º 1
0
    public void SetGridPointContent(Vector2 pos, Point.PointContent newContent)
    {
        int posX = Mathf.FloorToInt((pos.x - transform.position.x) / WorldManager.gridSize);
        int posY = Mathf.FloorToInt((pos.y - transform.position.z) / WorldManager.gridSize);

        pointArray[posX, posY].contains = newContent;

        if (newContent == Point.PointContent.Path)
        {
            pointArray[posX, posY].buildable = false;
        }
        if (newContent == Point.PointContent.Building)
        {
            pointArray[posX, posY].buildable = false;
        }
        if (newContent == Point.PointContent.Resource)
        {
            pointArray[posX, posY].buildable = false;
        }
        if (newContent == Point.PointContent.Empty)
        {
            pointArray[posX, posY].buildable = true;
        }

        //Debug.Log("added: "+pointArray[posX, posY].contains + " at: " + posX + "," + posY);
    }
Ejemplo n.º 2
0
    private void SetGridPoints(Point.PointContent _fill)
    {
        Vector3 pos      = transform.position;
        float   gridSize = WorldManager.gridSize;
        Map     worldMap = WorldManager.GetMap();

        float offsetX = ((size.x + 1) % 2) * (gridSize / 2);
        float offsetZ = ((size.y + 1) % 2) * (gridSize / 2);

        for (int i = 0; i < size.x; i++)
        {
            for (int j = 0; j < size.y; j++)
            {
                Vector3 pointPos = new Vector3(pos.x - ((Mathf.FloorToInt((size.x - 1) / 2) * gridSize) + offsetX) + (gridSize * i), pos.y,
                                               pos.z - ((Mathf.FloorToInt((size.y - 1) / 2) * gridSize) + offsetZ) + (gridSize * j));
                worldMap.SetGridPointContent(new Vector2(pointPos.x, pointPos.z), _fill);
            }
        }
    }
Ejemplo n.º 3
0
    private void SetGridPoints(Point.PointContent _fill)
    {
        Vector3 pos = transform.position;
        //Debug.Log(pos);
        float gridSize = WorldManager.gridSize;
        Map   worldMap = WorldManager.GetMap();

        float offsetX = ((buildingData.TileSizeX + 1) % 2) * (gridSize / 2);
        float offsetZ = ((buildingData.TileSizeZ + 1) % 2) * (gridSize / 2);

        for (int i = 0; i < buildingData.TileSizeX; i++)
        {
            for (int j = 0; j < buildingData.TileSizeZ; j++)
            {
                Vector3 pointPos = new Vector3(pos.x - ((Mathf.FloorToInt((buildingData.TileSizeX - 1) / 2) * gridSize) + offsetX) + (gridSize * i), pos.y,
                                               pos.z - ((Mathf.FloorToInt((buildingData.TileSizeZ - 1) / 2) * gridSize) + offsetZ) + (gridSize * j));
                worldMap.SetGridPointContent(new Vector2(pointPos.x, pointPos.z), _fill);
            }
        }
    }
Ejemplo n.º 4
0
    public void SetGridPointContent(Vector2 pos, Point.PointContent newContent)
    {
        int posX = Mathf.FloorToInt((pos.x - transform.position.x) / WorldManager.gridSize);
        int posY = Mathf.FloorToInt((pos.y - transform.position.z) / WorldManager.gridSize);

        gridMap[posX, posY].contains = newContent;

        if (newContent == Point.PointContent.Path)
        {
            gridMap[posX, posY].buildable = false;
        }
        if (newContent == Point.PointContent.Building)
        {
            gridMap[posX, posY].buildable = false;
        }
        if (newContent == Point.PointContent.Resource)
        {
            gridMap[posX, posY].buildable = false;
        }
        if (newContent == Point.PointContent.Empty)
        {
            gridMap[posX, posY].buildable = true;
        }
    }