Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Upgrade"/> class.
 /// </summary>
 /// <param name="player">The player.</param>
 /// <param name="location">The location.</param>
 /// <param name="name">The name.</param>
 public Upgrade(Player player, Vector2 location, string name, int maximumLevel)
 {
     this.player = player;
     this.maximumLevel = maximumLevel;
     setLocation(location);
     Name = name;
 }
 /// <summary>
 /// Collisions the specified entity.
 /// </summary>
 /// <param name="player">The player.</param>
 /// <param name="npc">The NPC.</param>
 /// <returns></returns>
 public static bool collision(Player player, NPC npc)
 {
     if (npc.visible) {
         if (npc.attacking) //Waarom controleren op collision als ie toch stilstaat...
         {
             TimeSpan hitTimePassed = DateTime.Now - npc.lastHit;
             if (hitTimePassed.TotalMilliseconds >= npc.definition.attackSpeed)
             {
                 if (player.electricWallTimer > 0)
                 {
                     npc.hit(new Hit(npc, player, player.Damage));
                 }
                 player.hit(new Hit(player, npc, GameWorld.random.Next(1, npc.Damage)));
                 npc.lastHit = DateTime.Now;
             }
             return true;
         }
         GifAnimation mainTexture = npc.definition.mainTexture;
         Rectangle npcRectangle = new Rectangle(npc.getX(), npc.getY(), mainTexture.Width, mainTexture.Height);
         Rectangle wallRectangle = new Rectangle(player.Wall.getX(), player.Wall.getY(), player.Wall.definition.mainTexture.Width, player.Wall.definition.mainTexture.Height);
         if (intersects(npcRectangle, wallRectangle) && (npc.getX() >= (player.Wall.getX() + player.Wall.definition.mainTexture.Width / 2) - npc.definition.mainTexture.Width))
         {
             Matrix npcMatrix = Matrix.CreateTranslation(npc.getX(), npc.getY(), 0);
             Matrix wallMatrix = Matrix.CreateTranslation(player.Wall.getX(), player.Wall.getY(), 0);
             Vector2 collision = texturesCollide(player.Wall.definition.pixels, wallMatrix, npc.definition.pixels, npcMatrix);
             if (collision.X != -1 && collision.Y != -1)
             {
                 TimeSpan hitTimePassed = DateTime.Now - npc.lastHit;
                 if (hitTimePassed.TotalMilliseconds >= npc.definition.attackSpeed)
                 {
                     if (player.electricWallTimer > 0)
                     {
                         npc.hit(new Hit(npc, player, player.Damage));
                     }
                     player.hit(new Hit(player, npc, GameWorld.random.Next(1, npc.Damage)));
                     npc.attacking = true;
                     npc.lastHit = DateTime.Now;
                 }
                 return true;
             }
         }
     }
     return false;
 }
Example #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()
 {
     player = new Player(); //Voor crosshair
     //animation = Content.Load<GifAnimation>("wolfanim");
     highScores.LoadContent();
     arduino.connect();
     playerUpdate.start();
     npcUpdate.start();
     CleanUp.INSTANCE.start();
 }
Example #4
0
 /// <summary>
 /// Creates a new game.
 /// </summary>
 public void newGame()
 {
     inGameMusic = new Audio("achtergrond muziek", true);
     EnterFistBoss = new Audio("jiminy_christmas", false);
     defeatBoss = new Audio("time_for_upgrades", false);
     defeatBoss2 = new Audio("take_care_of_things", false);
     youDie = new Audio("dills_my_pickle", false);
     enterSecondBoss = new Audio("son_of_a_gun", false);
     enterThirdBoss = new Audio("herd_of_turtles", false);
     player = new Player();
     time.Reset();
     time.Start();
     IManager.gameOverInterface.gameWon = false;
     lock (npcs)
     {
         npcs.Clear();
     }
     //Reset all levels.
     int level = 1;
     LevelInformation levelInfo = LevelInformation.forValue(level);
     while (levelInfo != null)
     {
         levelInfo.Reset();
         level++;
         levelInfo = LevelInformation.forValue(level);
     }
     gameMap.ClearProjectiles(); //Remove existing projectiles.
     gameMap.LoadGameObjects(); //Reload game objects.
     inGameMusic.PlaySound();
 }