示例#1
0
    //disables overlays then if unit occupies the tile, calculates move overlays for it
    public void OnNewTile(Tile tile)
    {
        CurrentUnit = null;

        _overlaysManager.DisableTemporaryOverlays();

        if (tile.IsOccupied())
        {
            CurrentUnit = tile.Occupier;
            if (_battleTurnManager.IsInActiveGroup(CurrentUnit))
            {
                UnitMoveTiles = BattleMovementUtils.FindViableMoves(CurrentUnit);
                AttackedTiles = BattleMovementUtils.FindAttackedTiles(UnitMoveTiles, CurrentUnit.GetWeaponsRanges());
                _overlaysManager.EnablePlayerMoveOverlays(UnitMoveTiles);
                _overlaysManager.EnableAttackedOverlays(AttackedTiles);
            }
            else
            {
                EnemyTiles = BattleMovementUtils.FindViableMoves(CurrentUnit);
                EnemyTiles.UnionWith(BattleMovementUtils.FindAttackedTiles(EnemyTiles, CurrentUnit.GetWeaponsRanges()));
                _overlaysManager.EnableEnemyOverlays(EnemyTiles);
            }
        }
    }
示例#2
0
    public void HandleInput()
    {
        if (_inputManager.ZoomIn)
        {
            _cameraMover.ZoomIn();
        }

        if (_inputManager.ZoomOut)
        {
            _cameraMover.ZoomOut();
        }

        if (_inputManager.RotateLeft)
        {
            _cameraMover.RotateLeft();
        }

        if (_inputManager.RotateRight)
        {
            _cameraMover.RotateRight();
        }

        if (_inputManager.SelectDown)
        {
            if (_cursor.UnitIsSelected)
            {
                if (_cursor.IsInRangeOfSelectedUnit())
                {
                    _inputManager.InputState = EInputState.ActionMenu;
                    _cursor.enabled          = false;
                    var targetTile = BattleMovementUtils.GetDestinationTile();
                    _cursor.SelectedUnit.Move(targetTile);
                    showUnitActions();
                }
            }
            else if (_cursor.HoveredTile.IsOccupied())
            {
                var  hoveredUnit = _cursor.HoveredTile.Occupier;
                bool isUnitFromTheACtiveGroup = hoveredUnit.Group ==
                                                _battleManager.BattleTurnManager.ActiveGroup;
                if (isUnitFromTheACtiveGroup)
                {
                    _cursor.SelectUnit();
                    //_battleManager.BattleMovement.OnNewTile(_cursor.HoveredTile);
                }
                else
                {
                    _overlaysManager.DisableTemporaryOverlays();
                    _battleMovement.ClearUnitTiles();
                    _battleMovement.TrackEnemyRange(hoveredUnit);
                    _battleMovement.UpdateTrackedTiles();
                    _overlaysManager.UpdateTrackedOverlays();
                }
            }
            else
            {
                _inputManager.InputState = EInputState.GeneralMenu;
                _cursor.enabled          = false;
                showGeneralActions();
            }
        }
        else if (_inputManager.CancelDown)
        {
            if (_cursor.UnitIsSelected)
            {
                BattleMovementUtils.HidePath();
                BattleMovementUtils.ResetPath();

                if (_cursor.HoveredTile != _cursor.SelectedUnit.OccupiedTile)
                {
                    _battleManager.OverlaysManager.DisableTemporaryOverlays();
                }

                _cursor.DeselectUnit();
            }
            else if (_cursor.HoveredTile.IsOccupied())
            {
                var  hoveredUnit = _cursor.HoveredTile.Occupier;
                bool isUnitFromTheACtiveGroup = hoveredUnit.Group ==
                                                _battleManager.BattleTurnManager.ActiveGroup;

                if (!isUnitFromTheACtiveGroup)
                {
                    _battleMovement.UntrackEnemyRange(hoveredUnit);
                    _battleMovement.UpdateTrackedTiles();
                    _overlaysManager.UpdateTrackedOverlays();
                }
            }
        }
    }