Example #1
0
    public static Item Factory(Types type)
    {
        Item ret = null;

        if (type == Types.None)
        {
            return(null);
        }

        ret = FromType(type);

        string[] archetype = ItemArchetype(type);
        ret.BaseInit(archetype[0], archetype[1], archetype[2]);
        ret.type = type;

        if (ret.name != "")
        {
            Node retNode = ret as Node;
            retNode.Name = ret.name;
        }

        ret.id = Session.NextItemId();


        Material mat = GFX.GetColorSpatialMaterial(ret.color);

        ret.SetMaterial(mat);


        return(ret);
    }
Example #2
0
    public void InitTerrain(string terrainFile)
    {
        PackedScene ps       = (PackedScene)GD.Load(terrainFile);
        Node        instance = ps.Instance();

        AddChild(instance);
        terrain = (Spatial)instance;

        // Everything below this line is a dirty hack to work around a bug.
        GridMap gm = Util.GetChildByName(terrain, "Map") as GridMap;

        MeshLibrary    theme  = gm.Theme;
        List <Vector3> colors = new List <Vector3> {
            new Vector3(0.537f, 0.101f, 0.101f),
            new Vector3(0.141f, 0.313f, 0.125f),
            new Vector3(0.137f, 0.215f, 0.521f),
            new Vector3(0.690f, 0.321f, 0.129f),
            new Vector3(0.490f, 0.168f, 0.490f),
            new Vector3(0.717f, 0.694f, 0.203f),
            new Vector3(1, 1, 1),
            new Vector3(0, 0, 0)
        };

        for (int i = 0; i < 8; i++)
        {
            ArrayMesh       arrMesh  = theme.GetItemMesh(i) as ArrayMesh;
            SpatialMaterial material = GFX.GetColorSpatialMaterial(colors[i]) as SpatialMaterial;

            material.EmissionEnabled = true;
            material.Emission        = GFX.Color(colors[i]);
            material.EmissionEnergy  = 0.5f;

            material.TransmissionEnabled = true;
            material.Transmission        = GFX.Color(colors[i]);

            material.RefractionEnabled = false;

            material.Metallic = 1f;

            material.Roughness = 0.5f;

            arrMesh.SurfaceSetMaterial(0, material);
        }
    }