Exemplo n.º 1
0
 private void Form1_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         if (Zbran)
         {
             if (hrac.Mana > 0)
             {
                 Projectile projectile = new Projectile();
                 projectile.Strelba(Player, this, e.X);
                 hrac.Mana -= 20;
             }
         }
         else
         {
             if (!AtckTmr.Enabled)
             {
                 Melee weapon = new Melee();
                 weapon.Utok(Player, this, e.X);
                 Atck = 0;
                 AtckTmr.Start();
             }
         }
     }
 }
Exemplo n.º 2
0
 private void AtckTmr_Tick(object sender, EventArgs e)
 {
     Atck++;
     if (!(Atck < 30))
     {
         foreach (PictureBox weapon in Controls)
         {
             if ((string)weapon.Tag == "Weapon")
             {
                 Controls.Remove(weapon);
                 zasah = false;
                 AtckTmr.Stop();
             }
         }
     }
     else
     {
         if (Left && collision.CollisionRight(Player, Controls))
         {
             foreach (PictureBox weapon in Controls)
             {
                 if ((string)weapon.Tag == "Weapon")
                 {
                     weapon.Left -= PlayerSpeed;
                 }
             }
         }
         if (Right && collision.CollisionLeft(Player, Controls))
         {
             foreach (PictureBox weapon in Controls)
             {
                 if ((string)weapon.Tag == "Weapon")
                 {
                     weapon.Left += PlayerSpeed;
                 }
             }
         }
     }
     foreach (PictureBox weapon in Controls)
     {
         if ((string)weapon.Tag == "Weapon" && !zasah)
         {
             foreach (PictureBox npc in Controls)
             {
                 if ((string)npc.Tag == "npc" && weapon.Bounds.IntersectsWith(npc.Bounds))
                 {
                     Zasah(npc);
                     zasah = true;
                 }
             }
         }
     }
 }