Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        main = this;
        Settings.Init();
        ParseArguments();

        playerInventory = new PlayerInventory();

        Settings.Set("nomonsters", args.nomonsters ? "true" : "false");

        midiEnabled = args.midi;

        engineWad = new WadFile("nasty.wad");

        if (midiEnabled)
        {
            if (File.Exists(args.soundfont))
            {
                midiPlayer = gameObject.AddComponent <MidiPlayer>();
                midiPlayer.LoadBank(new PatchBank(File.OpenRead(args.soundfont), "sf2"));
            }
            else
            {
                if (engineWad.Contains("GMBANK"))
                {
                    midiPlayer = gameObject.AddComponent <MidiPlayer>();
                    midiPlayer.LoadBank(new PatchBank(engineWad.GetLumpAsMemoryStream("GMBANK"), "bank"));
                }
                else
                {
                    Debug.LogError("No soundfont found, disabling midi");
                }
            }
        }

        IwadData iwadData = JsonUtility.FromJson <IwadData>(engineWad.GetLumpAsText("IWADS"));

        cheatCodes = new List <string>()
        {
            "idclev",
            "idclip",
            "kill",
            "test"
        };

        SetupTitleCamera();

        string iwadDirectory = Settings.Get("iwads_path", "./");

        if (args.iwad == "")           // Run IWAD selection tool

        {
            foundIwads = new List <IwadInfo>();
            iwadPaths  = new List <string>();

            var fileInfo = new DirectoryInfo(iwadDirectory).GetFiles();
            foreach (var file in fileInfo)
            {
                string fileMd5 = WadFile.GetMD5(file.FullName);
                if (file.Extension.ToUpper() == ".WAD")
                {
                    for (int i = 0; i < iwadData.iwads.Length; i++)
                    {
                        if (fileMd5 == iwadData.iwads[i].md5)
                        {
                            foundIwads.Add(iwadData.iwads[i]);
                            iwadPaths.Add(file.FullName);
                        }
                    }
                }
            }

            if (foundIwads.Count == 0)
            {
                Debug.LogError("Cannot find any iwads!");
            }
            if (foundIwads.Count > 1)
            {
                iwadSelector = true;
            }

            if (foundIwads.Count == 1)
            {
                SetupWad(foundIwads[0], iwadPaths[0]);
            }
        }
        else
        {
            for (int i = 0; i < iwadData.iwads.Length; i++)
            {
                if (WadFile.GetMD5(args.iwad) == iwadData.iwads[i].md5)
                {
                    SetupWad(iwadData.iwads[i], args.iwad);
                    break;
                }
            }
        }
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        ParseArguments();

        if (args.soundfont == "")
        {
            midiEnabled = false;
        }

        if (midiEnabled)
        {
            if (File.Exists(args.soundfont))
            {
                midiPlayer = gameObject.AddComponent <MidiPlayer>();
                midiPlayer.LoadBank(new PatchBank(File.OpenRead(args.soundfont)));
            }
            else
            {
                Debug.LogError("No soundfont found, disabling midi");
            }
        }

        cheatCodes = new List <string>()
        {
            "idclev",
            "kill",
            "test"
        };

        engineWad = new WadFile("nasty.wad");
        SetupTitleCamera();
        mapinfo = MapInfoLump.Load(engineWad.GetLumpAsText("NMAPINFO"));


        IwadData iwadData = JsonUtility.FromJson <IwadData>(engineWad.GetLumpAsText("IWADS"));


        if (args.iwad == "")           // Run IWAD selection tool

        {
            foundIwads = new List <IwadInfo>();
            for (int i = 0; i < iwadData.iwads.Length; i++)
            {
                for (int j = 0; j < iwadData.iwads[i].filenames.Length; j++)
                {
                    if (System.IO.File.Exists(iwadData.iwads[i].filenames[j]))
                    {
                        foundIwads.Add(iwadData.iwads[i]);
                    }
                }
            }

            if (foundIwads.Count == 0)
            {
                Debug.LogError("Cannot find any iwads!");
            }
            if (foundIwads.Count > 1)
            {
                iwadSelector = true;
            }

            if (foundIwads.Count == 1)
            {
                SetupWad(foundIwads[0]);
            }
        }
        else
        {
            for (int i = 0; i < iwadData.iwads.Length; i++)
            {
                if (args.iwad == iwadData.iwads[i].filenames[0])
                {
                    SetupWad(iwadData.iwads[i]);
                    break;
                }
            }
        }
    }