示例#1
0
    public void UpdateTileset(Tile[,] newTiles)
    {
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                var tile = newTiles[i, j];
                if (tile.containsCloud)
                {
                    var color = tile.containedCloud.GetColour();
                    cloudTiles[i, j].Color = new Color(0, 0, 1, 0.3f);
                }

                if (tile.containsPatch)
                {
                    var color = tile.containedPath.GetColour();
                    floorTiles[i, j].Color = new Color(color[0], color[1], color[2], 1f);
                }

                if (tile.containsPlayer)
                {
                    if (playerSprites[i, j] == null)
                    {
                        var textureRect = new TextureRect();
                        textureRect.SetStretchMode(TextureRect.StretchModeEnum.Scale);
                        textureRect.SetExpand(true);
                        textureRect.Texture      = playerTexture;
                        textureRect.MarginLeft   = i * scaleFactor;
                        textureRect.MarginRight  = i * scaleFactor + 0.9f * scaleFactor;
                        textureRect.MarginTop    = j * scaleFactor;
                        textureRect.MarginBottom = j * scaleFactor + 0.7f * scaleFactor;
                        AddChild(textureRect);
                    }
                }
            }
        }
    }