Esempio n. 1
0
        public override void Execute(Ship ship)
        {
            if (!Completed)
            {
                base.Execute(ship);

                if (Math.Round(ship.GetAngle()) == Math.Round(EndValue))
                {
                    Completed = true;
                }
                else
                {
                    if (Clockwise)
                    {
                        ship.UpdateAngle(1);
                    }
                    else
                    {
                        ship.UpdateAngle(-1);
                    }

                    double angle = ship.GetAngle();
                    if (angle < 0)
                    {
                        angle = 360;
                    }
                    if (angle > 360)
                    {
                        angle = 0;
                    }
                    ship.SetAngle(angle);
                }
            }
        }
Esempio n. 2
0
        public override void Execute(Ship ship)
        {
            if (!Completed)
            {
                base.Execute(ship);

                double angle    = ship.GetAngle();
                double radangle = (angle - 90) * 0.017453292519943295769236907684886;
                double xdir     = Math.Cos(radangle);
                double ydir     = Math.Sin(radangle);

                if (Forward)
                {
                    ship.UpdatePosition(xdir * Speed, ydir * Speed);
                }
                else
                {
                    ship.UpdatePosition(xdir * -Speed, ydir * -Speed);
                }

                if (ship.GetX() < MainWindow._instance.WindowXOffset ||
                    ship.GetX() > MainWindow._instance.WindowWidthOffset - ship.Width ||
                    ship.GetY() < MainWindow._instance.WindowYOffset ||
                    ship.GetY() > MainWindow._instance.WindowHeightOffset - ship.Height)
                {
                    Completed = true;
                    if (ship.GetX() < MainWindow._instance.WindowXOffset)
                    {
                        ship.SetX(MainWindow._instance.WindowXOffset);
                        ship.Commander.ExecuteOnCollideWithLeft();
                    }
                    else
                    if (ship.GetX() > MainWindow._instance.WindowWidthOffset - ship.Width)
                    {
                        ship.SetX(MainWindow._instance.WindowWidthOffset - ship.Width);
                        ship.Commander.ExecuteOnCollideWithRight();
                    }
                    else
                    if (ship.GetY() < MainWindow._instance.WindowYOffset)
                    {
                        ship.SetY(MainWindow._instance.WindowYOffset);
                        ship.Commander.ExecuteOnCollideWithTop();
                    }
                    else
                    if (ship.GetY() > MainWindow._instance.WindowHeightOffset - ship.Height)
                    {
                        ship.SetY(MainWindow._instance.WindowHeightOffset - ship.Height);
                        ship.Commander.ExecuteOnCollideWithBottom();
                    }
                }

                ElapsedTime++;
                if (ElapsedTime >= Amount)
                {
                    Completed = true;
                }
            }
        }
        public double GetAngle()
        {
            if (Ship != null)
            {
                return(Ship.GetAngle());
            }

            return(0);
        }
Esempio n. 4
0
        public override void Execute(Ship ship)
        {
            base.Execute(ship);
            if (ship != null)
            {
                if (Type == 0 && ship.CanFireBullet)
                {
                    ship.CanFireBullet = false;
                    Bullet b = new Bullet("Data\\Ships\\bullet1.png", ship.GetX() + ship.Width / 2 - 15, ship.GetY() + ship.Height / 2 - 15, ship);
                    b.SetAngle(ship.GetAngle());
                    b.Speed     = 5;
                    b.Damage    = 5;
                    b.drawOrder = ship.DrawOrder + 100;
                    MainWindow._instance.AddedComponents.Add(b);
                }
                else
                if (Type == 1 && ship.CanFirePlasma)
                {
                    ship.CanFirePlasma = false;
                    Bullet b = new Bullet("Data\\Ships\\bullet2.png", ship.GetX() + ship.Width / 2 - 18, ship.GetY() + ship.Height / 2 - 18, ship);
                    b.SetAngle(ship.GetAngle());
                    b.Speed     = 6;
                    b.Damage    = 10;
                    b.drawOrder = ship.DrawOrder + 100;
                    MainWindow._instance.AddedComponents.Add(b);
                }
                else
                if (Type == 2 && ship.CanFireMissile)
                {
                    ship.CanFireMissile = false;
                    Bullet b = new Bullet("Data\\Ships\\bullet3.png", ship.GetX() + ship.Width / 2 - 15, ship.GetY() + ship.Height / 2 - 21, ship);
                    b.SetAngle(ship.GetAngle());
                    b.Speed     = 4;
                    b.Damage    = 15;
                    b.drawOrder = ship.DrawOrder + 100;
                    MainWindow._instance.AddedComponents.Add(b);
                }
            }

            Completed = true;
        }
Esempio n. 5
0
        public override void Execute(Ship ship)
        {
            base.Execute(ship);
            if (ship != null)
            {
                if (Type == 0 && ship.CanFireBullet)
                {
                    ship.CanFireBullet = false;
                    Bullet b = new Bullet("Data\\Ships\\bullet1.png", ship.GetX() + ship.Width / 2 - 15, ship.GetY() + ship.Height / 2 - 15, ship);
                    b.SetAngle(ship.GetAngle());
                    b.Speed = 5;
                    b.Damage = 5;
                    b.drawOrder = ship.DrawOrder + 100;
                    MainWindow._instance.AddedComponents.Add(b);
                }
                else
                    if (Type == 1 && ship.CanFirePlasma)
                    {
                        ship.CanFirePlasma = false;
                        Bullet b = new Bullet("Data\\Ships\\bullet2.png", ship.GetX() + ship.Width / 2 - 18, ship.GetY() + ship.Height / 2 - 18, ship);
                        b.SetAngle(ship.GetAngle());
                        b.Speed = 6;
                        b.Damage = 10;
                        b.drawOrder = ship.DrawOrder + 100;
                        MainWindow._instance.AddedComponents.Add(b);
                    }
                    else
                        if (Type == 2 && ship.CanFireMissile)
                        {
                            ship.CanFireMissile = false;
                            Bullet b = new Bullet("Data\\Ships\\bullet3.png", ship.GetX() + ship.Width / 2 - 15, ship.GetY() + ship.Height / 2 - 21, ship);
                            b.SetAngle(ship.GetAngle());
                            b.Speed = 4;
                            b.Damage = 15;
                            b.drawOrder = ship.DrawOrder + 100;
                            MainWindow._instance.AddedComponents.Add(b);
                        }
            }

            Completed = true;
        }
Esempio n. 6
0
        public override void Execute(Ship ship)
        {
            if (!Completed)
            {
                base.Execute(ship);

                double angle = ship.GetAngle();
                double radangle = (angle - 90) * 0.017453292519943295769236907684886;
                double xdir = Math.Cos(radangle);
                double ydir = Math.Sin(radangle);

                if (Forward)
                    ship.UpdatePosition(xdir * Speed, ydir * Speed);
                else
                    ship.UpdatePosition(xdir * -Speed, ydir * -Speed);

                if (ship.GetX() < MainWindow._instance.WindowXOffset ||
                    ship.GetX() > MainWindow._instance.WindowWidthOffset-ship.Width ||
                    ship.GetY() < MainWindow._instance.WindowYOffset ||
                    ship.GetY() > MainWindow._instance.WindowHeightOffset-ship.Height)
                {
                    Completed = true;
                    if (ship.GetX() < MainWindow._instance.WindowXOffset)
                    {
                        ship.SetX(MainWindow._instance.WindowXOffset);
                        ship.Commander.ExecuteOnCollideWithLeft();
                    }
                    else
                    if (ship.GetX() > MainWindow._instance.WindowWidthOffset - ship.Width)
                    {
                        ship.SetX(MainWindow._instance.WindowWidthOffset - ship.Width);
                        ship.Commander.ExecuteOnCollideWithRight();
                    }
                    else
                    if (ship.GetY() < MainWindow._instance.WindowYOffset)
                    {
                        ship.SetY(MainWindow._instance.WindowYOffset);
                        ship.Commander.ExecuteOnCollideWithTop();
                    }
                    else
                    if (ship.GetY() > MainWindow._instance.WindowHeightOffset - ship.Height)
                    {
                        ship.SetY(MainWindow._instance.WindowHeightOffset - ship.Height);
                        ship.Commander.ExecuteOnCollideWithBottom();
                    }
                }

                ElapsedTime++;
                if (ElapsedTime >= Amount)
                    Completed = true;
            }
        }
        public override void Execute(Ship ship)
        {
            if (!Completed)
            {
                base.Execute(ship);

                if (Math.Round(ship.GetAngle()) == Math.Round(EndValue))
                    Completed = true;
                else
                {
                    if (Clockwise)
                        ship.UpdateAngle(1);
                    else
                        ship.UpdateAngle(-1);

                    double angle = ship.GetAngle();
                    if (angle < 0) angle = 360;
                    if (angle > 360) angle = 0;
                    ship.SetAngle(angle);
                }
            }
        }
 /// <summary>
 ///  Rotates a ship anti-clockwise to the specified angle
 /// </summary>
 /// <param name="angle"> The angle to rotate to.</param>
 public void RotateLeft(double angle)
 {
     if (Ship != null)
     {
         RotateAction ra = new RotateAction(Ship.GetAngle(), angle, false);
         if (IsEvent)
         {
             AddEvent(ra);
         }
         else
         {
             AddAction(ra);
         }
     }
 }
Esempio n. 9
0
        public override void Execute(Ship ship)
        {
            base.Execute(ship);
            if (ship != null && ship.CanScan)
            {
                ship.CanScan = false;
                Bullet b = new Bullet("Data\\scanBullet.png", ship.GetX() + ship.Width / 2 - 30, ship.GetY() + ship.Height / 2 - 5, ship);
                b.SetAngle(ship.GetAngle());
                b.Speed     = 15;
                b.drawOrder = 250;
                b.IsScanner = true;
                MainWindow._instance.AddedComponents.Add(b);
            }

            Completed = true;
        }
Esempio n. 10
0
        public override void Execute(Ship ship)
        {
            base.Execute(ship);
            if (ship != null && ship.CanScan)
            {
                ship.CanScan = false;
                Bullet b = new Bullet("Data\\scanBullet.png", ship.GetX() + ship.Width / 2 - 30, ship.GetY() + ship.Height / 2 - 5, ship);
                b.SetAngle(ship.GetAngle());
                b.Speed = 15;
                b.drawOrder = 250;
                b.IsScanner = true;
                MainWindow._instance.AddedComponents.Add(b);
            }

            Completed = true;
        }