Exemplo n.º 1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here


            //base initialize calls loadcontent
            base.Initialize();


            random       = new Random();
            playArea     = new Rectangle(lhs, top, rhs - lhs, bot - top);
            spritePlayer = new Sprite3(true, playerTex, 50, SCREEN_HEIGHT / 2 - 50);
            spritePlayer.setWidthHeight(100, 100);
            spritePlayer.setFlip(SpriteEffects.FlipHorizontally);
            //spritePlayer.setBB(0,0,200, 200);



            scrollBack       = new ScrollBackGround(texBackground, texBackground.Bounds, new Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), -1 + playerSpeeeeeed, 2);
            scrollFore       = new ScrollBackGround(texForeground, texForeground.Bounds, new Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), -2 + playerSpeeeeeed, 2);
            textScore        = new TextRenderable("Score : " + score.ToString(), new Vector2(100, 100), spriteFont, Color.Red);
            textStartGame    = new TextRenderable("PRESS ENTER TO START", new Vector2(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2), spriteFont, Color.Red);
            particleList     = new SpriteList();
            enemyList        = new SpriteList();
            playerBulletList = new SpriteList();
        }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        ScrollBackGround myScript = (ScrollBackGround)target;

        if (GUILayout.Button("Place Rock (will delete the previous rocks!)"))
        {
            if (myScript != null)
            {
                myScript.PlaceRocks();
            }
        }
        if (GUILayout.Button("Place Torches (will delete the previous torches!)"))
        {
            if (myScript != null)
            {
                myScript.PlaceTorches();
            }
        }
        if (GUILayout.Button("Remove All Asthetics (torches and rocks)"))
        {
            if (myScript != null)
            {
                myScript.RemoveAllAsthetics();
            }
        }
        myScript.UpdateSize();
    }
Exemplo n.º 3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            LineBatch.init(GraphicsDevice);
            // TODO: use this.Content to load your game content here
            texBack   = Util.texFromFile(GraphicsDevice, dir + "ricefield.png");
            texpaddle = Util.texFromFile(GraphicsDevice, dir + "slime.png");
            texBall   = Util.texFromFile(GraphicsDevice, dir + "slime_slice.png"); //***
            texEnemy  = Util.texFromFile(GraphicsDevice, dir + "ghost.png");
            texGrass1 = Util.texFromFile(GraphicsDevice, dir + "grass1.png");
            texBoom   = Util.texFromFile(GraphicsDevice, dir + "Boom3.png");
            font      = Content.Load <SpriteFont>("incoming");

            paddle = new Sprite3(true, texpaddle, lhs, yy);
            paddle.setBBToTexture();

            enemyList = new SpriteList();
            ballList  = new SpriteList();
            booms     = new SpriteList();

            back1      = new ScrollBackGround(texBack, texBack.Bounds, new Rectangle(0, 0, rhs, 380), -1, 2);
            grass1     = new ScrollBackGround(texGrass1, texGrass1.Bounds, new Rectangle(0, bot - (texGrass1.Height + 30), rhs, bot / 2), -1, 2);
            playArea   = new Rectangle(lhs, top, rhs, bot - 10);
            enemyYY    = new Random();
            enemySpeed = new Random();
        }
Exemplo n.º 4
0
        public override void EnterLevel(int fromLevelNum)
        {
            base.EnterLevel(fromLevelNum);
            Console.WriteLine("BEGINNING ");
            if (gameStateManager.getLevel(fromLevelNum) is GameLevel1)
            {
                GameLevel1 lastGameLevel = gameStateManager.getLevel(fromLevelNum) as GameLevel1;
                level = lastGameLevel.level + 1;
                Console.WriteLine("LEVEL: " + level.ToString());
                score        = lastGameLevel.score;
                enemyToSpawn = lastGameLevel.enemyToSpawn + 3;
            }
            else
            {
                level        = 1;
                score        = 0;
                enemyToSpawn = 10;
            }

            enemyCounter = 0;
            //initialize level texts
            textLevel      = new TextRenderable("LEVEL: " + level.ToString(), new Vector2(20, 20), spriteFont, Color.Red);
            textScore.text = "Score : " + score.ToString();

            //initialize player for new level
            player = new Player(true, playerTex, 50, Game1.SCREEN_HEIGHT / 2 - 50);
            player.setWidthHeight(100, 100);
            player.setFlip(SpriteEffects.FlipHorizontally);

            //initalize level state
            levelState = LEVELSTATE.LEVELSTART;

            //initialize lists
            particleList     = new SpriteList();
            enemyList        = new SpriteList();
            playerBulletList = new SpriteList();

            Console.WriteLine("enemyCounter" + enemyCounter);
            Console.WriteLine("enemyToSpawn" + enemyToSpawn);


            scrollBack = new ScrollBackGround(texBackground, texBackground.Bounds, new Rectangle(0, 0, Game1.SCREEN_WIDTH, Game1.SCREEN_HEIGHT), -1 + player.playerBackgroundSpeed, 2);
            scrollFore = new ScrollBackGround(texForeground, texForeground.Bounds, new Rectangle(0, 0, Game1.SCREEN_WIDTH, Game1.SCREEN_HEIGHT), -2 + player.playerBackgroundSpeed, 2);

            //initialize eneemy player targetting.
            EnemyEasy.player = player;
        }
Exemplo n.º 5
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            LineBatch.init(GraphicsDevice);

            // load all fonts for the splash screen and levels
            llFont = Content.Load <SpriteFont>("Large");
            mmFont = Content.Load <SpriteFont>("Medium");
            ssFont = Content.Load <SpriteFont>("Small");

            // load  textures from local content directory
            kcTexPath   = @"/Users/jfc/Desktop/CrazyCat_Assignment_GPT/GPT_Assignment/GPT_Assignment/Content/kittyCat.png";
            kittyCatTex = Util.texFromFile(GraphicsDevice, kcTexPath);

            bbTexPath     = @"/Users/jfc/Desktop/CrazyCat_Assignment_GPT/GPT_Assignment/GPT_Assignment/Content/Background.png";
            backgroundTex = Util.texFromFile(GraphicsDevice, bbTexPath);

            playerTexPath = @"/Users/jfc/Desktop/CrazyCat_Assignment_GPT/GPT_Assignment/GPT_Assignment/Content/KittyCatFrames.png";
            playerTex     = Util.texFromFile(GraphicsDevice, playerTexPath);

            doggyTexPath = @"/Users/jfc/Desktop/CrazyCat_Assignment_GPT/GPT_Assignment/GPT_Assignment/CrazyDogFrames.png";
            doggyTex     = Util.texFromFile(GraphicsDevice, doggyTexPath);

            yarnTex = Content.Load <Texture2D>("Yarn");

            // position vector for the cat sprite on main splash screen
            kittyCatVec   = new Vector2(275, 50);
            titleVec      = new Vector2(100, 300);
            sloganVec     = new Vector2(290, 400);
            instructVec   = new Vector2(315, 425);
            levelIntroVec = new Vector2(250, 200);
            playerVec     = new Vector2(600, 400);
            doggyVec      = new Vector2(0, 400);


            // make the cat sprite for the main splash screen
            kittyCat = new Sprite3(true, kittyCatTex, kittyCatVec.X, kittyCatVec.Y);

            // prepare the crazy dog for level 2
            crazyDog = new Sprite3(false, doggyTex, doggyVec.X, doggyVec.Y);



            // color for the level text and alpha value
            ltCol = new Color(0, 255, 0, 1);
            // level text initialization
            levelText = new TextRenderable("Blabla", levelIntroVec, llFont, Color.Red);


            // source and destination rectangles for the scrolling background
            backgroundDest   = new Rectangle(0, 0, 800, 600);
            backgroundSource = new Rectangle(0, 0, 800, 600);

            // draw background
            background = new ScrollBackGround(backgroundTex, backgroundDest, backgroundSource, 5.0f, 2);

            // player vector and player texture

            playerSprite = new Sprite3(true, playerTex, playerVec.X, playerVec.Y);

            // initialize frame vector
            playerFrames = new Vector2[10];

            // frame vector values 1280x128

            playerFrames[0].X = 0; playerFrames[0].Y = 0;
            playerFrames[1].X = 1; playerFrames[1].Y = 0;
            playerFrames[2].X = 2; playerFrames[2].Y = 0;
            playerFrames[3].X = 3; playerFrames[3].Y = 0;
            playerFrames[4].X = 4; playerFrames[4].Y = 0;
            playerFrames[5].X = 5; playerFrames[5].Y = 0;
            playerFrames[6].X = 6; playerFrames[6].Y = 0;
            playerFrames[7].X = 7; playerFrames[7].Y = 0;
            playerFrames[8].X = 8; playerFrames[8].Y = 0;
            playerFrames[9].X = 9; playerFrames[9].Y = 0;

            // set all the parameters for the cute little kitty cat
            playerSprite.setWidthHeight(64, 64);
            playerSprite.setWidthHeightOfTex(1280, 128);
            playerSprite.setXframes(10);
            playerSprite.setYframes(0);
            playerSprite.setBB(0, 0, 128, 128);
            playerSprite.setAnimationSequence(playerFrames, 0, 9, 15);
            playerSprite.animationStart();

            // the parameters for the player sprite jumping
            playerJump      = false;
            playerJumpSpeed = 0;

            // store the initial positions of the player sprite
            prevPos.Y = playerVec.Y;
            prevPos.X = playerVec.X;

            // initialize sounds for the game
            jumpo      = Content.Load <SoundEffect>("Sounds/Boing");
            jumpoSound = new LimitSound(jumpo, 1);

            success      = Content.Load <SoundEffect>("Sounds/Success");
            successSound = new LimitSound(success, 1);

            barko      = Content.Load <SoundEffect>("Sounds/Growl");
            barkoSound = new LimitSound(barko, 1);

            kaching      = Content.Load <SoundEffect>("Sounds/Kaching");
            kachingSound = new LimitSound(kaching, 1);

            yowlin      = Content.Load <SoundEffect>("Sounds/Yowl");
            yowlinSound = new LimitSound(yowlin, 1);

            easterEgg = Content.Load <SoundEffect>("Sounds/OhWhatever");
            eeSound   = new LimitSound(easterEgg, 1);


            /// yarn ball sprite list
            ///
            ///
            ///
            ///
            ///
            ///

            yarnBalls = new SpriteList();

            Sprite3 yb;

            for (int i = 0; i < maxYarnBalls; i++)
            {
                // temporarily set to doggyVec for positioning - change later?
                yb = new Sprite3(true, yarnTex, doggyVec.X + i * 50, doggyVec.Y - i * 50);
                yb.setDeltaSpeed(new Vector2((float)(1 + rnd.NextDouble()), 0));
                yb.setWidthHeight(32, 32);
                yb.setWidthHeightOfTex(32, 32);
                yb.setHSoffset(new Vector2(32, 32));
                yb.setBBToTexture();
                yb.setMoveSpeed(2.1f);

                yarnBalls.addSpriteReuse(yb);
            }



            // initialize frame vector for dog
            doggyFrames = new Vector2[8];


            doggyFrames[0].X = 0; doggyFrames[0].Y = 0;
            doggyFrames[1].X = 1; doggyFrames[1].Y = 0;
            doggyFrames[2].X = 2; doggyFrames[2].Y = 0;
            doggyFrames[3].X = 3; doggyFrames[3].Y = 0;
            doggyFrames[4].X = 4; doggyFrames[4].Y = 0;
            doggyFrames[5].X = 5; doggyFrames[5].Y = 0;
            doggyFrames[6].X = 6; doggyFrames[6].Y = 0;
            doggyFrames[7].X = 7; doggyFrames[7].Y = 0;

            crazyDog.setWidthHeight(64, 64);
            crazyDog.setWidthHeightOfTex(1024, 128);
            crazyDog.setXframes(8);
            crazyDog.setYframes(0);
            crazyDog.setBB(0, 0, 128, 128);
            crazyDog.setAnimationSequence(playerFrames, 0, 7, 15);
            crazyDog.animationStart();
        }
Exemplo n.º 6
0
        public override void LoadContent()
        {
            this.weaponManager = new WeaponManager();

            this.players = new List <Player>();

            this.bulletActive = false;
            this.addMaterial  = false;
            this.rocketFlying = false;

            background = Content.Load <Texture2D>("Textures/Level3/moon");

            this.backgroundOriginal = Content.Load <Texture2D>("Textures/Level3/moon");

            this.bold = Content.Load <SpriteFont>("Fonts/spriteFontBold");

            this.backgroundOriginalColour = new Color[this.backgroundOriginal.Width * this.backgroundOriginal.Height];
            this.backgroundOriginal.GetData(this.backgroundOriginalColour);

            tank = Content.Load <Texture2D>("Textures/tank-custom");

            font = Content.Load <SpriteFont>("Fonts/spritefont1");

            parachute = Content.Load <Texture2D>("Textures/parachute");

            this.scrollTex = Content.Load <Texture2D>("Textures/Level3/background_parallax");

            this.missile_thumbnail = Content.Load <Texture2D>("Textures/missile-thumbnail");

            color = new Color[background.Width * background.Height];
            background.GetData(color);

            turret = Content.Load <Texture2D>("Textures/turret");

            this.tex = Content.Load <Texture2D>("Textures/Particle2");

            this.hud = Content.Load <Texture2D>("Textures/hud2");

            this.scrollBackGround = new ScrollBackGround(this.scrollTex, new Rectangle(0, 0, 1400, 800), this.backgroundRectangle, 1.0f, 1);

            bullet      = Content.Load <Texture2D>("Textures/circle2");
            bulletColor = new Color[bullet.Width * bullet.Height];
            bullet.GetData(bulletColor);


            //Reset the modified terrain from the original texture
            this.color = this.backgroundOriginalColour;
            this.background.SetData(this.color);


            //Initialise the players:

            players.Add(new Player(0, tank, new Vector2(195, 0), Color.Green, turret, new Vector2(195 + 37, 21), Color.Green, this.weaponManager));

            players.Add(new Player(1, tank, new Vector2(1000, 0), Color.Blue, turret, new Vector2(1000 + 37, 21), Color.Blue, this.weaponManager));

            players[0].setTurretOrigin(2, 5);
            players[1].setTurretOrigin(2, 5);

            levelManager = new LevelManager(players, gameStateManager);
            levelManager.setCurrentPlayer(players[0]);
            levelManager.setGameStatus(true);

            rocketPosition = new Vector2(levelManager.getCurrentPlayer().getPlayerPosition().X + tank.Width / 2, levelManager.getCurrentPlayer().getPlayerPosition().Y);

            this.p = new ParticleSystemModified(new Vector2(levelManager.getCurrentPlayer().getPlayerPosition().X + (tank.Width / 2), levelManager.getCurrentPlayer().getPlayerPosition().Y), 400, 999, 108);
            // ps = new ParticleSystem(new Vector2(0,0), 400, 999, 167);

            //Start the snow particles
            // simulateSnow();

            //Initialise sounds


            this.launch         = Content.Load <SoundEffect>("Sounds/rlaunch");
            this.launchInsatnce = this.launch.CreateInstance();

            this.hit         = Content.Load <SoundEffect>("Sounds/single_explosion");
            this.hitInstance = this.hit.CreateInstance();
        }