コード例 #1
0
ファイル: TitleSetup.cs プロジェクト: raynler/DoomUnity
    public void SetupMaterial(WadFile wad)
    {
        titleIsPNG = wad.DetectType("TITLEPIC") == DataType.PNG;

        if (titleIsPNG)
        {
            mr.material = new Material(Shader.Find("Doom/Unlit Truecolor Texture"));
        }
        else
        {
            mr.material = new Material(Shader.Find("Doom/Unlit Texture"));
        }

        if (titleIsPNG)
        {
            Texture2D image = new Texture2D(2, 2);
            ImageConversion.LoadImage(image, wad.GetLump("TITLEPIC"));
            mr.material.SetTexture("_MainTex", image);
            float ratio = (float)Screen.width / (float)Screen.height;
            transform.localScale    = new Vector3(ratio * 2f, 2f);
            transform.localPosition = new Vector3(0f, 0f, 1f);
        }
        else
        {
            mr.material.SetTexture("_Palette", new Palette(wad.GetLump("PLAYPAL")).GetLookupTexture());
            mr.material.SetTexture("_Colormap", new Colormap(wad.GetLump("COLORMAP")).GetLookupTexture());
            mr.material.SetTexture("_MainTex", DoomGraphic.BuildPatch("TITLEPIC", wad, true));
            float ratio = (float)Screen.width / (float)Screen.height;
            transform.localScale    = new Vector3(ratio * 2f, -2f);
            transform.localPosition = new Vector3(0f, 0f, 1f);
        }
    }
コード例 #2
0
ファイル: GameSetup.cs プロジェクト: raynler/DoomUnity
    void PlayMidi(string name)
    {
        if (midiPlayer != null)
        {
            MidiFile midi    = null;
            DataType musType = wad.DetectType(name);
            if (musType == DataType.MIDI)
            {
                midi = new MidiFile(wad.GetLump(name));
            }
            else if (musType == DataType.MUS)
            {
                midi = new MidiFile(new Mus2Mid(wad.GetLump(name)).MidiData());
            }
            else
            {
                Debug.LogError("Not a midi or mus which are the only thigns supported rn surprisingly enough");
            }

            if (midi != null)
            {
                midiPlayer.Stop();
                midiPlayer.LoadMidi(midi);
                midiPlayer.Play();
            }
        }
    }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        messages         = new List <HUDMessage>();
        consoleMessages  = new List <GameObject>();
        consoleObject    = new GameObject("console");
        main             = this;
        gameObject.layer = 9;
        SetupCamera();
        SetupMaterials();
        //audioSource = gameObject.AddComponent<AudioSource>();
        //audioSource.spatialBlend = 0.0f;
        // try {
        // soundMessage = new DoomSound(wad.GetLump("DSRADIO"), "HUD/Message").ToAudioClip();
        // } catch {}
        SpriteRenderer sr = consoleObject.AddComponent <SpriteRenderer>();


        if (wad.DetectType("TITLEPIC") == DataType.PNG)
        {
            Texture2D image = new Texture2D(2, 2);
            ImageConversion.LoadImage(image, wad.GetLump("TITLEPIC"));
            sr.sprite = Sprite.Create(image, new Rect(0f, 0f, image.width, image.height), new Vector2(0.5f, -0.45f));
            sr.flipY  = false;
            consoleObject.transform.localScale = new Vector3(320f / image.width, 200f / image.height);
            //sr.color = new Color(0.1f, 0.1f, 0.1f, 1.0f);
        }
        else
        {
            sr.material = messageMaterial;
            sr.sprite   = Sprite.Create(new DoomGraphic(wad.GetLump("TITLEPIC")).ToRenderMap(), new Rect(0f, 0f, 320, -200), new Vector2(0.5f, -0.45f));
            sr.flipY    = true;
            sr.material.SetFloat("_Brightness", 0.3f);
        }

        consoleObject.layer = 9;

        GameObject consoleInputObject = new GameObject("Console Input");

        consoleInputSR                             = consoleInputObject.AddComponent <SpriteRenderer>();
        consoleInputSR.material                    = messageMaterial;
        consoleInputObject.transform.parent        = consoleObject.transform;
        consoleInputObject.transform.localPosition = new Vector3(-((float)Screen.width / (float)Screen.height), 1f, -0.1f);
        consoleInputObject.transform.localScale    = new Vector3(1f, -1f, 1f);
        consoleInputObject.layer                   = 9;

        mapNameObj                         = new GameObject("Map name");
        mapNameSR                          = mapNameObj.AddComponent <SpriteRenderer>();
        mapNameSR.material                 = messageMaterial;
        mapNameObj.transform.parent        = transform;
        mapNameObj.layer                   = 9;
        mapNameObj.transform.localPosition = new Vector3(-((float)Screen.width / (float)Screen.height), -((float)Screen.width / (float)Screen.height) + 0.5f, 0.1f);
        mapNameObj.transform.localScale    = new Vector3(1f, -1f, 1f);
        HideMapName();

        // GameObject statusBar = new GameObject("StatusBar");
        // statusBar.layer = 9;
        // statusBar.transform.parent = transform;
        // StatusBar sbar = statusBar.AddComponent<StatusBar>();
        // sbar.Build(wad);
    }
コード例 #4
0
ファイル: DoomMapBuilder.cs プロジェクト: MSylvia/DoomUnity
 DoomTexture GetInfo(string name, bool tryUpper = true)
 {
     if (textureTable.Contains(name))
     {
         return(textureTable.Get(name.ToUpper()));
     }
     else
     {
         if (wad.Contains(name))
         {
             DataType type = wad.DetectType(name);
             if (type == DataType.DoomFlat)
             {
                 return(new DoomTexture(name, 64, 64, null));
             }
             else if (type == DataType.PNG)
             {
                 Texture2D image = new Texture2D(2, 2, TextureFormat.ARGB32, false);
                 ImageConversion.LoadImage(image, wad.GetLump(name));
                 image.filterMode = FilterMode.Point;
                 return(new DoomTexture(name, image.width, image.height, null));
             }
             else
             {
                 throw new Exception("Unknown texture type: " + name);
             }
         }
         else
         {
             if (tryUpper)
             {
                 return(GetInfo(name.ToUpper(), false));
             }
             throw new Exception("Cannot find texture: " + name);
         }
     }
 }