Ejemplo n.º 1
0
    private void FixedUpdate()
    {
        var collisionMap = mapGenerator.GetCollisonMap();

        var(genX, genY) = mapGenerator.generatorCoords;
        var(endX, endY) = mapGenerator.endpointCoords;
        var playerPosition = playerObject.transform.position;
        int tx             = (int)playerPosition.x;
        int ty             = (int)playerPosition.y;

        for (int y = ty - radius; y < ty + radius; y++)
        {
            if (y < 0 || y >= mapGenerator.size)
            {
                continue;
            }

            for (int x = tx - radius; x < tx + radius; x++)
            {
                if (x < 0 || x >= mapGenerator.size)
                {
                    continue;
                }

                if (Vector2.Distance(new Vector2(x, y), playerPosition) <= radius)
                {
                    if (x == genX && y == genY)
                    {
                        texture.SetPixel(x, y, GENERATOR_COLOR);
                    }
                    else if (x == endX && y == endY)
                    {
                        texture.SetPixel(x, y, ENDPOINT_COLOR);
                    }
                    else if (cableGrid.IsTilePowered(x, y))
                    {
                        texture.SetPixel(x, y, CABLE_COLOR);
                    }
                    else if (collisionMap[x, y])
                    {
                        texture.SetPixel(x, y, WALL_COLOR);
                    }
                    else
                    {
                        texture.SetPixel(x, y, GROUND_COLOR);
                    }
                }
            }
        }

        texture.Apply();
        minimapUi.texture = texture;
    }
Ejemplo n.º 2
0
 public void RegeneratePowerInfo()
 {
     hasPower = cableGrid.IsTilePowered(x, y); // TODO: MIGHT BE A PERF PROBLEM
 }
Ejemplo n.º 3
0
 public void RegeneratePowerInfo()
 {
     hasPower = cableGrid.IsTilePowered(tileX, tileY);
 }