private void OnTextTimer(uint id, object cookie) { this.timerDt += 0.01f; if (this.timerDt >= 2f || this.tooltipHelper == null) { this.textLabel.Visible = false; this.KillTextTimer(); return; } float gameObjectHeight = this.viewComp.GameObjectHeight; float extraHeightOffGround = Easing.CubicEaseOut(this.timerDt, gameObjectHeight, gameObjectHeight + 1.5f, 2f); this.tooltipHelper.UpdateLocation(extraHeightOffGround, false); }
private IEnumerator ResizeDebug() { int d = 400; int time = 0; while (true) { var s = Easing.CubicEaseOut(time, 0.8f, 1, d); SetScaleXY(s, s); time = time > d ? 0 : time + Time.deltaTime; yield return(null); } }
public override void OnUpdate(float dt) { if (this.AgeSeconds <= this.stage2TransKeyFrameS) { Vector3 zero = Vector3.zero; zero.x = Easing.Linear(this.AgeSeconds, this.view.StartLocation.x, this.deltaS1.x, this.stage1DurS); zero.z = Easing.Linear(this.AgeSeconds, this.view.StartLocation.z, this.deltaS1.z, this.stage1DurS); zero.y = Easing.CubicEaseOut(this.AgeSeconds, this.view.StartLocation.y, this.deltaS1.y, this.stage1DurS); if (this.view.EmitterTracker != null) { this.view.EmitterTracker.position = zero; } if (this.view.MeshTracker != null) { this.view.MeshTracker.position = zero; } if (this.view.DefaultTracker != null) { this.view.DefaultTracker.position = zero; } base.CurrentLocation = zero; return; } if (this.AgeSeconds >= this.stage2KeyFrameS) { Vector3 vector = this.stage1EndPos; float t = this.AgeSeconds - this.stage2KeyFrameS; vector.x = Easing.ExpoEaseIn(t, this.stage1EndPos.x, this.deltaS2.x, this.stage2DurS); vector.z = Easing.ExpoEaseIn(t, this.stage1EndPos.z, this.deltaS2.z, this.stage2DurS); vector.y = Easing.ExpoEaseIn(t, this.stage1EndPos.y, this.deltaS2.y, this.stage2DurS); if (this.view.EmitterTracker != null) { this.view.EmitterTracker.position = vector; } if (this.view.MeshTracker != null) { this.view.MeshTracker.position = vector; } if (this.view.DefaultTracker != null) { this.view.DefaultTracker.position = vector; } base.CurrentLocation = vector; } }
protected override void DoEasing() { switch (type) { case EasingType.LINEAR: easingValue = new Vector3( Easing.Linear(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.Linear(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.Linear(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.EXPOOUT: easingValue = new Vector3( Easing.ExpoEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.ExpoEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.ExpoEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.EXPOIN: easingValue = new Vector3( Easing.ExpoEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.ExpoEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.ExpoEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.EXPOINOUT: easingValue = new Vector3( Easing.ExpoEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.ExpoEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.ExpoEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.EXPOOUTIN: easingValue = new Vector3( Easing.ExpoEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.ExpoEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.ExpoEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.CIRCOUT: easingValue = new Vector3( Easing.CircEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.CircEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.CircEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.CIRCIN: easingValue = new Vector3( Easing.CircEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.CircEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.CircEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.CIRCINOUT: easingValue = new Vector3( Easing.CircEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.CircEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.CircEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.CIRCOUTIN: easingValue = new Vector3( Easing.CircEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.CircEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.CircEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUADOUT: easingValue = new Vector3( Easing.QuadEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuadEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuadEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUADIN: easingValue = new Vector3( Easing.QuadEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuadEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuadEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUADINOUT: easingValue = new Vector3( Easing.QuadEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuadEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuadEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUADOUTIN: easingValue = new Vector3( Easing.QuadEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuadEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuadEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.SINEOUT: easingValue = new Vector3( Easing.SineEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.SineEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.SineEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.SINEIN: easingValue = new Vector3( Easing.SineEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.SineEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.SineEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.SINEINOUT: easingValue = new Vector3( Easing.SineEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.SineEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.SineEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.SINEOUTIN: easingValue = new Vector3( Easing.SineEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.SineEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.SineEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.CUBICOUT: easingValue = new Vector3( Easing.CubicEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.CubicEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.CubicEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.CUBICIN: easingValue = new Vector3( Easing.CubicEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.CubicEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.CubicEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.CUBICINOUT: easingValue = new Vector3( Easing.CubicEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.CubicEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.CubicEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.CUBICOUTIN: easingValue = new Vector3( Easing.CubicEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.CubicEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.CubicEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUARTOUT: easingValue = new Vector3( Easing.QuartEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuartEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuartEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUARTIN: easingValue = new Vector3( Easing.QuartEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuartEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuartEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUARTINOUT: easingValue = new Vector3( Easing.QuartEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuartEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuartEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUARTOUTIN: easingValue = new Vector3( Easing.QuartEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuartEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuartEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUINTOUT: easingValue = new Vector3( Easing.QuintEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuintEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuintEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUINTIN: easingValue = new Vector3( Easing.QuintEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuintEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuintEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUINTINOUT: easingValue = new Vector3( Easing.QuintEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuintEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuintEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUINTOUTIN: easingValue = new Vector3( Easing.QuintEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuintEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuintEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.ELASTICOUT: easingValue = new Vector3( Easing.ElasticEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.ElasticEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.ElasticEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.ELASTICIN: easingValue = new Vector3( Easing.ElasticEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.ElasticEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.ElasticEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.ELASTICINOUT: easingValue = new Vector3( Easing.ElasticEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.ElasticEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.ElasticEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.ELASTICOUTIN: easingValue = new Vector3( Easing.ElasticEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.ElasticEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.ElasticEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.BOUNCEOUT: easingValue = new Vector3( Easing.BounceEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.BounceEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.BounceEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.BOUNCEIN: easingValue = new Vector3( Easing.BounceEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.BounceEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.BounceEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.BOUNCEINOUT: easingValue = new Vector3( Easing.BounceEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.BounceEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.BounceEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.BOUNCEOUTIN: easingValue = new Vector3( Easing.BounceEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.BounceEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.BounceEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.BACKOUT: easingValue = new Vector3( Easing.BackEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.BackEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.BackEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.BACKIN: easingValue = new Vector3( Easing.BackEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.BackEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.BackEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.BACKINOUT: easingValue = new Vector3( Easing.BackEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.BackEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.BackEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.BACKOUTIN: easingValue = new Vector3( Easing.BackEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.BackEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.BackEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; default: break; } switch (property) { case Property.POSITION: transform.localPosition = easingValue; break; case Property.ROTATION: transform.localRotation = Quaternion.Euler(easingValue); break; case Property.SCALE: transform.localScale = easingValue; break; default: break; } currentTime += Time.deltaTime; if (currentTime >= durationTime) { switch (property) { case Property.POSITION: transform.localPosition = finalValue; break; case Property.ROTATION: transform.localRotation = Quaternion.Euler(finalValue); break; case Property.SCALE: transform.localScale = finalValue; break; default: break; } currentTime = durationTime; Vector3 ini = finalValue; finalValue = initialValue; initialValue = ini; deltaValue = finalValue - initialValue; if (startGame != null) { startGame.StartLoad(); } if (endScreenLogic != null) { endScreenLogic.LoadScene(); } if (animLoop == true) { currentTime = 0; } } }
void EasingsUpdate() { if (GameCore.Instance.playerController.spawnGiantSun && (timeDelay > 0) && !GameCore.Instance.reviveFirstFrame) { timeDelay -= Time.deltaTime * 1000f; } else if (timeDelay > 0) { timeDelay -= Time.deltaTime; } else if (timeCounter < timeDuration) { if (GameCore.Instance.playerController.spawnGiantSun && !GameCore.Instance.reviveFirstFrame) { timeCounter += Time.deltaTime * 1000f; } else { timeCounter += Time.deltaTime; } #region Easings List switch (easingFunctionType) { case Easing.EasingFunctionType.BackEaseIn: { currentValue = (float)Easing.BackEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.BackEaseInOut: { currentValue = (float)Easing.BackEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.BackEaseOut: { currentValue = (float)Easing.BackEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.BackEaseOutIn: { currentValue = (float)Easing.BackEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.BounceEaseIn: { currentValue = (float)Easing.BounceEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.BounceEaseInOut: { currentValue = (float)Easing.BounceEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.BounceEaseOut: { currentValue = (float)Easing.BounceEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.BounceEaseOutIn: { currentValue = (float)Easing.BounceEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.CircEaseIn: { currentValue = (float)Easing.CircEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.CircEaseInOut: { currentValue = (float)Easing.CircEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.CircEaseOut: { currentValue = (float)Easing.CircEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.CircEaseOutIn: { currentValue = (float)Easing.CircEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.CubicEaseIn: { currentValue = (float)Easing.CubicEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.CubicEaseInOut: { currentValue = (float)Easing.CubicEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.CubicEaseOut: { currentValue = (float)Easing.CubicEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.CubicEaseOutIn: { currentValue = (float)Easing.CubicEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.ElasticEaseIn: { currentValue = (float)Easing.ElasticEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.ElasticEaseInOut: { currentValue = (float)Easing.ElasticEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.ElasticEaseOut: { currentValue = (float)Easing.ElasticEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.ElasticEaseOutIn: { currentValue = (float)Easing.ElasticEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.ExpoEaseIn: { currentValue = (float)Easing.ExpoEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.ExpoEaseInOut: { currentValue = (float)Easing.ExpoEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.ExpoEaseOut: { currentValue = (float)Easing.ExpoEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.ExpoEaseOutIn: { currentValue = (float)Easing.ExpoEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.Linear: { currentValue = (float)Easing.Linear(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.QuadEaseIn: { currentValue = (float)Easing.QuadEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.QuadEaseInOut: { currentValue = (float)Easing.QuadEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.QuadEaseOut: { currentValue = (float)Easing.QuadEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.QuadEaseOutIn: { currentValue = (float)Easing.QuadEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.QuartEaseIn: { currentValue = (float)Easing.QuartEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.QuartEaseInOut: { currentValue = (float)Easing.QuartEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.QuartEaseOut: { currentValue = (float)Easing.QuartEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.QuartEaseOutIn: { currentValue = (float)Easing.QuartEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.QuintEaseIn: { currentValue = (float)Easing.QuintEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.QuintEaseInOut: { currentValue = (float)Easing.QuintEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.QuintEaseOut: { currentValue = (float)Easing.QuintEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.QuintEaseOutIn: { currentValue = (float)Easing.QuintEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.SineEaseIn: { currentValue = (float)Easing.SineEaseIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.SineEaseInOut: { currentValue = (float)Easing.SineEaseInOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.SineEaseOut: { currentValue = (float)Easing.SineEaseOut(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; case Easing.EasingFunctionType.SineEaseOutIn: { currentValue = (float)Easing.SineEaseOutIn(timeCounter, initialValue, (finalValue - initialValue), timeDuration); } break; } //End Switch Here #endregion #region Easing Target Colors switch (easingTarget) { case Easing.EasingTarget.ColorR: { targetTransform.GetComponent <Renderer>().material.color = new Color(currentValue, targetTransform.GetComponent <Renderer>().material.color.g, targetTransform.GetComponent <Renderer>().material.color.b, targetTransform.GetComponent <Renderer>().material.color.a); } break; case Easing.EasingTarget.ColorG: { targetTransform.GetComponent <Renderer>().material.color = new Color(targetTransform.GetComponent <Renderer>().material.color.r, currentValue, targetTransform.GetComponent <Renderer>().material.color.b, targetTransform.GetComponent <Renderer>().material.color.a); } break; case Easing.EasingTarget.ColorB: { targetTransform.GetComponent <Renderer>().material.color = new Color(targetTransform.GetComponent <Renderer>().material.color.r, targetTransform.GetComponent <Renderer>().material.color.g, currentValue, targetTransform.GetComponent <Renderer>().material.color.a); } break; case Easing.EasingTarget.ColorA: { targetTransform.GetComponent <Renderer>().material.color = new Color(targetTransform.GetComponent <Renderer>().material.color.r, targetTransform.GetComponent <Renderer>().material.color.g, targetTransform.GetComponent <Renderer>().material.color.b, currentValue); } break; } #endregion #region Easing Transform Targets if (easingTargetRelativeSpace == Easing.EasingTargetRelativeSpace.WORLD) { switch (easingTarget) { case Easing.EasingTarget.PositionX: { targetTransform.position = new Vector3(currentValue, targetTransform.position.y, targetTransform.position.z); } break; case Easing.EasingTarget.PositionY: { targetTransform.position = new Vector3(targetTransform.position.x, currentValue, targetTransform.position.z); } break; case Easing.EasingTarget.PositionZ: { targetTransform.position = new Vector3(targetTransform.position.x, targetTransform.position.y, currentValue); } break; case Easing.EasingTarget.RotationX: { targetTransform.eulerAngles = new Vector3(currentValue, targetTransform.eulerAngles.y, targetTransform.eulerAngles.z); } break; case Easing.EasingTarget.RotationY: { targetTransform.eulerAngles = new Vector3(targetTransform.eulerAngles.x, currentValue, targetTransform.eulerAngles.z); } break; case Easing.EasingTarget.RotationZ: { targetTransform.eulerAngles = new Vector3(targetTransform.eulerAngles.x, targetTransform.eulerAngles.y, currentValue); } break; case Easing.EasingTarget.ScaleX: { Debug.Log("Unity Engine doesn't have 'WORLD Scale'"); } break; case Easing.EasingTarget.ScaleY: { Debug.Log("Unity Engine doesn't have 'WORLD Scale'"); } break; case Easing.EasingTarget.ScaleZ: { Debug.Log("Unity Engine doesn't have 'WORLD Scale'"); } break; case Easing.EasingTarget.ScaleALL: { Debug.Log("Unity Engine doesn't have 'WORLD Scale'"); } break; } } else if (easingTargetRelativeSpace == Easing.EasingTargetRelativeSpace.LOCAL) { switch (easingTarget) { case Easing.EasingTarget.PositionX: { targetTransform.localPosition = new Vector3(currentValue, targetTransform.localPosition.y, targetTransform.localPosition.z); } break; case Easing.EasingTarget.PositionY: { targetTransform.localPosition = new Vector3(targetTransform.position.x, currentValue, targetTransform.localPosition.z); } break; case Easing.EasingTarget.PositionZ: { targetTransform.localPosition = new Vector3(targetTransform.localPosition.x, targetTransform.localPosition.y, currentValue); } break; case Easing.EasingTarget.RotationX: { targetTransform.localEulerAngles = new Vector3(currentValue, targetTransform.localEulerAngles.y, targetTransform.localEulerAngles.z); } break; case Easing.EasingTarget.RotationY: { targetTransform.localEulerAngles = new Vector3(targetTransform.localEulerAngles.x, currentValue, targetTransform.localEulerAngles.z); } break; case Easing.EasingTarget.RotationZ: { targetTransform.localEulerAngles = new Vector3(targetTransform.localEulerAngles.x, targetTransform.localEulerAngles.y, currentValue); } break; case Easing.EasingTarget.ScaleX: { targetTransform.localScale = new Vector3(currentValue, targetTransform.localScale.y, targetTransform.localScale.z); } break; case Easing.EasingTarget.ScaleY: { targetTransform.localScale = new Vector3(targetTransform.localScale.x, currentValue, targetTransform.localScale.z); } break; case Easing.EasingTarget.ScaleZ: { targetTransform.localScale = new Vector3(targetTransform.localScale.x, targetTransform.localScale.y, currentValue); } break; case Easing.EasingTarget.ScaleALL: { targetTransform.localScale = new Vector3(currentValue, currentValue, currentValue); } break; } } #endregion } else { Restart(); } }
public override void draw(float t, float dt) { Starburst.inst().GraphicsDevice.Clear(Color.Black); base.draw(t, dt); Viewport vp = sprite_batch.GraphicsDevice.Viewport; var entities = Starburst.inst().get_entities_fast(typeof(Input)); sprite_batch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied); if (!started) { startTime = t; started = true; } // avstånd för animationerna int animationDistance = 150; // header-animation (upp->ner) float headerY = (t - startTime < animateInTime) ? (float)Easing.BounceEaseOut((t - startTime), -50, animationDistance, animateInTime) : 100; String text = "Choose players"; Vector2 textSize = largeFont.MeasureString(text); sprite_batch.DrawString(largeFont, text, new Vector2((int)((vp.Width * .5f) - (textSize.X * .5f)), headerY), Color.White); // rita ut kontrollrutor (4 st) int maxPlayers = 4; int totalRectWidth = vp.Width - 40; int spacing = 20; int rectSize = (int)(totalRectWidth / maxPlayers - (spacing * (maxPlayers - 1) / maxPlayers)); int startPos = (int)(vp.Width * .5f - totalRectWidth * .5); int rectangleY = 300; for (int i = 0; i < maxPlayers; i++) { int team = (i >> 1) + 1; // kontroll-rutor-animation (vä->hö) int currentLeftX = startPos + rectSize * i + spacing * i; int boxAnimationDistance = (int)(i < 2 ? animationDistance * 0.5 : -animationDistance * 0.5); int startLeftX = currentLeftX - boxAnimationDistance; if (t - startTime < animateInTime) { currentLeftX = (int)Easing.ElasticEaseOut((t - startTime), startLeftX, boxAnimationDistance, animateInTime); } Rectangle destRect = new Rectangle(currentLeftX, rectangleY, rectSize, rectSize); var col = new Color(0.0f, 0.0f, 0.0f, 0.4f); if (parent.gameConfig.mode == 0) { col = (team == 1) ? new Color(1.0f, 0.2f, 0.2f, 0.3f) : new Color(0.0f, 0.5f, 1.0f, 0.3f); } if (i < playerSlots.Count && playerSlots[i] == SlotStatus.Selected) { var q = 0.5f + textOpacity * 0.5f; col = Color.Gold * q; GFX_Util.fill_rect(sprite_batch, destRect, Color.Gold * 0.2f); GFX_Util.fill_rect(sprite_batch, new Rectangle(destRect.Left, destRect.Top, 4, destRect.Height), new Color(col.R, col.G, col.B, col.A)); GFX_Util.fill_rect(sprite_batch, new Rectangle(destRect.Right - 4, destRect.Top, 4, destRect.Height), new Color(col.R, col.G, col.B, col.A)); GFX_Util.fill_rect(sprite_batch, new Rectangle(destRect.Left + 4, destRect.Top, destRect.Width - 8, 4), new Color(col.R, col.G, col.B, col.A)); GFX_Util.fill_rect(sprite_batch, new Rectangle(destRect.Left + 4, destRect.Bottom - 4, destRect.Width - 8, 4), new Color(col.R, col.G, col.B, col.A)); } else { GFX_Util.fill_rect(sprite_batch, destRect, col); GFX_Util.fill_rect(sprite_batch, new Rectangle(destRect.Left, destRect.Top, 4, destRect.Height), new Color(col.R, col.G, col.B, 255)); GFX_Util.fill_rect(sprite_batch, new Rectangle(destRect.Right - 4, destRect.Top, 4, destRect.Height), new Color(col.R, col.G, col.B, 255)); GFX_Util.fill_rect(sprite_batch, new Rectangle(destRect.Left + 4, destRect.Top, destRect.Width - 8, 4), new Color(col.R, col.G, col.B, 255)); GFX_Util.fill_rect(sprite_batch, new Rectangle(destRect.Left + 4, destRect.Bottom - 4, destRect.Width - 8, 4), new Color(col.R, col.G, col.B, 255)); } } // rita ut lagsaker om lagläge if (parent.gameConfig.mode == 0) { String teamText = "Red Team"; Vector2 teamTextSize = font.MeasureString(teamText); sprite_batch.DrawString(font, teamText, new Vector2(startPos + rectSize + spacing * .5f - teamTextSize.X * .5f, rectangleY - 50), new Color(1.0f, 0.2f, 0.2f)); String botText = (parent.gameConfig.red_bots == 0 ? "No" : parent.gameConfig.red_bots.ToString()) + " Bot" + (parent.gameConfig.red_bots != 1 ? "s" : ""); Vector2 botTextSize = smallFont.MeasureString(botText); sprite_batch.DrawString(smallFont, botText, new Vector2(startPos + rectSize + spacing * .5f - botTextSize.X * .5f, rectangleY - 25), Color.White); teamText = "Blue Team"; teamTextSize = font.MeasureString(teamText); sprite_batch.DrawString(font, teamText, new Vector2(startPos + rectSize + spacing * .5f - teamTextSize.X * .5f + (vp.Width * .5f), rectangleY - 50), new Color(0.0f, 0.5f, 1.0f)); botText = (parent.gameConfig.blue_bots == 0 ? "No" : parent.gameConfig.blue_bots.ToString()) + " Bot" + (parent.gameConfig.blue_bots != 1 ? "s" : ""); botTextSize = smallFont.MeasureString(botText); sprite_batch.DrawString(smallFont, botText, new Vector2(startPos + rectSize + spacing * .5f - botTextSize.X * .5f + (vp.Width * .5f), rectangleY - 25), Color.White); } else { String botText = (parent.gameConfig.red_bots + parent.gameConfig.blue_bots == 0 ? "No" : (parent.gameConfig.red_bots + parent.gameConfig.blue_bots).ToString()) + (((parent.gameConfig.red_bots + parent.gameConfig.blue_bots) == 1) ? " Bot" : " Bots"); Vector2 botTextSize = smallFont.MeasureString(botText); sprite_batch.DrawString(smallFont, botText, new Vector2((vp.Width * .5f) - botTextSize.X * .5f, rectangleY - 25), Color.White); } /** * Rita ut kontroller **/ Vector2 controllerIconSize = new Vector2(84, 60); //ikon för kontroll if (lowRes) { controllerIconSize *= .75f; } int controllerBtnSize = !lowRes ? 50 : 38; // ikon för knapp int keyboardBtnSize = !lowRes ? 40 : 30; // ikon för knapp int arrowSize = 30; // nedÃ¥tpil int totalControllerWidth = (int)(entities.Count * controllerIconSize.X); String selectText = "press fire"; Vector2 selectTextSize = font.MeasureString(selectText); for (int i = 0; i < entities.Count; i++) { Entity entity = entities[i]; Input input = entity.get_component <Input>(); Position position = entity.get_component <Position>(); Texture2D texture = entity.get_component <Sprite>().texture; String subtitle = "" + (i + 1); if (input.device == Input.InputType.Controller) { subtitle = "" + ((int)input.gp_index + 1); } Vector2 subtitleSize = font.MeasureString(subtitle); Rectangle iconRect = new Rectangle(); // kontroll-animation (kanske med individuell tids-offset) float timeOffset = (float)randoms[i] * .5f; int currentY = rectangleY - 150; int animDistance = 50; int startY = currentY - animDistance; float controllerOpacity = 1; if (t - startTime < timeOffset) { controllerOpacity = 0; } else if (t - startTime >= timeOffset && t - startTime < animateInTime + timeOffset) { currentY = (int)Easing.CubicEaseOut((t - startTime - timeOffset), startY, animDistance, animateInTime + timeOffset); controllerOpacity = (float)Easing.Linear((t - startTime - timeOffset), 0, 1, animateInTime + timeOffset); } // om längst upp, sprid ut jämnt if (position.y == 0) { iconRect = new Rectangle((int)(vp.Width * .5f - totalControllerWidth * .5f + controllerIconSize.X * i), currentY, (int)controllerIconSize.X, (int)controllerIconSize.Y); int arrowX = (int)(vp.Width * .5f - totalControllerWidth * .5f + controllerIconSize.X * i + controllerIconSize.X * .5f - arrowSize * .5f); sprite_batch.Draw(downArrow, new Rectangle(arrowX, (int)(rectangleY - 150 + controllerIconSize.Y), arrowSize, arrowSize), new Color(Color.White, textOpacity)); } // annars en plats per spelaryta else { int currentRectStartPos = startPos + rectSize * (int)position.x + spacing * (int)position.x; int positionX = (int)(currentRectStartPos + rectSize * .5f - (int)(controllerIconSize.X * .5f)); if (position.y == 1) { iconRect = new Rectangle(positionX, rectangleY - (int)(controllerIconSize.Y * .5f), (int)controllerIconSize.X, (int)controllerIconSize.Y); if (input.device == Input.InputType.Controller) { sprite_batch.Draw(controller_a_button, new Rectangle((int)(currentRectStartPos + rectSize * .5f - controllerBtnSize * .5f), (int)(rectangleY + rectSize * .5f + controllerBtnSize * .5f + 5), controllerBtnSize, controllerBtnSize), new Color(Color.White, textOpacity)); } else { String key = input.primary_fire.ToString(); // annan font? Vector2 keySize = font.MeasureString(key); sprite_batch.Draw(keyboard_key, new Rectangle((int)(currentRectStartPos + rectSize * .5f - keyboardBtnSize * .5f), (int)(rectangleY + rectSize * .5f + keyboardBtnSize), keyboardBtnSize, keyboardBtnSize), new Color(Color.White, textOpacity)); sprite_batch.DrawString(font, key, new Vector2(currentRectStartPos + rectSize * .5f - keySize.X * .5f, rectangleY + rectSize * .5f + keyboardBtnSize), new Color(Color.White, textOpacity)); } } else { iconRect = new Rectangle(positionX, rectangleY + (int)(rectSize * .5f) - (int)(controllerIconSize.Y * .5f) - (int)(selectTextSize.Y * .5f), (int)controllerIconSize.X, (int)controllerIconSize.Y); } } sprite_batch.Draw(texture, destinationRectangle: iconRect, color: new Color(Color.White, controllerOpacity), layerDepth: .5f); } for (int i = 0; i < playerSlots.Count; i++) { // rita i kontroll-rektanglarna baserat pÃ¥ deras status if (playerSlots[i] == SlotStatus.Hovering) { int currentRectStartPos = startPos + rectSize * i + spacing * i; int currentRectXCenter = (int)(currentRectStartPos + rectSize * .5f); sprite_batch.DrawString(font, "Press fire\nto confirm", new Vector2(currentRectXCenter - selectTextSize.X * .5f, rectangleY + (int)(rectSize * .5f) - selectTextSize.Y), new Color(Color.White, textOpacity)); } else if (playerSlots[i] == SlotStatus.Selected) { String ready = "Ready"; Vector2 size = font.MeasureString(ready); int currentRectStartPos = startPos + rectSize * i + spacing * i; int positionX = (int)(currentRectStartPos + rectSize * .5f - (int)(size.X * .5f)); sprite_batch.DrawString(font, ready, new Vector2(positionX, rectangleY + rectSize * .5f - controllerIconSize.Y * .5f - selectTextSize.Y * .5f + controllerIconSize.Y), Color.White); } } // kontroll-"tutorial" int yPos = (int)(vp.Height - controllerBtnSize - 15); int heightDiff = (int)(controllerBtnSize - textSize.Y); if (gamepads.Contains(true)) { String text_ok = "Ok"; String text_select = "Select"; textSize = font.MeasureString(text_ok); sprite_batch.Draw(controller_a_button, new Rectangle(20, yPos, controllerBtnSize, controllerBtnSize), Color.White); sprite_batch.DrawString(font, text_ok, new Vector2(20 + controllerBtnSize + 10, yPos + heightDiff * .5f), Color.White); sprite_batch.Draw(controller_l_stick, new Rectangle((int)(20 + controllerBtnSize + 10 + textSize.X + 10), yPos, controllerBtnSize, controllerBtnSize), Color.White); sprite_batch.DrawString(font, text_select, new Vector2(20 + controllerBtnSize + 10 + textSize.X + 10 + controllerBtnSize + 10, yPos + heightDiff * .5f), Color.White); } text = "Press Enter to start game"; textSize = font.MeasureString(text); sprite_batch.DrawString(font, text, new Vector2((int)((vp.Width * .5f) - (textSize.X * .5f)), yPos + heightDiff * .5f), haveEnoughPlayers() ? new Color(Color.Gold, (textOpacity * .8f) + .2f) : Color.Gray); sprite_batch.End(); System.Threading.Thread.Sleep(10); // no need to spam menu }
public override void draw(float t, float dt) { if (vol < 0.7f) { vol += 0.7f * dt / 3.0f; if (vol > 0.7f) { vol = 0.7f; } MediaPlayer.Volume = vol; } if (fade < 1.0f) { fade += 1.0f * dt / 3.0f; if (fade > 1.0f) { fade = 1.0f; } } Starburst.inst().GraphicsDevice.Clear(Color.Black); base.draw(t, dt); Viewport vp = sprite_batch.GraphicsDevice.Viewport; int middleSpacing = 20; // hämta spelare och position var entities = Starburst.inst().get_entities_fast(typeof(Input)); Position position; if (entities.Count > 0) { position = entities[0].get_component <Position>(); } else { position = new Position(); } sprite_batch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied); var s = "v" + Starburst.VERSION; var ts = GFX_Util.measure_string_small(s); GFX_Util.draw_def_text_small(sprite_batch, s, vp.Width - ts.X - 10, vp.Height - 10 - ts.Y); String logo = "Starburst"; Vector2 logoSize = largeFont.MeasureString(logo); if (!started) { startTime = t; started = true; } //logo-animation float logoY = (t - startTime < animateInTime) ? (float)Easing.BounceEaseOut((t - startTime), -70, 150, animateInTime) : 80; float opacity = (t - startTime < animateInTime * .5f) ? (float)Easing.QuadEaseInOut((t - startTime), 0, 1, animateInTime * .5f) : 1; sprite_batch.DrawString(largeFont, logo, new Vector2(vp.Width * .5f - logoSize.X * .5f, logoY), new Color(Color.Gold, opacity)); int currentTopY = 225; if (lowRes) { int endY = (int)(vp.Height * .5f - 15); currentTopY = 160; largeMapSize = endY - currentTopY; smallMapSize = (int)(largeMapSize * .75f); } // map-animation vid navigation int animDistance = 150; int startY = currentTopY - animDistance; if (t - startTime < animateInTime) { currentTopY = (int)Easing.CubicEaseOut((t - startTime), startY, animDistance, animateInTime); } // map-switch-animation float mapAnimationSize = smallMapSize; float currentMapSize = largeMapSize; if (animateMap) { currentMapSize = (float)Easing.BackEaseOut((t - mapAnimationStartTime), largeMapSize - mapAnimationSize, mapAnimationSize, mapAnimationDuration); } String map = "Map"; Vector2 mapTextSize = font.MeasureString(map); sprite_batch.DrawString(font, map, new Vector2(vp.Width * .5f - mapTextSize.X * .5f, currentTopY), Color.White); int mapY = currentTopY + 50; sprite_batch.Draw(map0, new Rectangle((int)(vp.Width * .5f - (currentMapSize * .85f + currentMapSize * .15f) * .5f - smallMapSize - 20), (int)(mapY + (largeMapSize - smallMapSize) * .5f), smallMapSize, smallMapSize), Color.White * 0.75f); sprite_batch.Draw(map2, new Rectangle((int)(vp.Width * .5f + (currentMapSize * .85f + currentMapSize * .15f) * .5f + 20), (int)(mapY + (largeMapSize - smallMapSize) * .5f), smallMapSize, smallMapSize), Color.White * 0.75f); sprite_batch.Draw(map1, new Rectangle((int)(vp.Width * .5f - currentMapSize * .5f), (int)(mapY + (largeMapSize - currentMapSize) * .5f), (int)currentMapSize, (int)currentMapSize), Color.White); String arrow = "<"; Vector2 arrowSize = font.MeasureString(arrow); sprite_batch.DrawString(font, "<", new Vector2((int)(vp.Width * .5f - largeMapSize * .5f - 20 - smallMapSize - 20 - arrowSize.X), mapY + largeMapSize * .5f - arrowSize.Y * .5f), (position.y == (int)options.map ? new Color(Color.Gold, textOpacity) : Color.White)); sprite_batch.DrawString(font, ">", new Vector2((int)(vp.Width * .5f + largeMapSize * .5f + 20 + smallMapSize + 20), mapY + largeMapSize * .5f - arrowSize.Y * .5f), (position.y == (int)options.map ? new Color(Color.Gold, textOpacity) : Color.White)); int settingOffset = (int)(vp.Height * .5f + 75); String ctfString = "Capture the flag"; Vector2 leftTextSize = font.MeasureString(ctfString); int leftTextX = (int)(vp.Width * .5f - leftTextSize.X - middleSpacing); int rightTextX = (int)(vp.Width * .5f + middleSpacing); int rowHeight = !lowRes ? 40 : 30; // settings-animation animDistance = -150; startY = settingOffset - animDistance; if (t - startTime < animateInTime) { settingOffset = (int)Easing.CubicEaseOut((t - startTime), startY, animDistance, animateInTime); } sprite_batch.DrawString(font, "Map mode", new Vector2(leftTextX, settingOffset), Color.White); sprite_batch.DrawString(font, maps[currentMapIndex].mapName, new Vector2(rightTextX, settingOffset), Color.White); settingOffset += (int)(rowHeight * .5f); sprite_batch.DrawString(font, "Game time", new Vector2(leftTextX, settingOffset + rowHeight * 1), Color.White); int time = 5; if (gameTime == GameTime.Ten) { time = 10; } else if (gameTime == GameTime.Twenty) { time = 20; } else if (gameTime == GameTime.Thirty) { time = 30; } String timeString = "< " + time + " minutes >"; sprite_batch.DrawString(font, timeString, new Vector2(rightTextX, settingOffset + rowHeight * 1), (position.y == (int)options.time ? new Color(Color.Gold, textOpacity) : Color.White)); sprite_batch.DrawString(font, "Asteroids", new Vector2(leftTextX, settingOffset + rowHeight * 2), Color.White); String asteroidString = "Off"; if (asteroidCount == Amount.few) { asteroidString = "Few"; } else if (asteroidCount == Amount.medium) { asteroidString = "Medium"; } else if (asteroidCount == Amount.many) { asteroidString = "Many"; } sprite_batch.DrawString(font, "< " + asteroidString + " >", new Vector2(rightTextX, settingOffset + rowHeight * 2), (position.y == (int)options.asteroids ? new Color(Color.Gold, textOpacity) : Color.White)); sprite_batch.DrawString(font, "Powerups", new Vector2(leftTextX, settingOffset + rowHeight * 3), Color.White); String powerupString = "Off"; if (powerupCount == Amount.few) { powerupString = "Few"; } else if (powerupCount == Amount.medium) { powerupString = "Medium"; } else if (powerupCount == Amount.many) { powerupString = "Many"; } sprite_batch.DrawString(font, "< " + powerupString + " >", new Vector2(rightTextX, settingOffset + rowHeight * 3), (position.y == (int)options.powerups ? new Color(Color.Gold, textOpacity) : Color.White)); MapConfig currentMap = maps[currentMapIndex]; if (currentMap.bots) { sprite_batch.DrawString(font, (currentMap.gameMode == Playing.Game_Config.GM_DEATHMATCH) ? "AI" : "Red AI", new Vector2(leftTextX, settingOffset + rowHeight * 4), Color.White); sprite_batch.DrawString(font, "< " + (currentMap.gameMode == Playing.Game_Config.GM_DEATHMATCH ? (redBots == 0 ? "off" : (redBots).ToString() + " bot" + (redBots != 1 ? "s" : "")) : redBots == 0 ? "off" : redBots.ToString() + " bot" + (redBots != 1 ? "s" : "")) + " >", new Vector2(rightTextX, settingOffset + rowHeight * 4), (position.y == (int)options.redBots ? new Color(Color.Gold, textOpacity) : Color.White)); if (currentMap.gameMode == Playing.Game_Config.GM_TEAM_DEATHMATCH) { sprite_batch.DrawString(font, "Blue AI", new Vector2(leftTextX, settingOffset + rowHeight * 5), Color.White); sprite_batch.DrawString(font, "< " + (blueBots == 0 ? "off" : blueBots.ToString() + " bot" + (blueBots != 1 ? "s" : "")) + " >", new Vector2(rightTextX, settingOffset + rowHeight * 5), (position.y == (int)options.blueBots ? new Color(Color.Gold, textOpacity) : Color.White)); } } // kontroll-"tutorial" if (gamepads.Contains(true)) { sprite_batch.Draw(controller_a_button, new Rectangle(20, yPos, controllerBtnSize, controllerBtnSize), Color.White); sprite_batch.DrawString(font, text_ok, new Vector2(20 + controllerBtnSize + 10, yPos + heightDiff * .5f), Color.White); sprite_batch.Draw(controller_l_stick, new Rectangle((int)(20 + controllerBtnSize + 10 + okSize.X + 10), yPos, controllerBtnSize, controllerBtnSize), Color.White); sprite_batch.DrawString(font, text_select, new Vector2(20 + controllerBtnSize + 10 + okSize.X + 10 + controllerBtnSize + 10, yPos + heightDiff * .5f), Color.White); } String text = "Continue to player selection"; Vector2 textSize = font.MeasureString(text); sprite_batch.DrawString(font, text, new Vector2((int)((vp.Width * .5f) - (textSize.X * .5f)), vp.Height - (lowRes ? 50 : 80)), (position.y == (int)options.proceed ? new Color(Color.Gold, textOpacity) : Color.White)); String exitText = "Exit game"; Vector2 exitTextSize = font.MeasureString(exitText); sprite_batch.DrawString(font, exitText, new Vector2((int)((vp.Width * .5f) - (exitTextSize.X * .5f)), vp.Height - (lowRes ? 25 : 40)), (position.y == (int)options.exit ? new Color(Color.Gold, textOpacity) : Color.White)); GFX_Util.fill_rect(sprite_batch, new Rectangle(0, 0, vp.Width, vp.Height), Color.Black * (1.0f - fade)); sprite_batch.End(); System.Threading.Thread.Sleep(10); // no need to spam menu }
protected override void DoEasing() { switch (type) { case EasingType.LINEAR: easingValue = new Vector3( Easing.Linear(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.Linear(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.Linear(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.EXPOOUT: easingValue = new Vector3( Easing.ExpoEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.ExpoEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.ExpoEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.EXPOIN: easingValue = new Vector3( Easing.ExpoEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.ExpoEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.ExpoEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.EXPOINOUT: easingValue = new Vector3( Easing.ExpoEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.ExpoEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.ExpoEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.EXPOOUTIN: easingValue = new Vector3( Easing.ExpoEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.ExpoEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.ExpoEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.CIRCOUT: easingValue = new Vector3( Easing.CircEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.CircEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.CircEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.CIRCIN: easingValue = new Vector3( Easing.CircEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.CircEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.CircEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.CIRCINOUT: easingValue = new Vector3( Easing.CircEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.CircEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.CircEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.CIRCOUTIN: easingValue = new Vector3( Easing.CircEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.CircEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.CircEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUADOUT: easingValue = new Vector3( Easing.QuadEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuadEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuadEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUADIN: easingValue = new Vector3( Easing.QuadEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuadEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuadEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUADINOUT: easingValue = new Vector3( Easing.QuadEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuadEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuadEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUADOUTIN: easingValue = new Vector3( Easing.QuadEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuadEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuadEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.SINEOUT: easingValue = new Vector3( Easing.SineEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.SineEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.SineEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.SINEIN: easingValue = new Vector3( Easing.SineEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.SineEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.SineEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.SINEINOUT: easingValue = new Vector3( Easing.SineEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.SineEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.SineEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.SINEOUTIN: easingValue = new Vector3( Easing.SineEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.SineEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.SineEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.CUBICOUT: easingValue = new Vector3( Easing.CubicEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.CubicEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.CubicEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.CUBICIN: easingValue = new Vector3( Easing.CubicEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.CubicEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.CubicEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.CUBICINOUT: easingValue = new Vector3( Easing.CubicEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.CubicEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.CubicEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.CUBICOUTIN: easingValue = new Vector3( Easing.CubicEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.CubicEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.CubicEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUARTOUT: easingValue = new Vector3( Easing.QuartEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuartEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuartEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUARTIN: easingValue = new Vector3( Easing.QuartEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuartEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuartEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUARTINOUT: easingValue = new Vector3( Easing.QuartEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuartEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuartEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUARTOUTIN: easingValue = new Vector3( Easing.QuartEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuartEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuartEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUINTOUT: easingValue = new Vector3( Easing.QuintEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuintEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuintEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUINTIN: easingValue = new Vector3( Easing.QuintEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuintEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuintEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUINTINOUT: easingValue = new Vector3( Easing.QuintEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuintEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuintEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.QUINTOUTIN: easingValue = new Vector3( Easing.QuintEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.QuintEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.QuintEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.ELASTICOUT: easingValue = new Vector3( Easing.ElasticEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.ElasticEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.ElasticEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.ELASTICIN: easingValue = new Vector3( Easing.ElasticEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.ElasticEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.ElasticEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.ELASTICINOUT: easingValue = new Vector3( Easing.ElasticEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.ElasticEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.ElasticEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.ELASTICOUTIN: easingValue = new Vector3( Easing.ElasticEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.ElasticEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.ElasticEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.BOUNCEOUT: easingValue = new Vector3( Easing.BounceEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.BounceEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.BounceEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.BOUNCEIN: easingValue = new Vector3( Easing.BounceEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.BounceEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.BounceEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.BOUNCEINOUT: easingValue = new Vector3( Easing.BounceEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.BounceEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.BounceEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.BOUNCEOUTIN: easingValue = new Vector3( Easing.BounceEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.BounceEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.BounceEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.BACKOUT: easingValue = new Vector3( Easing.BackEaseOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.BackEaseOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.BackEaseOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.BACKIN: easingValue = new Vector3( Easing.BackEaseIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.BackEaseIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.BackEaseIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.BACKINOUT: easingValue = new Vector3( Easing.BackEaseInOut(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.BackEaseInOut(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.BackEaseInOut(currentTime, initialValue.z, deltaValue.z, durationTime)); break; case EasingType.BACKOUTIN: easingValue = new Vector3( Easing.BackEaseOutIn(currentTime, initialValue.x, deltaValue.x, durationTime), Easing.BackEaseOutIn(currentTime, initialValue.y, deltaValue.y, durationTime), Easing.BackEaseOutIn(currentTime, initialValue.z, deltaValue.z, durationTime)); break; default: break; } switch (property) { case Property.POSITION: transform.position = easingValue; break; case Property.ROTATION: transform.localRotation = Quaternion.Euler(easingValue); break; case Property.SCALE: transform.localScale = easingValue; break; default: break; } currentTime += Time.deltaTime; if (currentTime >= durationTime) { switch (property) { case Property.POSITION: transform.position = finalValue; break; case Property.ROTATION: transform.localRotation = Quaternion.Euler(finalValue); break; case Property.SCALE: transform.localScale = finalValue; break; default: break; } currentTime = durationTime; Vector3 ini = finalValue; finalValue = initialValue; initialValue = ini; deltaValue = finalValue - initialValue; if (loopCounter > 0) { currentTime = 0; loopCounter--; } //else //{ // cooldown.Activate(); // loopCounter = 1; //} } }
public static double CubicEaseOut(double t, double b, double c, double d) { return(Easing.CubicEaseOut(t, b, c - b, d)); }
public static float CubicEaseOut(float t, float b, float c, float d) { return(Easing.CubicEaseOut(t, b, c - b, d)); }