示例#1
0
    public TileElement(GameObject go, String type, String text)
    {
        this.type          = type;
        this.text          = text;
        this.tileElementGo = new GameObjectSerializable(go, go.name);
        if (type == "AdditionalElement")
        {
            this.mesh = new MeshSerializable(go.GetComponentInChildren <MeshFilter>().mesh);
            if (go.GetComponent <MeshRenderer>().material.color != null)
            {
                this.materialColorR = go.GetComponentInChildren <MeshRenderer>().material.color.r;
                this.materialColorG = go.GetComponentInChildren <MeshRenderer>().material.color.g;
                this.materialColorB = go.GetComponentInChildren <MeshRenderer>().material.color.b;
            }
            this.materialName = "TransparentGreyMaterial";
        }

        else
        {
            this.mesh = new MeshSerializable(go.GetComponent <MeshFilter>().mesh);
            if (go.GetComponent <MeshRenderer>().material.color != null)
            {
                this.materialColorR = go.GetComponent <MeshRenderer>().material.color.r;
                this.materialColorG = go.GetComponent <MeshRenderer>().material.color.g;
                this.materialColorB = go.GetComponent <MeshRenderer>().material.color.b;
            }
            this.materialName = "BuildingsDefaultMat";
        }
    }
示例#2
0
    public MapTile(GameObject tileGO)
    {
        this.tileGO       = new GameObjectSerializable(tileGO, tileGO.name);
        this.mesh         = new MeshSerializable(tileGO.GetComponent <MeshFilter>().mesh);
        this.materialName = "TerrainMaterial";
        Texture2D texture = (Texture2D)tileGO.GetComponent <MeshRenderer>().material.mainTexture;

        this.textureData = texture.EncodeToPNG();
        //File.WriteAllBytes("Serialized/" + "tile" + index + ".png", texture.EncodeToPNG());
    }
示例#3
0
    public TileElement(GameObject go, String type, Color color, String text)
    {
        this.type          = type;
        this.text          = text;
        this.tileElementGo = new GameObjectSerializable(go, go.name);
        this.mesh          = new MeshSerializable(go.GetComponent <MeshFilter>().mesh);
        if (type.Equals("Road"))
        {
            this.materialName = "RoadsDefaultMaterial";
        }
        else if (type.Equals("MapBuilding"))
        {
            this.materialName = "BuildingsDefaultMat";
        }
        else
        {
            this.materialName = "TransparentGreyMaterial";
        }

        this.materialColorR = color.r;
        this.materialColorG = color.g;
        this.materialColorB = color.b;
    }