示例#1
0
 public BackgroundParticleSettings(AssetManager assets, int actNumber)
 {
     TextDictionary td = new TextDictionary(assets.GetText("particles"));
     string act = "act" + actNumber;
     numParticles = td.LookupInt32(act, "numParticles");
     if (numParticles > 0)
     {
         rotationRateRange = td.LookupVector2(act, "rotationRateRange");
         scaleRange = td.LookupVector2(act, "scaleRange");
         colorLow = td.LookupColor(act, "colorLow");
         colorHigh = td.LookupColor(act, "colorHigh");
         texture = assets.GetTexture(td.LookupString(act, "texture"));
         distance = td.LookupSingle(act, "dist");
     }
 }
示例#2
0
        public static ParallaxBackgroundSet Build(AssetManager assets, Camera camera, Vector2 seamstressStart, string assetName)
        {
            TextDictionary assetDictionary = new TextDictionary(assets.GetText("parallax"));
            int layers = assetDictionary.LookupInt32(assetName, "layers");
            ParallaxBackground[] backgrounds = new ParallaxBackground[layers];
            BackgroundParticleSet particles = new BackgroundParticleSet(assets, camera.Dimensions, Convert.ToInt32(assetName.Substring(3)));
            int particleLayer = -1;
            for (int i = 0; i < layers; i++)
            {
                Texture2D tex;
                if (assetDictionary.CheckPropertyExists(assetName, "name" + i))
                    tex = assets.GetTexture(assetDictionary.LookupString(assetName, "name" + i));
                else
                    tex = assets.GetTexture(assetName + "_layer" + i);
                float dist, scale;
                Vector2 offset, velocity, repeat;
                Anchor anchor;
                try { dist = assetDictionary.LookupSingle(assetName, "dist" + i); }
                catch { dist = 1; }
                try { offset = assetDictionary.LookupVector2(assetName, "offset" + i); }
                catch { offset = Vector2.Zero; }
                try { velocity = assetDictionary.LookupVector2(assetName, "velocity" + i); }
                catch { velocity = Vector2.Zero; }
                try { scale = assetDictionary.LookupSingle(assetName, "scale" + i); }
                catch { scale = 1; }
                try { repeat = assetDictionary.LookupVector2(assetName, "repeat" + i); }
                catch { repeat = new Vector2(1, 0); }
                if (!assetDictionary.CheckPropertyExists(assetName, "anchor" + i) ||
                    !Enum.TryParse<Anchor>(assetDictionary.LookupString(assetName, "anchor" + i), out anchor))
                    anchor = Anchor.BottomLeft;
                backgrounds[i] = new ParallaxBackground(assets, tex, offset, velocity, dist, scale, anchor, repeat);
                if (dist > particles.Distance)
                    particleLayer = i;
            }
            ParallaxBackgroundSet pbs = new ParallaxBackgroundSet();
            pbs.backgrounds = backgrounds;
            pbs.camera = new Camera(camera.Dimensions, camera.Position, camera.Rotation, camera.Scale);
            pbs.color = assetDictionary.LookupColor(assetName, "color");
            pbs.particleLayer = particleLayer;
            pbs.particles = particles;
            pbs.seamstressStart = seamstressStart;

            return pbs;
        }