示例#1
0
        public void Process()
        {
            IEntityAnimator entityAnimator = _entity.view.Controller.Animator;
            bool            actorIsVisible = _entity.view.Controller.IsVisible;

            if (actorIsVisible)
            {
                entityAnimator.StandUp();
            }
        }
示例#2
0
        public virtual void Process()
        {
            IGameEntity     entity         = ActorData.Entity;
            IEntityAnimator entityAnimator = entity.EntityAnimator;
            bool            actorIsVisible = entity.IsVisible;

            if (actorIsVisible)
            {
                entityAnimator.KnockOut();
            }
        }
示例#3
0
        public virtual void Process()
        {
            IViewController view           = _entity.view.Controller;
            IEntityAnimator entityAnimator = view.Animator;
            bool            actorIsVisible = view.IsVisible;

            if (actorIsVisible)
            {
                entityAnimator.Bump(_entity.position.Position, BumpedPosition);
            }
        }
示例#4
0
        public virtual void Process()
        {
            IViewController view           = _entity.view.Controller;
            IEntityAnimator entityAnimator = view.Animator;
            bool            actorIsVisible = view.IsVisible;

            if (actorIsVisible)
            {
                entityAnimator.KnockOut();
            }
        }
示例#5
0
        public virtual void Process()
        {
            IGameEntity     entity         = ActorData.Entity;
            IEntityAnimator entityAnimator = entity.EntityAnimator;
            bool            actorIsVisible = entity.IsVisible;

            _actorAligner.AlignActorToDirection(ActorData.Entity, BumpedPosition.x - ActorData.LogicalPosition.x);
            if (actorIsVisible)
            {
                entityAnimator.Bump(ActorData.LogicalPosition, BumpedPosition);
            }
        }
示例#6
0
        public void Process()
        {
            // todo: this piece of code is repeated among many effects. This should be definitely shared.
            IGameEntity     entity         = ActorData.Entity;
            IEntityAnimator entityAnimator = entity.EntityAnimator;
            bool            actorIsVisible = entity.IsVisible;

            if (actorIsVisible)
            {
                entityAnimator.StandUp();
            }
        }
示例#7
0
        public virtual void Process()
        {
            Position position = _entity.position.Position;
            bool     visibleActorsAreClose = _entity.isPlayerControlled &&
                                             _entityDetector.DetectEntities(position, 4)
                                             .Any(e => e != _entity && e.hasEnergy && e.hasView && e.view.Controller.IsVisible);

            if (visibleActorsAreClose)
            {
                DateTime potentialBlockedUntil = DateTime.UtcNow + TimeSpan.FromMilliseconds(150);
                if (_entity.hasBlockedUntil)
                {
                    if (potentialBlockedUntil > _entity.blockedUntil.BlockedUntil)
                    {
                        _entity.ReplaceBlockedUntil(potentialBlockedUntil);
                    }
                }
                else
                {
                    _entity.AddBlockedUntil(potentialBlockedUntil);
                }
            }

            IViewController view           = _entity.view.Controller;
            IEntityAnimator entityAnimator = view.Animator;

            if (view.IsVisible)
            {
                bool playerActorIsNear = _entityDetector.DetectEntities(position, 5).Any(a => a.isPlayerControlled);
                if (playerActorIsNear)
                {
                    entityAnimator.MoveTo(PreviousPosition, position);
                }
            }
            Vector3 animationTargetPosition = _unityGridInfoProvider.GetCellCenterWorld(position);

            view.Transform.position = animationTargetPosition;
        }
示例#8
0
        public virtual void Process()
        {
            bool visibleEnemiesClose = ActorData.ControlledByPlayer &&
                                       _entityDetector.DetectActors(ActorData.LogicalPosition, 3)
                                       .Count(a => a.Team != Team.Beasts && a.Entity.IsVisible) > 0;

            if (visibleEnemiesClose)
            {
                DateTime potentialBlockedUntil = DateTime.UtcNow + TimeSpan.FromMilliseconds(150);
                ActorData.BlockedUntil = potentialBlockedUntil > ActorData.BlockedUntil
                                        ? potentialBlockedUntil : ActorData.BlockedUntil;
            }

            IGameEntity     entity         = ActorData.Entity;
            IEntityAnimator entityAnimator = entity.EntityAnimator;

            IEnumerable <ActorData> enemiesNearby = _entityDetector.DetectActors(ActorData.LogicalPosition, 3)
                                                    .Where(e => ActorData.Team != e.Team)
                                                    .Where(e => Vector2IntUtilities.IsOneTwoOrThreeSteps(e.LogicalPosition, ActorData.LogicalPosition));

            // this code orientates the actor to face the closest danger, even if it means stepping backwards
            List <Vector2Int> directionsToOneStepEnemiesNearby = enemiesNearby.Select(e => e.LogicalPosition - ActorData.LogicalPosition)
                                                                 .Where(direction => Vector2IntUtilities.IsOneStep(direction))
                                                                 .ToList();
            List <Vector2Int> directionsToAllEnemiesNearby = enemiesNearby.Select(e => e.LogicalPosition - ActorData.LogicalPosition).ToList();
            List <Vector2Int> directionsToRelevantEnemiesNearby
                = directionsToOneStepEnemiesNearby.Any() ? directionsToOneStepEnemiesNearby : directionsToAllEnemiesNearby;

            bool thereAreSomeEnemiesOnOneSide = directionsToRelevantEnemiesNearby.Any()
                                                &&
                                                (directionsToRelevantEnemiesNearby.All(direction => direction.x < 0) ||
                                                 directionsToRelevantEnemiesNearby.All(direction => direction.x > 0));

            if (thereAreSomeEnemiesOnOneSide)
            {
                _actorAligner.AlignActorToDirection(ActorData.Entity, directionsToRelevantEnemiesNearby.First().x);
            }
            else
            {
                _actorAligner.AlignActorToDirection(ActorData.Entity, ActorData.LogicalPosition.x - PreviousPosition.x);
            }

            if (entity.IsVisible)
            {
                entityAnimator.MoveTo(PreviousPosition, ActorData.LogicalPosition);
            }
            else
            {
                Vector3 animationTargetPosition = _gridInfoProvider.GetCellCenterWorld(ActorData.LogicalPosition);

                // The next line makes this class kind of untestable, because ActorData.Entity is a MonoBehaviour. I believe it must be so,
                // so that we can see and assign the reference to it in the inspector window. If this happens more often in other effects,
                // we could maybe extract some kind of proxy class to keep the Entity, so that we can test with fake proxy.
                entity.Position = animationTargetPosition;
            }

            if (!ActorData.ControlledByPlayer)
            {
                return;
            }

            ItemData itemOnTheGround = _entityDetector.DetectItems(ActorData.LogicalPosition).FirstOrDefault();

            if (itemOnTheGround != null)
            {
                _uiConfig.TooltipPresenter.Present(itemOnTheGround.ItemDefinition, false);
            }
        }