Esempio n. 1
0
    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);
    }
Esempio n. 2
0
    private void HandleDragDrop(ProvinceNeighborsTable neighbors)
    {
        bool validDrag = GetWasValidDragDrop(neighbors);

        if (validDrag)
        {
            InteractionMain.Factions.ActiveInteraction.RequestAttackOrMerge(_selectedProvince, _draggedOnProvince);
        }
    }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
    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);
    }
Esempio n. 6
0
    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);
    }
Esempio n. 7
0
    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;
        }
    }
Esempio n. 8
0
    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);
 }
Esempio n. 10
0
 internal void Update(GameState gameState, ProvinceNeighborsTable neighbors)
 {
     Map.Update(gameState, neighbors);
 }