예제 #1
0
 public override void Update(Karta karta)
 {
     CheckWallCollision(karta);
     Move();
     //Attack
     if (Mouse.GetState().LeftButton == ButtonState.Pressed && attackDelay <= 0)
     {
         Attack();
         attackDelay = 20;
     }
     attackDelay--;
     for (int i = 0; i < projectileList.Count; i++)
     {
         projectileList[i].Update(karta);
         if (projectileList[i].IsDead)
         {
             projectileList.RemoveAt(i);
         }
     }
     if (Keyboard.GetState().IsKeyDown(Keys.P))
     {
         SaveData();
     }
     base.Update(karta);
 }
예제 #2
0
 private void CheckWallCollision(Karta karta)
 {
     collisionDir = CollisionDir.None;
     foreach (Grid grid in karta.gridArray)
     {
         if (hitbox.Intersects(grid.GridBox) && grid.isSolid)
         {
             direction.X = -direction.X;
             direction.Y = -direction.Y;
             break;
         }
     }
 }
예제 #3
0
 public override void Update(Karta karta)
 {
     move = true;
     CheckWallCollision(karta);
     Move();
     if (dirTime <= 0)
     {
         Direction();
         dirTime = defaultDirTime;
     }
     dirTime--;
     base.Update(karta);
 }
예제 #4
0
 //Wall collision
 public void ShotToWallCollision(Karta karta)
 {
     foreach (Grid grid in karta.gridArray)
     {
         Rectangle tempHitbox = Hitbox;
         if (tempHitbox.Intersects(grid.GridBox) && grid.isSolid && BounceTimes != 0)
         {
             Bounce(grid.GridBox);
         }
         else if (tempHitbox.Intersects(grid.GridBox) && grid.isSolid && BounceTimes <= 0)
         {
             IsDead = true;
             break;
         }
     }
 }
예제 #5
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();
     IsMouseVisible = true;
     karta          = new Karta(kartaTex, new Vector2(0, 0), stenTex, markTex);
     window         = Window.ClientBounds;
     rng            = new Random();
     spawnTimer     = 60;
     br             = new BinaryReader(new FileStream("scoretable.dat", FileMode.OpenOrCreate, FileAccess.Read));
     enemyHP        = 1;
     while (br.BaseStream.Position != br.BaseStream.Length)
     {
         scoretable.Add(br.ReadInt32());
     }
     br.Close();
 }
예제 #6
0
 private void CheckWallCollision(Karta karta)
 {
     collisionDir = CollisionDir.None;
     foreach (Grid grid in karta.gridArray)
     {
         //Check wall collision
         if (Keyboard.GetState().IsKeyDown(Keys.W))
         {
             hitboxTemp = new Rectangle((int)position.X, (int)(position.Y - speed), size, size);
             if (hitboxTemp.Intersects(grid.GridBox) && grid.isSolid)
             {
                 collisionDir |= CollisionDir.North;
             }
         }
         if (Keyboard.GetState().IsKeyDown(Keys.A))
         {
             hitboxTemp = new Rectangle((int)(position.X - speed), (int)position.Y, size, size);
             if (hitboxTemp.Intersects(grid.GridBox) && grid.isSolid)
             {
                 collisionDir |= CollisionDir.West;
             }
         }
         if (Keyboard.GetState().IsKeyDown(Keys.S))
         {
             hitboxTemp = new Rectangle((int)position.X, (int)(position.Y + speed), size, size);
             if (hitboxTemp.Intersects(grid.GridBox) && grid.isSolid)
             {
                 collisionDir |= CollisionDir.South;
             }
         }
         if (Keyboard.GetState().IsKeyDown(Keys.D))
         {
             hitboxTemp = new Rectangle((int)(position.X + speed), (int)position.Y, size, size);
             if (hitboxTemp.Intersects(grid.GridBox) && grid.isSolid)
             {
                 collisionDir |= CollisionDir.East;
             }
         }
     }
 }
예제 #7
0
 public override void Update(Karta karta)
 {
     base.Update(karta);
     ShotToWallCollision(karta);
 }
예제 #8
0
 //Förflyttar projectile
 public virtual void Move(Karta karta)
 {
     pos += direction * speed;
 }
예제 #9
0
 public virtual void Update(Karta karta)
 {
     Move(karta);
     Hitbox = new Rectangle((int)pos.X, (int)pos.Y, size, size);
 }
예제 #10
0
 public virtual void Update(Karta karta)
 {
     hitbox = new Rectangle((int)position.X, (int)position.Y, size, size);
 }