public override void draw(TapAndSlashDraw context) { float animationProgress = timeAlive / context.tapEffectDuration; float mx = (x2 - x1) * animationProgress + x1; float my = (y2 - y1) * animationProgress + y1; context.drawSwipe(mx, my, x2, y2); }
public override void draw( TapAndSlashDraw context ) { float animationProgress = timeAlive / context.tapEffectDuration; float mx = (x2-x1)*animationProgress + x1; float my = (y2-y1)*animationProgress + y1; context.drawSwipe( mx, my, x2, y2 ); }
void OnGUI() { if (centeredStyle == null) { centeredStyle = new GUIStyle(GUI.skin.label); centeredStyle.alignment = TextAnchor.UpperCenter; centeredStyle.fontSize = 36; centeredStyle.font = Resources.Load <Font>("UIFontRingBearer"); } GUIDrawRect(new Rect(0, 0, Screen.width, Screen.height), new Color(0, 0, 0, shadeAmount * maxShadeAmount)); if (visible) { GUI.Label(new Rect(20, 20, 3 * Screen.width / 4, 200), message, centeredStyle); TapAndSlashDraw draw = GetComponent <TapAndSlashDraw>(); float animationProgress = time / animationDuration * 2; if (animationProgress < 0.25f) { float handX = Screen.width * (start.x + handDistance * (1 - animationProgress / 0.25f)); float handY = Screen.height * (start.y + handDistance * (1 - animationProgress / 0.25f)); Color orig = GUI.color; GUI.color = new Color(1.0f, 1.0f, 1.0f, animationProgress / 0.25f); GUI.DrawTexture(new Rect(handX, Screen.height - handY, 80, 80), hand); GUI.color = orig; lastPhase = 0; } else if (animationProgress < 0.75f) { float handX = Screen.width * (start.x + (end.x - start.x) * ((animationProgress - 0.25f) / 0.5f)); float handY = Screen.height * (start.y + (end.y - start.y) * ((animationProgress - 0.25f) / 0.5f)); if (lastPhase == 0) { draw.addTap(Screen.width * start.x, Screen.height * start.y); } draw.drawSwipe(Screen.width * start.x, Screen.height * start.y, handX, handY); GUI.DrawTexture(new Rect(handX, Screen.height - handY, 80, 80), hand); lastPhase = 1; } else if (animationProgress < 1) { float handX = Screen.width * (end.x + handDistance * ((animationProgress - 0.75f) / 0.25f)); float handY = Screen.height * (end.y + handDistance * ((animationProgress - 0.75f) / 0.25f)); if (lastPhase == 1) { draw.addSwipe(Screen.width * start.x, Screen.height * start.y, Screen.width * end.x, Screen.height * end.y); draw.addUntap(Screen.width * end.x, Screen.height * end.y); } Color orig = GUI.color; GUI.color = new Color(1.0f, 1.0f, 1.0f, 1 - ((animationProgress - 0.75f) / 0.25f)); GUI.DrawTexture(new Rect(handX, Screen.height - handY, 80, 80), hand); GUI.color = orig; lastPhase = 2; } } }