Esempio n. 1
0
        private bool BuildMaterial(Wm3Texture texture, float ambient)
        {
            if (TemplateMaterials.IsInitialized)
            {
                float alpha  = 1.0f;
                float albedo = texture.Albedo;

                m_ambient = CalculateAmbient(texture, ambient, m_textureType);
                if (m_textureType == LevelTextureType.SPRITE)
                {
                    if (texture.Flags.IsSet(Wm3Flags.Ghost) || texture.Flags.IsSet(Wm3Flags.Diaphanous))
                    {
                        alpha = 0.7f;
                    }
                    m_material = new Material(TemplateMaterials.GetSprite());
                }
                else
                {
                    if (texture.Flags.IsSet(Wm3Flags.Ghost) || texture.Flags.IsSet(Wm3Flags.Diaphanous))
                    {
                        m_material = new Material(TemplateMaterials.GetOverlay());
                        alpha      = 0.7f;
                    }

                    else if (texture.Flags.IsSet(Wm3Flags.Sky))
                    {
                        m_material = new Material(TemplateMaterials.GetSky());
                        albedo     = 0;
                    }

                    else if (m_textureType == LevelTextureType.OVERLAY)
                    {
                        m_material = new Material(TemplateMaterials.GetOverlay());
                    }

                    else
                    {
                        m_material = new Material(TemplateMaterials.GetSolid());
                    }
                }

                m_material.renderQueue = -1; //force shader render queue in case template material was setup the wrong way
                m_material.mainTexture = m_sprite.texture;
                m_material.name        = texture.Name + " A" + m_ambient.ToString("0.00");
                if (m_textureType == LevelTextureType.SPRITE)
                {
                    m_material.name += "S";
                }
                Color col = new Color(m_ambient, m_ambient, m_ambient, alpha);
                m_material.color = col;
                m_material.SetFloat("_Diffuse", albedo * 0.01f);
                return(true);
            }
            else
            {
                Debug.LogError("LevelTexture.BuildMaterial: BaseMaterial not configured");
                m_material = null;
                return(false);
            }
        }
Esempio n. 2
0
        private void Run()
        {
            Save();

            bool proceed = true;

            if (s_levelData == null)
            {
                proceed = false;
                EditorUtility.DisplayDialog("Error", "No level data file configured.", "Ok");
            }

            if (proceed && s_defaultMaterials[0] == null)
            {
                proceed = false;
                EditorUtility.DisplayDialog("Error", "No solid material configured.", "Ok");
            }

            if (proceed)
            {
                Debug.ClearDeveloperConsole();
                TemplateMaterials.Reset();
                Wm3Loader loader = new Wm3Loader();
                loader.LoadWM3(s_levelData);
                Wm3Data      data    = loader.Data;
                LevelBuilder builder = new LevelBuilder();
                builder.Construct(data);
            }
        }