Exemplo n.º 1
0
        /// <inheritdoc />
        internal override void BehaviorAtNewFrame()
        {
            NewScreenEntrance = null;
            Point newPosition = Tools.ComputeMovementNextPointInDirection(X, Y, _movementTimeManager.Distance(Speed), Engine.Default.KeyPress.Direction);

            // If any movement.
            if (!newPosition.X.Equal(X) || !newPosition.Y.Equal(Y))
            {
                CheckPotentialOverlapAndAdjustPosition(ref newPosition);

                CheckNewScreenEntrance(ref newPosition);

                Direction = Engine.Default.KeyPress.Direction ?? Direction;

                AssigneNewPositionAndAddToHistory(newPosition);
            }

            ManageHit();

            // Proceeds to proximity actions (open chests...)
            // Single action at a time.
            if (Engine.Default.KeyPress.PressAction)
            {
                foreach (Chest chest in Engine.Default.CurrentScreen.ClosedChests)
                {
                    if (chest.Overlap(ResizeToRatio(Constants.Player.ACTION_RANGE)) && chest.PlayerIsLookingTo())
                    {
                        chest.TryOpen();
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        internal override void BehaviorAtNewFrame()
        {
            Point newPositionPoint = _path.ComputeNextPosition(this, _movementTimeManager.Distance(Speed));

            if (!TryToOverlapPlayerWithShield(newPositionPoint))
            {
                SetCoordinatesDirection(newPositionPoint);
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        internal override void BehaviorAtNewFrame()
        {
            base.BehaviorAtNewFrame();

            Point nextPos = Tools.ComputeMovementNextPointInDirection(X, Y, _elapser.Distance(Constants.Arrow.SPEED), Direction);

            Move(nextPos.X, nextPos.Y);

            // Checks if hit enemies.
            // Checks if hit player.
            // Checks if outside screen.
            _hitOrAway = Engine.Default.CurrentScreen.Enemies.Any(e => e != _thrownBy && Overlap(e)) ||
                         (Overlap(Engine.Default.Player) && Engine.Default.Player != _thrownBy) ||
                         !Engine.Default.CurrentScreen.IsInside(this);
        }