示例#1
0
        protected override void LoadContent()
        {
            loadScreen = Content.Load<Texture2D>("Images\\gui\\loadscreen");
            loadScreenDraw(loadScreen, new Vector2(-90, -20));
            loadPauseScreen();

            yeah = Content.Load<SoundEffect>("yeah2");
            ohno = Content.Load<SoundEffect>("ohno");
            backgroundMusic = Content.Load<SoundEffect>("ToyRoom");
            myBoy = Content.Load<SoundEffect>("goodboy");
            myBoyInst = myBoy.CreateInstance();

            mamaTxt = Content.Load<Texture2D>("Images\\mama");
            mannTexture = Content.Load<Texture2D>("Images\\theBoy");
            mannTexture2 = Content.Load<Texture2D>("Images\\theBoyShowing");
            mannTexture3 = Content.Load<Texture2D>("Images\\boytup");
            boyDissapointedTxt = Content.Load<Texture2D>("Images\\boytdown");
            roomTexture = Content.Load<Texture2D>("Images\\theroom");
            crayonTxt = Content.Load<Texture2D>("Images\\bigcrayonside");
            indicatorTxt = Content.Load<Texture2D>("Images\\indicator");
            guiBubbleTxt = Content.Load<Texture2D>("Images\\talkingBubbleLeft");
            roomdooropen = Content.Load<Texture2D>("Images\\roomdooropen");

            textures[0] = Content.Load<Texture2D>("Images\\sportscar");
            textures[1] = Content.Load<Texture2D>("Images\\theplane");
            textures[2] = Content.Load<Texture2D>("Images\\train");
            textures[3] = Content.Load<Texture2D>("Images\\tractor");
            textures[4] = Content.Load<Texture2D>("Images\\digger");
            textures[5] = Content.Load<Texture2D>("Images\\dino");
            textures[6] = Content.Load<Texture2D>("Images\\baby");
            textures[7] = Content.Load<Texture2D>("Images\\soldier");
            textures[8] = Content.Load<Texture2D>("Images\\actionFigure");
            textures[9] = Content.Load<Texture2D>("Images\\teddy");
            textures[10] = Content.Load<Texture2D>("Images\\block");
            textures[11] = Content.Load<Texture2D>("Images\\ball");
            textures[12] = Content.Load<Texture2D>("Images\\balloon");
            textures[13] = Content.Load<Texture2D>("Images\\colored\\pad");
            textures[14] = Content.Load<Texture2D>("Images\\horse");
            textures[15] = Content.Load<Texture2D>("Images\\racecar");
            textures[16] = Content.Load<Texture2D>("Images\\dumper");

            spriteFont = Content.Load<SpriteFont>("sf20");

            basketTxt = Content.Load<Texture2D>("Images\\wheelBasket1");
            basketOpeningTxt = Content.Load<Texture2D>("Images\\wheelBasket2");

            yeahinst = yeah.CreateInstance();
            ohnoinst = ohno.CreateInstance();
            backgroundMusicInst = backgroundMusic.CreateInstance();

            talkingBubble = new GameGUI(this.Game, spriteFont, new Vector2(185, 130), "Friend! Hurry help!! \n You must be  \n very quick now!!", Color.Black, 0f, new Vector2(0, 0), 1f, 0f);
            talkingBubble.GuiBackgroundRect = guiBubbleRct;
            talkingBubble.GuiBackgroundTxt = guiBubbleTxt;
            talkingBubble.GuiVisible = true;

            boy = new BasicComponent(this.Game, mannTexture, mannRect, 0.0f);
            basketLeft = new BasicComponent(this.Game, basketTxt, basketLeftRect, 0.0f);
            basketOpening = new BasicComponent(this.Game, basketOpeningTxt, basketOpeningRct, Color.White, 0.0f);

            roomBackground = new BasicComponent(this.Game, roomTexture, roomRect, Color.White, 0.0f);
            toy = new MoveAbleComponent(this.Game, textures[0], rectangles[0], Color.Orange, 0.0f);
            mama = new BasicComponent(this.Game, mamaTxt, mamaRct, 0.0f);
            mama.ItemDraw = false;
            indicator = new BasicComponent(this.Game, indicatorTxt, indicatorRct, Color.White, 0.0f);
            indicator.DrawOrder = 12122;
            indicator.ItemDraw = false;
            Components.Add(indicator);
            roomBackground.DrawOrder = -100;
            basketLeft.DrawOrder = 213;
            basketOpening.DrawOrder = 198;
            toy.DrawOrder = 199;
            boy.DrawOrder = 100;
            talkingBubble.DrawOrder = 1112;
            mama.DrawOrder = 20000;
            Components.Add(mama);
            Components.Add(roomBackground);
            toy.CompRectX = 10000;
            addToys(450, 460, 0, 700, 330, 390, 0, 700, true, true, 150, 150, false);
            Components.Add(gameGUI);
            Components.Add(boy);
            Components.Add(basketOpening);
            Components.Add(toy);
            Components.Add(basketLeft);
            crayons = new BasicComponent[4];
            for (int i = 0; i <crayons.Length; i++)
            {
                BasicComponent crayonTemp = new BasicComponent(this.Game, crayonTxt, crayonRect, colorList[i], 0.0f);
                crayonTemp.ItemDraw = true;
                crayonRect.X += 200;
                crayonTemp.DrawOrder = 212;
                crayons[i] = crayonTemp;
                Components.Add(crayonTemp);
            }
            Components.Add(talkingBubble);

            for (int i = 0; i < 20; i++)
            {
                newRand = rnd.Next(0, textures.Length - 1);
                toysBackground.addGraphicItem(newRand, textures[newRand], rectangles[newRand], true, true, 330, 370, 0, 700);
                toysCollected.Add(newRand);
            }

            base.LoadContent();
        }
示例#2
0
        protected override void LoadContent()
        {
            loadScreen = Content.Load<Texture2D>("Images\\gui\\loadscreen");
            loadScreenDraw(loadScreen, new Vector2(-90, -20));
            loadPauseScreen();

            yeah = Content.Load<SoundEffect>("yeah2");
            ohno = Content.Load<SoundEffect>("ohno");
            backgroundMusic = Content.Load<SoundEffect>("ToyRoom");
            indicatorTxt = Content.Load<Texture2D>("Images\\indicator");
            mannTexture = Content.Load<Texture2D>("Images\\theBoy");
            mannTexture2 = Content.Load<Texture2D>("Images\\theBoyShowing");
            mannTexture3 = Content.Load<Texture2D>("Images\\boytup");
            boyDissapointedTxt = Content.Load<Texture2D>("Images\\boytdown");
            roomTexture = Content.Load<Texture2D>("Images\\theroom");
            guiBubbleTxt = Content.Load<Texture2D>("Images\\talkingBubbleLeft");
            basketOpeningTxt = Content.Load<Texture2D>("Images\\wheelBasket2");

            textures[0] = Content.Load<Texture2D>("Images\\sportscar");
            textures[1] = Content.Load<Texture2D>("Images\\theplane");
            textures[2] = Content.Load<Texture2D>("Images\\train");
            textures[3] = Content.Load<Texture2D>("Images\\tractor");
            textures[4] = Content.Load<Texture2D>("Images\\digger");
            textures[5] = Content.Load<Texture2D>("Images\\dino");
            textures[6] = Content.Load<Texture2D>("Images\\baby");
            textures[7] = Content.Load<Texture2D>("Images\\soldier");
            textures[8] = Content.Load<Texture2D>("Images\\actionFigure");
            textures[9] = Content.Load<Texture2D>("Images\\teddy");
            textures[10] = Content.Load<Texture2D>("Images\\block");
            textures[11] = Content.Load<Texture2D>("Images\\ball");
            textures[12] = Content.Load<Texture2D>("Images\\balloon");
            textures[13] = Content.Load<Texture2D>("Images\\colored\\pad");
            textures[14] = Content.Load<Texture2D>("Images\\horse");
            textures[15] = Content.Load<Texture2D>("Images\\racecar");
            textures[16] = Content.Load<Texture2D>("Images\\dumper");

            basketTxt = Content.Load<Texture2D>("Images\\wheelBasket1");

            spriteFont = Content.Load<SpriteFont>("sf20");

            spriteFont = Content.Load<SpriteFont>("sf20");
            spriteFont.LineSpacing = 25;
            spriteFont.Spacing = 1;
            talkingBubble = new GameGUI(this.Game, spriteFont, new Vector2(150, 80), "Please help ! \n Be quick! \n Or more toys \n will come", Color.Black, 0f, new Vector2(0, 0), 1f, 0f);
            talkingBubble.GuiBackgroundRect = guiBubbleRct;
            talkingBubble.GuiBackgroundTxt = guiBubbleTxt;
            talkingBubble.GuiVisible = true;

            talkingBubble.DrawOrder = 10000;

            boy = new BasicComponent(this.Game, mannTexture, mannRect, 0f);
            basketLeft = new BasicComponent(this.Game, basketTxt, basketLeftRect, 0.0f);
            basketRight = new BasicComponent(this.Game, basketTxt, basketRightRect, 0.0f);
            basketOpeningLeft = new BasicComponent(this.Game, basketOpeningTxt, basketOpeningLRct, 0.0f);
            basketOpeningRight = new BasicComponent(this.Game, basketOpeningTxt, basketOpeningRRct, 0.0f);

            roomBackground = new BasicComponent(this.Game, roomTexture, roomRect, Color.White, 0.0f);
            toy = new MoveAbleComponent(this.Game, textures[0], defaultRect, Color.Orange, 0.0f);

            roomBackground.DrawOrder = -100;
            basketLeft.DrawOrder = 200;
            basketRight.DrawOrder = 201;
            basketOpeningLeft.DrawOrder = 198;
            basketOpeningRight.DrawOrder = 197;
            toy.DrawOrder = 199;
            boy.DrawOrder = 100;

            yeahinst = yeah.CreateInstance();
            ohnoinst = ohno.CreateInstance();
            backgroundMusicInst = backgroundMusic.CreateInstance();
            indicator = new BasicComponent(this.Game, indicatorTxt, indicatorRct, Color.White, 0.0f);
            indicator.DrawOrder = 12122;
            indicator.ItemDraw = false;
            Components.Add(indicator);
            Components.Add(roomBackground);

            //for (int i = 0; i < textures.Length; i++)
            //{
            //    addFloorToy(i, i);
            //}

            addToys(420, 450, 0, 700, 300, 330, 0, 700, true, true, 222, 150, true);

            Components.Add(boy);

            Components.Add(basketOpeningRight);
            Components.Add(basketOpeningLeft);
            Components.Add(toy);
            Components.Add(basketLeft);
            Components.Add(basketRight);

            Components.Add(talkingBubble);
            base.LoadContent();
        }
        protected override void UnloadContent()
        {
            loadScreenDraw(loadScreen, new Vector2(-90, -20));
            accelSensor = null;
            indicator = null;
            basketLeft = null;
            basketOpeningLeft = null;
            basketOpeningLeft = null;
            basketRight = null;
            mama = null;
            boy = null;
            toy = null;
            talkingBubble = null;
            toysCollected = null;
            for (int r = 0; r < rectangles.Count; r++)
                rectangles[r] = Rectangle.Empty;
            Content.Unload();
            Components.Clear();
            rectangles.Clear();
            for (int txt = 0; txt < textures.Count; txt++)
            {
                textures[txt] = null;
            }
            rectangles.Clear();
            textures.Clear();
            GC.Collect();
            GC.WaitForPendingFinalizers();

            string test = GC.GetTotalMemory(true).ToString();
            Debug.WriteLine(test);

            base.UnloadContent();
        }
示例#4
0
        protected override void LoadContent()
        {
            try
            {
                loadScreen = Content.Load<Texture2D>("Images\\gui\\loadscreen");
                loadScreenDraw(loadScreen, new Vector2(-90, -20));

                backgroundMusic = Content.Load<SoundEffect>("ToyRoom");
                yeah = Content.Load<SoundEffect>("yeah2");
                ohno = Content.Load<SoundEffect>("ohno");
                indicatorTxt = Content.Load<Texture2D>("Images\\indicator");

                mannTexture = Content.Load<Texture2D>("Images\\theBoy");
                mannTexture2 = Content.Load<Texture2D>("Images\\theBoyShowing");
                mannTexture3 = Content.Load<Texture2D>("Images\\boytup");
                roomTexture = Content.Load<Texture2D>("Images\\theroom");
                guiBubbleTxt = Content.Load<Texture2D>("Images\\tlkBubble");
                basketOpeningTxt = Content.Load<Texture2D>("Images\\wheelBasket2");

                textures[0] = Content.Load<Texture2D>("Images\\Colored\\sportscar");
                textures[1] = Content.Load<Texture2D>("Images\\Colored\\theplane");
                textures[2] = Content.Load<Texture2D>("Images\\Colored\\train");
                textures[3] = Content.Load<Texture2D>("Images\\Colored\\tractor");
                textures[4] = Content.Load<Texture2D>("Images\\Colored\\digger");
                textures[5] = Content.Load<Texture2D>("Images\\Colored\\dino");
                textures[6] = Content.Load<Texture2D>("Images\\Colored\\baby");
                textures[7] = Content.Load<Texture2D>("Images\\Colored\\soldier");
                textures[8] = Content.Load<Texture2D>("Images\\Colored\\actionFigure");
                textures[9] = Content.Load<Texture2D>("Images\\Colored\\teddy");
                textures[10] = Content.Load<Texture2D>("Images\\Colored\\block");
                textures[11] = Content.Load<Texture2D>("Images\\Colored\\ball");
                textures[12] = Content.Load<Texture2D>("Images\\Colored\\balloon");
                textures[13] = Content.Load<Texture2D>("Images\\Colored\\pad");
                textures[14] = Content.Load<Texture2D>("Images\\Colored\\horse");
                textures[15] = Content.Load<Texture2D>("Images\\Colored\\racecar");
                textures[16] = Content.Load<Texture2D>("Images\\Colored\\dumper");

                basketLeftTxt = Content.Load<Texture2D>("Images\\wheelBasket1");
            }
            catch (Exception ex)
            {
            }

            spriteFont = Content.Load<SpriteFont>("sf20");
            spriteFont.LineSpacing = 25;
            spriteFont.Spacing = 1;

            boy = new BasicComponent(this.Game, mannTexture, mannRect, 0f);
            basketLeft = new BasicComponent(this.Game, basketLeftTxt, basketLeftRect, Color.LightBlue, 0.0f);
            basketOpening = new BasicComponent(this.Game, basketOpeningTxt, basketOpeningRct, Color.LightBlue, 0.0f);
            roomBackground = new BasicComponent(this.Game, roomTexture, roomRect, Color.White, 0.0f);
            toy = new MoveAbleComponent(this.Game, textures[0], defaultRect, Color.White, 0.0f);
            talkingBubble = new GameGUI(this.Game, spriteFont, new Vector2(210, 65), "Hello friend!  \n Please help! \n  Hurry! or more \n toys will come! ", Color.Black, 0f, new Vector2(0, 0), 1f, 0f);
            talkingBubble.GuiBackgroundRect = guiBubbleRct;
            talkingBubble.GuiBackgroundTxt = guiBubbleTxt;
            talkingBubble.GuiVisible = true;

            talkingBubble.DrawOrder = 11127;
            roomBackground.DrawOrder = -100;
            basketLeft.DrawOrder = 200;
            basketOpening.DrawOrder = 198;
            toy.DrawOrder = 199;
            boy.DrawOrder = 100;

            yeahinst = yeah.CreateInstance();
            backgroundMusicInst = backgroundMusic.CreateInstance();

            indicator = new BasicComponent(this.Game, indicatorTxt, indicatorRct, Color.White, 0.0f);
            indicator.DrawOrder = 12122;
            indicator.ItemDraw = false;

            Components.Add(roomBackground);
            addToys(410, 440, 0, 700, 360, 390, 0, 700, true, false, 222, 150, true);

            Components.Add(boy);
            Components.Add(basketOpening);

            Components.Add(toy);
            Components.Add(basketLeft);
            loadPauseScreen();
            Components.Add(indicator);
            Components.Add(talkingBubble);
               // numberOfTurns = textures.Length;
            toy.CompRectX = -10000;
            base.LoadContent();
        }
示例#5
0
        protected override void UnloadContent()
        {
            accelSensor = null;
            indicator = null;
            basketLeft = null;
            basketOpeningLeft = null;

            basketRight = null;
            mama = null;
            boy = null;
            toy = null;
            talkingBubble = null;
            gameStorage = null;
            toysBackground = null;
            toysForeground = null;
            toyName = null;
            gameStorage = null;
            spriteBatch = null;
            mannTexture = null;
            mannTexture2 = null;
            mannTexture3 = null;
            basketTxt = null;
            boyDissapointedTxt = null;
            roomTexture = null;
            crayonTxt = null;
            guiBubbleTxt = null;
            basketLeftTxt = null;
            basketOpeningTxt = null;
            loadScreen = null;
            pauseScreenTxt = null;
            indicatorTxt = null;

            resumeTxt = null;
            restartTxt = null;
            pauseButtonTxt = null;
            menuButtonTxt = null;
            mamaTxt = null;
            roomdooropen = null;
            mannRect = Rectangle.Empty;
            bskHit = Rectangle.Empty;
            basketLeftRect = Rectangle.Empty;
            mannRect2 = Rectangle.Empty;
            mannRect3 = Rectangle.Empty;
            defaultRect = Rectangle.Empty;
            roomRect = Rectangle.Empty;
            indicatorRct = Rectangle.Empty;
            crayonRect = Rectangle.Empty;
            guiBubbleRct = Rectangle.Empty;
            basketOpeningRct = Rectangle.Empty;
            basketRightRect = Rectangle.Empty;
            basketOpeningLRct = Rectangle.Empty;
            basketOpeningRRct = Rectangle.Empty;
            bskHitL = Rectangle.Empty;
            bskHitR = Rectangle.Empty;
            pauseScreenRect = Rectangle.Empty;
            restartRect = Rectangle.Empty;
            resumeRect = Rectangle.Empty;
            pauseButtonRect = Rectangle.Empty;
            menuButtonRect = Rectangle.Empty;
            mamaRct = Rectangle.Empty;
            mannRect4 = Rectangle.Empty;
            gameGUI = null;
            colorList = null;

            rnd = null;
            toy = null;
            spriteFont = null;
            boy = null;
            roomBackground = null;
            basketOpening = null;
            basketOpeningLeft = null;
            basketOpeningRight = null; basketRight = null;
            pauseScreen = null;
            resumeButton = null;
            restartButton = null;
            pauseButton = null;
            menuButton = null;
            indicator = null;
            mama = null;

            Components.Clear();
            for (int i = 0; i < rectangles.Length; i++)
            {
                rectangles[i] = Rectangle.Empty;
            }
            if (crayons != null)
            {
                for (int c = 0; c < crayons.Length; c++)
                {
                    crayons[c] = null;

                }
            }
            crayons = null;
            backgroundMusic = null;
            yeah = null;
            ohno = null;
            myBoy = null;
            toysCollected.Clear();
            toysCollected = null;
            yeahinst = null;
            ohnoinst = null;
            backgroundMusicInst = null;
            myBoyInst = null;
            graphics = null;
            vibration = null;
            gameMS = null;
            toysBackground = null;
            toysForeground = null;
            toyName = string.Empty;
            toyNamePrefix = string.Empty;
            musicStateStopped = string.Empty;
            for (int r = 0; r < rectangles.Length; r++)
                rectangles[r] = Rectangle.Empty;
            Content.Unload();
            while (Components.Count > 0)
                Components.RemoveAt(0);

            for (int txt = 0; txt < textures.Length; txt++)
            {
                textures[txt] = null;
            }

            textures = null;
            unLoadPauseScreen();

            base.UnloadContent();

            string test = GC.GetTotalMemory(true).ToString();
        }