Пример #1
0
        public void Update(float deltaTime)
        {
            //if (PlayerInput.KeyHit(InputType.Crouch) && (this == MainSub)) FlipX();

            if (Level.Loaded == null)
            {
                return;
            }

            if (subBody == null)
            {
                return;
            }

            subBody.Body.LinearVelocity = new Vector2(
                LockX ? 0.0f : subBody.Body.LinearVelocity.X,
                LockY ? 0.0f : subBody.Body.LinearVelocity.Y);


            subBody.Update(deltaTime);

            for (int i = 0; i < 2; i++)
            {
                if (Submarine.MainSubs[i] == null)
                {
                    continue;
                }
                if (this != Submarine.MainSubs[i] && Submarine.MainSubs[i].DockedTo.Contains(this))
                {
                    return;
                }
            }

            //send updates more frequently if moving fast
            networkUpdateTimer -= MathHelper.Clamp(Velocity.Length() * 10.0f, 0.1f, 5.0f) * deltaTime;

            if (networkUpdateTimer < 0.0f)
            {
                networkUpdateTimer = 1.0f;
            }
        }
Пример #2
0
        public void Update(float deltaTime)
        {
            //if (PlayerInput.KeyHit(InputType.Crouch) && (this == MainSub)) FlipX();

            if (Level.Loaded == null || subBody == null)
            {
                return;
            }

            if (WorldPosition.Y < Level.MaxEntityDepth &&
                subBody.Body.Enabled &&
                (GameMain.NetworkMember?.RespawnManager == null || this != GameMain.NetworkMember.RespawnManager.RespawnShuttle))
            {
                subBody.Body.ResetDynamics();
                subBody.Body.Enabled = false;

                foreach (MapEntity e in MapEntity.mapEntityList)
                {
                    if (e.Submarine == this)
                    {
                        Spawner.AddToRemoveQueue(e);
                    }
                }

                foreach (Character c in Character.CharacterList)
                {
                    if (c.Submarine == this)
                    {
                        c.Kill(CauseOfDeath.Pressure);
                        c.Enabled = false;
                    }
                }

                return;
            }

            subBody.Body.LinearVelocity = new Vector2(
                LockX ? 0.0f : subBody.Body.LinearVelocity.X,
                LockY ? 0.0f : subBody.Body.LinearVelocity.Y);


            subBody.Update(deltaTime);

            for (int i = 0; i < 2; i++)
            {
                if (MainSubs[i] == null)
                {
                    continue;
                }
                if (this != MainSubs[i] && MainSubs[i].DockedTo.Contains(this))
                {
                    return;
                }
            }

            //send updates more frequently if moving fast
            networkUpdateTimer -= MathHelper.Clamp(Velocity.Length() * 10.0f, 0.1f, 5.0f) * deltaTime;

            if (networkUpdateTimer < 0.0f)
            {
                networkUpdateTimer = 1.0f;
            }
        }