private void AddExplosion(Vector2 position, int xOffset, int yOffset, float velocity, int animationSpeedMS)
        {
            position.X += xOffset;
            position.Y += yOffset;

            Explosion ex = new Explosion ();
            ex.Initialize (Graphics.Explosion, position, velocity, animationSpeedMS);
            explosions.Add (ex);
            Sound.SFX_Explosion.Play ();
        }
예제 #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]);
                        }
                    }
                }
            };
        }