Esempio n. 1
0
        void UpdateAnimationTree()
        {
            if (EntitySystemWorld.Instance.Simulation && !EntitySystemWorld.Instance.SystemPauseOfSimulation)
            {
                AnimationTree tree = GetFirstAnimationTree();
                if (tree != null)
                {
                    bool onGround = GetElapsedTimeSinceLastGroundContact() < .2f;                    //IsOnGround();

                    bool   move      = false;
                    Degree moveAngle = 0;
                    float  moveSpeed = 0;
                    if (onGround && GroundRelativeVelocitySmooth.ToVec2().Length() > .05f)
                    {
                        move = true;
                        Vec2   localVec = (Rotation.GetInverse() * GroundRelativeVelocity).ToVec2();
                        Radian angle    = MathFunctions.ATan(localVec.Y, localVec.X);
                        moveAngle = angle.InDegrees();
                        moveSpeed = GroundRelativeVelocity.ToVec2().Length();
                    }

                    tree.SetParameterValue("move", move ? 1 : 0);
                    tree.SetParameterValue("run", move && IsNeedRun() ? 1 : 0);
                    tree.SetParameterValue("moveAngle", moveAngle);
                    tree.SetParameterValue("moveSpeed", moveSpeed);
                    tree.SetParameterValue("fly", !onGround ? 1 : 0);
                }
            }
        }
Esempio n. 2
0
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnTick()"/>.</summary>
        protected override void OnTick()
        {
            CalculateRelativeVelocity();

            base.OnTick();

            TickContusionTime();

            //if (Damager_Ball_Player != null && Damager_Ball_Player.LastStepLinearVelocity != null)
            //     RelativeVelocity += Damager_Ball_Player.LastStepLinearVelocity / skilllevel;
            //else
            //     RelativeVelocity = currentvelocity + (forward(strength)) + (right(strength));

            float speed = GroundRelativeVelocity.Length();

            if (speed >= 1)
            {
                speed = 1f;
            }

            if (Damager_Ball_Player != null)
            {
                Damager_Ball_Player.AddForce(ForceType.Global, TickDelta, new Vec3(0, 0, speed *= PhysicsGravity), Position);
            }

            TickMovement();

            if (Intellect != null)
            {
                TickIntellect(Intellect);
            }

            //UpdateRotation();
            //TickJump(false);

            //if (IsOnGround())
            //    onGroundTime += TickDelta;
            //else
            //    onGroundTime = 0;

            //if (forceMoveVectorTimer != 0)
            //    forceMoveVectorTimer--;

            //if (turret != null)
            //    turretTimer += TickDelta; //can add remove after 10 seconds
        }
Esempio n. 3
0
        protected override void OnUpdateBaseAnimation()
        {
            base.OnUpdateBaseAnimation();

            //walk animation
            if (IsOnGround() && GroundRelativeVelocity.ToVec2().LengthSqr() > .3f)
            {
                float velocity = (Rotation.GetInverse() * GroundRelativeVelocity).X *
                                 Type.WalkAnimationVelocityMultiplier;
                UpdateBaseAnimation(Type.WalkAnimationName, true, true, velocity);
                return;
            }

            //idle animation
            {
                UpdateBaseAnimation(Type.IdleAnimationName, true, true, 1);
                return;
            }
        }
        void UpdateFirstPersonArmsAttachedMesh(MapObjectAttachedMesh armsAttachedMesh, Camera camera)
        {
            //update animation tree
            if (EntitySystemWorld.Instance.Simulation && !EntitySystemWorld.Instance.SystemPauseOfSimulation)
            {
                AnimationTree tree = armsAttachedMesh.AnimationTree;
                if (tree != null)
                {
                    bool onGround = GetElapsedTimeSinceLastGroundContact() < .2f;                    //IsOnGround();

                    bool  move      = false;
                    float moveSpeed = 0;
                    if (onGround && GroundRelativeVelocitySmooth.ToVec2().Length() > .05f)
                    {
                        move      = true;
                        moveSpeed = GroundRelativeVelocity.ToVec2().Length();
                    }

                    tree.SetParameterValue("move", move ? 1 : 0);
                    tree.SetParameterValue("run", move && IsNeedRun() ? 1 : 0);
                    tree.SetParameterValue("moveSpeed", moveSpeed);
                    float moveSpeedFactor = moveSpeed / Type.RunForwardMaxSpeed;
                    if (moveSpeedFactor > 1)
                    {
                        moveSpeedFactor = 1;
                    }
                    tree.SetParameterValue("moveSpeedFactor", moveSpeedFactor);
                }
            }

            //update scene node
            armsAttachedMesh.SceneNode.Position = camera.Position + camera.Rotation * armsAttachedMesh.TypeObject.Position;
            armsAttachedMesh.SceneNode.Rotation = camera.Rotation * armsAttachedMesh.TypeObject.Rotation;

            //use this code to look arms from another point of view. Useful for calibration position of attached weapon.
            //armsAttachedMesh.SceneNode.Position = new Vec3( 0, 0, 2 ) + Quat.Identity * armsAttachedMesh.TypeObject.Position;
            //armsAttachedMesh.SceneNode.Rotation = Quat.Identity * armsAttachedMesh.TypeObject.Rotation;
        }