Java Code Examples for master.flame.danmaku.danmaku.model.BaseDanmaku#getType()

The following examples show how to use master.flame.danmaku.danmaku.model.BaseDanmaku#getType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DanmakuUtils.java    From letv with Apache License 2.0 6 votes vote down vote up
public static boolean willHitInDuration(IDisplayer disp, BaseDanmaku d1, BaseDanmaku d2, long duration, long currTime) {
    int type1 = d1.getType();
    if (type1 != d2.getType()) {
        return false;
    }
    if (d1.isOutside()) {
        return false;
    }
    long dTime = d2.time - d1.time;
    if (dTime < 0) {
        return true;
    }
    if (Math.abs(dTime) >= duration || d1.isTimeOut() || d2.isTimeOut()) {
        return false;
    }
    if (type1 == 5 || type1 == 4) {
        return true;
    }
    return checkHitAtTime(disp, d1, d2, currTime) || checkHitAtTime(disp, d1, d2, d1.time + d1.getDuration());
}
 
Example 2
Source File: DanmakuFactory.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void fillLinePathData(BaseDanmaku item, float[][] points, float scaleX, float scaleY) {
    if (item.getType() == 7 && points.length != 0 && points[0].length == 2) {
        for (int i = 0; i < points.length; i++) {
            float[] fArr = points[i];
            fArr[0] = fArr[0] * scaleX;
            fArr = points[i];
            fArr[1] = fArr[1] * scaleY;
        }
        ((SpecialDanmaku) item).setLinePathData(points);
    }
}
 
Example 3
Source File: DanmakusRetainer.java    From letv with Apache License 2.0 5 votes vote down vote up
public void fix(BaseDanmaku danmaku, IDisplayer disp, Verifier verifier) {
    switch (danmaku.getType()) {
        case 1:
            if (this.rldrInstance == null) {
                this.rldrInstance = new RLDanmakusRetainer();
            }
            this.rldrInstance.fix(danmaku, disp, verifier);
            return;
        case 4:
            if (this.fbdrInstance == null) {
                this.fbdrInstance = new FBDanmakusRetainer();
            }
            this.fbdrInstance.fix(danmaku, disp, verifier);
            return;
        case 5:
            if (this.ftdrInstance == null) {
                this.ftdrInstance = new FTDanmakusRetainer();
            }
            this.ftdrInstance.fix(danmaku, disp, verifier);
            return;
        case 6:
            if (this.lrdrInstance == null) {
                this.lrdrInstance = new RLDanmakusRetainer();
            }
            this.lrdrInstance.fix(danmaku, disp, verifier);
            return;
        case 7:
            danmaku.layout(disp, 0.0f, 0.0f);
            return;
        default:
            return;
    }
}
 
Example 4
Source File: DanmakuFactory.java    From letv with Apache License 2.0 4 votes vote down vote up
public void fillTranslationData(BaseDanmaku item, float beginX, float beginY, float endX, float endY, long translationDuration, long translationStartDelay, float scaleX, float scaleY) {
    if (item.getType() == 7) {
        ((SpecialDanmaku) item).setTranslationData(beginX * scaleX, beginY * scaleY, endX * scaleX, endY * scaleY, translationDuration, translationStartDelay);
        updateSpecicalDanmakuDuration(item);
    }
}
 
Example 5
Source File: DanmakuFactory.java    From letv with Apache License 2.0 4 votes vote down vote up
public void fillAlphaData(BaseDanmaku item, int beginAlpha, int endAlpha, long alphaDuraion) {
    if (item.getType() == 7) {
        ((SpecialDanmaku) item).setAlphaData(beginAlpha, endAlpha, alphaDuraion);
        updateSpecicalDanmakuDuration(item);
    }
}
 
Example 6
Source File: AndroidDisplayer.java    From letv with Apache License 2.0 4 votes vote down vote up
public int draw(BaseDanmaku danmaku) {
    float top = danmaku.getTop();
    float left = danmaku.getLeft();
    if (this.canvas == null) {
        return 0;
    }
    Paint alphaPaint = null;
    boolean needRestore = false;
    if (danmaku.getType() == 7) {
        if (danmaku.getAlpha() == AlphaValue.TRANSPARENT) {
            return 0;
        }
        if (!(danmaku.rotationZ == 0.0f && danmaku.rotationY == 0.0f)) {
            saveCanvas(danmaku, this.canvas, left, top);
            needRestore = true;
        }
        if (danmaku.getAlpha() != AlphaValue.MAX) {
            alphaPaint = this.ALPHA_PAINT;
            alphaPaint.setAlpha(danmaku.getAlpha());
        }
    }
    if (alphaPaint != null && alphaPaint.getAlpha() == AlphaValue.TRANSPARENT) {
        return 0;
    }
    boolean cacheDrawn = false;
    int result = 1;
    if (danmaku.hasDrawingCache() && danmaku.cache != null) {
        DrawingCacheHolder holder = ((DrawingCache) danmaku.cache).get();
        if (holder != null) {
            cacheDrawn = holder.draw(this.canvas, left, top, alphaPaint);
        }
    }
    if (!cacheDrawn) {
        if (alphaPaint != null) {
            this.PAINT.setAlpha(alphaPaint.getAlpha());
        } else {
            resetPaintAlpha(this.PAINT);
        }
        drawDanmaku(danmaku, this.canvas, left, top, false);
        result = 2;
    }
    if (danmaku.isClickZan) {
        this.sStuffer.drawClickBg(danmaku, this.canvas, left, top);
    }
    if (needRestore) {
        restoreCanvas(this.canvas);
    }
    return result;
}
 
Example 7
Source File: DanmakuUtils.java    From letv with Apache License 2.0 4 votes vote down vote up
public static final int compare(BaseDanmaku obj1, BaseDanmaku obj2) {
    if (obj1 == obj2) {
        return 0;
    }
    if (obj1 == null) {
        return -1;
    }
    if (obj2 == null) {
        return 1;
    }
    long val = obj1.time - obj2.time;
    if (val > 0) {
        return 1;
    }
    if (val < 0) {
        return -1;
    }
    int result = obj1.index - obj2.index;
    if (result > 0) {
        return 1;
    }
    if (result < 0) {
        return -1;
    }
    result = obj1.getType() - obj2.getType();
    if (result > 0) {
        return 1;
    }
    if (result < 0 || obj1.text == null) {
        return -1;
    }
    if (obj2.text == null) {
        return 1;
    }
    int r = obj1.text.toString().compareTo(obj2.text.toString());
    if (r != 0) {
        return r;
    }
    r = obj1.textColor - obj2.textColor;
    if (r == 0) {
        r = obj1.index - obj2.index;
        if (r == 0) {
            return obj1.hashCode() - obj1.hashCode();
        }
        if (r >= 0) {
            return 1;
        }
        return -1;
    } else if (r >= 0) {
        return 1;
    } else {
        return -1;
    }
}