Esempio n. 1
0
    public void ApplyCurrentTetramino(int x, int y, float rotation = 0f)
    {
        ForecastShape _shape = forecastQueue.forecastShapes[0];

        for (int i = 0; i < _shape.tiles.Count; i++)
        {
            Vector2Int offs = RotateOffset(_shape.tiles[i].offset, rotation);
            if (_shape.tiles[i].type == ForecastType.Water)
            {
                state.AddWater(x + offs.x, y + offs.y, 1);
            }
            if (_shape.tiles[i].type == ForecastType.Sun)
            {
                state.AddSunlight(x + offs.x, y + offs.y, 1);
            }
        }
        forecastQueue.forecastShapes.RemoveAt(0);
    }
Esempio n. 2
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 = "sun:" + 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.AddSunlight(x, y, 1);
                }
                sunBox.x += 20;
                if (GUI.Button(sunBox, "W"))
                {
                    state.AddWater(x, y, 1);
                }
            }
        }
    }