Ejemplo n.º 1
0
        //--------------------------HANDLE DIRECTION CHANGE--------------------------
        private void checkForDirectionChange(Entity e)
        {
            SmushComponent    smushComp = ( SmushComponent )e.getComponent(GlobalVars.SMUSH_COMPONENT_NAME);
            VelocityComponent velComp   = ( VelocityComponent )e.getComponent(GlobalVars.VELOCITY_COMPONENT_NAME);

            float stopBuffer = 0.01f;

            if (smushComp.getFallSpeed().X != 0 && Math.Abs(velComp.x) < stopBuffer)
            {
                if (smushComp.isFalling())
                {
                    startLowerWait(e);
                }
                else if (smushComp.isRising())
                {
                    startUpperWait(e);
                }
            }
            if (smushComp.getFallSpeed().Y != 0 && Math.Abs(velComp.y) < stopBuffer)
            {
                if (smushComp.isFalling())
                {
                    startLowerWait(e);
                }
                else if (smushComp.isRising())
                {
                    startUpperWait(e);
                }
            }
        }