public MainGameManager(GameSetup gameSetup) { MapAssetSet assetSet = gameSetup.MapDefinition.GetMapAssetSet(); Map map = new Map(assetSet.MapSetup); IEnumerable <PlayerSetup> playerSetups = PlayerSetup.CreateFromMapDefinition(assetSet.MapSetup); GameTurnTransition initialState = GetInitialState(playerSetups, map); _turns.Add(initialState); _provinceNeighbors = new ProvinceNeighborsTable(CurrentState); ObjectManager = new UnityObjectManager(map, assetSet, gameSetup.MapPrefab, gameSetup.FactionPrefab, gameSetup.OrderIndicatorPrefab, gameSetup.ScreenCanvas, initialState.AfterEverything, playerSetups); InteractionManager = new InteractionManager(this, map, gameSetup, ObjectManager, playerSetups); DisplayManager = new GameDisplayManager(this, gameSetup, playerSetups.Select(item => item.Faction), map, ObjectManager, InteractionManager.Factions, initialState.AfterEverything); }
private void HandleDragDrop(ProvinceNeighborsTable neighbors) { bool validDrag = GetWasValidDragDrop(neighbors); if (validDrag) { InteractionMain.Factions.ActiveInteraction.RequestAttackOrMerge(_selectedProvince, _draggedOnProvince); } }
private bool GetIsNeighborSelected(GameState gameState, ProvinceNeighborsTable neighborsTable, MapInteraction mapInteraction, Province myProvince) { if (mapInteraction.SelectedProvince != null) { HashSet <Province> neighbors = neighborsTable.GetNeighborsFor(mapInteraction.SelectedProvince); return(neighbors.Contains(myProvince)); } return(false); }
public void UpdateUiState(GameState gameState, MapInteraction mapInteraction, float timeDelta, UiAethetics aethetics, ProvinceNeighborsTable neighbors) { foreach (TileDisplay tile in TileDisplays) { tile.UpdateHighlighting(gameState, mapInteraction, aethetics.TransitionSpeed, timeDelta, neighbors); } _mapUnityObject.UpdateTileStatesBuffer(TileDisplays); }
private bool GetWasValidDragDrop(ProvinceNeighborsTable neighbors) { bool mouseJustUp = Input.GetMouseButtonUp(0); bool wasDragDrop = OwnedProvinceSelected && Dragging && _draggedOnProvince != null && _selectedProvince != _draggedOnProvince && mouseJustUp; if (wasDragDrop) { return(neighbors.GetNeighborsFor(_selectedProvince.Identifier).Contains(_draggedOnProvince.Identifier)); } return(false); }
public void AdvanceGame(GameTurnMoves moves) { GameTurnTransition newState = CurrentState.GetNextState(moves); _turns.Add(newState); IEnumerable <Faction> survivingFactions = newState.AfterEverything.GetSurvivingFactions(); if (survivingFactions.Count() < 2) { HandleGameConclusion(survivingFactions); } DisplayManager.UpdateDisplayWrappers(CurrentState); _provinceNeighbors = new ProvinceNeighborsTable(CurrentState); InteractionManager.Factions.RenewBuilders(survivingFactions); InteractionManager.Timeline.SetToMax(TurnsCount); }
public void Update(GameState currentGamestate, ProvinceNeighborsTable neighbors) { _hoveredProvince = GetProvinceUnderMouse(currentGamestate); bool mouseDown = Input.GetMouseButton(0); if (mouseDown) { bool mouseJustDown = Input.GetMouseButtonDown(0); if (mouseJustDown) { HandleHoverToSelected(currentGamestate); HandleSelectedToDragging(); } HandleDraggedUpon(); } else { HandleDragDrop(neighbors); _draggedOnProvince = null; Dragging = false; } }
public void UpdateHighlighting(GameState gameState, MapInteraction mapInteraction, float transitionSpeed, float timeDelta, ProvinceNeighborsTable neighbors) { Province myProvince = gameState.GetTilesProvince(Tile).Identifier; bool isNeighborSelected = mapInteraction.OwnedProvinceSelected && GetIsNeighborSelected(gameState, neighbors, mapInteraction, myProvince); float speed = transitionSpeed * timeDelta; bool isHovered = mapInteraction.HoveredProvince == myProvince; bool isSelected = mapInteraction.SelectedProvince == myProvince; bool isDragging = isSelected && mapInteraction.Dragging; bool isDragged = mapInteraction.DraggedOnProvince == myProvince; Hover = Mathf.Lerp(Hover, isHovered ? 1 : 0, speed); Selected = Mathf.Lerp(Selected, isSelected ? 1 : 0, speed); Dragging = Mathf.Lerp(Dragging, isDragging ? 1 : 0, speed); Dragged = Mathf.Lerp(Dragged, isDragged ? 1 : 0, speed); Targetable = Mathf.Lerp(Targetable, isNeighborSelected ? 1 : 0, speed); }
internal void UpdateUi(GameState gameState, float timeDelta, UiAethetics aethetics, ProvinceNeighborsTable neighbors) { UpdateUiAethetics(aethetics); Map.UpdateUiState(gameState, _mainManager.InteractionManager.Map, timeDelta, aethetics, neighbors); _factions.UpdateUi(gameState); }
internal void Update(GameState gameState, ProvinceNeighborsTable neighbors) { Map.Update(gameState, neighbors); }