public void SetBattle(Vector3 battleCenter, IEnumerable <ShipController> ships, IEnumerable <ShipTeam> teams, IEnumerable <IBattleUpdater> updaters) { this.battleCenter = battleCenter; ShipTeam.SetGoals(teams); this.teams = teams.ToList(); area = new BattleArea(448000, 3500, ShipOutOfBoundsAreaEvent); // x7 bit // new BattleArea(224000, 3500); // x6 bit running = true; paused = false; time = Time.time; this.updaters = updaters.ToArray(); addShipAbles = new IAddShipAble[] { area }.Concat(updaters.Select(u => u as IAddShipAble).Where(u => u != null)).ToArray(); removeShipAbles = new IRemoveShipAble[] { }.Concat(updaters.Select(u => u as IRemoveShipAble).Where(u => u != null)).ToArray(); destroyShipAbles = new IDestroyShipAble[] { area }.Concat(updaters.Select(u => u as IDestroyShipAble).Where(u => u != null)).ToArray(); foreach (var s in ships) { foreach (var u in addShipAbles) { u.AddShip(s); } } audioPlayer = (AudioPlayer)Instantiate(Resources.Load <AudioPlayer>(@"Prefabs\AudioPlayer"), transform.position, transform.rotation, transform); }
public static void WriteToConsole(BattleArea area) { for (var i = 0; i < area.Length; i++) { for (var j = 0; j < area.Width; j++) { BattleField field = area.ActualBattleArea[i, j]; switch (field) { case BattleField.Walkable: Console.Write('-'); break; case BattleField.NotWalkable: Console.Write('x'); break; case BattleField.Roman: Console.Write('^'); break; case BattleField.Gauls: Console.Write('*'); break; } } Console.WriteLine(); } }
private void DeleteInCompleteShip(BattleArea area, List <Point> pointsToDelete) { foreach (Point p in pointsToDelete) { area.BattleFields[p.X, p.Y] = new BattleField(new EmptyField(SymbolsContent.EmptyField)); } }
public AMaker(int height, int width, bool hasBoard, BattleArea area) { HasBoard = hasBoard; Height = HasBoard ? height + Board : height; Width = HasBoard ? width + Board : width; Area = area; }
public void AddShipTest() { BattleArea battleArea = new BattleArea(); Game game = new Game(); game.AddShip(battleArea, 1, 1, new CoOrdinates('1', 'A'), ShipType.TypeP); Assert.AreEqual(battleArea.AllShips.Count, 1); }
public void CreateBattleField_Return_81_Fields_Without_Board() { IAreaMaker maker = MakeMakers(false); BattleArea area = maker.CreateBattleArea(); Assert.AreEqual(196, area.BattleFields.Length); }
public override void InitializeAgent() { base.InitializeAgent(); battleArea = GetComponentInParent <BattleArea>(); rayPer = GetComponent <RayPerception3D>(); player = GetComponent <Player>(); aiAcademy = FindObjectOfType <AIAcademy>(); }
public BattleAreaTest() { battleArea = new BattleArea(5, 'E'); battleArea.SetShip(ShipType.Q, 'B', 2, 2, 3); battleArea.SetShip(ShipType.Q, 'A', 1, 2, 3); battleArea.SetShip(ShipType.P, 'D', 3, 2, 4); battleArea.SetShip(ShipType.P, 'E', 2, 2, 3); }
public void NoMissileTargetTest() { var battleArea1 = new BattleArea(2, 'B'); var result = battleArea1.Target('A', 1); Assert.AreEqual(Missile.NoMissile, result); }
public void CreateBattleField_AllFieldsCountEquals_121() { bool hasBoard = true; IAreaMaker maker = MakeMakers(hasBoard); BattleArea area = maker.CreateBattleArea(); Assert.AreEqual(256, area.BattleFields.Length); }
public ShipMaker(BattleArea area, IAreaMaker maker, LinkedList <ShipBase> ships) { Area = area; Height = maker.Height; Width = maker.Width; this.maker = maker; Ships = ships; ShipContainer = new ShipsContainer(); }
public void GetRemainingShipCountTest() { BattleArea battleArea = new BattleArea(); battleArea.AllShips.Add(new Ship(1, 1, ShipType.TypeP)); int count = battleArea.GetRemainingShipCount(); Assert.AreEqual(count, 1); }
public void UpdateCoordinatesTest() { BattleArea battleArea = new BattleArea(); CoOrdinates coords = new CoOrdinates('1', 'Y'); coords.Value = 1; battleArea.GetAcquireCoordinates().Add(coords); battleArea.UpdateCoordinates(new CoOrdinates('1', 'Y')); Assert.AreEqual(battleArea.GetAcquireCoordinates()[0].Value, 0); }
public void Test_BattleArea() { int Player2; BattleArea testArea = new BattleArea(6, 'F'); testArea.UpdateBattleFieldCells("A3", new Ship("P")); testArea.UpdateBattleFieldCells("F5", new Ship("Q")); Assert.AreEqual(3, testArea.TotalNoOfHitsBattleAreaCanTake); // P ship take 1 hit and Q one takes 2 hit to get destroyed Assert.AreEqual(true, testArea.MissileHitOrMiss("A3", "Player-1", out Player2)); Assert.AreEqual(true, testArea.MissileHitOrMiss("F5", "Player-1", out Player2)); Assert.AreEqual("Player-1", testArea.Name); Assert.AreEqual(1, testArea.TotalNoOfHitsBattleAreaCanTake); // Reduced to 1 as 2 missile have succesfully hit the Area }
public void GetShipTest() { BattleArea battleArea = new BattleArea(); IShip ship = new Ship(1, 1, ShipType.TypeP); ship.AcquiredCoordinates.Add(new CoOrdinates('1', 'A')); battleArea.AllShips.Add(ship); IShip ship1 = battleArea.GetShip(new CoOrdinates('1', 'A')); Assert.IsNotNull(ship1); }
void Start() { battleArea = GetComponentInParent <BattleArea>(); myRigidBody = GetComponent <Rigidbody>(); Canvas canvas = FindObjectOfType <Canvas>(); canvasRect = canvas.GetComponent <RectTransform>(); agent = GetComponent <PlayerAgent>(); statusBar = Instantiate(statusBarPrefab, canvas.transform); battleArea.players.Add(this.gameObject); rotation = transform.eulerAngles.y; }
public static bool ModPatch_BattleAction(BattleAction __instance, ref bool __result) { if (!Application.isPlaying || __instance.battleId.IsNullOrEmpty()) { __result = false; return(false); } string battleId = __instance.battleId; BattleArea battleArea = Game.Data.Get <BattleArea>(battleId); BattleGrid battleGrid = Game.Data.Get <BattleGrid>(battleArea?.BattleMap); if (battleGrid == null) { battleGrid = Randomizer.GetOneFromData <BattleGrid>(battleArea?.BattleMap); if (battleGrid != null) { BattleArea battleAreaClone = battleArea.Clone <BattleArea>(); battleAreaClone.Id = "!" + battleAreaClone.Id; battleAreaClone.BattleMap = battleGrid.Id; // 复写mapId ModExtensionSaveData.AddTempItem(battleAreaClone); battleId = battleAreaClone.Id; } } string mapId = battleGrid?.MapId; Console.WriteLine("当前MapId=" + Game.GameData.MapId); Console.WriteLine("需要MapId=" + mapId); if (mapId == Game.GameData.MapId) { Game.FSM.SendEvent("BATTLE", new Heluo.FSM.Main.BattleEventArgs() { BattleId = battleId }); __result = true; } else { CachedBattleId = battleId; Console.WriteLine("设置BattleId=" + CachedBattleId); Game.FSM.SendEvent("LOADING", new LoadingEventArgs { MapId = mapId, CinematicId = null, TimeStage = Heluo.Manager.TimeStage.None, LoadType = LoadType.Default }); __result = true; } return(false); }
BattleArea IAreaMaker.CreateBattleArea() { BattleArea area = new BattleArea(Height, Width); for (int i = 0; i < Height; i++) { for (int j = 0; j < Width; j++) { if (HasBoard && (j == 0 || i == 0 || j == Height - 1 || i == Width - 1)) { if (i == 0) { if (j == Height - 1) { area.BattleFields[i, j] = new BattleField(new BoundField(SymbolsContent.BoundFieldFirstElement)); } else { area.BattleFields[i, j] = new BattleField(new BoundField(Coordinates.MapToChar(j))); } } else if (j == 0) { if (i == Width - 1) { area.BattleFields[i, j] = new BattleField(new BoundField(SymbolsContent.BoundFieldFirstElement)); } else { area.BattleFields[i, j] = new BattleField(new BoundField(Coordinates.MapIntToStringFormat(i))); } } else if (j == Height - 1) { area.BattleFields[i, j] = new BattleField(new BoundField(SymbolsContent.BoundFieldLastElement)); } else { area.BattleFields[i, j] = new BattleField(new BoundField(SymbolsContent.BoundFieldDownElement)); } } else { area.BattleFields[i, j] = new BattleField(new EmptyField(SymbolsContent.EmptyField)); } } } return(area); }
public void UpdateCoordinateTest() { CoOrdinateConcreteMediator coordinateMediator = new CoOrdinateConcreteMediator(); BattleArea battleArea = new BattleArea(); battleArea.GetAcquireCoordinates().Add(new CoOrdinates('X', 'Y')); CoOrdinates coords = new CoOrdinates('X', 'Y'); coords.Value = 1; coordinateMediator.UpdateCoordinate(battleArea, coords); Assert.AreEqual(battleArea.GetAcquireCoordinates()[0].Value, 1); }
public PlayerTest() { battleArea = new BattleArea(5, 'E'); battleArea.SetShip(ShipType.Q, 'B', 2, 2, 3); battleArea.SetShip(ShipType.Q, 'A', 1, 2, 3); battleArea.SetShip(ShipType.P, 'D', 3, 2, 4); battleArea.SetShip(ShipType.P, 'E', 2, 2, 3); player = new Player("Player-1", battleArea); var battleArea2 = new BattleArea(5, 'E'); battleArea2.SetShip(ShipType.P, 'D', 3, 2, 4); battleArea2.SetShip(ShipType.Q, 'A', 1, 2, 3); player2 = new Player("Player-2", battleArea2); }
public void MatchPlayerArea(BattleArea playerArea, BattleArea npcArea, string targetPoint, ShipsContainer shipsContainer) { bool isDestroyShip = false; int y = Coordinates.MapToLiteral(targetPoint[0].ToString()); int x = int.Parse(targetPoint.Substring(1)); IField npcTarget = npcArea.BattleFields[x, y].Field; if (!(npcTarget is BoundField)) { if (npcTarget is ShipField) { Guid guid = (npcArea.BattleFields[x, y].Field as ShipField).ShipType.Guid; playerArea.BattleFields[x, y] = new BattleField(new ShipField(new RegularShip(true, guid))); List <ShipBase> listOfShips = shipsContainer.GetShipsByGuid(guid); listOfShips.First(d => (d.ShipsPoints.X == x && d.ShipsPoints.Y == y)).IsDestroy = true; foreach (ShipBase s in listOfShips) { if (!s.IsDestroy) { isDestroyShip = false; break; } isDestroyShip = true; } if (isDestroyShip) { foreach (ShipBase s in listOfShips) { playerArea.BattleFields[s.ShipsPoints.X, s.ShipsPoints.Y] = new BattleField(new ShipDestroyField()); foreach (Point p in s.NearShipPoints) { playerArea.BattleFields[p.X, p.Y] = new BattleField(new MissField()); } } } } else { playerArea.BattleFields[x, y] = new BattleField(new MissField()); } } }
public void AddShipTest() { BattleArea battleArea = new BattleArea(); IShip ship = new Ship(1, 1, ShipType.TypeP); Assert.AreEqual(battleArea.AllShips.Count, 0); battleArea.AddShip(ship, new CoOrdinates('1', 'A')); bool hasCoords = battleArea.GetAcquireCoordinates().Count > 0 && battleArea.GetAcquireCoordinates()[0].X == '1' && battleArea.GetAcquireCoordinates()[0].Y == 'A'; Assert.AreEqual(hasCoords, true); Assert.AreEqual(battleArea.AllShips.Count, 1); }
//If inside of trigger private void OnTriggerStay(Collider other) { //Attempt ot join battle if trigger is BattleArea if (other.tag == "BattleArea" && !inBattle) { BattleArea area = other.GetComponent <BattleArea>(); if (area.AreOpenSpots()) { currentBattleArea = area; currentBattleArea.AddCreature(gameObject, true); inBattle = true; } else { Destroy(this.gameObject); } } }
public void DamageTest() { BattleArea battleArea = new BattleArea(); IShip ship = new Ship(1, 1, ShipType.TypeP); CoOrdinates coords = new CoOrdinates('1', 'A'); coords.Value = 1; ship.AcquiredCoordinates.Add(coords); battleArea.AddShip(ship, new CoOrdinates('1', 'A')); bool result = battleArea.Damage(new CoOrdinates('1', 'A')); Assert.AreEqual(result, true); IShip ship1 = battleArea.AllShips[0]; Assert.AreEqual(ship1.AcquiredCoordinates[0].Value, 0); Assert.AreEqual(ship1.DamageStatus, DamageStatus.Destroyed); Assert.AreEqual(battleArea.GetAcquireCoordinates()[0].Value, 0); battleArea.AllShips.Add(ship); }
private bool validateCardsToPlayInQuest(List <BattleCard>[] questChunks) { int lastBattlePoints = 0; foreach (List <BattleCard> questChunk in questChunks) { BattleArea compareArea = new BattleArea(); foreach (BattleCard card in questChunk) { compareArea.Add(card); } if (compareArea.BattlePoints() - 10 < lastBattlePoints) { return(false); } lastBattlePoints = compareArea.BattlePoints(); } return(true); }
private bool validateCardsToSponsorQuest(List <AdventureCard>[] stages) { int lastBattlePoints = 0; foreach (List <AdventureCard> stage in stages) { BattleArea compareArea = new BattleArea(); List <BattleCard> nonTests = new List <BattleCard>(); bool StageIsTest = false; //filter test cards foreach (AdventureCard card in stage) { if (!(card is TestCard)) { nonTests.Add((BattleCard)card); } else { StageIsTest = true; break; } } if (!StageIsTest) { foreach (BattleCard card in nonTests) { compareArea.Add(card); } if (compareArea.BattlePoints() <= lastBattlePoints) { return(false); } lastBattlePoints = compareArea.BattlePoints(); } } return(true); }
//When enemy hits another trigger private void OnTriggerEnter(Collider other) { //If trigger is for BattleArea, attempt to join battle if (other.tag == "BattleArea" && !inBattle) { BattleArea area = other.GetComponent <BattleArea>(); if (area.AreOpenSpots()) { currentBattleArea = area; currentBattleArea.AddCreature(gameObject, true); inBattle = true; } else { Destroy(this.gameObject); } } //If trigger is part of path, keep following path else if (other.tag == "PathBlock") { currentPathTarget = GetNextSpot(other.gameObject); transform.rotation = currentPathTarget.transform.rotation; } }
void Start() { battleArea = GetComponentInParent <BattleArea>(); rayPer = GetComponent <RayPerception3D>(); player = GetComponent <Player>(); }
// Konstruktor klasy - stworzenie pola bitwy o zadanym rozmiarze. public Battle(int length = 10, int width = 20) { BattleArea = new BattleArea(length, width); }
public GameAreaManager(BattleArea area, GameShipManager shipManager) { Area = area; ShipManager = shipManager; ShipContainer = new ShipsContainer(); }
public static void SetBattleArea(BattleArea area) { GameHandler.Instance().battleArea = area; }
public void ClearData() { if(this.dropHandler != null) this.dropHandler.ClearData(); this.items = new Hashtable(); this.weapons = new Hashtable(); this.armors = new Hashtable(); this.money = 0; this.variables = new Hashtable(); this.numberVariables = new Hashtable(); this.recipes = new ArrayList(); this.inBattleArea = 0; this.battleArea = null; }