Ejemplo n.º 1
0
 private void Field_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (thread == null)
     {
         you.nextPos.x = (float)Mouse.GetPosition(field).X;
         you.nextPos.y = (float)Mouse.GetPosition(field).Y;
         you.Normalize();
         CreateYourDirection(you.nextPos);
     }
     else
     {
         if (!thread.IsAlive)
         {
             you.nextPos.x = (float)Mouse.GetPosition(field).X;
             you.nextPos.y = (float)Mouse.GetPosition(field).Y;
             you.Normalize();
             CreateYourDirection(you.nextPos);
             fps.Continue();
         }
         else
         {
             you.nextPos.x = (float)Mouse.GetPosition(field).X;
             you.nextPos.y = (float)Mouse.GetPosition(field).Y;
             you.Normalize();
             CreateYourDirection(you.nextPos);
         }
     }
 }
Ejemplo n.º 2
0
        public void GenerateAction()
        {
            action = () =>
            {
                Title              = you.FirstCooldown.ToString() + " " + you.SecondCooldown.ToString() + " " + you.Health.ToString() + " " + enemy.Health.ToString();
                FirstSkillCD.Text  = (you.FirstCooldown / 20).ToString();
                SecondSkillCD.Text = (you.SecondCooldown / 20).ToString();
                you.Move(1);

                if (enemy.nextPos.x != Network.enemyPos.x || enemy.nextPos.y != Network.enemyPos.y)
                {
                    enemy.nextPos.x = Network.enemyPos.x;
                    enemy.nextPos.y = Network.enemyPos.y;
                    enemy.Normalize();
                }
                enemy.Move(1);



                for (int i = 0; i < skills.Count; i++)
                {
                    if (skills[i].GetType() == typeof(Bullet))
                    {
                        if (skills[i].isYour)
                        {
                            if (Lenght(skills[i].center, enemy.center) <= RadSum(skills[i].Radius, enemy.Radius))
                            {
                                if (skills[i].CanDamage)
                                {
                                    enemy.Health       -= skills[i].Damage;
                                    skills[i].CanDamage = false;
                                    Ellipse a = new Ellipse();
                                    a.Width  = 2;
                                    a.Height = 2;
                                    a.Fill   = Brushes.Gray;
                                    Canvas.SetLeft(a, skills[i].center.x);
                                    Canvas.SetTop(a, skills[i].center.y);
                                    field.Children.Add(a);
                                }
                            }
                        }
                    }
                    else if (skills[i].GetType() == typeof(Explosion))
                    {
                        if (skills[i].isYour)
                        {
                            if (Lenght(skills[i].center, enemy.center) <= RadSum(skills[i].Radius, enemy.Radius))
                            {
                                enemy.Health       -= skills[i].Damage;
                                skills[i].CanDamage = false;
                                Ellipse a = new Ellipse();
                                a.Width  = 4;
                                a.Height = 4;
                                a.Fill   = Brushes.DarkGray;
                                Canvas.SetLeft(a, skills[i].center.x);
                                Canvas.SetTop(a, skills[i].center.y);
                                field.Children.Add(a);
                            }
                        }
                    }


                    if (!skills[i].Move(1))
                    {
                        if (skills[i].GetType() == typeof(Bullet))
                        {
                            field.Children.Remove(skills[i].Shape);
                            Skill t = new Explosion(skills[i].NextPos, true);
                            skills.Add(t);
                            field.Children.Add(t.Shape);
                            skills[i] = null;
                            skills.Remove(skills[i]);
                        }
                        else if (skills[i].GetType() == typeof(Explosion))
                        {
                            field.Children.Remove(skills[i].Shape);
                            skills[i] = null;
                            skills.Remove(skills[i]);
                        }
                        else if (skills[i].GetType() == typeof(Blink))
                        {
                            field.Children.Remove(skills[i].Shape);
                            skills[i] = null;
                            skills.Remove(skills[i]);
                        }
                    }
                }
            };
        }