protected internal override void ComputeRender(float renderProgress)
        {
            if (mCurrentBounds.Width() <= 0)
            {
                return;
            }

            RectF arcBounds = mCurrentBounds;

            //compute gas tube bounds
            mBottleBounds.Set(arcBounds.CenterX() - mBottleWidth / 2.0f, arcBounds.CenterY() - mBottleHeight / 2.0f, arcBounds.CenterX() + mBottleWidth / 2.0f, arcBounds.CenterY() + mBottleHeight / 2.0f);
            //compute pipe body bounds
            mWaterBounds.Set(mBottleBounds.Left + mStrokeWidth * 1.5f, mBottleBounds.Top + mWaterLowestPointToBottleneckDistance, mBottleBounds.Right - mStrokeWidth * 1.5f, mBottleBounds.Bottom - mStrokeWidth * 1.5f);

            //compute wave progress
            float totalWaveProgress   = renderProgress * mWaveCount;
            float currentWaveProgress = totalWaveProgress - ((int)totalWaveProgress);

            if (currentWaveProgress > 0.5f)
            {
                mProgress = 1.0f - MATERIAL_INTERPOLATOR.GetInterpolation((currentWaveProgress - 0.5f) * 2.0f);
            }
            else
            {
                mProgress = MATERIAL_INTERPOLATOR.GetInterpolation(currentWaveProgress * 2.0f);
            }

            //init water drop holders
            if (mWaterDropHolders.Count == 0)
            {
                InitWaterDropHolders(mBottleBounds, mWaterBounds);
            }

            //compute the location of these water drops
            foreach (WaterDropHolder waterDropHolder in mWaterDropHolders)
            {
                if (waterDropHolder.mDelayDuration < renderProgress && waterDropHolder.mDelayDuration + waterDropHolder.mDuration > renderProgress)
                {
                    float riseProgress = (renderProgress - waterDropHolder.mDelayDuration) / waterDropHolder.mDuration;
                    riseProgress = riseProgress < 0.5f ? riseProgress * 2.0f : 1.0f - (riseProgress - 0.5f) * 2.0f;
                    waterDropHolder.mCurrentY = waterDropHolder.mInitY - MATERIAL_INTERPOLATOR.GetInterpolation(riseProgress) * waterDropHolder.mRiseHeight;
                    waterDropHolder.mNeedDraw = true;
                }
                else
                {
                    waterDropHolder.mNeedDraw = false;
                }
            }

            //measure loading text
            mPaint.TextSize = mTextSize;
            mPaint.GetTextBounds(LOADING_TEXT, 0, LOADING_TEXT.Length, mLoadingBounds);
        }
예제 #2
0
        private Path CreateRiverPath(RectF arcBounds)
        {
            if (mRiverPath != null)
            {
                return(mRiverPath);
            }

            mRiverPath = new Path();

            RectF rectF = new RectF(arcBounds.CenterX() - mRiverWidth / 2.0f, arcBounds.CenterY() - mRiverHeight / 2.0f, arcBounds.CenterX() + mRiverWidth / 2.0f, arcBounds.CenterY() + mRiverHeight / 2.0f);

            rectF.Inset(mRiverBankWidth / 2.0f, mRiverBankWidth / 2.0f);

            mRiverPath.AddRect(rectF, Path.Direction.Cw);

            return(mRiverPath);
        }
예제 #3
0
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            int   saveCount = canvas.Save();
            RectF arcBounds = mTempBounds;

            arcBounds.Set(bounds);

            mPaint.Color = new Color(mColor);

            //calculate fish clip bounds
            //clip the width of the fish need to increase mPathDottedLineSize * 1.2f
            RectF  fishRectF = new RectF(mFishHeadPos[0] - mFishWidth / 2.0f - mPathDottedLineSize * 1.2f, mFishHeadPos[1] - mFishHeight / 2.0f, mFishHeadPos[0] + mFishWidth / 2.0f + mPathDottedLineSize * 1.2f, mFishHeadPos[1] + mFishHeight / 2.0f);
            Matrix matrix    = new Matrix();

            matrix.PostRotate(mFishRotateDegrees, fishRectF.CenterX(), fishRectF.CenterY());
            matrix.MapRect(fishRectF);

            //draw river
            int riverSaveCount = canvas.Save();

            mPaint.SetStyle(Paint.Style.Stroke);
            canvas.ClipRect(fishRectF, Region.Op.Difference);
            canvas.DrawPath(CreateRiverPath(arcBounds), mPaint);
            canvas.RestoreToCount(riverSaveCount);

            //draw fish
            int fishSaveCount = canvas.Save();

            mPaint.SetStyle(Paint.Style.Fill);
            canvas.Rotate(mFishRotateDegrees, mFishHeadPos[0], mFishHeadPos[1]);
            canvas.ClipPath(CreateFishEyePath(mFishHeadPos[0], mFishHeadPos[1] - mFishHeight * 0.06f), Region.Op.Difference);
            canvas.DrawPath(CreateFishPath(mFishHeadPos[0], mFishHeadPos[1]), mPaint);
            canvas.RestoreToCount(fishSaveCount);

            canvas.RestoreToCount(saveCount);
        }
예제 #4
0
        private Path CreateWaitPath(RectF bounds)
        {
            Path path = new Path();

            //create circle
            path.MoveTo(bounds.CenterX() + mWaitCircleRadius, bounds.CenterY());

            //create w
            path.CubicTo(bounds.CenterX() + mWaitCircleRadius, bounds.CenterY() - mWaitCircleRadius * 0.5f, bounds.CenterX() + mWaitCircleRadius * 0.3f, bounds.CenterY() - mWaitCircleRadius, bounds.CenterX() - mWaitCircleRadius * 0.35f, bounds.CenterY() + mWaitCircleRadius * 0.5f);
            path.QuadTo(bounds.CenterX() + mWaitCircleRadius, bounds.CenterY() - mWaitCircleRadius, bounds.CenterX() + mWaitCircleRadius * 0.05f, bounds.CenterY() + mWaitCircleRadius * 0.5f);
            path.LineTo(bounds.CenterX() + mWaitCircleRadius * 0.75f, bounds.CenterY() - mWaitCircleRadius * 0.2f);

            path.CubicTo(bounds.CenterX(), bounds.CenterY() + mWaitCircleRadius * 1f, bounds.CenterX() + mWaitCircleRadius, bounds.CenterY() + mWaitCircleRadius * 0.4f, bounds.CenterX() + mWaitCircleRadius, bounds.CenterY());

            //create arc
            path.ArcTo(new RectF(bounds.CenterX() - mWaitCircleRadius, bounds.CenterY() - mWaitCircleRadius, bounds.CenterX() + mWaitCircleRadius, bounds.CenterY() + mWaitCircleRadius), 0, -359);
            path.ArcTo(new RectF(bounds.CenterX() - mWaitCircleRadius, bounds.CenterY() - mWaitCircleRadius, bounds.CenterX() + mWaitCircleRadius, bounds.CenterY() + mWaitCircleRadius), 1, -359);
            path.ArcTo(new RectF(bounds.CenterX() - mWaitCircleRadius, bounds.CenterY() - mWaitCircleRadius, bounds.CenterX() + mWaitCircleRadius, bounds.CenterY() + mWaitCircleRadius), 2, -2);
            //create w
            path.CubicTo(bounds.CenterX() + mWaitCircleRadius, bounds.CenterY() - mWaitCircleRadius * 0.5f, bounds.CenterX() + mWaitCircleRadius * 0.3f, bounds.CenterY() - mWaitCircleRadius, bounds.CenterX() - mWaitCircleRadius * 0.35f, bounds.CenterY() + mWaitCircleRadius * 0.5f);
            path.QuadTo(bounds.CenterX() + mWaitCircleRadius, bounds.CenterY() - mWaitCircleRadius, bounds.CenterX() + mWaitCircleRadius * 0.05f, bounds.CenterY() + mWaitCircleRadius * 0.5f);
            path.LineTo(bounds.CenterX() + mWaitCircleRadius * 0.75f, bounds.CenterY() - mWaitCircleRadius * 0.2f);

            path.CubicTo(bounds.CenterX(), bounds.CenterY() + mWaitCircleRadius * 1f, bounds.CenterX() + mWaitCircleRadius, bounds.CenterY() + mWaitCircleRadius * 0.4f, bounds.CenterX() + mWaitCircleRadius, bounds.CenterY());

            return(path);
        }