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); 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 GetX() { if (Ship != null) { return(Ship.GetX()); } return(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; }
public void Backward(double amount) { if (Ship != null) { MoveAction ma = new MoveAction(Ship.GetX(), Ship.GetY(), amount, false, 2); if (IsEvent) { AddEvent(ma); } else { AddAction(ma); } } }
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; }