コード例 #1
0
        public bool CanRelocate(IHexCell newLocation)
        {
            if (newLocation == null)
            {
                throw new ArgumentNullException("newLocation");
            }

            return(PositionCanon.CanChangeOwnerOfPossession(this, newLocation));
        }
コード例 #2
0
        private void OnCellPointerEntered(IHexCell cell)
        {
            if (!IsDragging)
            {
                return;
            }

            if (cell != null && UnitPositionCanon.CanChangeOwnerOfPossession(SelectedUnit, cell))
            {
                ProspectiveNewLocation = cell;
            }
            else
            {
                ProspectiveNewLocation = null;
            }
        }
コード例 #3
0
        private void OnCellPointerEntered(IHexCell cell)
        {
            if (!IsDragging)
            {
                return;
            }

            IUnit attackCandidate = AttackOrderLogic.GetNextAttackTargetOnCell(cell);

            if (attackCandidate == SelectedUnit)
            {
                return;
            }

            if (attackCandidate != null && CombatExecuter.CanPerformMeleeAttack(SelectedUnit, attackCandidate))
            {
                SetUnitToAttack(attackCandidate);
                return;
            }

            var cityOnCell = CityLocationCanon.GetPossessionsOfOwner(cell).FirstOrDefault();

            if (cityOnCell != null && CombatExecuter.CanPerformMeleeAttack(SelectedUnit, cityOnCell.CombatFacade))
            {
                SetCityToAttack(cityOnCell);
                return;
            }

            var unitLocation = UnitPositionCanon.GetOwnerOfPossession(SelectedUnit);

            if (unitLocation != cell && UnitPositionCanon.CanChangeOwnerOfPossession(SelectedUnit, cell))
            {
                SetProspectiveTravelGoal(unitLocation, cell);
            }
            else
            {
                Clear();
            }
        }