示例#1
0
 public void Draw(SpriteBatch spriteBatch, AngryBallsEnvironment.GameState gameState)
 {
     if (gameState == AngryBallsEnvironment.GameState.levelBuilder)
     {
         Vector2 topLeft = new Vector2(position.X - size.X / 2, position.Y - size.Y / 2);
         spriteBatch.Draw(image, new Rectangle(topLeft.ToPoint(), size.ToPoint()), Color.White);
     }
 }
示例#2
0
        public SaveButton(AngryBallsEnvironment.GameState gameState)
        {
            image = Game1.saveImage;

            position = new Vector2(375, 75);
            size = new Vector2(80, 75);

            dragable = true;
        }
示例#3
0
        public LoadButton(AngryBallsEnvironment.GameState gameState)
        {
            image = Game1.loadButtonImage;

            position = new Vector2(475, 75);
            size = new Vector2(80, 75);

            dragable = true;
        }
示例#4
0
 public void WriteLevel(Map map, string name, AngryBallsEnvironment.GameState gameState)
 {
     if (gameState == AngryBallsEnvironment.GameState.dialog)
     {
         AngryBallsEnvironment.name = name;
         jsonWriter = new JSONEditor();
         jsonWriter.WriteLevel(map, name);
     }
 }
示例#5
0
        public void ReadLevel(Map map, string name, AngryBallsEnvironment.GameState gameState)
        {
            if (name == null)
                name = "default";

            if (File.Exists("Levels/LevelDemo/" + name + ".json"))
            {

                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(TBIList));
                //clear out all the existing TBI's
                foreach (FixedBrick element in map.TBIList.FixedBrickList.Reverse<FixedBrick>())
                {
                    map.TBIList.FixedBrickList.Remove(element);
                }

                foreach (ProxMine element in map.TBIList.placedMines.Reverse<ProxMine>())
                {
                    map.TBIList.placedMines.Remove(element);
                }

                foreach (ProxMine element in map.TBIList.unPlacedMines.Reverse<ProxMine>())
                    map.TBIList.unPlacedMines.Remove(element);

                foreach (DestructableTriangleBrick element in map.TBIList.unplacedTriangleBrickList.Reverse<DestructableTriangleBrick>())
                    map.TBIList.unplacedTriangleBrickList.Remove(element);

                foreach (Bomb element in map.TBIList.PlacedBomb.Reverse<Bomb>())
                {
                    map.TBIList.PlacedBomb.Remove(element);
                }

                //attempt to pull an entire TBIList out of the JSON serializer
                StreamReader readFileBetter = new StreamReader("Levels/LevelDemo/" + name + ".json");
                string objectString;

                //read file contents into a string, then close the file reader
                objectString = readFileBetter.ReadToEnd();
                readFileBetter.Close();

                //Convert the string to a byte[] and load it into a stream
                MemoryStream streamsBlow = new MemoryStream();
                byte[] byteFucker = Encoding.UTF8.GetBytes(objectString);
                streamsBlow.Write(byteFucker, 0, byteFucker.Length);

                //Fingers crossed...
                streamsBlow.Position = 0;
                if (streamsBlow.Length != 0)
                {
                    TBIList tempTBIList = (TBIList)ser.ReadObject(streamsBlow);
                    initObject(tempTBIList, map, gameState);
                }
            }
        }
 public void Toggle(ref AngryBallsEnvironment.GameState gameState)
 {
     MouseState mouseState = Mouse.GetState();
     if (isClicked(mouseState) && !build)
     {
         gameState = AngryBallsEnvironment.GameState.pause;
     }
     else
     {
         gameState = AngryBallsEnvironment.GameState.levelBuilder;
     }
 }
        public BuilderButton(AngryBallsEnvironment.GameState gameState)
        {
            image = Game1.builderImage;

            if (gameState == AngryBallsEnvironment.GameState.pause || gameState == AngryBallsEnvironment.GameState.levelBuilder)
            {
                build = true;
            }
            position = new Vector2(175, 75);
            size = new Vector2(80, 75);

            dragable = true;
        }
示例#8
0
        public SaveButton(AngryBallsEnvironment.GameState gameState)
        {
            image = Game1.saveImage;

            if (gameState == AngryBallsEnvironment.GameState.levelBuilder)
            {
                save = true;
            }
            position = new Vector2(150, 75);
            size = new Vector2(80, 75);

            dragable = true;
        }
示例#9
0
        //Move from env to map?
        public void Draw(SpriteBatch spriteBatch, AngryBallsEnvironment.GameState gameState)
        {
            //Draw Item Creators if we're in LevelBuilder mode
            if (gameState == AngryBallsEnvironment.GameState.levelBuilder)
            {
                fixedBrickCreator.draw(spriteBatch);
                destructableBrickCreator.draw(spriteBatch);
                mineCreator.draw(spriteBatch);
                triangleBrickCreator.draw(spriteBatch);
                destructableTriangleBrickCreator.draw(spriteBatch);
                hazardCreator.draw(spriteBatch);
            }

            //Draw ToolBox Contents
            foreach (Bomb element in TBIList.PlacedBomb)
            {
                if(gameState != AngryBallsEnvironment.GameState.levelBuilder)
                    element.draw(spriteBatch);
            }

            foreach (FixedBrick element in TBIList.unplacedTriangleBrickList)
            {
                if (gameState != AngryBallsEnvironment.GameState.levelBuilder)
                    element.draw(spriteBatch);

            }

            foreach (ProxMine element in TBIList.placedMines)
            {
                element.draw(spriteBatch);
            }

            foreach (ProxMine element in TBIList.unPlacedMines)
            {
                if (gameState != AngryBallsEnvironment.GameState.levelBuilder)
                    element.draw(spriteBatch);
            }

            foreach (FixedBrick element in TBIList.FixedBrickList)
            {
                element.draw(spriteBatch);
            }

            foreach (Hazard element in TBIList.hazardList)
                element.draw(spriteBatch);

            //Draw the EndGoal

            TBIList.endGoal.draw(spriteBatch);
        }
示例#10
0
        public void Draw(SpriteBatch spriteBatch, AngryBallsEnvironment.GameState gameState)
        {
            if (gameState != AngryBallsEnvironment.GameState.levelBuilder &&
                gameState != AngryBallsEnvironment.GameState.initialize)
            {
                Vector2 topLeft = new Vector2(position.X - size.X / 2, position.Y - size.Y / 2);

                if (play)
                    spriteBatch.Draw(pauseImage, new Rectangle(topLeft.ToPoint(), size.ToPoint()), Color.White);

                else if (pause)
                    spriteBatch.Draw(image, new Rectangle(topLeft.ToPoint(), size.ToPoint()), Color.White);
            }
        }
示例#11
0
        public BuilderButton(AngryBallsEnvironment.GameState gameState)
        {
            image = Game1.builderImage;

            fBrickCreator = new FixedBrickCreator();

            if (gameState == AngryBallsEnvironment.GameState.levelBuilder)
            {
                build = true;
            }
            position = new Vector2(275, 75);
            size = new Vector2(80, 75);

            dragable = true;
        }
示例#12
0
 public void Toggle(ref AngryBallsEnvironment.GameState gameState)
 {
     MouseState mouseState = Mouse.GetState();
     if (build)
     {
         if (gameState == AngryBallsEnvironment.GameState.pause)
         {
             gameState = AngryBallsEnvironment.GameState.levelBuilder;
         }
         else
         {
            gameState = AngryBallsEnvironment.GameState.initialize;
            fBrickCreator.Hide();
         }
     }
 }
示例#13
0
        private bool play = false; //Initialize to run state: Currently Playing, display pause icon

        #endregion Fields

        #region Constructors

        public PlayPauseButton(AngryBallsEnvironment.GameState gameState)
        {
            image = Game1.playButtonImage;
            pauseImage = Game1.pauseButtonImage;

            //initialize from gameState
            if(gameState == AngryBallsEnvironment.GameState.pause || gameState == AngryBallsEnvironment.GameState.initialize)
            {
                play = false;
                pause = true;
            }

            position = new Vector2(75, 75);
            size = new Vector2(75, 75);

            dragable = true;
        }
示例#14
0
 public void Toggle(ref AngryBallsEnvironment.GameState gameState)
 {
     if (play)
     {
         play = false;
         pause = true;
         AngryBallsEnvironment.builderButton.SetBuild(true);
         gameState = AngryBallsEnvironment.GameState.pause;
     }
     else if (pause)
     {
         play = true;
         pause = false;
         AngryBallsEnvironment.builderButton.SetBuild(false);
         gameState = AngryBallsEnvironment.GameState.run;
     }
 }
示例#15
0
        public TBoxItem FindClickedObject(MouseState mouseState, AngryBallsEnvironment.GameState gameState)
        {
            // Return Creators if we're in level builder mode
            if (gameState == AngryBallsEnvironment.GameState.levelBuilder)
            {
                if (fixedBrickCreator.isClicked(mouseState))
                {
                    return fixedBrickCreator;
                }

                if (mineCreator.isClicked(mouseState))
                {
                    return mineCreator;
                }
            }

            foreach (Bomb element in TBIList.PlacedBomb)
            {
                if (element.isClicked(mouseState))
                {
                    return element;
                }
            }

            foreach (ProxMine element in TBIList.placedMines)
            {
                if (element.isClicked(mouseState))
                {
                    return element;
                }
            }

            foreach (FixedBrick element in TBIList.FixedBrickList)
            {
                if (element.isClicked(mouseState))
                {
                    return element;
                }
            }

            return null;
        }
示例#16
0
        //Move from env to map?
        public void Draw(SpriteBatch spriteBatch, AngryBallsEnvironment.GameState gameState)
        {
            //Draw Item Creators if we're in LevelBuilder mode
            if (gameState == AngryBallsEnvironment.GameState.levelBuilder)
            {
                fixedBrickCreator.draw(spriteBatch);
                mineCreator.draw(spriteBatch);
            }

            //Draw ToolBox Contents
            foreach (Bomb element in TBIList.PlacedBomb)
            {
                element.draw(spriteBatch);
            }
            foreach (ProxMine element in TBIList.placedMines)
            {
                element.draw(spriteBatch);
            }

            foreach (FixedBrick element in TBIList.FixedBrickList)
            {
                element.draw(spriteBatch);
            }
        }
示例#17
0
        public TBoxItem FindClickedObject(MouseState mouseState, AngryBallsEnvironment.GameState gameState)
        {
            // Return Creators if we're in level builder mode
            if (gameState == AngryBallsEnvironment.GameState.levelBuilder)
            {
                if (fixedBrickCreator.isClicked(mouseState))
                {
                    return fixedBrickCreator;
                }

                if (destructableBrickCreator.isClicked(mouseState))
                {
                    return destructableBrickCreator;
                }

                if (mineCreator.isClicked(mouseState))
                {
                    return mineCreator;
                }

                if (triangleBrickCreator.isClicked(mouseState))
                {
                    return triangleBrickCreator;
                }

                if (destructableTriangleBrickCreator.isClicked(mouseState))
                {
                    return destructableTriangleBrickCreator;
                }

                if (hazardCreator.isClicked(mouseState))
                    return hazardCreator;

            }

            if (gameState == AngryBallsEnvironment.GameState.run)
            {
                foreach (Bomb element in TBIList.PlacedBomb)
                {
                    if (element.isClicked(mouseState))
                    {
                        return element;
                    }
                }

            }

            foreach (ProxMine element in TBIList.unPlacedMines)
            {
                if (element.isClicked(mouseState))
                {
                    return element;
                }
            }

            foreach (FixedBrick element in TBIList.unplacedTriangleBrickList)
            {
                if (element.isClicked(mouseState))
                    return element;
            }

            foreach (FixedBrick element in TBIList.FixedBrickList)
            {
                if (element.isClicked(mouseState))
                {
                    return element;
                }

            }

            foreach (Hazard element in TBIList.hazardList)
            {
                if (element.isClicked(mouseState))
                {
                    return element;
                }
            }

            return null;
        }
示例#18
0
        public void update(AngryBallsEnvironment.GameState gameState)
        {
            if (gameState == AngryBallsEnvironment.GameState.run)
            {
                if (placed)
                {
                    if (!SFX)
                    {
                        bombSFXInstance.Play();
                        SFX = true;
                    }

                    if (gameState == AngryBallsEnvironment.GameState.run)
                        bombSFXInstance.Resume();

                    timer -= 0.025;
                }

                if (timer <= -1)
                {
                    bombSFXInstance.Stop();
                }

                if (timer <= 0)
                {
                    Explode();
                }
            }
            else
                bombSFXInstance.Pause();
        }
示例#19
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            //initialize aspects of the physics engine world
            if (world == null)
            {
                world = new World(Vector2.UnitY * 9.8f);
            }
            else
            {
                world.Clear();
            }

            // Load Audio

            bombExplosion = Content.Load<SoundEffect>("TimeBomb");
            mineExplosion = Content.Load<SoundEffect>("Mine");

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            playButtonImage = Content.Load<Texture2D>("rp_play_icon_2");
            pauseButtonImage = Content.Load<Texture2D>("rp_pause_icon_2");
            ballImage = Content.Load<Texture2D>("rp_ball");
            bombImage = Content.Load<Texture2D>("rp_bomb_1");
            mineImage = Content.Load<Texture2D>("rp_mine_2");
            brickParticleImage = Content.Load<Texture2D>("rp_brick_explode_test_1");
            explodeImage = Content.Load<Texture2D>("rp_bomb_explode_1");
            mineExplodeImage = Content.Load<Texture2D>("rp_mine_explode_1");
            FixedBrickTextureAtlas = Content.Load<Texture2D>("rp_solid_bricks_2");
            DestructableBrickTextureAtlas = Content.Load<Texture2D>("rp_bricks_damaged_3");
            environmentBackground = Content.Load<Texture2D>("rp_background_1");
            toolBoxBackGround = Content.Load<Texture2D>("rp_tool_bar");
            bombTimerFont = Content.Load<SpriteFont>("BombTimer");
            //saveImage = Content.Load<Texture2D>("save");
            borderImage = Content.Load<Texture2D>("rp_border_1");
            clawOpen = Content.Load<Texture2D>("rp_claw_open");
            //bigCog = Content.Load<Texture2D>("rp_big_cog_1");
            builderImage = Content.Load<Texture2D>("BuilderIcon");
            environment = new AngryBallsEnvironment();

            // TODO: use this.Content to load your game content here
        }
示例#20
0
        public void update(AngryBallsEnvironment.GameState gameState)
        {
            if (exploded)
            {
                if (!SFX)
                {
                    mineSFXInstance.Play();
                    SFX = true;
                }

                if (gameState == AngryBallsEnvironment.GameState.run)
                {
                    Explode();
                    mineSFXInstance.Resume();
                }
                else
                    mineSFXInstance.Pause();

            }
        }
示例#21
0
        public TBoxItem FindRightClickedObject(MouseState mouseState, AngryBallsEnvironment.GameState gameState)
        {
            if (gameState == AngryBallsEnvironment.GameState.levelBuilder)
            {
                foreach (ProxMine element in TBIList.placedMines)
                {
                    if (element.isRightClicked(mouseState))
                    {
                        return element;
                    }
                }
            }

            foreach (TBoxItem element in TBIList.FixedBrickList)
            {
                if (element.isRightClicked(mouseState))
                {
                    return element;
                }
            }

            foreach(Hazard element in TBIList.hazardList)
            {
                if (element.isRightClicked(mouseState))
                {
                    return element;
                }
            }

            return null;
        }
示例#22
0
        private void initObject(TBIList tempTBIList, Map map, AngryBallsEnvironment.GameState gameState)
        {
            map.TBIList = tempTBIList;

            if (gameState == AngryBallsEnvironment.GameState.dialog)
                placed = false;
            else
                placed = true;

            foreach (TBoxItem element in map.TBIList.FixedBrickList)
            {
                element.initialize(placed);
            }

            foreach (Bomb element in map.TBIList.PlacedBomb)
            {
                element.initialize(placed);
            }

            foreach (ProxMine element in map.TBIList.placedMines)
            {
                element.initialize(placed);
            }

            foreach (Hazard element in map.TBIList.hazardList)
                element.initialize(placed);

            foreach (ProxMine element in map.TBIList.unPlacedMines)
            {
                element.initialize(false);
            }

            foreach (FixedBrick element in map.TBIList.unplacedTriangleBrickList)
                element.initialize(false);

            map.TBIList.endGoal.initialize(placed);
        }
示例#23
0
        public void Initialize(AngryBallsEnvironment.GameState gameState, string name)
        {
            JSONEditor jsonReader = new JSONEditor();
            jsonReader.ReadLevel(this, name, gameState);

            TBIList.Initialize();
        }
示例#24
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            //initialize aspects of the physics engine world
            //if (world == null)
            //{
            //    world = new World(Vector2.UnitY * 9.8f);
            //}
            //else
            //{
            //    world.Clear();
            //}

            // Load Audio
            bombExplosion = Content.Load<SoundEffect>("TimeBomb");
            mineExplosion = Content.Load<SoundEffect>("Mine");

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //Load Images
            playButtonImage = Content.Load<Texture2D>("rp_play_icon_2");
            pauseButtonImage = Content.Load<Texture2D>("rp_pause_icon_2");
            resetButtonImage = Content.Load<Texture2D>("rp_replay_icon_2");
            builderImage = Content.Load<Texture2D>("rp_hammer_tool");
            saveImage = Content.Load<Texture2D>("rp_save_icon_2");
            loadButtonImage = Content.Load<Texture2D>("load_image_temp");
            ballImage = Content.Load<Texture2D>("rp_angry_ball_new");
            bombImage = Content.Load<Texture2D>("rp_bomb_1");
            mineImage = Content.Load<Texture2D>("rp_mine_2");
            brickParticleImage = Content.Load<Texture2D>("rp_brick_explode_test_1");
            explodeImage = Content.Load<Texture2D>("rp_bomb_explode_1");
            mineExplodeImage = Content.Load<Texture2D>("rp_mine_explode_1");
            FixedBrickTextureAtlas = Content.Load<Texture2D>("rp_solid_bricks_2");
            fixedTriangleBrickImage = Content.Load<Texture2D>("rp_triangle_1");
            DestructableBrickTextureAtlas = Content.Load<Texture2D>("rp_bricks_damaged_3");
            DestructableTriangleBrickImage = Content.Load<Texture2D>("rp_triangle_2");
            DestructableTriangleDamage1 = Content.Load<Texture2D>("rp_triangle_damage_1");
            DestructableTriangleDamage2 = Content.Load<Texture2D>("rp_triangle_damage_2");
            environmentBackground = Content.Load<Texture2D>("rp_background_final");
            toolBoxBackGround = Content.Load<Texture2D>("rp_tool_bar");
            borderImage = Content.Load<Texture2D>("rp_border_1");
            clawOpen = Content.Load<Texture2D>("rp_claw_open");
            bigCog = Content.Load<Texture2D>("rp_big_cog_1");
            endGoalImage = Content.Load<Texture2D>("rp_pipe_end_cropped");
            dialogBkgImage = Content.Load<Texture2D>("dialog_bkg_temp");
            okImage = Content.Load<Texture2D>("ok_temp");
            cancelImage = Content.Load<Texture2D>("cancel_temp");
            hazardImage1 = Content.Load<Texture2D>("rp_blade_1");
            hazardImage2 = Content.Load<Texture2D>("rp_blade_2");
            springImage = Content.Load<Texture2D>("rp_spring_1");
            chickenImage = Content.Load<Texture2D>("rp_chicken");

            //Load Fonts
            bombTimerFont = Content.Load<SpriteFont>("BombTimer");
            WinFont = Content.Load<SpriteFont>("WinFont");
            WinHighlightFont = Content.Load<SpriteFont>("WinHighlightFont");

            environment = new AngryBallsEnvironment();
            // TODO: use this.Content to load your game content here
        }
示例#25
0
        public void update(AngryBallsEnvironment.GameState gameState)
        {
            //update any active Bombs, remove them if they have exploded
            foreach(Bomb element in TBIList.PlacedBomb.Reverse<Bomb>())
            {
                element.update(gameState);
                if (element.IsDestroyed())
                {
                    TBIList.PlacedBomb.Remove(element);
                }
            }
            //update any active mines, remove them if they have exploded
            foreach (ProxMine element in TBIList.placedMines.Reverse<ProxMine>())
            {
                element.update(gameState);
                if (element.IsDestroyed())
                {
                    TBIList.placedMines.Remove(element);
                }
            }

            foreach (ProxMine element in TBIList.unPlacedMines.Reverse<ProxMine>())
            {
                element.update(gameState);
                if (element.IsDestroyed())
                {
                    TBIList.unPlacedMines.Remove(element);
                }
            }

            //Check to see if any bricks have been destroyed, if so, handle it
            foreach (FixedBrick element in TBIList.FixedBrickList.Reverse<FixedBrick>())
            {
                element.Update();
                if (element.IsDestroyed())
                {
                    TBIList.FixedBrickList.Remove(element);
                }
            }

            foreach (DestructableTriangleBrick element in TBIList.unplacedTriangleBrickList.Reverse<FixedBrick>())
            {
                element.Update();
                if (element.IsDestroyed())
                {
                    TBIList.unplacedTriangleBrickList.Remove(element);
                }
            }
        }