Example #1
0
        public static void LoadResources()
        {
            //InitializeFont();

            foreach (string res in Assembly.GetExecutingAssembly().GetManifestResourceNames())
            {
                //Modding.Logger.Log(res);
                if (res.EndsWith(".wav"))
                {
                    Stream audioStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(res);
                    if (audioStream != null)
                    {
                        byte[] buffer = new byte[audioStream.Length];
                        audioStream.Read(buffer, 0, buffer.Length);
                        audioStream.Dispose();
                        string restemp = res.Replace("HollowPoint.assets.", "");
                        sfxDictionary.Add(restemp, WavUtility.ToAudioClip(buffer));
                    }
                    Modding.Logger.Log("[HOLLOW POINT] Created sound effect " + res);
                }
                else if (res.EndsWith(".png"))
                {
                    using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(res))
                    {
                        if (s == null)
                        {
                            continue;
                        }
                        byte[] buffer = new byte[s.Length];
                        s.Read(buffer, 0, buffer.Length);
                        s.Dispose();
                        string    restemp = res.Replace("HollowPoint.assets.", "");
                        Texture2D currSprite;
                        currSprite = new Texture2D(1, 1);
                        currSprite.LoadImage(buffer);
                        currSprite.Apply();
                        spriteDictionary.Add(restemp, currSprite);
                        Modding.Logger.Log("[HOLLOW POINT] Created sprite from embedded image: " + restemp);
                    }
                }
                else if (res.EndsWith(".xml"))
                {
                    using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(res))
                    {
                        using (StreamReader sr = new StreamReader(stream))
                        {
                            textChanges.LoadXml(sr.ReadToEnd());
                        }
                    }
                }
            }
        }
Example #2
0
        public static void LoadBulletSounds()
        {
            int bulletCount     = 0;
            int airsupportCount = 0;
            int gunCount        = 0;

            foreach (string res in Assembly.GetExecutingAssembly().GetManifestResourceNames())
            {
                if (res.EndsWith(".wav"))
                {
                    Modding.Logger.Log("[HOLLOW POINT] Found sound effect! Saving it.");
                    Stream audioStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(res);
                    if (audioStream != null && res.Contains("support"))
                    {
                        byte[] buffer = new byte[audioStream.Length];
                        audioStream.Read(buffer, 0, buffer.Length);
                        audioStream.Dispose();
                        airStrikeSoundFX[airsupportCount++] = WavUtility.ToAudioClip(buffer);
                    }
                    else if (audioStream != null)
                    {
                        byte[] buffer = new byte[audioStream.Length];
                        audioStream.Read(buffer, 0, buffer.Length);
                        audioStream.Dispose();
                        bulletSoundFX[bulletCount++] = WavUtility.ToAudioClip(buffer);
                    }
                }
                else if (res.EndsWith(".png"))
                {
                    using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(res))
                    {
                        if (s == null)
                        {
                            continue;
                        }
                        byte[] buffer = new byte[s.Length];
                        s.Read(buffer, 0, buffer.Length);
                        s.Dispose();
                        //Create texture from bytes
                        gunSprites[gunCount] = new Texture2D(1, 1);
                        gunSprites[gunCount].LoadImage(buffer);
                        gunSprites[gunCount].Apply();
                        Modding.Logger.Log("[HOLLOW POINT] Created sprite from embedded image: " + res);
                        gunCount++;
                    }
                }
            }
        }
Example #3
0
 public static void LoadBulletSounds()
 {
     foreach (string res in Assembly.GetExecutingAssembly().GetManifestResourceNames())
     {
         if (res.EndsWith(".wav"))
         {
             Modding.Logger.Log("Found sound effect! Saving it.");
             Stream audioStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(res);
             if (audioStream != null)
             {
                 byte[] buffer = new byte[audioStream.Length];
                 audioStream.Read(buffer, 0, buffer.Length);
                 audioStream.Dispose();
                 bulletSoundFX = WavUtility.ToAudioClip(buffer);
             }
         }
     }
 }