void DelayedAddShip(object oship) { IShip oldShip = (IShip)oship; Thread.Sleep(VictorySongWait); ShipSounds Victor = null; if (Array.IndexOf <string>(SuicideShipNames, oldShip.GetType().Name) != -1) { Victor = oldShip.ShipSounds; } foreach (IShip ship in GetShips()) { if (!ship.IsExpired) { if ((ship.FactionInfo.FactionCollection.GetDiplomacy(ship.FactionInfo, oldShip.FactionInfo) & FactionDiplomacy.Enemy) == FactionDiplomacy.Enemy) { Victor = ship.ShipSounds; break; } } } if (Victor != null) { Victor.Victory.Play(); } Thread.Sleep(DeathWait - VictorySongWait); lock (world) { ReMasterSDL.physicsTimer.Enabled = false; lock (syncroot) { GameResult gameResult = new GameResult(); IShip newShip = GetNewShip(oldShip.FactionInfo); //IShip newShip2 = (IShip)newShip.Clone(); newShip.AddControler(null, oldShip.Controlers[0]); if (oldShip.Controlers.Length > 1) { newShip.AddControler(null, oldShip.Controlers[1]); } AddShip(gameResult, newShip, oldShip.FactionInfo); world.HandleActionEvents(gameResult); } } BindWorld(CamerasLastPosition); MeleeMusic.PlayDefault(); Thread.Sleep(AfterChoiceWait); ReMasterSDL.physicsTimer.Enabled = true; }
void AddAIClone(GameResult gameResult, IShip newShip2, FactionInfo factionInfo) { newShip2.Current.Position.Linear += Vector2D.FromLengthAndAngle(900, (float)rand.NextDouble()); newShip2.SetAllPositions(); newShip2.AddControler(null, new ComplexAIControler()); newShip2.OnCreation(gameResult, factionInfo); SetTarget(newShip2); }
void AddAIClone(GameResult gameResult, FactionInfo faction, IShip target) { IShip ship = GetNewShip(faction); ship.Current.Position.Linear += Vector2D.FromLengthAndAngle(900 * rand.Next(1, 3), (float)rand.NextDouble()); ship.SetAllPositions(); ship.AddControler(null, new ComplexAIControler()); data.AddShip(gameResult, ship, faction); //ship.Target = target; }
public virtual void AddObjects() { GameResult gameResult = new GameResult(); AsteroidFaction.FactionType = FactionType.Debris; SuperMeleeData.AfterChoiceWait = 0; IShip ship = GetNewShip(player1); if (player1IsAI) { ship.AddControler(null, new ComplexAIControler()); } else { SuperMeleeData.AfterChoiceWait = 2500; PlayerControler c1 = new PlayerControler(this.player1config); data.controlers.Add(c1); ship.AddControler(null, c1); } data.AddShip(gameResult, ship, player1); IShip ship2 = GetNewShip(player2); if (player2IsAI) { ship2.AddControler(null, new ComplexAIControler()); } else { SuperMeleeData.AfterChoiceWait = 2500; PlayerControler c2 = new PlayerControler(this.player2config); data.controlers.Add(c2); ship2.AddControler(null, c2); } data.AddShip(gameResult, ship2, player2); if (ship2 == null) { return; } data.SetTarget(ship2); data.SetTarget(ship); //ship2.Target = ship; //ship.Target = ship2; for (int pos = 0; pos < player1WingmanCount; ++pos) { AddAIClone(gameResult, player1, ship2); } for (int pos = 0; pos < player2WingmanCount; ++pos) { AddAIClone(gameResult, player2, ship); } FactionInfo.DefaultFactionCollection.SetDiplomacy(player1, player2, FactionDiplomacy.Enemy); PhysicsState tmp = new PhysicsState(); tmp.Position = new ALVector2D(0, new Vector2D(1500, 1500)); data.world.AddIGravitySource(Planet.Create(gameResult, tmp)); data.world.CalcGravity = true; World.HandleActionEvents(gameResult); }