public void CreateArea() { CreateEmptyArea(); IShipMaker shipMaker = new ShipMaker(Area, _areaMaker, ShipManager.CreateShips()); Area = shipMaker.CreateBattleAreaWithShip(); ShipCount = shipMaker.ShipCount; ShipContainer = shipMaker.ShipContainer; }
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 Init( ElementItem[,] userGrid, ElementItem[,] computerGrid, int gridSize, Action onSetStartPageState, ShipsManager shipsManager, List <StepMessageItem> stepMessageItems, SessionDataManager sessionDataManager, Action <PageState> setGamePage, Action resetGrid) { FreshStart(); _shipsManager = shipsManager; _dragBlock = _shipsManager.DragBlock; _resetShips = _shipsManager.ResetShips; _restartButton.onClick.RemoveAllListeners(); _restartButton.onClick.AddListener(() => Restart( stepMessageItems, sessionDataManager, setGamePage, resetGrid)); _backToStartMenuButton.onClick.RemoveAllListeners(); _backToStartMenuButton.onClick.AddListener(onSetStartPageState.Invoke); _confirm.onClick.RemoveAllListeners(); _confirm.onClick.AddListener(() => { ConfirmShipsPositions(); _shipsManager.SetRandomShips(gridSize, _shipsManager.ComputerShips, computerGrid); }); _random.onClick.RemoveAllListeners(); _random.onClick.AddListener(() => { _shipsManager.SetRandomShipsForAll(); ShipsContainer.SetActive(false); HideGameObjects.SetActive(true); }); TryToActivateConfirmButton(); }
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 GameAreaManager(BattleArea area, GameShipManager shipManager) { Area = area; ShipManager = shipManager; ShipContainer = new ShipsContainer(); }
private void ConfirmShipsPositions() { ShipsContainer.SetActive(false); HideGameObjects.SetActive(true); }
private void FreshStart() { WinnerPanel.SetActive(false); HideGameObjects.SetActive(false); ShipsContainer.SetActive(true); }