Esempio n. 1
0
        public void DetectTest_OneInOutOfSingleTransition_ReturnsNull()
        {
            // ARRANGE

            var actorNodeMock = new Mock <IGraphNode>();
            var actorNode     = actorNodeMock.Object;

            var transitionNodeMock = new Mock <IGraphNode>();
            var transitionNode     = transitionNodeMock.Object;

            var sectorNodeMock = new Mock <ISectorNode>();
            var sectorNode     = sectorNodeMock.Object;

            var transition = new RoomTransition(sectorNode);

            var testedTrasitions = new Dictionary <IGraphNode, RoomTransition>
            {
                { transitionNode, transition }
            };

            var testedNodes = new[] { actorNode };

            RoomTransition expectedTransition = null;



            // ACT
            var factTransition = TransitionDetection.Detect(testedTrasitions, testedNodes);



            // ASSERT
            factTransition.Should().Be(expectedTransition);
        }
Esempio n. 2
0
        public void DetectTest_OneInSingleTransition_ReturnsThisTransition()
        {
            // ARRANGE

            var actorNodeMock = new Mock <IGraphNode>();
            var actorNode     = actorNodeMock.Object;

            var sectorNodeMock = new Mock <ISectorNode>();
            var sectorNode     = sectorNodeMock.Object;

            var transition = new SectorTransition(sectorNode);

            var testedTrasitions = new Dictionary <IGraphNode, SectorTransition>
            {
                { actorNode, transition }
            };

            var testedNodes = new[] { actorNode };

            var expectedTransition = transition;

            // ACT
            var factTransition = TransitionDetection.Detect(testedTrasitions, testedNodes);

            // ASSERT
            factTransition.Should().Be(expectedTransition);
        }
        /// <summary>
        /// Выполнение команды на перемещение и обновление игрового цикла.
        /// </summary>
        protected override void ExecuteTacticCommand()
        {
            var actorNode = CurrentActor.Node;
            var map       = SectorManager.CurrentSector.Map;

            var detectedTransition = TransitionDetection.Detect(map.Transitions, new[] { actorNode });

            SectorManager.CurrentSector.UseTransition(detectedTransition);
        }
Esempio n. 4
0
        public override void Execute()
        {
            var actorNode  = Actor.Node;
            var transition = TransitionDetection.Detect(Context.Sector.Map.Transitions, new[] { actorNode });

            if (transition != null)
            {
                Actor.MoveToOtherSector(Context.Sector, transition);
            }
            else
            {
                throw new InvalidOperationException("Попытка выполнить переход из узла, где нет перехода.");
            }
        }
        /// <summary>
        /// Определяем, может ли команда выполниться.
        /// </summary>
        /// <returns> Возвращает true, если перемещение возможно. Иначе, false. </returns>
        public override bool CanExecute()
        {
            if (CurrentActor == null)
            {
                return(false);
            }

            var actorNode = CurrentActor.Node;
            var map       = SectorManager.CurrentSector.Map;

            var detectedTransition = TransitionDetection.Detect(map.Transitions, new[] { actorNode });

            var actorOnTransition = detectedTransition != null;

            return(actorOnTransition);
        }
Esempio n. 6
0
        /// <summary>
        /// Определяем, может ли команда выполниться.
        /// </summary>
        /// <returns> Возвращает true, если перемещение возможно. Иначе, false. </returns>
        public override CanExecuteCheckResult CanExecute()
        {
            if (CurrentActor is null)
            {
                return(new CanExecuteCheckResult {
                    IsSuccess = false
                });
            }

            if (_player.Globe is null || _player.MainPerson is null)
            {
                // We can't check transition if the globe and/or the main person equal null.

                throw new InvalidOperationException("Player object is not initialized.");
            }

            var actorNode = CurrentActor.Node;
            var sector    = _player.SectorNode.Sector;

            if (sector is null)
            {
                throw new InvalidOperationException();
            }

            var map = sector.Map;

            var detectedTransition = TransitionDetection.Detect(map.Transitions, new[] { actorNode });

            var actorOnTransition = detectedTransition != null;

            if (!actorOnTransition)
            {
                return(new CanExecuteCheckResult {
                    IsSuccess = false
                });
            }

            return(new CanExecuteCheckResult {
                IsSuccess = true
            });
        }