public override void Update(KeyboardDevice keyboard)
        {
            if (IsCollidingInWalkingDirection())
            {
                ChangeDirection();
            }

            if (!IsOnPillar() && ent.IsOnGround() && !CanWalkWithoutFalling())
            {
                ChangeDirection();
            }

            Vec2d delta = GetDirectionVector() * MOB_ACC;

            if (IsOnMaxSpeed(MOB_SPEED))
            {
                delta *= 0;
            }

            if (!ent.IsOnGround() || CanWalkWithoutFalling() || IsOnPillar()) // Walk normal
            {
                DoGravitationalMovement(delta);
            }
            else // Emergency break
            {
                delta = new Vec2d(-movementDelta.X, 0);
                delta.DoMaxLength(MOB_ACC);

                DoGravitationalMovement(delta);
            }
        }
Esempio n. 2
0
        public void Calculate(Rect2d target, int window_width, int window_height, double mapW, double mapH, bool moveDown, bool capCorrection = true)
        {
            Rect2d cameraBox = GetOffsetBox(window_width, window_height);
            Vec2d  playerPos = target.GetMiddle();

            // Wenn man aus der Mittleren Box rausläuft - Offset Verschieben
            //###############################################################################

            Vec2d moveCorrection = cameraBox.GetDistanceTo(playerPos);


            if (moveDown && moveCorrection.Y == 0 && playerPos.Y != cameraBox.tl.Y)
            {
                moveCorrection.Y -= 5;
            }

            // Offset NICHT verschieben wenn amn damit die Grenzen der aktuellen Zone verletzten Würde
            //###############################################################################

            Vec2d zoneCorrection = GetVisionZoneCorrection(Value + moveCorrection, playerPos, window_width, window_height);

            Vec2d realCorrection = moveCorrection + zoneCorrection;

            if (capCorrection)
            {
                realCorrection.DoMaxLength(MAX_CORRECTION_SPEED);
            }
            if (realCorrection.GetLength() < 0.001)
            {
                realCorrection = Vec2d.Zero;
            }


            Value += realCorrection;
        }
Esempio n. 3
0
        private void MoveBy(Vec2d delta)
        {
            movementDelta += delta;

            ent.position += movementDelta;

            movementDelta.DoMaxLength(MAX_SPEED);

            //ent.DoCollisions(); // No Collisions with C-Particles
        }