public static void Main(string[] args) { //var battleship = Battleship.CreateBattleShip("Raven"); var factory = new ShipFactory <Battleship>(); var raven = factory.CreateShip(Battleships.Raven); var dominix = factory.CreateShip(Battleships.Dominix); var rokh = factory.CreateShip(Battleships.Rokh); var scorpion = factory.CreateShip(Battleships.Scorpion); var canon = new Weapon(Weapons.Cannon, WeaponGrades.Large); var projectile = new Weapon(Weapons.Projectile, WeaponGrades.Large); var laser = new Weapon(Weapons.Laser, WeaponGrades.Large); var missile = new Weapon(Weapons.Missile, WeaponGrades.Large); raven.InstallWeapon(canon, 1); dominix.InstallWeapon(projectile, 1); rokh.InstallWeapon(laser, 1); scorpion.InstallWeapon(missile, 1); var attackingPlanetOffensiveFormation = new BattleFormation("ap of"); var attackingPlanetDefensiveFormation = new BattleFormation("ap df"); var defensivePlanetOffensiveFormation = new BattleFormation("dp of"); var defensivePlanetDefensiveFormation = new BattleFormation("dp df"); attackingPlanetOffensiveFormation.SetFormationRow(raven, 100, 1); attackingPlanetDefensiveFormation.SetFormationRow(dominix, 100, 1); defensivePlanetOffensiveFormation.SetFormationRow(raven, 100, 1); defensivePlanetDefensiveFormation.SetFormationRow(raven, 100, 1); var attackingPlanetOffensiveFormationGeneral = new General(); var attackingPlanetDefensiveFormationGeneral = new General(); var defensivePlanetOffensiveFormationGeneral = new General(); var defensivePlanetDefensiveFormationGeneral = new General(); attackingPlanetOffensiveFormation.SetGeneral(attackingPlanetOffensiveFormationGeneral); attackingPlanetDefensiveFormation.SetGeneral(attackingPlanetDefensiveFormationGeneral); defensivePlanetDefensiveFormation.SetGeneral(defensivePlanetDefensiveFormationGeneral); defensivePlanetOffensiveFormation.SetGeneral(defensivePlanetOffensiveFormationGeneral); var attackingPlanet = new Planet(Planets.Pandora); var defensivePlanet = new Planet(Planets.Desert); attackingPlanet.AddFormation(attackingPlanetOffensiveFormation); attackingPlanet.AddFormation(attackingPlanetDefensiveFormation); defensivePlanet.AddFormation(defensivePlanetOffensiveFormation); defensivePlanet.AddFormation(defensivePlanetDefensiveFormation); attackingPlanet.ActivateFormation(attackingPlanetOffensiveFormation, BattleFormationType.Offensive); attackingPlanet.ActivateFormation(attackingPlanetDefensiveFormation, BattleFormationType.Defensive); defensivePlanet.ActivateFormation(defensivePlanetOffensiveFormation, BattleFormationType.Offensive); defensivePlanet.ActivateFormation(defensivePlanetDefensiveFormation, BattleFormationType.Defensive); BattleSimulator.CalculateBattleResult(attackingPlanet, defensivePlanet); }
private void Start() { if (_ship == null) { Ship = ShipFactory.getInstance().CreateShip(shipType); } stationConstructor = GetComponent <StationConstructor>(); }
public static GameSceneData NewGameDefault() { long id = 0; #region Player 1 ///////////////////////////////////Player 1/////////////////////////////////////////////////////// List <ResourcePersistance> player1Resources = new List <ResourcePersistance> { new ResourcePersistance(ResourceType.Metal, 500), new ResourcePersistance(ResourceType.Crystal, 500), new ResourcePersistance(ResourceType.BlackMatter, 100) }; List <ShipControllerPersistance> player1Ships = new List <ShipControllerPersistance>() { new ShipControllerPersistance(ShipFactory.getInstance().CreateShip(ShipType.MotherShip), ShipType.MotherShip, new MapObjectPersitance(id++, new Vector3(-15, 0, -20), new Vector3(1, 1, 1), Quaternion.identity, -1), new Navigation.FleetCommandQueue().Serialize(), false) }; #endregion Player 1 #region Player 2 List <ResourcePersistance> player2Resources = new List <ResourcePersistance> { new ResourcePersistance(ResourceType.Metal, 500), new ResourcePersistance(ResourceType.Crystal, 500), new ResourcePersistance(ResourceType.BlackMatter, 100) }; List <ShipControllerPersistance> player2Ships = new List <ShipControllerPersistance>() { new ShipControllerPersistance(ShipFactory.getInstance().CreateShip(ShipType.MotherShip), ShipType.MotherShip, new MapObjectPersitance(id++, new Vector3(15, 0, 20), new Vector3(1, 1, 1), Quaternion.identity, -1), new Navigation.FleetCommandQueue().Serialize(), false) }; #endregion Player 2 List <PlayerPersistance> players = new List <PlayerPersistance>() { new PlayerPersistance(new Player("player 1", 0, PlayerType.Real, new SerializableColor(Color.blue)), player1Resources, player1Ships, new List <StationControllerPersistance>()), new PlayerPersistance(new Player("player 2", 1, PlayerType.AI, new SerializableColor(Color.red)), player2Resources, player2Ships, new List <StationControllerPersistance>()) }; #region asteroids AsteroidFieldAsteroidSettings asteroidFieldAsteroidSettings = AsteroidFieldAsteroidSettings.CreateDefaultSettings(); AsteroidFieldControllerPersistance middleAsteroidField = new AsteroidFieldControllerPersistance(asteroidFieldAsteroidSettings.Serialize(), new List <AsteroidControllerPersistance>(), false, new MapObjectPersitance(id++, new Vector3(0, 0, 0), new Vector3(1, 1, 1), Quaternion.identity, -1), new Vector3(15, 3, 15)); #endregion asteroids return(new GameSceneData("New Game", new Vector2(40, 50), players, new List <AsteroidFieldControllerPersistance>() { middleAsteroidField }, id++)); }
public static ShipFactory SpawnShip() { // Create ShipFactory factory = new ShipFactory(Settings.ShipSpeed); // Bookkeeping Bookkeeper.Register(factory.Controller); return(factory); }
public void CloneStress() { Entity humanFaction = FactionFactory.CreateFaction(_game, "Humans"); Entity harbingerShipClass = ShipFactory.CreateNewShipClass(_game, humanFaction, "Harbinger"); for (int i = 0; i < 1000000; i++) { harbingerShipClass.Clone(_game.GlobalManager); } }
public GameInitializationStrategy() { this.shipsType = new Dictionary <Type, int> { { typeof(Battleship), GlobalConstants.InitialBattleshipsCount }, { typeof(Destroyer), GlobalConstants.InitialDestroyerCount } }; this.shipFactory = new ShipFactory(); }
public void AddShip_ShouldNotAdd_IfShipFallsOutsideBoundary() { var board = new Board(10); var ship = ShipFactory.NewBatteship(); var coordinate = new Coordinate(0, 9); var result = board.AddShip(ship, coordinate, Direction.Horizontal); Assert.IsFalse(result); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { this.shipFactory = new ShipFactory(); this.gameObjects = new List <GameObject>(); this.camera = new Camera(new Vector3(0, 100, -10), Vector3.Zero, this.GraphicsDevice.Viewport.AspectRatio, 5f); this.IsMouseVisible = true; base.Initialize(); }
public void CreateShip_WhenOneDimensionShipIsValid_ReturnsCorrectShip(OneDimensionShip oneDimensionShip, Ship expectedShip) { // Arrange var sutShipFactory = new ShipFactory(); // Act var result = sutShipFactory.CreateShip(oneDimensionShip); // Assert result.Should().Be(expectedShip); }
private void addBonusEnemyToGame() { var randomInt = RandomUtil.GetNextRandomFromMax(30); if (this.bonusEnemyShip == null) { this.bonusEnemyShip = (EnemyShip)ShipFactory.SelectShip(ShipFactory.ShipSelections.BonusShip); this.currentBackground.Children.Add(this.bonusEnemyShip.Sprite); this.placeBonusEnemyShip(); } }
public void TakeDamagHealthZeroTest() { IStarShip starShip = ShipFactory.CreateShip(ShipType.Fighter, ShipConfigurationType.Light); int damageAmount = 9000; AttackResult attackResult = new AttackResult { Damage = damageAmount }; starShip.TakeDamage(attackResult); Assert.Equal(0, starShip.Health); }
public Game(IBoardDimension size) { this.board = new Board(size); Ships = new List <Ship>(); Ships.Add(ShipFactory.CreateShip(ShipFactory.ShipType.Battleship, "HMS Barham")); Ships.Add(ShipFactory.CreateShip(ShipFactory.ShipType.Destroyer, "Hobart-class destroyer")); Ships.Add(ShipFactory.CreateShip(ShipFactory.ShipType.Destroyer, "Kashin-class destroyer")); AddShipsToBoard(Ships, size.Width, size.Height); }
public static void GeneratePlayersShipConfigurations() { ShipFactory.Initialize(); Global.RemoveAllShips(); foreach (var ship in SquadBuilderRoster.GetShips()) { ship.Ship.SkinName = GetSkinName(ship); Global.AddShip(ship.Ship, ship.Player, GetShipCostCalculated(ship)); } }
static void Main(string[] args) { IShipFactory shipFactory = new ShipFactory(); IStateTrackerFactory stateTrackerFactory = new StateTrackerFactory(shipFactory); var sampleScenarios = new SampleScenarios(stateTrackerFactory); sampleScenarios.RunHappyPathWithVerticalShip(); sampleScenarios.RunHappyPathWithHorizontalShip(); sampleScenarios.RunUnHappyPath1(); sampleScenarios.RunUnHappyPath2(); }
public void CreateShip_WhenOneDimensionShipIsNull_ThrowsArgumentNullException() { // Arrange var sutShipFactory = new ShipFactory(); OneDimensionShip oneDimensionShip = null; // Act Action action = () => sutShipFactory.CreateShip(oneDimensionShip); // Assert action.Should().ThrowExactly <ArgumentNullException>(); }
public void CreateFrigetLightConfigurationCollectionCountTest() { IStarShip ship = ShipFactory.CreateShip(ShipType.Friget, null); IShipConfiguration config = ShipConfigurationFactory.CreateShipConfiguration(ShipType.Friget, ShipConfigurationType.Light); Assert.True(config.attackImplements.Count() > 0); Assert.True(config.defendImplements.Count() > 0); Assert.True(config.upgradeImplements.Count() > 0); Assert.True(config.attackImplements.Sum(x => x.Size) <= ship.NumberOfAttackSlots); Assert.True(config.defendImplements.Sum(x => x.Size) <= ship.NumberOfDefendSlots); Assert.True(config.upgradeImplements.Sum(x => x.Size) <= ship.NumberOfUpgradeSlots); }
private void Awake() { var shipFactory = new ShipFactory(Instantiate(shipConfiguration)); var shipBuilder = shipFactory.Create(shipPlayerConfiguration.ShipId.Id); shipBuilder.WithShipConfiguration(shipPlayerConfiguration) .WithTypeOfInput(TypeOfInput.TouchInput) .WithPrefabProjectile(shipPlayerConfiguration.ProjectileId); ship = shipBuilder.Build(); }
public void CreateShipConfigurationDestroyerLightTest() { IStarShip ship = ShipFactory.CreateShip(ShipType.Destroyer, ShipConfigurationType.Light); Assert.True(ship.Armor != 0); Assert.True(ship.Speed != 0); Assert.True(ship.Health != 0); Assert.True(ship.Power != 0); Assert.True(ship.NumberOfAttackSlotsAvailable >= 0); Assert.True(ship.NumberOfDefendSlotsAvailable >= 0); Assert.True(ship.NumberOfUpgradeSlotsAvailable >= 0); }
public void AddCustomShip() { //Arrange int expectedWeight = 100 * 1000; Ship actual; //Act actual = ShipFactory.GenerateCustomShip(100, new System.Drawing.Size(4, 3)); //Assert Assert.AreEqual(expectedWeight, actual.MaxWeight); }
public void StarShipTest() { IStarShip ship = ShipFactory.CreateShip(ShipType.Fighter, ShipConfigurationType.Heavy); Assert.True(ship.availableAttackImplements.Count > 0); Assert.True(ship.AttackImplements.Count > 0); Assert.True(ship.DefendImplements.Count > 0); Assert.True(ship.UpgradeImplements.Count > 0); Assert.True(ship.NumberOfAttackSlotsAvailable == ship.NumberOfAttackSlots - ship.AttackImplements.Sum(x => x.Size)); Assert.True(ship.NumberOfDefendSlotsAvailable == ship.NumberOfDefendSlots - ship.DefendImplements.Sum(x => x.Size)); Assert.True(ship.NumberOfUpgradeSlotsAvailable == ship.NumberOfUpgradeSlots - ship.UpgradeImplements.Sum(x => x.Size)); }
public void CreateShipConfigurationFrigetHeavyTest() { IStarShip ship = ShipFactory.CreateShip(ShipType.Friget, ShipConfigurationType.Heavy); Assert.True(ship.Armor != 0); Assert.True(ship.Speed != 0); Assert.True(ship.Health != 0); Assert.True(ship.Power != 0); Assert.True(ship.NumberOfAttackSlotsAvailable >= 0); Assert.True(ship.NumberOfDefendSlotsAvailable >= 0); Assert.True(ship.NumberOfUpgradeSlotsAvailable >= 0); }
public void TakeDamageTest() { IStarShip starShip = ShipFactory.CreateShip(ShipType.Fighter, ShipConfigurationType.Light); var oHealth = starShip.Health; int damageAmount = starShip.Armor + 20; AttackResult attackResult = new AttackResult { Damage = damageAmount }; starShip.TakeDamage(attackResult); Assert.Equal(oHealth - 20, starShip.Health); Assert.Equal(0, starShip.Armor); }
public void AddDefaultShip_Test() { //Arrange Ship expected = new Ship(new System.Drawing.Size(4, 3), 400000); Ship actual; //Act actual = ShipFactory.GenerateDefaultShip(); //Assert Assert.AreEqual(expected.Size, actual.Size); Assert.AreEqual(expected.MaxWeight, actual.MaxWeight); }
public int GetComputerSinkShipCount(ShipType shipType) { int count = 0; ShipFactory.GetInstance(shipType).AllShips.ForEach(ship => { if (GetRedSquareCount(ship) == ship.Count) { count++; } }); return(count); }
public GameLogicIntegrationTests() { _configMock = new Mock <IOptions <AppSettings> >(MockBehavior.Strict); var settingsChecker = new SettingsChecker(_configMock.Object); var randomWrapper = new RandomWrapper(); var shipFactory = new ShipFactory(_configMock.Object, randomWrapper); var grid = new Logic.Grid.Grid(); var gridBuilder = new GridBuilder(_configMock.Object, shipFactory, grid); var coordinateValidator = new CoordinateValidator(); var coordinateParser = new CoordinateParser(coordinateValidator); _sut = new GameLogic(settingsChecker, gridBuilder, coordinateParser); }
public void NotifyObserversTest() { IStarShip ship = ShipFactory.CreateShip(ShipType.Fighter, ShipConfigurationType.Balanced); int oHandA = ship.Health + ship.Armor; var attackAggregator = new AttackAggregator(); attackAggregator.RegisterObserver(ship); attackAggregator.NotifyObservers(new AttackResult { Damage = 10 }); Assert.Equal(ship.Health + ship.Armor + 10, oHandA); attackAggregator.UnregisterObserver(ship); }
public static PlayerModel GenerateIAPlayer(PlayerModel model) { PlayerModel computer = new PlayerModel("Computer", new MapModel()); foreach (var ship in model.Ships) { computer.Ships.Add(ShipFactory.GenerateUnplacedCopy(ship)); } ShipController.PlaceAllShipsRandomly(computer.Ships); PlayerController.PlaceShipsOnMap(computer); return(computer); }
static void Main(string[] args) { ShipFactory factory = new ShipFactory(); Ship bs = factory.makeShip(1); Ship ts = factory.makeShip(2); Console.WriteLine(bs.weaponsystem.fire()); Console.WriteLine(bs.weaponsystem.reload()); Console.WriteLine(ts.weaponsystem.fire()); Console.WriteLine(ts.weaponsystem.reload()); Console.ReadLine(); }
protected override void Run(ETModel.Session session, M2C_CreateShips message) { ShipComponent unitComponent = ETModel.Game.Scene.GetComponent <ShipComponent>(); foreach (ShipInfo unitInfo in message.Ships) { if (unitComponent.Get(unitInfo.ShipId) != null) { continue; } Ship ship = ShipFactory.Create(unitInfo.ShipId); ship.Position = new Vector3(unitInfo.X, unitInfo.Y, unitInfo.Z); } }
public void AddShipVertical_ShouldAddVertically() { var board = new Board(10); var ship = ShipFactory.NewDestoryer(); var coordinate = new Coordinate(3, 3); var result = board.AddShip(ship, coordinate, Direction.Vertical); var squaresWithShip = board.Squares.Where(x => x.Ship == ship); //verify columns are same Assert.AreEqual(squaresWithShip.Where(x => x.Coordinate.Column == coordinate.Column).Count(), ship.Length); Assert.AreEqual(squaresWithShip.Select(x => x.Coordinate.Row).Distinct().Count(), ship.Length); }