Пример #1
0
    private void RenderTilesWithGUI()
    {
        Vector3 tileOffset = new Vector3(tileWidth, 0f, tileWidth);
        // buffers
        Rect box; string statusString; Vector3 labelPositionW; Vector2 labelPositionS;

        // draw status box at center of each tile on screen
        for (int x = 0; x < state.dimensions.x; x++)
        {
            for (int y = 0; y < state.dimensions.y; y++)
            {
                labelPositionW   = origin.position + Vector3.Scale(tileOffset, new Vector3(x, 0, y)) + heightOffset * Vector3.up + new Vector3(tileWidth / 2f, 0f, tileWidth / 2f);
                labelPositionS   = mainCamera.WorldToScreenPoint(labelPositionW);
                labelPositionS.y = Screen.height - labelPositionS.y; // flip the y coordinate to convert from camera screen space to GUI space.
                box = new Rect(labelPositionS.x, labelPositionS.y, boxdimensions.x, boxdimensions.y);
                Rect box2 = box;
                box2.x      -= 3; box2.y -= 3;
                box2.height  = 6; box2.width = 6;
                statusString = x + "," + y;  //+state.tiles[x, y].sunlightLevel +"\nwtr:"+state.tiles[x, y].waterLevel;
                GUI.Box(box, statusString);
                GUI.DrawTexture(box2, Texture2D.whiteTexture, ScaleMode.StretchToFill, false, 1f, Color.yellow, 0f, 0f);
                Rect sunBox = box;
                sunBox.y     -= 20;
                sunBox.width  = 20;
                sunBox.height = 20;
                if (GUI.Button(sunBox, "S"))
                {
                    state.AddWeather(x, y, ForecastType.Sun, 1);
                }
                sunBox.x += 20;
                if (GUI.Button(sunBox, "W"))
                {
                    state.AddWeather(x, y, ForecastType.Water, 1);
                }
            }
        }
    }
Пример #2
0
    // public ForecastQueue forecastQueue;

    public void ApplyCurrentTetramino(ForecastShape _shape)
    {
        // Debug.Log("Applying!!!");
        int          x    = shapePositioning.currentOriginTile.x;
        int          y    = shapePositioning.currentOriginTile.y;
        ForecastType type = WeatherQueue.currentWeather;

        for (int i = 0; i < _shape.tiles.Count; i++)
        {
            Vector2Int offs = ShapePositioning.RotateOffset(_shape.tiles[i].offset, shapePositioning.rotation);
            // note that this is not using the type on the forecastTile (deprecated), but is instead using the current weather in the weatherqueue.
            if (_shape.tiles[i].type != ForecastType.None)
            {
                state.AddWeather(x + offs.x, y + offs.y, type, 1);
            }
            // if(_shape.tiles[i].type == ForecastType.Sun) state.AddSunlight(x+offs.x, y+offs.y, 1);
        }
    }