コード例 #1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            distTravelled += Body.LinearVelocity.Length();
            if (AsType.UniformScale < 0.69f)
            {
                AsType.UniformScale = JabMath.MoveTowards(AsType.UniformScale, 0.7f, 0.25f);
            }
            else
            {
                AsType.UniformScale = 0.7f;
            }
            if (distTravelled > 32)
            {
                Body.CollisionGroup = 0;
            }

            if (destructionTimer > 0)
            {
                destructionTimer -= gttf(gameTime);
                if (destructionTimer < 0)
                {
                    RaiseFlag(Jabber.Flags.DELETE);


                    Explosion exp = new Explosion(10, 300, 1.0f, 0.7f, scene.World, Position);
                    Body.IgnoreRayCast = true;
                    exp.Initialize(Jabber.BaseGame.Get.Content);
                    exp.Position = Position;
                    scene.AddNode(exp);
                    RaiseFlag(Jabber.Flags.DELETE);
                    Body.IgnoreRayCast = false;

                    AudioQueue.PlayOnce("Sounds/Explode_Chicken");
                }
                else
                {
                    float val = destructionTimer;
                    Colour = new Color(1.0f, val, val, 1.0f);

                    // AsType.UniformScale = (float)Math.Sin(destructionTimer * 5.0f * JabMath.PI) + 1;

                    AsType.UniformScale = JabMath.LinearInterpolate(0.8f, 0.85f, (float)Math.Sin(destructionTimer * 5.0f * JabMath.PI) + 1);
                    DoDimensions        = false;
                    int k = 0;
                }
            }
            if (Body.LinearVelocity.Length() < 0.001f)
            {
                noMoveTimer += gttf(gameTime);
                if (noMoveTimer > 1.0f && destructionTimer < 0)
                {
                    destructionTimer = 1.0f;
                }
            }
            else
            {
                noMoveTimer = 0.0f;
            }
        }
コード例 #2
0
        public override void ProcessEvent(Event ev)
        {
            base.ProcessEvent(ev);

            if (ev is BreakableDestroyed && !(ev is BreakableHit))
            {
                SingleScore s          = new SingleScore(this);
                int         scoreToAdd = 0;
                switch ((ev as BreakableDestroyed).Broken)
                {
                case BreakableBody.BodyMaterial.WOOD:
                    scoreToAdd += 100;
                    break;

                case BreakableBody.BodyMaterial.GLASS:
                    scoreToAdd += 50;
                    break;

                case BreakableBody.BodyMaterial.CONCRETE:
                    scoreToAdd += 200;
                    break;
                }
                score += scoreToAdd;
                s.Text = scoreToAdd.ToString();
                s.Initialize(BaseGame.Get.Content);
                s.Width    = s.Height = 10;
                s.Position = ev.Position;
                scene.AddNode(s);
            }
        }
コード例 #3
0
ファイル: BreakableBody.cs プロジェクト: meds/ChicksnVixens
        public virtual void CreateSplinters()
        {
            float   x      = (float)Math.Sin((float)Rot);
            float   y      = (float)Math.Cos((float)Rot);
            Vector2 rotDir = new Vector2(x, y);

            rotDir.Normalize();

            /*
             * for (float f = Height * ScaleY / 2.0f; f > -Height * ScaleY / 2.0f; f -= 40)//Height * ScaleY / 5.0f)
             * {
             *  for (int i = 0; i < 4; i++)
             *  {
             *      if (BaseGame.Random.Next(1, 5) == 2)
             *      {
             *          Vector2 fuzz = new Vector2(RandomFloatInRange(-Width / 2.0f, Width / 2.0f), RandomFloatInRange(-Width / 2.0f, Width / 2.0f));
             *          Vector2 firstPos = Position + f * rotDir + fuzz;
             *
             *          Splinter s = new Splinter(material);
             *          s.Initialize(BaseGame.Get.Content);
             *          s.Position = firstPos;
             *          scene.AddNode(s);
             *      }
             *  }
             * }*/
            int cur = 0;

            for (float f = Height * ScaleY / 2.0f; f > -Height * ScaleY / 2.0f; f -= 80)
            {
                for (float j = Width * ScaleY / 2.0f; j > -Width * ScaleY / 2.0f; j -= 80)
                {
                    Vector2 fuzz     = new Vector2(RandomFloatInRange(-Width / 2.0f, Width / 2.0f), RandomFloatInRange(-Width / 2.0f, Width / 2.0f));
                    Vector2 firstPos = Position + f * rotDir + fuzz;

                    preMadeSplinters[cur].Position = firstPos;
                    scene.AddNode(preMadeSplinters[cur]);
                    ++cur;
                    if (cur >= preMadeSplinters.Count)
                    {
                        break;
                    }
                }
                if (cur >= preMadeSplinters.Count)
                {
                    break;
                }
            }
            preMadeSplinters.Clear();
        }
コード例 #4
0
        public override void OnPress(Vector2 pos)
        {
            base.OnPress(pos);

            if (active)
            {
                active = false;

                Egg e = new Egg(Position, scene);
                e.Initialize(Jabber.BaseGame.Get.Content);
                scene.AddNode(e);

                Body.AddLinearImpulse(new Vector2(0, 13));
                AudioQueue.PlayOnce("Sounds/EggLay");
                Deactivate();
            }
        }
コード例 #5
0
        public override void Initialize(Microsoft.Xna.Framework.Content.ContentManager content)
        {
            base.Initialize(content);
            FarWorld world = new FarWorld();

            scene = new GameScene(world, Content);

            locationText.Initialize(Content);
            locationText.Text = "NONE";

            ArrowScroll a = new ArrowScroll();

            a.Initialize(Content);
            a.Right = false;
            scene.AddNode(a);


            a = new ArrowScroll();
            a.Initialize(Content);
            scene.AddNode(a);


            map = new MapUI();
            map.Initialize(Content);

            scene.AddNode(map);


            Components.Add(scene);


            for (int i = 0; i < ChicksnVixensGame.Get.locationOrder.Count; i++)
            {
                worldLocations.Add(ChicksnVixensGame.Get.locationOrder[i]);
            }

            BlankNess faderInner = new BlankNess();

            faderInner.Initialize(Content);

            faderInner.fullBlankity = 1.0f;
            faderInner.fadeInTimer  = 1.0f;
            faderInner.fadeSpeed    = 2.0f;
            faderInner.RaiseFlag(Flags.FADE_OUT);
            Components.Add(faderInner);


            locked = new MenuObj("ui/ui");
            locked.Initialize(content);
            locked.CreateFramesFromXML("ui/ui_frames");
            locked.CurrentFrame = "lock";
            locked.ResetDimensions();
            locked.UniformScale = ScaleFactor * 2.0f;
            locked.Position     = Vector2.Zero;
            locked.Colour       = new Color(0, 0, 0, 0);
            Components.Add(locked);

            EventManager.Get.SendImmediateEvent(new NewLocationSelected());

            string location = worldLocations[curLocation];

            Cam.TargetPos   = map.GetLocation(location);
            Cam.targetScale = 2;
            Cam.LevelSelect = false;
        }
コード例 #6
0
        //todo: add left/right extreme values for create[location] functions!
        public static void CreateParis(GameScene scene, int leftmostpos, int rightmostpos)
        {
            if (content != null)
            {
                content.Dispose();
                content = null;
            }
            if (LastMusicPlayed != "paris")
            {
                LastMusicPlayed = "paris";
                AudioManager.PlayMusic("paris");
            }
            content = new ContentManager(BaseGame.Get.Services);
            content.RootDirectory = "Content";

            int j = 0;

            for (int i = leftmostpos - 5000; i < rightmostpos + 5000;)
            {
                Sprite s = new Sprite("textures/backgrounds/paris/paris");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/paris/paris_frames");
                s.CurrentFrame = "underground";
                s.ResetDimensions();
                s.UniformScale = 4.0f;
                s.Handle       = BaseSprite.SpriteHandle.CENTER;

                s.Layer = BaseSprite.SpriteLayer.LAYER8;

                s.PosX = i;// +s.Width * s.ScaleX / 1.01f;
                s.PosY = -s.Height * s.ScaleY / 2.0f;

                i += (int)(s.Width * s.ScaleX / 1.01f);

                scene.AddNode(s);
            }

            j = 0;


            for (int i = leftmostpos - 5000; i < rightmostpos + 5000;)
            {
                Sprite s = new Sprite("textures/backgrounds/paris/paris");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/paris/paris_frames");
                s.CurrentFrame = "distantbg";
                s.ResetDimensions();
                s.UniformScale = 4.0f;
                s.Handle       = BaseSprite.SpriteHandle.CENTER;
                s.CamPosScale  = new Vector2(0.05f, 1.0f);
                s.Layer        = BaseSprite.SpriteLayer.BACKGROUND_LAYER3;

                s.PosX = i;// j++ * s.Width * s.ScaleX / 1.01f;
                s.PosY = s.Height * s.ScaleY / 2.0f;


                i += (int)(s.Width * s.ScaleX / 1.01f);

                scene.AddNode(s);
            }
            j = 0;


            {
                MenuObj s = new MenuObj("textures/backgrounds/paris/paris");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/paris/paris_frames");
                s.CurrentFrame = "rawbg";
                s.ResetDimensions();
                s.UniformScale = 1.5f;
                s.Layer        = BaseSprite.SpriteLayer.BACKGROUND_LAYER6;

                s.Width    = BaseGame.Get.BackBufferWidth;
                s.Height   = BaseGame.Get.BackBufferHeight;
                s.Position = Vector2.Zero;

                scene.AddNode(s);
            }

            /*
             *
             * for (int i = leftmostpos - 5000; i < rightmostpos + 5000; )
             * {
             *  Sprite s = new Sprite("textures/backgrounds/paris/paris");
             *  s.Initialize(content);
             *  s.CreateFramesFromXML("textures/backgrounds/paris/paris_frames");
             *  s.CurrentFrame = "cloud1";
             *  s.ResetDimensions();
             *  s.UniformScale = 2.0f;
             *  s.Handle = BaseSprite.SpriteHandle.CENTER;
             *  s.CamPosScale = new Vector2(0.05f, 1.0f);
             *  s.Layer = BaseSprite.SpriteLayer.BACKGROUND_LAYER4;
             *
             *  s.PosX = (j++ * 1.5f) * s.Width * s.ScaleX / 1.01f;
             *  s.PosY = s.Height * s.ScaleY / 2.0f + 150;
             *
             *  i += (int)(s.Width * s.ScaleX);
             *
             *  scene.AddNode(s);
             * }*/


            /* {
             *   Sprite s = new Sprite("textures/backgrounds/paris/paris");
             *   s.Initialize(content);
             *   s.CreateFramesFromXML("textures/backgrounds/paris/paris_frames");
             *   s.CurrentFrame = "rawbg";
             *   s.ResetDimensions();
             *   s.UniformScale = 2.0f;
             *   s.Layer = BaseSprite.SpriteLayer.BACKGROUND_LAYER5;
             *
             *   s.Width = 1000000;
             *   s.PosY = s.Height * s.ScaleY / 2.0f;
             *
             *   scene.AddNode(s);
             * }*/
            /*
             * {
             *  Sprite s = new Jabber.Util.UI.MenuObj("textures/backgrounds/paris/paris");
             *  s.Initialize(content);
             *  s.CreateFramesFromXML("textures/backgrounds/paris/paris_frames");
             *  s.CurrentFrame = "skycore";
             *  s.ResetDimensions();
             *  s.UniformScale = 1.0f;
             *  s.Layer = BaseSprite.SpriteLayer.BACKGROUND_LAYER6;
             *
             *  s.Width = BaseGame.Get.BackBufferWidth;
             *  s.Height = BaseGame.Get.BackBufferHeight;
             *  s.Position = Vector2.Zero;
             *
             *  scene.AddNode(s);
             * }*/
            {
                Sprite s = new Sprite("textures/backgrounds/paris/paris");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/paris/paris_frames");
                s.CurrentFrame = "eiffel";
                s.ResetDimensions();
                s.UniformScale = 4.0f;
                s.Layer        = BaseSprite.SpriteLayer.BACKGROUND_LAYER2;

                s.PosY        = s.Height * s.ScaleY / 2.0f;
                s.CamPosScale = new Vector2(0.8f, 1.0f);

                scene.AddNode(s);
            }

            /*
             * for (int i = -100; i < 100; i++)
             * {
             *  Sprite s = new Sprite("parisbg");
             *  s.Initialize(content);
             *  s.CreateFramesFromXML("textures/backgrounds/paris/paris_frames");
             *  s.CurrentFrame = "closebuildings";
             *  s.ResetDimensions();
             *  s.UniformScale = 2.0f;
             *  s.Layer = BaseSprite.SpriteLayer.BACKGROUND_LAYER2;
             *
             *  s.PosX = i * s.Width * s.ScaleX * 0.999f;
             *  s.PosY = s.Height * s.ScaleY / 2.0f;
             *
             *  s.CamPosScale = new Vector2(0.4f, 1.0f);
             *
             *  scene.AddNode(s);
             * }*/
            /*
             * {
             *  Sprite s = new Sprite("parisbg");
             *  s.Initialize(content);
             *  s.CreateFramesFromXML("Content/paris_frames.xml");
             *  s.CurrentFrame = "SkyGradient";
             *  s.ResetDimensions();
             *  s.UniformScale = 2.0f;
             *  s.Layer = BaseSprite.SpriteLayer.BACKGROUND_LAYER3;
             *
             *  s.Width = 1000000;
             *  s.PosY = s.Height * s.ScaleY / 2.0f;
             *
             *  scene.AddNode(s);
             * }
             * {
             *  Sprite s = new Sprite("parisbg");
             *  s.Initialize(content);
             *  s.CreateFramesFromXML("Content/paris_frames.xml");
             *  s.CurrentFrame = "Sky";
             *  s.ResetDimensions();
             *  s.UniformScale = 2.0f;
             *  s.Layer = BaseSprite.SpriteLayer.BACKGROUND_LAYER5;
             *
             *  s.Width = 1000000;
             *  s.Height = 1000000;
             *  s.PosY = s.Height * s.ScaleY / 2.0f + 100;
             *
             *  scene.AddNode(s);
             * }*/
        }
コード例 #7
0
        public void Load(ContentManager content, GameScene game)
        {
            //This process can be sped up by editing the TiledMax files to parse directly into our data structures.
            FileInfo fi = new FileInfo(mapFile);
            TiledMax.Map map = TiledMax.Map.Open (File.OpenRead(Path.Combine(content.RootDirectory,mapFile)), content.RootDirectory);
            Layers = map.Layers;

            int tileID = 1;

            //Read in textures and set up convenient structures for drawing tiles.
            foreach (TiledMax.TileSet ts in map.TileSets) {
                string filename = Path.Combine(Path.GetDirectoryName(mapFile), ts.Images[0].Source);

                Texture2D tileSheet = content.Load<Texture2D> (filename);
                TileWidth = ts.TileWidth;
                TileHeight = ts.TileHeight; //Multiple tileset sizes? How to handle? Take the max?

                //TODO: Account for margins and spacing here!
                int colCount = tileSheet.Width / TileWidth;
                int rowCount = tileSheet.Height / TileHeight;
                int tileCount = rowCount * colCount;
                int currentRow = 0;
                int currentCol = 0;

                //Note: tileID is held outside of loop to handle multiple tilesheets; each starts off where the last left.
                //The code below should be rewritten so that tile.ID does not require addition, and instead the loop
                //boundaries take on the additional math.
                for (int i = 0; i < tileCount; i++) {
                    GameTile tile = new GameTile ();
                    tile.display.texture = tileSheet;
                    tile.display.rect = new Rectangle (currentCol * TileWidth, currentRow * TileHeight, TileWidth, TileHeight); //Rectangle with this tile's texture on the sheet.
                    tile.ID = tileID + i;
                    int relative_id = tile.ID - ts.FirstGid;
                    if (ts.TileProperties.ContainsKey (relative_id)) {//Need to actually check what properties these are! This is a placeholder.
                        TiledMax.Properties props = ts.TileProperties [relative_id];
                        if (props.ContainsKey ("solid"))
                            tile.solid = true;
                        if (props.ContainsKey ("spawn"))
                            tile.SpawnType = (String)props ["spawn"];
                    }
                    Tiles.Add (tileID + i, tile);
                    currentCol++;
                    if (currentCol >= colCount) {
                        currentCol = 0;
                        currentRow++;
                    }
                }
                tileID += tileCount;

            }
            //Spawn things that should be spawned.
            foreach (TiledMax.Layer layer in map.Layers) {

                MapWidth = layer.Width * TileWidth;
                MapHeight = layer.Height * TileHeight;
                bool layerSolid = layer.Properties.ContainsKey ("solid");
                String layerSpawnType = layer.Properties.ContainsKey ("spawn") ? (String)layer.Properties ["spawn"] : "";
                int width = layer.Width;
                int height = layer.Height;
                for (int y = 0; y < layer.Height; y++) {
                    for (int x = 0; x < layer.Width; x++) {
                        Rectangle destination = new Rectangle (x * map.TileWidth, y * map.TileHeight, map.TileWidth, map.TileHeight);
                        tileID = layer.Data [y, x] - 1;
                        if (tileID > 0) {
                            GameTile tile = Tiles [tileID];
                            if (layerSolid || tile.solid) {
                                if (layerSpawnType == "" && tile.SpawnType == "")
                                    game.SpawnEntity ("Terrain", destination, layer.Properties);
                            }
                            game.SpawnEntity (layerSpawnType == "" ? tile.SpawnType : layerSpawnType, destination, layer.Properties);
                        }
                    }
                }
            }
            //Look for special objects, like player spawn points.
            foreach (TiledMax.ObjectGroup og in map.ObjectGroups) {
                foreach (TiledMax.MapObject obj in og) {

                    if (obj.Gid != -1) {
                        GameTile tile = Tiles [obj.Gid];
                        obj.Y -= tile.display.rect.Height;
                        if (obj.Type == "") {
                            String spawnType = tile.SpawnType;
                            if (spawnType != "") {
                                obj.Type = "spawn:" + spawnType;
                                if (!obj.Properties.ContainsKey("identifier"))
                                    obj.Properties.Add ("identifier", obj.Name);
                            }
                        }

                        if (obj.Width == 0 && obj.Height == 0) {
                            obj.Width = tile.display.rect.Width;
                            obj.Height = tile.display.rect.Height;
                        }

                    }
                    Rectangle destination = new Rectangle (obj.X, obj.Y, obj.Width, obj.Height);
                    Properties properties = obj.Properties;

                    if (obj.Type.StartsWith ("spawn:")) {
                        //6 = length of "spawn:"
                        game.SpawnEntity (obj.Type.Substring (6), destination, obj.Properties);
                        continue;
                    }

                    switch (obj.Type) {
                    case "spawn":
                        game.SpawnEntity (obj.Name, destination, obj.Properties);
                        break;
                    case "warp":
                        String locationTarget = (obj.Properties.ContainsKey ("location")) ? (String)obj.Properties ["location"] : "default";
                        game.AddLoadTrigger (obj.Name, locationTarget, destination); // , obj.Properties);
                        break;
                    case "location":
                        Locations.Add (obj.Name, destination);
                        break;
                    case "node":
                        game.AddNode (obj.Name, (string)obj.Properties ["next"], destination);
                        break;
                    }
                }
            }
        }
コード例 #8
0
        public static void CreateAustralia(GameScene scene, int leftmostpos, int rightmostpos)
        {
            if (content != null)
            {
                content.Dispose();
                content = null;
            }
            if (LastMusicPlayed != "uluru")
            {
                LastMusicPlayed = "uluru";
                AudioManager.PlayMusic("uluru");
            }
            content = new ContentManager(BaseGame.Get.Services);
            content.RootDirectory = "Content";

            int j = 0;

            for (int i = leftmostpos - 5000; i < rightmostpos + 5000;)
            {
                Sprite s = new Sprite("textures/backgrounds/australia/australia");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/australia/australia_frames");
                s.CurrentFrame = "underground";
                s.ResetDimensions();
                s.UniformScale = 4.0f;
                s.Handle       = BaseSprite.SpriteHandle.CENTER;

                s.Layer = BaseSprite.SpriteLayer.LAYER8;

                s.PosX = i;// +s.Width * s.ScaleX / 1.01f;
                s.PosY = -s.Height * s.ScaleY / 2.0f;

                i += (int)(s.Width * s.ScaleX / 1.01f);

                scene.AddNode(s);
            }
            j = 0;

            //for (int i = leftmostpos - 5000; i < rightmostpos + 5000; )
            {
                Sprite s = new Sprite("textures/backgrounds/australia/australia");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/australia/australia_frames");
                s.CurrentFrame = "distantmountain";
                s.ResetDimensions();
                s.UniformScale = 4.0f;
                s.Handle       = BaseSprite.SpriteHandle.CENTER;
                s.CamPosScale  = new Vector2(0.05f, 1.0f);
                s.Layer        = BaseSprite.SpriteLayer.BACKGROUND_LAYER4;

                s.PosX = 0;// j++ * s.Width * s.ScaleX / 1.01f;
                s.PosY = s.Height * s.ScaleY / 2.0f;


                //i += (int)(s.Width * s.ScaleX / 1.01f);

                scene.AddNode(s);
            }
            j = 0;

            float height = 0;

            for (int i = leftmostpos - 5000; i < rightmostpos + 5000;)
            {
                Sprite s = new Sprite("textures/backgrounds/australia/australia");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/australia/australia_frames");
                s.CurrentFrame = "skycloud";
                s.ResetDimensions();
                s.UniformScale = 4.0f;
                s.Handle       = BaseSprite.SpriteHandle.CENTER;
                s.CamPosScale  = new Vector2(0.05f, 1.0f);
                s.Layer        = BaseSprite.SpriteLayer.BACKGROUND_LAYER5;

                s.PosX = i;// (j++ * 1.0f) * s.Width * s.ScaleX / 1.01f;
                s.PosY = s.Height * s.ScaleY / 2.0f;

                i     += (int)(s.Width * s.ScaleX / 1.01f);
                height = s.Height * s.ScaleY;
                scene.AddNode(s);
            }
            {
                Sprite s = new Sprite("textures/backgrounds/australia/australia");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/australia/australia_frames");
                s.CurrentFrame = "topsky";
                s.ResetDimensions();
                s.UniformScale = 2.0f;
                s.Handle       = BaseSprite.SpriteHandle.CENTER;
                s.CamPosScale  = new Vector2(0.05f, 1.0f);
                s.Layer        = BaseSprite.SpriteLayer.BACKGROUND_LAYER5;

                s.PosX = 0;                                   // (j++ * 1.0f) * s.Width * s.ScaleX / 1.01f;
                s.PosY = height + s.Height * s.ScaleY / 2.1f; // *2.0f;

                s.Width = 1000000;

                scene.AddNode(s);
            }

            {
                MenuObj s = new MenuObj("textures/backgrounds/australia/australia");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/australia/australia_frames");
                s.CurrentFrame = "rawbg";
                s.ResetDimensions();
                s.UniformScale = 1.5f;
                s.Layer        = BaseSprite.SpriteLayer.BACKGROUND_LAYER6;

                s.Width    = BaseGame.Get.BackBufferWidth;
                s.Height   = BaseGame.Get.BackBufferHeight;
                s.Position = Vector2.Zero;

                scene.AddNode(s);
            }

            /*
             * {
             *  Sprite s = new Sprite("textures/backgrounds/australia/australia");
             *  s.Initialize(content);
             *  s.CreateFramesFromXML("textures/backgrounds/australia/australia_frames");
             *  s.CurrentFrame = "rawbg";
             *  s.ResetDimensions();
             *  s.UniformScale = 2.0f;
             *  s.Layer = BaseSprite.SpriteLayer.BACKGROUND_LAYER6;
             *
             *  s.Width = 1000000;
             *  s.Height = 1000000;
             *  s.PosY = s.Height * s.ScaleY / 2.0f + 100;
             *
             *  scene.AddNode(s);
             * }*/



            for (int i = leftmostpos - 5000; i < rightmostpos + 5000;)
            {
                Sprite s = new Sprite("textures/backgrounds/australia/australia");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/australia/australia_frames");
                s.CurrentFrame = "bgstripclose";
                s.ResetDimensions();
                s.UniformScale = 2.6f;
                s.Handle       = BaseSprite.SpriteHandle.CENTER;

                s.Layer = BaseSprite.SpriteLayer.BACKGROUND_LAYER2;

                s.PosX        = i;// +s.Width * s.ScaleX / 1.01f;
                s.PosY        = s.Height * s.ScaleY / 2.0f;
                s.CamPosScale = new Vector2(0.3f, 1.0f);
                i            += (int)(s.Width * s.ScaleX / 1.01f);

                scene.AddNode(s);
            }
            j = 0;


            for (int i = leftmostpos - 5000; i < rightmostpos + 5000;)
            {
                Sprite s = new Sprite("textures/backgrounds/australia/australia");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/australia/australia_frames");
                s.CurrentFrame = "bgstripfar";
                s.ResetDimensions();
                s.UniformScale = 2.0f;
                s.Handle       = BaseSprite.SpriteHandle.CENTER;

                s.Layer       = BaseSprite.SpriteLayer.BACKGROUND_LAYER3;
                s.CamPosScale = new Vector2(0.1f, 1.0f);

                s.PosX = i;// +s.Width * s.ScaleX / 1.01f;
                s.PosY = s.Height * s.ScaleY / 2.0f;

                i += (int)(s.Width * s.ScaleX / 1.01f);

                scene.AddNode(s);
            }
            j = 0;
        }
コード例 #9
0
        //todo: add left/right extreme values for create[location] functions!
        public static void CreateVesuvius(GameScene scene, int leftmostpos, int rightmostpos)
        {
            if (content != null)
            {
                content.Dispose();
                content = null;
            }
            if (LastMusicPlayed != "vesuvius")
            {
                LastMusicPlayed = "vesuvius";
                AudioManager.PlayMusic("vesuvius");
            }

            content = new ContentManager(BaseGame.Get.Services);
            content.RootDirectory = "Content";

            int j = 0;

            for (int i = leftmostpos - 5000; i < rightmostpos + 5000;)
            {
                Sprite s = new Sprite("textures/backgrounds/vesuvius/vesuvius");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/vesuvius/vesuvius_frames");
                s.CurrentFrame = "underground";
                s.ResetDimensions();
                s.UniformScale = 4.0f;
                s.Handle       = BaseSprite.SpriteHandle.CENTER;

                s.Layer = BaseSprite.SpriteLayer.LAYER8;

                s.PosX = i;
                s.PosY = -s.Height * s.ScaleY / 2.0f;

                i += (int)(s.Width * s.ScaleX / 1.01f);

                scene.AddNode(s);
            }
            j = 0;

            for (int i = leftmostpos - 5000; i < rightmostpos + 5000;)
            {
                Sprite s = new Sprite("textures/backgrounds/vesuvius/vesuvius");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/vesuvius/vesuvius_frames");
                s.CurrentFrame = "closehill";
                s.ResetDimensions();
                s.UniformScale = 4.0f;
                s.Handle       = BaseSprite.SpriteHandle.CENTER;
                s.CamPosScale  = new Vector2(0.4f, 1.0f);
                s.Layer        = BaseSprite.SpriteLayer.BACKGROUND_LAYER2;

                s.PosX = i;
                s.PosY = s.Height * s.ScaleY / 2.0f;


                i += (int)(s.Width * s.ScaleX / 1.01f);

                scene.AddNode(s);
            }
            j = 0;



            for (int i = leftmostpos - 5000; i < rightmostpos + 5000;)
            {
                Sprite s = new Sprite("textures/backgrounds/vesuvius/vesuvius");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/vesuvius/vesuvius_frames");
                s.CurrentFrame = "cloud";
                s.ResetDimensions();
                s.UniformScale = 2.0f;
                s.Handle       = BaseSprite.SpriteHandle.CENTER;
                s.CamPosScale  = new Vector2(0.1f, 1.0f);
                s.Layer        = BaseSprite.SpriteLayer.BACKGROUND_LAYER2;

                s.PosX = i;
                s.PosY = s.Height * s.ScaleY / 2.0f + 400;


                i += (int)((s.Width * s.ScaleX / 1.01f * 1.8f) * JabJect.RandomFloatInRange(1.5f, 2.0f));

                scene.AddNode(s);
            }
            j = 0;



            for (int i = leftmostpos - 5000; i < rightmostpos + 5000;)
            {
                Sprite s = new Sprite("textures/backgrounds/vesuvius/vesuvius");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/vesuvius/vesuvius_frames");
                s.CurrentFrame = "hill";
                s.ResetDimensions();
                s.UniformScale = 4.0f;
                s.Handle       = BaseSprite.SpriteHandle.CENTER;
                s.CamPosScale  = new Vector2(0.3f, 1.0f);
                s.Layer        = BaseSprite.SpriteLayer.BACKGROUND_LAYER3;

                s.PosX = i;
                s.PosY = s.Height * s.ScaleY / 2.0f;


                i += (int)(s.Width * s.ScaleX / 1.01f);

                scene.AddNode(s);
            }
            j = 0;



            for (int i = leftmostpos - 5000; i < rightmostpos + 5000;)
            {
                Sprite s = new Sprite("textures/backgrounds/vesuvius/vesuvius");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/vesuvius/vesuvius_frames");
                s.CurrentFrame = "midmountain";
                s.ResetDimensions();
                s.UniformScale = 4.0f;
                s.Handle       = BaseSprite.SpriteHandle.CENTER;
                s.CamPosScale  = new Vector2(0.3f, 1.0f);
                s.Layer        = BaseSprite.SpriteLayer.BACKGROUND_LAYER4;

                s.PosX = i;
                s.PosY = s.Height * s.ScaleY / 2.0f;


                i += (int)(s.Width * s.ScaleX / 1.01f);

                scene.AddNode(s);
            }
            j = 0;


            {
                Sprite s = new Jabber.Util.UI.MenuObj("textures/backgrounds/vesuvius/vesuvius");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/vesuvius/vesuvius_frames");
                s.CurrentFrame = "sky";
                s.ResetDimensions();
                s.UniformScale = 2.0f;
                s.Layer        = BaseSprite.SpriteLayer.BACKGROUND_LAYER6;

                s.Width    = BaseGame.Get.BackBufferWidth;
                s.Height   = BaseGame.Get.BackBufferHeight;
                s.Position = Vector2.Zero;

                scene.AddNode(s);
            }
            {
                Sprite s = new Sprite("textures/backgrounds/vesuvius/vesuvius");
                s.Initialize(content);
                s.CreateFramesFromXML("textures/backgrounds/vesuvius/vesuvius_frames");
                s.CurrentFrame = "vesuvius";
                s.ResetDimensions();
                s.UniformScale = 7.0f;
                s.Layer        = BaseSprite.SpriteLayer.BACKGROUND_LAYER5;

                s.PosY        = s.Height * s.ScaleY / 2.0f;
                s.CamPosScale = new Vector2(0.2f, 1.0f);

                scene.AddNode(s);
            }
        }