Exemple #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()
 {
     graphics.PreferredBackBufferHeight = 288;
     graphics.PreferredBackBufferWidth  = 320;
     graphics.ApplyChanges();
     scale = MathHelper.Min(scaleX, scaleY);
     #region Levels
     allNPCS    = npcs.AllNPCS;
     allObjects = objects.AllObjects;
     Levels     = new Dictionary <string, Level>();
     area1      = new Level("area1", true, allNPCS["area1"]);
     area2      = new Level("area2", true, allNPCS["area2"]);
     area3      = new CollectionQuest("area3", false, allNPCS["area3"], allObjects["testQuestObjects"]);
     area4      = new ShootingQuest("area1", true, new Dictionary <string, NPC>(), allObjects["testShootingObjects"]);
     area5      = new Level("area4", true, allNPCS["area5"]);
     Levels.Add("area1", area1);
     Levels.Add("area2", area2);
     Levels.Add("area3", area3);
     Levels.Add("area4", area4);
     Levels.Add("area5", area5);
     #endregion
     player = new Player(new Vector2(41, 108));
     base.Initialize();
 }
        public void Update(GameTime gT, Player p, GamePadState gP, KeyboardState kB, ShootingQuest lvl, Game1 game, Dictionary <string, Object> targets, Matrix cam)
        {
            #region Mouse
            mS       = Mouse.GetState(game.Window);
            mP       = new Vector2(mS.X, mS.Y);
            mPTarget = new Vector2(mS.X - 16, mS.Y - 32);
            mPTarget = Vector2.Transform(mPTarget, Matrix.Invert(cam));
            #endregion
            #region Shooting
            if (mS.LeftButton == ButtonState.Pressed && mSP.LeftButton == ButtonState.Released && !shot)
            {
                if (bCount > 0)
                {
                    foreach (KeyValuePair <string, Object> tgt in targets)
                    {
                        tgt.Value.Update(gT, p, gP, kB, game, lvl, mPTarget);
                    }
                    shot = true;
                    revolverShoot.FrameIndex = 0;
                    bCount--;
                    Debug.WriteLine("Bang!" + " Rounds Left: " + bCount);
                }
                else
                {
                    Debug.WriteLine("OUT OF AMMO");
                }
            }

            if (mS.RightButton == ButtonState.Pressed && bCount == 0)
            {
                bCount = 6;
                Debug.WriteLine("RELOAD");
            }
            #endregion
            mSP = mS;
        }
Exemple #3
0
 public virtual void Update(GameTime gT, Player p, GamePadState gP, KeyboardState kB, Game1 game, ShootingQuest lvl, Vector2 mP)
 {
 }
Exemple #4
0
        public override void Update(GameTime gT, Player p, GamePadState gP, KeyboardState kB, Game1 game, ShootingQuest lvl, Vector2 mP)
        {
            Vector2 vect = pos - mP;
            float   dist = vect.Length();

            if (dist <= 5.0f && !isHit)
            {
                isHit = true;
                lvl.HitCount++;
            }
        }