Пример #1
0
    public override VGDLMovementTypes activeMovement(VGDLSprite sprite, Vector2 action, float speed = -1)
    {
        if (!sprite.stationary)
        {
            if (speed == 0)
            {
                if (sprite.speed <= 0)
                {
                    speed = 1;
                }
                else
                {
                    speed = sprite.speed;
                }
            }

            if (speed != 0 && !action.Equals(Vector2.negativeInfinity) && !(action.Equals(Vector2.zero)))
            {
                if (sprite.rotateInPlace)
                {
                    bool change = sprite.updateOrientation(action);
                    if (change)
                    {
                        return(VGDLMovementTypes.ROTATE);
                    }
                }

                if (sprite.updatePos(action, (int)(speed * gridSize.x)))
                {
                    return(VGDLMovementTypes.MOVE);
                }
            }
        }
        return(VGDLMovementTypes.STILL);
    }