Esempio n. 1
0
        // --------------------------------------------------------------------------------------------
        public void OnDragFromUnitView(UnitView unitView, Vector2 prevDragPosition, Vector2 dragDelta)
        {
            if (_selectedUnit != null && unitView.Unit != _selectedUnit)
            {
                return;
            }

            if (_game.board.RaycastToPlane(_game.gameCamera.ScreenPointToRay(prevDragPosition + dragDelta), out Vector3 worldPos))
            {
                BoardTile boardTile = _game.board.GetBoardTileAtPosition(worldPos);
                if (boardTile != null && boardTile != _prevBoardTile)
                {
                    _prevBoardTile = boardTile;
                }
            }

            if (_pathSelectionView.IsBuilt)
            {
                _pathSelectionView.PathTo(_prevBoardTile);
            }

            if (_useSkillView.IsBuilt)
            {
                _useSkillView.TargetTowardTile(_prevBoardTile);
            }
        }
Esempio n. 2
0
        // --------------------------------------------------------------------------------------------
        protected override void Build()
        {
            UnitView.CreateForGame(_game, this, _data, (UnitView view) =>
            {
                _view = view;
            });

            _owner.PlayerTurnStarted += Player_PlayerTurnStarted;
            _owner.PlayerTurnEnded   += Player_PlayerTurnEnded;
        }
Esempio n. 3
0
        // --------------------------------------------------------------------------------------------
        public void OnSelectedUnitView(UnitView unitView)
        {
            // TODO: show some sort of context menu for the unit here
            // TODO: for now, just destroy any visible views

            if (_pathSelectionView.IsBuilt)
            {
                _pathSelectionView.Destroy();
            }

            if (_useSkillView.IsBuilt)
            {
                _useSkillView.Destroy();
            }
        }
Esempio n. 4
0
        // --------------------------------------------------------------------------------------------
        public void OnPointerDownOverUnitView(UnitView unitView)
        {
            _selectedUnit           = unitView.Unit;
            _pathSelectionView.unit = _selectedUnit;
            _useSkillView.unit      = _selectedUnit;
            _prevBoardTile          = unitView.Unit.BoardTile;

            if (_selectedUnit.CanMove && !_pathSelectionView.IsBuilt)
            {
                // only show the UnitPathSelectionView if the unit can move
                _pathSelectionView.Render(AppManager.Transform);
            }
            if (_selectedUnit.CanUseSkill && !_useSkillView.IsBuilt)
            {
                // only show the UnitUseSkillView if the unit can use its skill
                _useSkillView.Render(AppManager.Transform);
            }
        }
Esempio n. 5
0
        // --------------------------------------------------------------------------------------------
        public static void CreateForGame(Game game, Unit unit, UnitData data, InstantiateDelegate callback)
        {
            AppManager.AssetManager.Load(data.prefabPath, (bool successful, GameObject payload) =>
            {
                if (successful)
                {
                    GameObject viewGo = Instantiate(payload, unit.Transform, false);

                    UnitView view       = viewGo.GetComponent <UnitView>();
                    view.Unit           = unit;
                    view._healthBarView = new UIUnitHealthBarView(game, unit);

                    _unitToView.Add(unit, view);

                    callback(view);
                }
            });
        }
Esempio n. 6
0
 // --------------------------------------------------------------------------------------------
 public static bool TryGetView(Unit unit, out UnitView view)
 {
     return(_unitToView.TryGetValue(unit, out view));
 }
Esempio n. 7
0
 // --------------------------------------------------------------------------------------------
 public void OnSelectedUnitView(UnitView unitView)
 {
 }
Esempio n. 8
0
 // --------------------------------------------------------------------------------------------
 public void OnPointerDownOverUnitView(UnitView unitView)
 {
 }
Esempio n. 9
0
 // --------------------------------------------------------------------------------------------
 public void OnDragFromUnitView(UnitView unitView, Vector2 prevDragPosition, Vector2 dragDelta)
 {
 }