Example #1
0
 public void AddAnimation(Drawable sprite_anim, SoundEffect sound)
 {
     SceneUnit temp = new SceneUnit();
     temp.m_sprite = sprite_anim;
     temp.m_sound = sound;
     m_animList.Add(temp);
 }
Example #2
0
 public Blinker(Drawable sprite, Color color, int frames)
     : base(sprite)
 {
     m_color = color;
     m_frames = frames;
     m_init_color = sprite.Tint;
 }
Example #3
0
 public AlphaFader(Drawable sprite, int fade_to, int delta)
     : base(sprite)
 {
     m_delta = delta;
     m_fade_to = fade_to;
     m_init_alpha = Tint.A;
 }
Example #4
0
 public LogXYMover(Drawable sprite, int dst_x, int dst_y)
     : base(sprite)
 {
     m_x_dst = dst_x;
     m_y_dst = dst_y;
     m_init_x = X_Pos;
     m_init_y = Y_Pos;
 }
Example #5
0
        public LinearXYMover(Drawable sprite, int dst_x, int dst_y, float vel_mag)
            : base(sprite)
        {
            m_dst_pos = new Vector2(dst_x,dst_y);
            m_init_pos = new Vector2(X_Pos, Y_Pos);

            m_vel_mag = vel_mag;
        }
Example #6
0
        public DirXYMover(Drawable sprite, int mov_x, int mov_y, float speed)
            : base(sprite)
        {
            m_init_pos.X = sprite.X_Pos;
            m_init_pos.Y = sprite.Y_Pos;

            m_mov_x = mov_x;
            m_mov_y = mov_y;

            m_set_dst = false;

            m_vel_mag = speed;
        }
Example #7
0
 public SpriteDecorator(Drawable sprite)
 {
     m_drawable_sprite = sprite;
     Draw_State = DrawableState.Active;
 }
Example #8
0
 public TimeOutDrawable(Drawable sprite, int ticks, bool draw)
     : base(sprite)
 {
     m_draw = draw;
     m_total_ticks = ticks;
 }
Example #9
0
        public void AddItem(Drawable item, Selected fcn_ptr, string music_name)
        {
            SelectionItem temp = new SelectionItem();
            temp.m_sprite = item;

            m_num_items++;

            if (++m_x == m_columns)
            {
                m_x = 0;
            }

            temp.m_sprite.X_Pos = m_xpos + (m_x * item.Width) + (m_x * m_spacing);
            temp.m_sprite.Y_Pos = m_ypos + (m_y * item.Height) + (m_y * m_spacing);
            // Make the item selectable
            m_grid[m_y, m_x].m_selectable = true;
            m_grid[m_y, m_x].m_list_index = m_num_items - 1;

            Console.WriteLine("Grid[" + m_y + ", " + m_x + "] Set to true");

            // Update rows
            if (m_y != (int)((m_num_items/ m_columns)))
            {
                m_y++;
                m_rows++;
                m_grid = HelperUtils.ResizeArray<GridItem>(m_grid, m_rows, m_columns);

                // Set new constructed row to false
                for (int i = 0; i < m_columns; i++)
                {
                    m_grid[m_rows - 1, i] = new GridItem();
                    m_grid[m_rows - 1, i].m_selectable = false;
                }
            }
            temp.m_music_name = music_name;
            temp.m_fcn_ptr = fcn_ptr;
            temp.m_border = HelperUtils.BuildBorder(new Rectangle((int)temp.m_sprite.X_Pos, (int)temp.m_sprite.Y_Pos, temp.m_sprite.Width, temp.m_sprite.Height), m_border_width);

            if (m_list.Count == 0)
            {
                temp.m_selected = true;
                m_selected_x = 0;
                m_selected_y = 0;
                m_cue = m_soundbank.GetCue(music_name);
            }
            else
            {
                temp.m_selected = false;
            }

            m_list.Add(temp);
        }
Example #10
0
 public void AddAnimation(Drawable sprite_anim)
 {
     SceneUnit temp = new SceneUnit();
     temp.m_sprite = sprite_anim;
     m_animList.Add(temp);
 }
Example #11
0
        public void SetCurrentAnimation(int index)
        {
            m_currAnim = m_animList[index];
            m_currAnim.Reset();
            m_currAnim.X_Pos = m_xpos;
            m_currAnim.Y_Pos = m_ypos;

            if (m_dir == Direction.Right)
            {
                m_currAnim.Effects = SpriteEffects.None;
            }
            else
            {
                m_currAnim.Effects = SpriteEffects.FlipHorizontally;
            }
        }
Example #12
0
 public void AddAnimation(Drawable sprite)
 {
     m_animList.Add(sprite);
 }
Example #13
0
 public TimeOutDrawable(Drawable sprite, int ticks, bool draw) : base(sprite)
 {
     m_draw        = draw;
     m_total_ticks = ticks;
 }
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");

            /*  LOAD TEXTURES, SOUNDS AND FONTS */

            tree = content.Load<Texture2D>("DuckHunt\\Textures\\tree");
            ground = content.Load<Texture2D>("DuckHunt\\Textures\\ground");
            bush = content.Load<Texture2D>("DuckHunt\\Textures\\bush");
            m_player_textures[0] = content.Load<Texture2D>("DuckHunt\\Textures\\panel");
            walkingdog = content.Load<Texture2D>("DuckHunt\\Textures\\walkdog");
            flyawaysign = content.Load<Texture2D>("DuckHunt\\Textures\\flyawaysign");
            m_player_textures[1] = content.Load<Texture2D>("DuckHunt\\Textures\\score");
            m_player_textures[2] = content.Load<Texture2D>("DuckHunt\\Textures\\clouds");
            m_player_textures[3] = content.Load<Texture2D>("DuckHunt\\Textures\\duckcall");
            m_player_textures[4] = content.Load<Texture2D>("DuckHunt\\Textures\\shot");
            clouds[0] = content.Load<Texture2D>("DuckHunt\\Textures\\smallcloud");
            clouds[1] = content.Load<Texture2D>("DuckHunt\\Textures\\medcloud");
            clouds[2] = content.Load<Texture2D>("DuckHunt\\Textures\\bigcloud");

            dogbark = content.Load<SoundEffect>("DuckHunt\\Sounds\\dogbark");
            m_shot = content.Load<SoundEffect>("DuckHunt\\Sounds\\shot");
            startround = content.Load<SoundEffect>("DuckHunt\\Sounds\\startround");
            endround = content.Load<SoundEffect>("DuckHunt\\Sounds\\roundend");
            pause = content.Load<SoundEffect>("DuckHunt\\Sounds\\pause");

            m_num = content.Load<SpriteFont>("Fonts\\bignesfont");
            m_score_fnt = content.Load<SpriteFont>("Fonts\\hugenesfont");

            debug = new Texture2D(ScreenManager.GraphicsDevice, 1, 1);
            debug.SetData(new Color[] { new Color(255, 255, 255) });

            m_clouds_p1 = new Clouds(0, clouds);//, debug);
            m_clouds_p2 = new Clouds(1, clouds);//, debug);
            m_clouds = new Cloud[m_clouds_p1.CloudsA.Length*2];

            m_clouds[0] = m_clouds_p1.CloudsA[0];
            m_clouds[1] = m_clouds_p1.CloudsA[1];
            m_clouds[2] = m_clouds_p1.CloudsA[2];
            m_clouds[3] = m_clouds_p1.CloudsA[0];
            m_clouds[4] = m_clouds_p1.CloudsA[1];
            m_clouds[5] = m_clouds_p1.CloudsA[2];
            m_clouds[6] = m_clouds_p2.CloudsA[0];
            m_clouds[7] = m_clouds_p2.CloudsA[1];
            m_clouds[8] = m_clouds_p2.CloudsA[2];
            m_clouds[9] = m_clouds_p2.CloudsA[0];
            m_clouds[10] = m_clouds_p2.CloudsA[1];
            m_clouds[11] = m_clouds_p2.CloudsA[2];

            /* SETUP ALL ANIMATIONSPRITES */
            wdog.BuildAnimation(walkingdog, 1, 8, true, new int[4] { 1, 2, 3, 4 });
            wdog.SetFrame(0, 8, null);
            wdog.SetFrame(1, 8, null);
            wdog.SetFrame(2, 8, null);
            wdog.SetFrame(3, 8, null);
            wdog.X_Pos = HelperUtils.SafeBoundary.X + 22;
            wdog.Y_Pos = HelperUtils.SafeBoundary.Y + 471;

            sdog.BuildAnimation(walkingdog, 1, 8, true, new int[6] { 1, 0, 1, 0, 1, 0 });
            sdog.SetFrame(0, 8, null);
            sdog.SetFrame(1, 8, null);
            sdog.SetFrame(2, 8, null);
            sdog.SetFrame(3, 8, null);
            sdog.SetFrame(4, 8, null);
            sdog.SetFrame(5, 8, null);

            sprdog.BuildAnimation(walkingdog, 1, 8, true, new int[1] { 5 });
            sprdog.SetFrame(0, 100, null);

            jdog1.BuildAnimation(walkingdog, 1, 8, true, new int[1] { 6 });
            jdog1.SetFrame(0, 1000, dogbark);

            jdog2.BuildAnimation(walkingdog, 1, 8, true, new int[1] { 6 });
            jdog2.SetFrame(0, 50, dogbark);

            jdog3.BuildAnimation(walkingdog, 1, 8, true, new int[1] { 7 });
            jdog3.SetFrame(0, 50, dogbark);

            /*   MAKE INTRO ANIMATION   */
            m_intro.AddAnimation(new DirXYMover(wdog, 180, 0, 1.7f));
            m_intro.AddAnimation(new TimeOutDrawable(sdog, 49, true));
            m_intro.AddAnimation(new DirXYMover(wdog, 180, 0, 1.7f));
            m_intro.AddAnimation(new TimeOutDrawable(sdog, 49, true));
            m_intro.AddAnimation(new DirXYMover(wdog, 10, 0, 1.7f));
            m_intro.AddAnimation(new TimeOutDrawable(sprdog, 49, true));
            m_intro.AddAnimation(new DirXYMover(jdog1, 5, -50, 3.5f));
            m_intro.AddAnimation(new DirXYMover(jdog1, 15, -25, 3.0f));
            m_intro.AddAnimation(new DirXYMover(jdog2, 15, -25, 3.0f));
            m_intro.AddAnimation(new DirXYMover(jdog3, 40, 40, 3.0f));
            m_intro.BuildScene(new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
            m_intro.Scene_State = DrawableState.Active;

            /* Make a texture for bg. NOT gonna be needed when I change the dimension of screen */
            ScreenTexture = new Texture2D(ScreenManager.GraphicsDevice, 1, 1);
            ScreenTexture.SetData(new Color[] { Color.White });

            /* Build the SHOT animations */
            flash = new Texture2D(ScreenManager.GraphicsDevice, 1, 1);
            flash.SetData(new Color[] { new Color(255, 255, 255, 128) });

            m_flash = new TimeOutDrawable(new Image(HelperUtils.SafeBoundary.X, HelperUtils.SafeBoundary.Y, 1024, 612, flash), 3, false);
            m_flash.Draw_State = DrawableState.Finished;

            /* Create Players */
            m_player1 = new DuckHuntPlayer(0);
            m_player1.LoadContent(m_player_textures, m_num, m_score_fnt, boxrec);
            m_player2 = new DuckHuntPlayer(1);
            m_player2.LoadContent(m_player_textures, m_num, m_score_fnt, boxrec);

            newbound = Boundary.CreateBoundRects(boxrec);
            bounddata = new CollisionData[newbound.Length];

            bounddata[0] = new CollisionData(newbound[0]);
            bounddata[1] = new CollisionData(newbound[1]);
            bounddata[2] = new CollisionData(newbound[2]);
            bounddata[3] = new CollisionData(newbound[3]);
            bounddata[4] = new CollisionData(newbound[4]);
            bounddata[5] = new CollisionData(newbound[5]);
            bounddata[6] = new CollisionData(newbound[6]);
            bounddata[7] = new CollisionData(newbound[7]);
            bounddata[8] = new CollisionData(newbound[8]);
            bounddata[9] = new CollisionData(newbound[9]);

            m_ducks = new DuckPopulation(content, bounddata);

            // FLY AWAY SIGN
            m_fly_sign.Texture = flyawaysign;
            m_fly_sign.X_Pos = ScreenManager.GraphicsDevice.Viewport.Width / 2 - m_fly_sign.Texture.Width / 2;
            m_fly_sign.Y_Pos = HelperUtils.SafeBoundary.Y + 256;

            // A real game would probably have more content than this sample, so
            // it would take longer to load. We simulate that by delaying for a
            // while, giving you a chance to admire the beautiful loading screen.
            Thread.Sleep(1000);

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();
        }
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            PlayerIndex playerIndex;

            // Look up inputs for the active player profile.
            //int playerIndex = (int)ControllingPlayer.Value;

            KeyboardState keyboardState1 = input.CurrentKeyboardStates[0];
            GamePadState gamePadState1 = input.CurrentGamePadStates[0];
            KeyboardState keyboardState2 = input.CurrentKeyboardStates[1];
            GamePadState gamePadState2 = input.CurrentGamePadStates[1];

            // The game pauses either if the user presses the pause button, or if
            // they unplug the active gamepad. This requires us to keep track of
            // whether a gamepad was ever plugged in, because we don't want to pause
            // on PC if they are playing with a keyboard and have no gamepad at all!
            bool gamePadDisconnected = !gamePadState1.IsConnected &&
                                       input.GamePadWasConnected[0] &&
                                       !gamePadState2.IsConnected &&
                                       input.GamePadWasConnected[1];

            if ((input.IsPauseGame(null) || gamePadDisconnected) && m_intro.Scene_State == DrawableState.Finished)
            {
                pause.Play();
                m_paused = true;
                ScreenManager.AddScreen(new DuckHuntPauseMenuScreen(this), null);
            }

             // Handle Cloud Input
             // (DuckHuntPlayer 1)
            if ((input.IsNewKeyPress(Keys.D, PlayerIndex.One, out playerIndex) ||
               input.IsNewButtonPress(Buttons.X, PlayerIndex.One, out playerIndex)) &&
               m_intro.Scene_State == DrawableState.Finished &&
               !m_ducks.Intermission() &&
               m_player1.CloudNum != 0 &&
               m_ducks.BallsAlive() &&
               m_clouds_p1.State == DrawableState.Finished)
            {
                m_clouds_p1.Reset();

                m_player1.CloudNum -= 1;
            }

            // (DuckHuntPlayer 2)
            if ((input.IsNewKeyPress(Keys.OemComma, PlayerIndex.Two, out playerIndex) ||
                input.IsNewButtonPress(Buttons.X, PlayerIndex.Two, out playerIndex)) &&
                m_intro.Scene_State == DrawableState.Finished &&
                !m_ducks.Intermission() &&
                m_player2.CloudNum != 0 &&
                m_ducks.BallsAlive()  &&
                m_clouds_p2.State == DrawableState.Finished)
            {
                m_clouds_p2.Reset();

                m_player2.CloudNum -= 1;
            }

            // Handle Duck Calls
            // (DuckHuntPlayer 1)
            if ((input.IsNewKeyPress(Keys.F, PlayerIndex.One, out playerIndex) ||
                input.IsNewButtonPress(Buttons.Y, PlayerIndex.One, out playerIndex)) &&
                m_intro.Scene_State == DrawableState.Finished &&
                !m_ducks.Intermission() &&
                m_player1.DuckCallNum != 0 &&
                m_ducks.OneBallAlive())
            {
                m_ducks.ReleaseDuck();
                // Play duck call sound
                m_player1.DuckCallNum -= 1;
            }

            // (DuckHuntPlayer 2)
            if ((input.IsNewKeyPress(Keys.OemPeriod, PlayerIndex.Two, out playerIndex) ||
                input.IsNewButtonPress(Buttons.Y, PlayerIndex.Two, out playerIndex)) &&
                m_intro.Scene_State == DrawableState.Finished &&
                !m_ducks.Intermission() &&
                m_player2.DuckCallNum != 0 &&
                m_ducks.OneBallAlive())
            {
                m_ducks.ReleaseDuck();
                // Play duck call sound
                m_player2.DuckCallNum -= 1;
            }

            // Handle Shot Input
            // (DuckHuntPlayer 1)
            if ((input.IsNewKeyPress(Keys.G, PlayerIndex.One, out playerIndex) ||
               input.IsNewButtonPress(Buttons.B, PlayerIndex.One, out playerIndex)) &&
                m_intro.Scene_State == DrawableState.Finished &&
                !m_ducks.Intermission() &&
                m_player1.ShotNum != 0 &&
                m_ducks.BallsAlive())
            {
                if (m_ducks.DuckOneState == BallState.Active)
                {
                    m_ducks.DuckOneXVelocity *= -1.5f;
                    m_ducks.DuckOneYVelocity *= 1.5f;
                    m_ducks.DuckOneHit = Direction.None;
                    if (m_ducks.DuckOneDir == Direction.Right)
                    {
                        m_ducks.DuckOneDir = Direction.Left;
                    }
                    else if (m_ducks.DuckOneDir == Direction.Left)
                    {
                        m_ducks.DuckOneDir = Direction.Right;
                    }

                    m_duck1_flash = new TimeOutDrawable(new Image(m_ducks.DuckOneRectangle.X,
                                                              m_ducks.DuckOneRectangle.Y,
                                                              40, 40, flash), 5, false);
                }

                if (m_ducks.DuckTwoState == BallState.Active)
                {
                    m_ducks.DuckTwoXVelocity *= -1.5f;
                    m_ducks.DuckTwoYVelocity *= 1.5f;
                    m_ducks.DuckTwoHit = Direction.None;
                    if (m_ducks.DuckTwoDir == Direction.Right)
                    {
                        m_ducks.DuckTwoDir = Direction.Left;
                    }
                    else if (m_ducks.DuckTwoDir == Direction.Left)
                    {
                        m_ducks.DuckTwoDir = Direction.Right;
                    }

                    m_duck2_flash = new TimeOutDrawable(new Image(m_ducks.DuckTwoRectangle.X,
                                                              m_ducks.DuckTwoRectangle.Y,
                                                              40, 40, flash), 8, false);
                }
                m_duck1_flash.Tint = new Color(255, 255, 255, 128);
                m_duck2_flash.Tint = new Color(255, 255, 255, 128);
                m_flash.Reset();
                m_player1.ShotNum -= 1;
                m_shot.Play();
            }

            // (DuckHuntPlayer 2)
            if ((input.IsNewKeyPress(Keys.OemQuestion, PlayerIndex.Two, out playerIndex) ||
                input.IsNewButtonPress(Buttons.B, PlayerIndex.Two, out playerIndex)) &&
                m_intro.Scene_State == DrawableState.Finished &&
                !m_ducks.Intermission() &&
                m_player2.ShotNum != 0 &&
                m_ducks.BallsAlive())
            {
                if (m_ducks.DuckOneState == BallState.Active)
                {
                    m_ducks.DuckOneXVelocity *= -1.5f;
                    m_ducks.DuckOneYVelocity *= 1.5f;
                    m_ducks.DuckOneHit = Direction.None;
                    if (m_ducks.DuckOneDir == Direction.Right)
                    {
                        m_ducks.DuckOneDir = Direction.Left;
                    }
                    else if (m_ducks.DuckOneDir == Direction.Left)
                    {
                        m_ducks.DuckOneDir = Direction.Right;
                    }

                    m_duck1_flash = new TimeOutDrawable(new Image(m_ducks.DuckOneRectangle.X,
                                                              m_ducks.DuckOneRectangle.Y,
                                                              40, 40, flash), 8, false);
                }

                if (m_ducks.DuckTwoState == BallState.Active)
                {
                    m_ducks.DuckTwoXVelocity *= -1.5f;
                    m_ducks.DuckTwoYVelocity *= 1.5f;
                    m_ducks.DuckTwoHit = Direction.None;
                    if (m_ducks.DuckTwoDir == Direction.Right)
                    {
                        m_ducks.DuckTwoDir = Direction.Left;
                    }
                    else if (m_ducks.DuckTwoDir == Direction.Left)
                    {
                        m_ducks.DuckTwoDir = Direction.Right;
                    }
                    m_duck2_flash = new TimeOutDrawable(new Image(m_ducks.DuckTwoRectangle.X,
                                                              m_ducks.DuckTwoRectangle.Y,
                                                              40, 40, flash), 8, false);
                }
                m_duck1_flash.Tint = new Color(255, 255, 255, 128);
                m_duck2_flash.Tint = new Color(255, 255, 255, 128);
                m_flash.Reset();
                m_shot.Play();
                m_player2.ShotNum -= 1;
            }

            if (m_intro.Scene_State == DrawableState.Finished)
            {
                m_player1.UpdatePaddle(keyboardState1, gamePadState1, m_clouds_p2.CloudsA);
                m_player2.UpdatePaddle(keyboardState2, gamePadState2, m_clouds_p1.CloudsA);
            }
        }