コード例 #1
0
ファイル: DoomGraphic.cs プロジェクト: Petethegoat/DoomUnity
    public static Texture2D BuildTexture(string name, WadFile wad)
    {
        TextureTable textures = new TextureTable(wad.GetLump("TEXTURE1"));

        return(BuildTexture(name, wad, textures));
    }
コード例 #2
0
ファイル: DoomGraphic.cs プロジェクト: Petethegoat/DoomUnity
    public static Texture2D BuildPatch(int index, WadFile wad)
    {
        PatchTable pnames = new PatchTable(wad.GetLump("PNAMES"));

        return(BuildPatch(pnames.patches[index], wad));
    }
コード例 #3
0
 void SetupMaterial()
 {
     spriteMaterial = new Material(Shader.Find("Doom/Unlit Texture"));
     spriteMaterial.SetTexture("_Palette", new Palette(wad.GetLump("PLAYPAL")).GetLookupTexture());
     spriteMaterial.SetTexture("_Colormap", new Colormap(wad.GetLump("COLORMAP")).GetLookupTexture());
 }
コード例 #4
0
    // Use this for initialization
    void Start()
    {
        messages         = new List <HUDMessage>();
        consoleMessages  = new List <GameObject>();
        consoleObject    = new GameObject("console");
        main             = this;
        gameObject.layer = LayerMask.NameToLayer("HUD");
        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 = LayerMask.NameToLayer("HUD");

        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                   = LayerMask.NameToLayer("HUD");

        mapNameObj                         = new GameObject("Map name");
        mapNameSR                          = mapNameObj.AddComponent <SpriteRenderer>();
        mapNameSR.material                 = messageMaterial;
        mapNameObj.transform.parent        = transform;
        mapNameObj.layer                   = LayerMask.NameToLayer("HUD");
        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);
        if (mapname != null)
        {
            UpdateMapName();
        }
        HideMapName();

        // GameObject statusBar = new GameObject("StatusBar");
        // statusBar.layer = 9;
        // statusBar.transform.parent = transform;
        // StatusBar sbar = statusBar.AddComponent<StatusBar>();
        // sbar.Build(wad);
    }
コード例 #5
0
ファイル: LevelEntity.cs プロジェクト: raynler/DoomUnity
    public void LoadMultigen(MultigenObject mobj, WadFile wad)
    {
        this.mobj = mobj;
        this.wad  = wad;

        if (sprites == null)
        {
            sprites = new Dictionary <string, Sprite[]>();
        }

        if (itemPickupSound == null)
        {
            itemPickupSound = new DoomSound(wad.GetLump("DSITEMUP"), "DSITEMUP").ToAudioClip();
        }

        if (weaponPickupSound == null)
        {
            weaponPickupSound = new DoomSound(wad.GetLump("DSWPNUP"), "DSWPNUP").ToAudioClip();
        }

        MF_MISSILE   = mobj.data["flags"].Contains("MF_MISSILE");
        MF_SPECIAL   = mobj.data["flags"].Contains("MF_SPECIAL");
        MF_SOLID     = mobj.data["flags"].Contains("MF_SOLID");
        MF_COUNTKILL = mobj.data["flags"].Contains("MF_COUNTKILL");

        boxCollider           = GetComponent <BoxCollider>();
        boxCollider.isTrigger = !MF_SOLID;



        radius = ReadFracValue(mobj.data["radius"]);
        height = ReadFracValue(mobj.data["height"]);
        speed  = ReadFracValue(mobj.data["speed"]);
        move   = new Vector3();

        float vHeight = height;

        if (!MF_SPECIAL)
        {
            vHeight -= stepHeight * 0.5f;
        }
        else
        {
            vHeight *= 2f;
        }
        boxCollider.size   = new Vector3(radius, vHeight, radius);
        boxCollider.center = new Vector3(0f, (vHeight * 0.5f), 0f);

        reactionTime = float.Parse(mobj.data["reactiontime"]) * tick;

        spriteMaterial = new Material(Shader.Find("Doom/Texture"));
        Texture2D paletteLookup  = new Palette(wad.GetLump("PLAYPAL")).GetLookupTexture();
        Texture2D colormapLookup = new Colormap(wad.GetLump("COLORMAP")).GetLookupTexture();

        spriteMaterial.SetTexture("_Palette", paletteLookup);
        spriteMaterial.SetTexture("_Colormap", colormapLookup);

        spriteRenderer          = spriteTransform.gameObject.AddComponent <SpriteRenderer>();
        spriteRenderer.material = spriteMaterial;

        switch (mobj.data["seesound"])
        {
        case "sfx_posit1":
        case "sfx_posit2":
        case "sfx_posit3":
            seeSounds = new AudioClip[] {
                new DoomSound(wad.GetLump("DSPOSIT1"), "DSPOSIT1").ToAudioClip(),
                new DoomSound(wad.GetLump("DSPOSIT2"), "DSPOSIT2").ToAudioClip(),
                new DoomSound(wad.GetLump("DSPOSIT3"), "DSPOSIT3").ToAudioClip()
            };
            break;

        case "sfx_bgsit1":
        case "sfx_bgsit2":
            seeSounds = new AudioClip[] {
                new DoomSound(wad.GetLump("DSBGSIT1"), "DSBGSIT1").ToAudioClip(),
                new DoomSound(wad.GetLump("DSBGSIT2"), "DSBGSIT2").ToAudioClip()
            };
            break;

        default:
            string seeSoundName = ParseSoundName(mobj.data["seesound"]);

            if (wad.Contains(seeSoundName))
            {
                seeSound = new DoomSound(wad.GetLump(seeSoundName), seeSoundName).ToAudioClip();
            }
            break;
        }



        string activeSoundName = ParseSoundName(mobj.data["activesound"]);

        if (wad.Contains(activeSoundName))
        {
            activeSound = new DoomSound(wad.GetLump(activeSoundName), activeSoundName).ToAudioClip();
        }

        string attackSoundName = ParseSoundName(mobj.data["attacksound"]);

        if (wad.Contains(attackSoundName))
        {
            attackSound = new DoomSound(wad.GetLump(attackSoundName), attackSoundName).ToAudioClip();
        }

        string deathSoundName = ParseSoundName(mobj.data["deathsound"]);

        if (wad.Contains(deathSoundName))
        {
            deathSound = new DoomSound(wad.GetLump(deathSoundName), deathSoundName).ToAudioClip();
        }

        audioSource = GetComponent <AudioSource>();

        // UpdateVerticalPosition();
        SetState(mobj.data["spawnstate"]);
    }