示例#1
0
        void BuildMap()
        {
            amoeba = new GameObject(amoebaTex, Vector2.Zero, startRadius, 0f);
            mx = 0;
            my = 0;
            zoom = 1.0f;

            objects = new List<GameObject>();
            furBalls = new List<GameObject>();
            objectTex = new List<Texture2D>();
            objectPos = new List<Vector2>();
            furBallTex = new List<Texture2D>();
            furBallPos = new List<Vector2>();

            objectScaleValue = backgroundSize / mapTex.Width;

            for (int i = 0; i < mapTex.Height; i++)
            {
                for (int j = 0; j < mapTex.Width; j++)
                {
                    if (data[i * mapTex.Width + j] < 0)
                    {
                        int value = data[i * mapTex.Width + j] + 0x1000000;
                        int red = value / (0x10000);
                        int green = (value / 0x100) % 0x100;
                        int blue = (value) % 0x100;

                        float xPos = (j - (mapTex.Width - 1) / 2.0f) * objectScaleValue;
                        float yPos = (i - (mapTex.Height - 1) / 2.0f) * objectScaleValue;

                        if (red > 0 && green == 0 && blue == 0)
                        {
                            objectPos.Add(new Vector2(xPos, yPos));
                            if (red <= 32)
                                objectTex.Add(red32Tex);
                            else if (red <= 64)
                                objectTex.Add(red64Tex);
                            else if (red <= 128)
                                objectTex.Add(red128Tex);
                            else
                                objectTex.Add(red256Tex);
                        }
                        else if (red == 0 && green > 0 && blue == 0)
                        {
                            objectPos.Add(new Vector2(xPos, yPos));
                            if (green <= 32)
                                objectTex.Add(green32Tex);
                            else if (green <= 64)
                                objectTex.Add(green64Tex);
                            else if (green <= 128)
                                objectTex.Add(green128Tex);
                            else
                                objectTex.Add(green256Tex);
                        }
                        else if (red == 0 && green == 0 && blue > 0)
                        {
                            objectPos.Add(new Vector2(xPos, yPos));
                            if (blue <= 32)
                                objectTex.Add(blue32Tex);
                            else if (blue <= 64)
                                objectTex.Add(blue64Tex);
                            else if (blue <= 128)
                                objectTex.Add(blue128Tex);
                            else
                                objectTex.Add(blue256Tex);
                        }
                        else if (red == green && green == blue)
                        {
                            furBallPos.Add(new Vector2(xPos, yPos));
                            if (red <= 32)
                                furBallTex.Add(furBall32Tex);
                            else if (red <= 64)
                                furBallTex.Add(furBall64Tex);
                            else if (red <= 128)
                                furBallTex.Add(furBall128Tex);
                            else
                                furBallTex.Add(furBall256Tex);
                        }
                    }
                }
            }

            for (int i = 0; i < objectPos.Count; i++)
            {
                objects.Add(new GameObject(objectTex[i], objectPos[i], 1f, 0f));
            }

            for (int i = 0; i < furBallPos.Count; i++)
            {
                furBalls.Add(new GameObject(furBallTex[i], furBallPos[i], 1f, (float)(random.NextDouble() * Math.PI * 2)));
            }
            backgroundScale = backgroundSize / backgroundTex.Width;
            background = new GameObject(backgroundTex, Vector2.Zero, backgroundScale, 0);
            cat = new GameObject(catTex, new Vector2(-backgroundSize/2.0f, -backgroundSize/2.0f), maxAmoebaRadius / catTex.Width, 3.0f*(float)Math.PI/4);
        }
示例#2
0
 int GetColor(GameObject obj)
 {
     if (obj.sprite == red32Tex || obj.sprite == red64Tex || obj.sprite == red128Tex || obj.sprite == red256Tex)
         return red;
     else if (obj.sprite == green32Tex || obj.sprite == green64Tex || obj.sprite == green128Tex || obj.sprite == green256Tex)
         return green;
     else
         return blue;
 }
示例#3
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            titleBackground = new GameObject(Content.Load<Texture2D>("Pictures\\Background"), Vector2.Zero, 1.7f, 0f);
            storyBackground = new GameObject(Content.Load<Texture2D>("TitlePictures\\Story"), Vector2.Zero, 0.5f, 0f);
            storyTxt = new GameObject(Content.Load<Texture2D>("TitlePictures\\StoryText"), Vector2.Zero, 0.5f, 0f);
            storyFrame = new GameObject(Content.Load<Texture2D>("TitlePictures\\StoryFrame"), Vector2.Zero, 0.5f, 0f);
            canEat = new GameObject(Content.Load<Texture2D>("TitlePictures\\Caneat"), Vector2.Zero, 1f, 0f);
            cannotEat = new GameObject(Content.Load<Texture2D>("TitlePictures\\Cannoteat"), Vector2.Zero, 1f, 0f);
            ending = new GameObject(Content.Load<Texture2D>("TitlePictures\\Ending"), Vector2.Zero, 1f, 0f);
            endText = new GameObject(Content.Load<Texture2D>("TitlePictures\\Endtext"), Vector2.Zero, 1f, 0f);

            amoebaTex = Content.Load<Texture2D>("Pictures\\Amoeba");
            amoebaMouth = Content.Load<Texture2D>("Pictures\\AmoebaMouth");


            Texture2D arrowTex = Content.Load<Texture2D>("Pictures\\Arrow");
            arrow = new GameObject(arrowTex, Vector2.Zero, 1.0f, 0f);

            backgroundTex = Content.Load<Texture2D>("Pictures\\Background");

            red32Tex = Content.Load<Texture2D>("Pictures\\Red-32");
            red64Tex = Content.Load<Texture2D>("Pictures\\Red-64");
            red128Tex = Content.Load<Texture2D>("Pictures\\Red-128");
            red256Tex = Content.Load<Texture2D>("Pictures\\Red-256");

            green32Tex = Content.Load<Texture2D>("Pictures\\Green-32");
            green64Tex = Content.Load<Texture2D>("Pictures\\Green-64");
            green128Tex = Content.Load<Texture2D>("Pictures\\Green-128");
            green256Tex = Content.Load<Texture2D>("Pictures\\Green-256");

            blue32Tex = Content.Load<Texture2D>("Pictures\\Blue-32");
            blue64Tex = Content.Load<Texture2D>("Pictures\\Blue-64");
            blue128Tex = Content.Load<Texture2D>("Pictures\\Blue-128");
            blue256Tex = Content.Load<Texture2D>("Pictures\\Blue-256");

            furBall32Tex = Content.Load<Texture2D>("Pictures\\FurBall-32");
            furBall64Tex = Content.Load<Texture2D>("Pictures\\FurBall-64");
            furBall128Tex = Content.Load<Texture2D>("Pictures\\FurBall-128");
            furBall256Tex = Content.Load<Texture2D>("Pictures\\FurBall-256");

            mapTex = Content.Load<Texture2D>("Pictures\\Map");

            catTex = Content.Load<Texture2D>("Pictures\\Cat");

            font16 = Content.Load<SpriteFont>("Fonts\\Font16");
            font36Reg = Content.Load<SpriteFont>("Fonts\\Font36Reg");
            font36Bold = Content.Load<SpriteFont>("Fonts\\Font36Bold");
            font24Reg = Content.Load<SpriteFont>("Fonts\\Font24Reg");
            font24Bold = Content.Load<SpriteFont>("Fonts\\Font24Bold");
            font72 = Content.Load<SpriteFont>("Fonts\\Font72");
            data = new int[mapTex.Width * mapTex.Height];
            mapTex.GetData<int>(data);

            BuildMap();
            turnLeft = new GameObject(Content.Load<Texture2D>("TitlePictures\\TurnLeft"), Vector2.Zero, 1f, 0f);
            turnRight = new GameObject(Content.Load<Texture2D>("TitlePictures\\TurnRight"), Vector2.Zero, 1f, 0f);


            engine = new AudioEngine("Content\\Music\\Audio.xgs");
            soundBank = new SoundBank(engine, "Content\\Music\\Sound_Bank.xsb");
            waveBank = new WaveBank(engine, "Content\\Music\\Wave_Bank.xwb");

            backgroundMusic = soundBank.GetCue("background");
            backgroundMusic.Play();
        }