public void OnPlayerDeath_gameOver() { //arrange // bool eventCaught=true; int lives = 1; //int score = 10; ScoreAndLife sl = new ScoreAndLife(lives, laserFactory, bombFactory); Player player = new Player(screenWidth, screenHeight, playerSpeed, playerWidth, playerHeight, laserFactory, bombFactory, sl, timerIntervalPlayerRespawn); Bunkers bunkers = new Bunkers(numBunkers, screenWidth, screenHeight, bunkerWidth, bunkerHeight, bunkerHealth, playerHeight, spaceBetweenBunkerAndPlayer); Mothership mothership = new Mothership(screenWidth, mothershipWidth, mothershipHeight, mothershipSpeed, mothershipPoints, timerIntervalMothership, mothershipSpacerFromTop); AlienSquad alienSquad = new AlienSquad(bunkers, bombFactory, laserFactory, player, mothership, sl, numRows, numColumns, screenWidth, player.BoundingBox.Height, alienWidth, alienHeight, alienSpeed, spacer, bombFrequency, alienPointStart, alienPointDecrement, alienSpacerFromTop, speedIncrease, bombFrequencyIncrement, bombFrequencyMin); //act laserFactory.RegisterAlienSquad(alienSquad); laserFactory.RegisterBunkers(bunkers); laserFactory.RegisterMothership(mothership); //sl.gameOver += delegate() //{ // eventCaught = true; //}; sl.OnPlayerDeath(); int result = sl.Lives; //assert Assert.AreEqual(0, result); //expected, actual //Assert.IsTrue(eventCaught); }
public ProtagonistsAnimation(Simulator simulator, Mothership mothership) { Simulator = simulator; Mothership = mothership; Protagonist = new SpaceshipCursor(simulator.Scene, new Vector3(-200, -600, 0), 5, VisualPriorities.Cutscenes.IntroProtagonist, new Color(95, 71, 255), "Cursor1", true); Wife = new SpaceshipCursor(Simulator.Scene, new Vector3(-200, -600, 0), 5, VisualPriorities.Cutscenes.IntroWife, new Color(255, 0, 136), "Cursor2", true); Protagonist.FadeIn(); Wife.FadeIn(); ProtagonistText = new ManualTextBubble(Simulator.Scene, new Text("I must warn the\n\nother colonies!", @"Pixelite") { SizeX = 2 }, Protagonist.Position, VisualPriorities.Cutscenes.IntroProtagonist - 0.00001) { Alpha = 0 }; State = ProtagonistState.None; TimeBeforeArrival = IntroCutscene.Timing["ProtagonistIn"]; TimeBeforeAbduction = TimeBeforeArrival + 20000; TimeBeforeGoGetHelp = TimeBeforeAbduction + 4000; TimeBeforeFireAgainAtMothership = TimeBeforeGoGetHelp + 2000; TimeBeforeGoInCenter = TimeBeforeFireAgainAtMothership + 18000; TimeBeforeWarnColonies = TimeBeforeGoInCenter + 20000; TimeBeforeTeleport = TimeBeforeWarnColonies + 10000; PathArrivalProtagonist = GetPathArrivalProtagonist(); PathArrivalWife = GetPathArrivalWife(); TimeOnPathProtaAndWife = 0; }
public MothershipSprite(Game game, Mothership mothership, Player player, Texture2D texture) : base(game) { this.mothership = mothership; this.player = player; this.texture = texture; }
public LogicedPirateSquad[] LogicDefenders(Squad squad) { #region Distrbution if (squad.Count <= 0) { return(new LogicedPirateSquad[0]); } int EnemyMotherships = Bot.Engine.EnemyMotherships.Length; #endregion Distrbution PirateLogic BaseLogic = DefenseBaseLogic(); LogicedPirateSquad[] Squads = new LogicedPirateSquad[0]; for (int idx = 0; idx < EnemyMotherships; idx++) { Mothership Target = Bot.Engine.EnemyMotherships[idx]; Squad CurrentSquad = squad.Take(Deploy(Target)).ToList(); squad = squad.FilterOutBySquad(CurrentSquad); if (CurrentSquad.Count <= 0) { continue; } LogicedPirateSquad LogicedCurrentSquad = new LogicedPirateSquad(CurrentSquad.Select(x => x.LogicPirate(BaseLogic)).ToArray(), DefenseLogic(Target)); Squads = Squads.Concat(new LogicedPirateSquad[] { LogicedCurrentSquad }).ToArray(); } return(Squads); }
public void Update() { LaserFactory laserFactory = new LaserFactory(laserSpeed, laserWidth, laserHeight, numRows * numColumns); BombFactory bombFactory = new BombFactory(bombSpeed, bombWidth, bombHeight, numBombSlots); ScoreAndLife scoreAndLife = new ScoreAndLife(lives, laserFactory, bombFactory); Player player = new Player(screenWidth, screenHeight, playerSpeed, playerWidth, playerHeight, laserFactory, bombFactory, scoreAndLife, timerIntervalPlayerRespawn); Bunkers bunkers = new Bunkers(numBunkers, screenWidth, screenHeight, bunkerWidth, bunkerHeight, bunkerHealth, playerHeight, spaceBetweenBunkerAndPlayer); Mothership mothership = new Mothership(screenWidth, mothershipWidth, mothershipHeight, mothershipSpeed, mothershipPoints, timerIntervalMothership, mothershipSpacerFromTop); //int screenWidth = 100; //int alienWidth = 1; //int alienHeight = 2; //int alienSpeed = 1; //int spacer = 1; //int numRows = 1; //int rowLength = 1; //int playerHeight = 0; //arrange //Bunkers bunkers = new Bunkers(numBunkers, screenWidth, screenHeight, bunkerWidth, bunkerHeight, bunkerHealth, playerHeight, spaceBetweenBunkerAndPlayer); BombFactory bf = new BombFactory(0, 0, 0, 0); AlienSquad alienS = new AlienSquad(bunkers, bombFactory, laserFactory, player, mothership, scoreAndLife, numRows, numColumns, screenWidth, player.BoundingBox.Height, alienWidth, alienHeight, alienSpeed, spacer, bombFrequency, alienPointStart, alienPointDecrement, alienSpacerFromTop, speedIncrease, bombFrequencyIncrement, bombFrequencyMin); //act alienS.Update(); //assert //Assert.AreEqual(,); //expected, actual }
internal override void load() { base.load(); Music.sharedInstance.play(GameMusic.MusicType.battle); PlayerData playerData = MemoryCard.current.playerData; gameWorld.load(); physicsWorld.Gravity = Vector2.Zero; mothership = new Mothership(Mothership.Team.blue); mothership.loadHealthBar(gameWorld); gameWorld.addChild(mothership); foreach (MothershipSlotData mothershipSlotData in playerData.mothership.slots.OrderBy(i => i.index)) { Spaceship spaceship = new Spaceship(mothershipSlotData.spaceship, true); mothership.spaceships.Add(spaceship); } mothership.loadSpaceships(gameWorld); botMothership = new Mothership(Mothership.Team.red); botMothership.loadHealthBar(gameWorld); gameWorld.addChild(botMothership); Mission mission = Mission.types[playerData.botLevel]; foreach (Spaceship.Rarity rarity in mission.rarities) { Spaceship spaceship = new Spaceship(MathHelper.Clamp((mission.level + random.Next(-2, 0)), 1, 10), rarity, true, Mothership.Team.red, mission.color); botMothership.spaceships.Add(spaceship); } botMothership.loadSpaceships(gameWorld); mothership.updateMaxHealth(botMothership.spaceships); botMothership.updateMaxHealth(mothership.spaceships); // foreach (Spaceship spaceship in mothership.spaceships) { spaceship.physicsBody.IgnoreCollisionWith(mothership.physicsBody); } foreach (Spaceship spaceship in botMothership.spaceships) { spaceship.physicsBody.IgnoreCollisionWith(botMothership.physicsBody); } // nextState = State.battle; }
public override int Deploy(Mothership mothership) { int total = AssignSizes().arg1; int EnemyMotherships = Bot.Engine.EnemyMotherships.Length; if (EnemyMotherships <= 0) { return(0); } EnemyMotherships = System.Math.Min(System.Math.Max(1, total / 2), EnemyMotherships); Mothership[] Motherships = Bot.Engine.EnemyMotherships.OrderBy(x => x.Distance(Bot.Engine.EnemyCapsules.Select(y => y.InitialLocation).Nearest(x))).ToArray(); int BaseSize = total / EnemyMotherships; int Remainder = System.Math.Max((total - BaseSize * EnemyMotherships) % EnemyMotherships, 0); for (int i = 0; i < EnemyMotherships; i++) { if (mothership.Id == Motherships[i].Id) { return(BaseSize + (i < Remainder ? 1 : 0)); } } return(0); }
public virtual void Initialize() { if (!initialized) { buttonPrefab = (GameObject) Resources.Load("Prefabs/UI/TextButton"); mothership = GameObject.FindGameObjectWithTag ("Mothership"); mothershipscript = mothership.GetComponent<Mothership> (); buttonPrefab = (GameObject)Resources.Load ("Prefabs/UI/TextButton"); Transform displayControlParent = transform.FindChild ("Display Controls"); displayParent = transform.FindChild("Display"); selectedObjectName = transform.FindChild ("Status/SelectedUnitName").GetComponent<Text> (); selectedObjectClass = transform.FindChild ("Status/SelectedClassName").GetComponent<Text> (); for (int i = 0; i < displayControlParent.childCount; i++){ displayControls.Add(displayControlParent.GetChild(i).GetComponent<Button>()); string name = displayControls [i].gameObject.name.Substring (8); //first seven characters are 'Display ' displays.Add(displayParent.FindChild(name)); //find the corresponding display to the button to show it int pass = i; //pass this along to avoid mutating the value of the function set displayControls[i].onClick.AddListener (()=> ToggleDisplayTo(pass)); if (name == "Deploy"){ deployButtonOrganizer = displays[i].GetComponentInChildren<ButtonOrganizer>(); displayControls[i].onClick.AddListener (()=> DisplayDeploy()); } } initialized = true; } }
public void IsCollidedWithTest() { // GameItem-Liste initialisieren GameItem.GameItemList = new System.Collections.Generic.LinkedList <IGameItem>(); // Mutterschiff initialisieren Vector2 position = GameItemConstants.MothershipPosition; // Position Vector2 velocity = GameItemConstants.MothershipVelocity; // Geschwindigkeit int hitpoints = GameItemConstants.MothershipHitpoints; // Lebenspunkte int damage = GameItemConstants.MothershipDamage; // Schaden Weapon weapon = null; // Waffe int scoreGain = GameItemConstants.MothershipScoreGain; // Punktzahl Mothership target = new Mothership(position, velocity, hitpoints, damage, weapon, scoreGain); // Mutterschiff erzeugen // Als Kollisionspartner ein normales Spielerprojektil erzeugen IGameItem collisionPartner = new Projectile(GameItemConstants.MothershipPosition, Vector2.Zero, ProjectileTypeEnum.PlayerNormalProjectile, GameItemConstants.PlayerNormalProjectileHitpoints, Vector2.Zero, GameItemConstants.PlayerNormalProjectileDamage); // TODO: Passenden Wert initialisieren target.IsCollidedWith(collisionPartner); int expected = GameItemConstants.MothershipHitpoints - GameItemConstants.PlayerNormalProjectileDamage; Assert.AreEqual(target.Hitpoints, expected); // GameItem-Liste zurücksetzen GameItem.GameItemList = null; }
public SquadLogic DefenseLogic() { Mothership MS = Bot.Engine.EnemyMotherships[0]; int SCORE_EXTREME_DANGER_TIME = 7; int SCORE_DANGER_TIME = 12; int EXTREME_DANGER_DETAIL_COUNT = 2; Delegates.FilterFunction <Pirate> EnemyHasPush = x => Bot.Engine.GetEnemyPiratesInRange(x.GetLocation(), Bot.Engine.PushRange).Count > 1; Delegates.DefenseFunction <Pirate> ExtremeDangerFunction = p => { bool CapsuleInGame = Bot.Engine.EnemyLivingCapsules.Any(y => y.IsHeld()); return(new DefenseStats((p.HasCapsule() || !CapsuleInGame) && ((PirateShip)p).TurnsToReach(MS) <= SCORE_EXTREME_DANGER_TIME ? p.Distance(MS) : 0, p.NumPushesForCapsuleLoss)); }; Delegates.DefenseFunction <Pirate> DangerFunction = p => { bool CapsuleInGame = Bot.Engine.EnemyLivingCapsules.Any(y => y.IsHeld()); return(new DefenseStats((p.HasCapsule() || !CapsuleInGame) && EnemyHasPush(p) && (p.Distance(MS) - (EnemyHasPush(p) ? p.PushDistance : 0)) / p.MaxSpeed <= SCORE_DANGER_TIME ? p.Distance(MS) : 0, p.NumPushesForCapsuleLoss)); }; BasicDefenseSquad <Pirate> DefensePlugin = new BasicDefenseSquad <Pirate>(MS.Location, EXTREME_DANGER_DETAIL_COUNT, () => Bot.Engine.EnemyLivingPirates.Select(x => (Pirate)x).ToArray(), ExtremeDangerFunction, DangerFunction); SquadLogic logic = new SquadLogic(DefensePlugin); return(logic); }
public Mothership GetBestMothershipThroughWormholes(Pirate pirate) { var mothershipWormholes = new Dictionary <Mothership, int>(); Mothership bestMothership = null; int distance = int.MaxValue; foreach (var mothership in game.GetEnemyMotherships()) { var distances = new List <int>(); foreach (var wormhole in game.GetAllWormholes().Where(wormhole => wormhole.TurnsToReactivate < pirate.Steps(mothership) / 4)) { var distanceThroughCurrent = DistanceThroughWormhole(pirate.Location, mothership.Location, wormhole, game.GetAllWormholes().Where(hole => hole.TurnsToReactivate < pirate.Steps(mothership) / 4)); distances.Add(distanceThroughCurrent); } var normalDistance = pirate.Distance(mothership); if (distances.Any() && distances.Min() < distance) { bestMothership = mothership; distance = distances.Min(); } if (distances.Any() && normalDistance < distance) { bestMothership = mothership; distance = normalDistance; } } if (bestMothership == null) { bestMothership = game.GetEnemyMotherships().OrderBy(mothership => pirate.Steps(mothership) / (int)((double)mothership.ValueMultiplier).Sqrt()).FirstOrDefault(); } return(bestMothership); }
public override int Deploy(Mothership mothership) { if (mothership.Id == 0) { return(AssignSizes().arg1); } return(0); }
public override void ExecuteStrategy() { DeathBallAttacker pusher = null; List <DeathBallDefender> baseDefenders = new List <DeathBallDefender>(); List <ICommand> participants = new List <ICommand>(Participants); foreach (ICommand pirate in participants) { if (pirate is DeathBallAttacker) { pusher = pirate as DeathBallAttacker; } } participants.Remove(pusher); foreach (BaseDefender BD in participants.Cast <BaseDefender>().ToList()) { GameSettings.Game.Debug("DeathBall = " + BD.Pirate.Id); } if (participants != null) { baseDefenders = participants.Cast <DeathBallDefender>().ToList(); } Asteroid dodge = null; foreach (DeathBallDefender defender in baseDefenders) { foreach (Asteroid asteroid in GameSettings.Game.GetLivingAsteroids()) { Mothership closestMothership = FieldAnalyzer.GetClosestEnemyMothership(defender.Pirate); if (closestMothership != null) { if (asteroid.GetLocation().InRange(closestMothership, 500)) { dodge = asteroid; } } } if (pusher.PushedAsteroid && dodge != null) { GameSettings.Game.Debug("Asteroid DeathBall is: " + dodge.Location); defender.WhereToDefend = dodge.GetLocation().Towards(defender.Pirate, dodge.Size + 50); } } foreach (ICommand bot in Participants) { bot.ExecuteCommand(); } }
public void DelayedStart() { Mothership = Instantiate(mothershipPrefab, transform.position, transform.rotation, Owner.PlayerController.transform) .GetComponent <Mothership>(); Mothership.Owner.PlayerController = Owner.PlayerController; Mothership.Owner.PlayerNumber = Owner.PlayerNumber; Mothership.Planet = Planet; }
public void Run() { const int NUM_ENEMIES = 4; ConsoleKeyInfo userkey; Spaceship ship = new Spaceship(); MovingBackground back = new MovingBackground(); Scoreboard sb = new Scoreboard(); Enemy[] enemies = new Enemy[NUM_ENEMIES]; enemies[0] = new EnemyLevel1(); enemies[1] = new EnemyLevel2(); enemies[2] = new EnemyLevel3(); enemies[3] = new EnemyLevel4(); Mothership ms = new Mothership(); PlayerShot shot1 = new PlayerShot(20, 10); EnemyShot shot2 = new EnemyShot(15, 1); while (true) { // Update elements position and appearance back.Update(); ms.Update(); ship.Update(); foreach (Enemy e in enemies) { e.Update(); } shot1.Update(); shot2.Update(); // Screen update Console.Clear(); back.Draw(); sb.Draw(); ms.Draw(); ship.Draw(); foreach (Enemy e in enemies) { e.Draw(); } shot1.Draw(); shot2.Draw(); // Get user input userkey = Console.ReadKey(true); switch (userkey.Key) { case ConsoleKey.A: ship.MoveLeft(); break; case ConsoleKey.D: ship.MoveRight(); break; case ConsoleKey.Escape: return; } } }
public void PlaceMotherShipAndScrapyard() { GameObject scrapObj = GameLogic.Instantiate(GameLogic.Instance.prefabScrapyard) as GameObject; mScrapyard = scrapObj.GetComponent <Scrapyard>(); GameObject objMothership = GameLogic.Instantiate(GameLogic.Instance.prefabMothership) as GameObject; mAllianceMothership = objMothership.GetComponent <Mothership>(); mAllianceMothership.AllianceBelongingTo = this; mScrapyard.Setup(this); if (StartingPlanet.WorldPos.x < 0) { //prefer left scrapyard if (GameLogic.Instance.GetPlanetOnPos(StartingPlanet.WorldPos + new Vector2(-1, 0)) == null) { mScrapyard.transform.localPosition = new Vector3((StartingPlanet.WorldPos.x - 1) * 6, StartingPlanet.WorldPos.y * 6, 0); mAllianceMothership.transform.localPosition = new Vector3((StartingPlanet.WorldPos.x - 2) * 6, StartingPlanet.WorldPos.y * 6, 0); return; } } else if (StartingPlanet.WorldPos.x > 0) { //prefer right scrapyard if (GameLogic.Instance.GetPlanetOnPos(StartingPlanet.WorldPos + new Vector2(+1, 0)) == null) // try to place right { mScrapyard.transform.localPosition = new Vector3((StartingPlanet.WorldPos.x + 1) * 6, StartingPlanet.WorldPos.y * 6, 0); mAllianceMothership.transform.localPosition = new Vector3((StartingPlanet.WorldPos.x + 2) * 6, StartingPlanet.WorldPos.y * 6, 0); return; } } // try to place left if (GameLogic.Instance.GetPlanetOnPos(StartingPlanet.WorldPos + new Vector2(-1, 0)) == null) { mScrapyard.transform.localPosition = new Vector3((StartingPlanet.WorldPos.x - 1) * 6, StartingPlanet.WorldPos.y * 6, 0); mAllianceMothership.transform.localPosition = new Vector3((StartingPlanet.WorldPos.x - 2) * 6, StartingPlanet.WorldPos.y * 6, 0); } else if (GameLogic.Instance.GetPlanetOnPos(StartingPlanet.WorldPos + new Vector2(+1, 0)) == null) // try to place right { mScrapyard.transform.localPosition = new Vector3((StartingPlanet.WorldPos.x + 1) * 6, StartingPlanet.WorldPos.y * 6, 0); mAllianceMothership.transform.localPosition = new Vector3((StartingPlanet.WorldPos.x + 2) * 6, StartingPlanet.WorldPos.y * 6, 0); } else if (GameLogic.Instance.GetPlanetOnPos(StartingPlanet.WorldPos + new Vector2(0, -1)) == null) // try to place top { mScrapyard.transform.localPosition = new Vector3(StartingPlanet.WorldPos.x * 6, (StartingPlanet.WorldPos.y - 1) * 6, 0); mAllianceMothership.transform.localPosition = new Vector3(StartingPlanet.WorldPos.x * 6, (StartingPlanet.WorldPos.y - 2) * 6, 0); } else if (GameLogic.Instance.GetPlanetOnPos(StartingPlanet.WorldPos + new Vector2(0, +1)) == null) // try to place bottom { mScrapyard.transform.localPosition = new Vector3(StartingPlanet.WorldPos.x * 6, (StartingPlanet.WorldPos.y + 1) * 6, 0); mAllianceMothership.transform.localPosition = new Vector3(StartingPlanet.WorldPos.x * 6, (StartingPlanet.WorldPos.y + 2) * 6, 0); } }
public void Initialize() { if (!m_IsInitialized) { m_MotherShip = new Mothership(m_Game); m_MotherShip.Initialize(); m_MotherShip.Enabled = false; m_MotherShip.Visible = false; m_MotherShipTimer = new Random().Next(k_MinTimeBetweenMotherShips, k_MaxTimeBetweenMotherShips); m_IsInitialized = true; } }
/* * <WAHL> * Wird benötigt falls eine Partikel Engine eingebaut wird * private Explosion explosion; * */ /// <summary> /// Erstellt eine Representation des Mutterschiff-Aliens. /// </summary> public MothershipRepresentation(Mothership mothershipGameItem, GraphicsDeviceManager graphics) { this.graphics = graphics; this.model = ViewContent.RepresentationContent.MothershipModel; GameItem = mothershipGameItem; this.mothershipTexture = ViewContent.RepresentationContent.MothershipTexture; this.lastPosition = PlaneProjector.Convert2DTo3D(GameItem.Position); this.World = Matrix.CreateWorld(lastPosition, Vector3.Right, Vector3.Up); //[Anji] Schiffs-Antrieb this.mothershipEngine = (MothershipEngine)createParticleEngine(ViewContent.RepresentationContent.MothershipEngineTexture, PlaneProjector.ToScreenCoordinates(lastPosition, graphics), 1f, new Color(255, 96, 167)); }
/// <summary> /// Get the most closest enemy carrier to a city /// </summary> /// <param name="mothershipToProtect"></param> /// <returns></returns> public Pirate GetMostThreatningEnemyCarrier(Mothership mothershipToProtect) { foreach (Pirate pirate in GameSettings.Game.GetEnemyLivingPirates()) { if (pirate.HasCapsule() && pirate.Distance(mothershipToProtect) < pirate.PushDistance * 1.5) { //GameSettings.Game.Debug("Most threating EC = "+pirate); return(pirate); } } return(null); }
void Awake() { if (mInstance != null) { //Destroy(gameObject); //print("Duplicate music player is self-destructing"); } else { mInstance = this; //DontDestroyOnLoad(gameObject); } }
public ResistanceAnimation(Simulator simulator, Mothership mothership) { Simulator = simulator; Mothership = mothership; Battleships = new List<HumanBattleship>(); var b = new HumanBattleship(Simulator, "HumanBattleship1", VisualPriorities.Cutscenes.IntroHumanBattleships) { Position = new Vector3(0, 2000, 0) }; b.AddTurret(Simulator.TurretsFactory.Create(TurretType.Basic, 1, new Vector3(-18, -25, 0) * 4, true, false, false, false)); b.AddTurret(Simulator.TurretsFactory.Create(TurretType.Basic, 1, new Vector3(-18, -10, 0) * 4, true, false, false, false)); b.AddTurret(Simulator.TurretsFactory.Create(TurretType.RailGun, 2, new Vector3(20, -25, 0) * 4, true, false, false, false)); b.AddTurret(Simulator.TurretsFactory.Create(TurretType.Missile, 4, new Vector3(20, -10, 0) * 4, true, false, false, false)); b.AddTurret(Simulator.TurretsFactory.Create(TurretType.Basic, 2, new Vector3(0, 0, 0) * 4, true, false, false, false)); b.AddTurret(Simulator.TurretsFactory.Create(TurretType.SlowMotion, 1, new Vector3(0, -20, 0) * 4, true, false, false, false)); b.AddTurret(Simulator.TurretsFactory.Create(TurretType.SlowMotion, 2, new Vector3(0, 15, 0) * 4, true, false, false, false)); Battleships.Add(b); b = new HumanBattleship(Simulator, "HumanBattleship2", VisualPriorities.Cutscenes.IntroHumanBattleships) { Position = new Vector3(0, 2000, 0) }; b.AddTurret(Simulator.TurretsFactory.Create(TurretType.Gravitational, 5, new Vector3(-18, -15, 0) * 4, true, false, false, false)); b.AddTurret(Simulator.TurretsFactory.Create(TurretType.RailGun, 3, new Vector3(-18, 0, 0) * 4, true, false, false, false)); b.AddTurret(Simulator.TurretsFactory.Create(TurretType.Gravitational, 6, new Vector3(18, -15, 0) * 4, true, false, false, false)); b.AddTurret(Simulator.TurretsFactory.Create(TurretType.RailGun, 7, new Vector3(18, 0, 0) * 4, true, false, false, false)); b.AddTurret(Simulator.TurretsFactory.Create(TurretType.SlowMotion, 6, new Vector3(-18, 15, 0) * 4, true, false, false, false)); b.AddTurret(Simulator.TurretsFactory.Create(TurretType.Basic, 7, new Vector3(18, 15, 0) * 4, true, false, false, false)); Battleships.Add(b); b = new HumanBattleship(Simulator, "HumanBattleship3", VisualPriorities.Cutscenes.IntroHumanBattleships) { Position = new Vector3(0, 2000, 0) }; b.AddTurret(Simulator.TurretsFactory.Create(TurretType.Missile, 3, new Vector3(18, -10, 0) * 4, true, false, false, false)); b.AddTurret(Simulator.TurretsFactory.Create(TurretType.RailGun, 5, new Vector3(-18, -10, 0) * 4, true, false, false, false)); b.AddTurret(Simulator.TurretsFactory.Create(TurretType.SlowMotion, 5, new Vector3(9, 20, 0) * 4, true, false, false, false)); b.AddTurret(Simulator.TurretsFactory.Create(TurretType.Gravitational, 3, new Vector3(-9, 20, 0) * 4, true, false, false, false)); Battleships.Add(b); foreach (var ship in Battleships) Simulator.AddSpaceship(ship); State = ResistanceState.None; TimeBeforeArrival = IntroCutscene.Timing["HumanBattleshipsArrival"]; TimeBeforeFiring = IntroCutscene.Timing["HumanBattleshipsFiring"]; TimeBeforeDestruction = IntroCutscene.Timing["HumanBattleshipsDestruction"]; }
public List <Pirate> GetClosestEnemyPiratesToMothership(BaseDefender defender) { List <Pirate> closestEnemyPirates = new List <Pirate>(); Mothership closestEnemyMotherShip = GameSettings.Game.GetEnemyMotherships().OrderBy(Mothership => Mothership.Location.Distance(defender.Pirate)).ToList()[0]; foreach (Pirate pirate in GameSettings.Game.GetEnemyLivingPirates()) { if (pirate.Distance(closestEnemyMotherShip) < defender.Pirate.PushDistance * 3.5) { closestEnemyPirates.Add(pirate); } } return(closestEnemyPirates); }
public void Move_Left() { //arrange int mothershipW = 10; int screenW = 20; int speed = 5; //should end up at 0 Mothership ms = new Mothership(screenW, mothershipW, mothershipHeight, speed, mothershipPoints, timerIntervalMothership, mothershipSpacerFromTop); //act ms.Move(); int x = ms.BoundingBox.X; //assert Assert.AreEqual(5, x); //expected, actual }
public bool DoTurn(PirateShip ship) { foreach (PirateShip p in ship.GetPiratesInPushRange().Where(x => Filter(x))) { Mothership closestMothership = Bot.Engine.EnemyMotherships.FirstBy(x => x.Distance(p)); bool CanKill = ((Location)(((Point)p).InDirection(closestMothership, ship.MaxSpeed))).DistanceFromBorder() <= ship.PushDistance; if (ship.CanPush(p) && CanKill) { if (ship.Push(p, p.ClosestBorder())) { return(true); } } } return(false); }
private bool CheckIfCapsuleCanReachMothership(Pirate capsuleHolder, Mothership mothership) //Working on this Function -Mahmoud { if (mothership == null) { return(false); } if (capsuleHolder.InRange(mothership, mothership.UnloadRange * 3) && NumberOfAvailableEnemyPushers(capsuleHolder) < capsuleHolder.NumPushesForCapsuleLoss && NumberOfEnemiesOnTheWay(capsuleHolder, mothership.Location) < capsuleHolder.NumPushesForCapsuleLoss) { // AssignDestination(capsuleHolder, mothership.Location); availablePirates.Remove(capsuleHolder); return(true); } return(false); }
/// <summary> /// Returns the closest capsule to a mothership /// </summary> /// <param name="mothership"></param> /// <returns></returns> public Capsule GetClosestEnemyCapsuleToMothership(Mothership mothership) { int minDistance = 100000; Capsule minCapsule = null; foreach (Capsule capsule in GameSettings.Game.GetEnemyCapsules()) { if (capsule.InitialLocation.Distance(mothership) < minDistance) { minDistance = capsule.InitialLocation.Distance(mothership); minCapsule = capsule; } } return(minCapsule); }
public Mothership GetClosestEnemyMothership(Pirate pirate) { Mothership minMothership = null; int minDistance = 1000000; foreach (Mothership mother in GameSettings.Game.GetEnemyMotherships()) { if (mother.Distance(pirate) < minDistance) { minMothership = mother; minDistance = mother.Distance(pirate); } } return(minMothership); }
/// <summary> /// Returns a list of carriers that are close to their city /// </summary> /// <returns></returns> private List <Pirate> CarrierCloseToCity() { List <Pirate> closeCarriers = new List <Pirate>(); foreach (Pirate enemyPirate in GameSettings.Game.GetEnemyLivingPirates()) { if (enemyPirate.HasCapsule()) { Mothership closestEnemyMotherShip = GameSettings.Game.GetEnemyMotherships().OrderBy(Mothership => Mothership.Location.Distance(enemyPirate)).ToList()[0]; if (enemyPirate.Distance(closestEnemyMotherShip) < enemyPirate.PushDistance * 2) { closeCarriers.Add(enemyPirate); } } } return(closeCarriers); }
void SceneLoaded(Scene curScene, LoadSceneMode loadMode) { sceneName = SceneManager.GetActiveScene().name; Debug.Log(sceneName); if (sceneName == "PaulScene") { combatScript = GameObject.Find("Player").GetComponent <CombatTest>(); shipScript = GameObject.Find("Mothership").GetComponent <Mothership>(); destroyedAsteroids = 0; finalHealth = 100; gameTimer = endGameTime; Debug.Log("timer set"); timerText = GameObject.Find("Timer Text").GetComponent <Text>(); StartCoroutine(GameTimer()); } }
// Start is called before the first frame update public void Init(PMain _pMain) { m_PMain = _pMain; m_Mothership = FindObjectOfType <Mothership>(); m_WeaponCharges[0] = SceneCamera.Instance.transform.Find("UI/Reticles/Weapon_Charge_Left").GetComponent <Image>(); m_WeaponCharges[1] = SceneCamera.Instance.transform.Find("UI/Reticles/Weapon_Charge_Right").GetComponent <Image>(); m_HealthBar = SceneCamera.Instance.transform.Find("UI/Health").GetComponent <Image>(); m_AmmoCounters[0] = transform.Find("Ammo_Left").GetComponent <TextMesh>(); m_AmmoCounters[1] = transform.Find("Ammo_Right").GetComponent <TextMesh>(); m_TextSize = m_AmmoCounters[0].characterSize; m_Clock = transform.Find("Clock").GetComponent <TextMesh>(); }
public override SquadLogic DefenseLogic(Mothership MS) { #region Scoring Functions Delegates.FilterFunction <MapObject> EnemyHasPush = x => Bot.Engine.GetEnemyPiratesInRange(x.GetLocation(), Bot.Engine.PushRange).Count > 1; Delegates.DefenseFunction <SpaceObject> ExtremeDangerFunction = x => { bool CapsuleInGame = Bot.Engine.EnemyLivingCapsules.Any(y => y.IsHeld()); if (x is Pirate p) { return(new DefenseStats((p.HasCapsule() || !CapsuleInGame) && ((PirateShip)p).TurnsToReach(MS) <= SCORE_EXTREME_DANGER_TIME ? p.Distance(MS) : 0, PirateDeployer((PirateShip)p))); } else if (x is Wormhole w) { return(new DefenseStats(w.Distance(MS) / Bot.Engine.MaxPirateSpeed <= SCORE_EXTREME_DANGER_TIME ? w.Distance(MS) + Bot.Engine.MaxPirateSpeed * SCORE_EXTREME_DANGER_TIME : 0, WormholeDeployer(w))); } else { return(new DefenseStats(0, 0)); } }; Delegates.DefenseFunction <SpaceObject> DangerFunction = x => { bool CapsuleInGame = Bot.Engine.EnemyLivingCapsules.Any(y => y.IsHeld()); if (x is Pirate p) { return(new DefenseStats((p.HasCapsule() || !CapsuleInGame) && EnemyHasPush(p) && (p.Distance(MS) - (EnemyHasPush(p) ? p.PushDistance : 0)) / p.MaxSpeed <= SCORE_DANGER_TIME ? p.Distance(MS) : 0, PirateDeployer((PirateShip)p))); } else if (x is Wormhole w) { return(new DefenseStats(w.Distance(MS) / Bot.Engine.MaxPirateSpeed <= SCORE_DANGER_TIME ? w.Distance(MS) + Bot.Engine.MaxPirateSpeed * SCORE_DANGER_TIME : 0, WormholeDeployer(w))); } else { return(new DefenseStats(0, 0)); } }; #endregion Scoring Functions BasicDefenseSquad <SpaceObject> DefensePlugin = new BasicDefenseSquad <SpaceObject>(MS.Location, EXTREME_DANGER_DETAIL_COUNT, () => Bot.Engine.EnemyLivingPirates.Select(x => (SpaceObject)((Pirate)x)).Concat(Bot.Engine.AllWormholes).ToArray(), ExtremeDangerFunction, DangerFunction, DefensePushMapper); SquadCamperPlugin camper = new SquadCamperPlugin(MS); return(new SquadLogic(DefensePlugin, camper)); }
public MothershipAnimation(Simulator simulator) { Simulator = simulator; Mothership = new Mothership(Simulator, VisualPriorities.Cutscenes.IntroMothership) { Direction = new Vector3(0, -1, 0), ShowShield = true, ShieldImageName = "MothershipHitMask", ShieldColor = Colors.Default.AlienBright, ShieldAlpha = 100, ShieldDistance = 10 }; Mothership.Position = new Vector3(0, -Mothership.Size.Y/2 - 360, 0); Simulator.AddSpaceship(Mothership); State = MothershipState.None; Simulator.Scene.Camera.Zoom = 1f; }
/// <summary> /// Set battle field by current level. /// </summary> private void setBattleField() { m_mothership = new Mothership(this); AddComponents(m_mothership); int fieldLevel = (m_level - 1) % 4; float enemiesJumpsForSecond = 2; int enemiesRows = 5; int enemiesColumns = 9 + fieldLevel; m_enemies = new EnemiesMatrix(this, enemiesColumns, enemiesRows, enemiesJumpsForSecond); m_enemies.AllEnemiesDead += nextStage; m_enemies.ArrivedMaxY += stageFailed; AddComponents(m_enemies); m_barriers = new BarriersArray(this, 4, fieldLevel); AddComponents(m_barriers); if (fieldLevel == 0) { Enemy.ResetScores(); } }
public List <MapObject> bestMothershipAndCapsulePair(Wormhole wormhole) { List <MapObject> best = new List <MapObject>(); Location partnerLocation = wormhole.Partner.Location; Mothership bestMothership = game.GetMyMotherships() //Closest Mothership to wormhole .OrderBy(mothership => mothership.Distance(wormhole.Location)) .FirstOrDefault(); Capsule bestCapsule = game.GetMyCapsules() //Closest Capsule to partner .OrderBy(capsule => capsule.Distance(wormhole.Partner)) .FirstOrDefault(); if (NewWormholeLocation[wormhole.Partner] != partnerLocation) { partnerLocation = wormhole.Partner.Location.Towards(partnerLocation, game.PushDistance); } int distance = WormholePossibleLocationDistance(bestMothership.Location, bestCapsule.Location, wormhole.Location, partnerLocation); bestMothership = game.GetMyMotherships() //Closest Mothership to partner .OrderBy(mothership => mothership.Distance(wormhole.Partner)) .FirstOrDefault(); bestCapsule = game.GetMyCapsules() //Closest Capsule to wormholelocation .OrderBy(capsule => capsule.Distance(wormhole.Location)) .FirstOrDefault(); int distance2 = WormholePossibleLocationDistance(bestMothership.Location, bestCapsule.Location, wormhole.Location, partnerLocation); if (distance < distance2) { bestMothership = game.GetMyMotherships() //Closest Mothership to wormhole .OrderBy(mothership => mothership.Distance(wormhole.Location)) .FirstOrDefault(); bestCapsule = game.GetMyCapsules() //Closest Capsule to partner .OrderBy(capsule => capsule.Distance(wormhole.Partner)) .FirstOrDefault(); best.Add(bestMothership); best.Add(bestCapsule); return(best); } best.Add(bestMothership); best.Add(bestCapsule); return(best); }
public void UpdateProjectiles_TouchMothership() { //arrange int laserSpeed = -5; int laserWidth = 1; int laserHeight = 1; int alienCount = 5; LaserFactory laser = new LaserFactory(laserSpeed, laserWidth, laserHeight, alienCount); int mothershipW = 10; int screenW = 20; int speed = 5; //should end up at 0 Mothership ms = new Mothership(screenW, mothershipW, mothershipHeight, speed, mothershipPoints, timerIntervalMothership, mothershipSpacerFromTop); //act int xMothership = ms.BoundingBox.X; int yMothership = ms.BoundingBox.Y; int xLaser = laser.Laser.BoundingBox.X; int yLaser = laser.Laser.BoundingBox.Y; laser.UpdateProjectiles(); int xMothership1 = ms.BoundingBox.X; int yMothership1 = ms.BoundingBox.Y; int xLaser1 = laser.Laser.BoundingBox.X; int yLaser1 = laser.Laser.BoundingBox.Y; //assert Assert.AreEqual(0, xMothership); //expected, actual Assert.AreEqual(0, yMothership); Assert.AreEqual(0, xLaser); //expected, actual Assert.AreEqual(0, yLaser); Assert.AreEqual(0, xMothership1); //expected, actual Assert.AreEqual(0, yMothership1); Assert.AreEqual(0, xLaser1); //expected, actual Assert.AreEqual(0, yLaser1); }
// Use this for initialization public override void Initialize() { player = transform.root.GetComponent< Player >(); units = player.transform.FindChild ("Units"); battleGooey = player.GetComponent<BattleGooey> (); battleMessaging = player.GetComponent<BattleMessaging> (); mothership = player.transform.GetComponentInChildren<Mothership> (); }
// Use this for initialization void Start () { playerMothershipReferenceObject = GameObject.Find("AstraHeavyCruiser01").GetComponentInChildren<Mothership>(); timer = 0; }