/***Constructor for interpolating GameFloat with constrains for the velocity***/ public GameFloat(float value, float target, float duration, int interpolationType, int loopType, GameFloat velocityConstrains) { this.f = value; this.loopType = loopType; this.duration = duration; this.interpolationType = interpolationType; this.elapsed = 0; this.minimum = Math.Min(value, target); this.maximum = Math.Max(value, target); //Find in which direction the GameFloat will interpolate if (this.f.Equals(this.minimum)) { this.target = GameFloat.Maximum; } else { this.target = GameFloat.Minimum; } //If there is no duration, set the magnitude to the value of the velocityConstrains. if (this.duration.Equals(GameFloat.NoDuration)) { this.magnitude = velocityConstrains.value; } else { //calculate the magnitude this.magnitude = this.getDistance() / this.duration; } this.velocity = velocityConstrains; }
/***Returns a float with the size of this GameFloat in relation to a second GameFloat, the value will be between 0.0 and 1.0***/ public float getOffset(GameFloat second) { float total = this.getDistance() + second.getDistance(); float offset = this.getDistance() / total; return(offset); }
/***Constructor for an interpolating GameFloat that takes a value, a target, an int for if the interpolationTyp and an int for loopingTYpe***/ public GameFloat(float value, float target, float duration, int interpolationType, int loopType) { this.f = value; this.loopType = loopType; this.duration = duration; this.interpolationType = interpolationType; this.elapsed = 0; this.minimum = Math.Min(value, target); this.maximum = Math.Max(value, target); //Find in which direction the GameFloat will interpolate if (this.f.Equals(this.minimum)) { this.target = GameFloat.Maximum; } else { this.target = GameFloat.Minimum; } //calculate the magnitude this.magnitude = this.getDistance() / this.duration; this.velocity = new GameFloat(0); }
/***Constructor for a GameFloat that takes a single float as parameter and ignores the constrains***/ public GameFloat(float value) { this.f = value; this.minimum = CONST.DoNotUseFloat; this.maximum = CONST.DoNotUseFloat; this.duration = CONST.DoNotUseInt; this.elapsed = CONST.DoNotUseInt; this.target = CONST.DoNotUseInt; this.interpolationType = CONST.DoNotUseInt; this.currentAcceleration = CONST.DoNotUseFloat; this.loopType = CONST.DoNotUseInt; this.velocity = null; this.magnitude = CONST.DoNotUseFloat; }
/***Constructor for a constrained GameFloat that takes a value, a minimum, a maximum and a bool for random***/ public GameFloat(float value, float minimum, float maximum, bool random) { this.f = value; this.minimum = minimum; this.maximum = maximum; this.duration = CONST.DoNotUseInt; this.elapsed = CONST.DoNotUseInt; this.target = CONST.DoNotUseInt; this.interpolationType = CONST.DoNotUseInt; this.currentAcceleration = CONST.DoNotUseFloat; this.loopType = CONST.DoNotUseInt; this.velocity = new GameFloat(0); if (random) { randomSeed++; this.randomGenerator = new Random(randomSeed); } this.magnitude = CONST.DoNotUseFloat; }
/***Returns a float with the size of this GameFloat in relation to a second GameFloat, the value will be between 0.0 and 1.0***/ public float getOffset(GameFloat second) { float total = this.getDistance() + second.getDistance(); float offset = this.getDistance() / total; return offset; }
/***Constructor for interpolating GameFloat with constrains for the velocity***/ public GameFloat(float value, float target, float duration, int interpolationType, int loopType, GameFloat velocityConstrains) { this.f = value; this.loopType = loopType; this.duration = duration; this.interpolationType = interpolationType; this.elapsed = 0; this.minimum = Math.Min(value, target); this.maximum = Math.Max(value, target); //Find in which direction the GameFloat will interpolate if (this.f.Equals(this.minimum)) { this.target = GameFloat.Maximum; } else { this.target = GameFloat.Minimum; } //If there is no duration, set the magnitude to the value of the velocityConstrains. if (this.duration.Equals(GameFloat.NoDuration)) { this.magnitude = velocityConstrains.value; } else { //calculate the magnitude this.magnitude = this.getDistance() / this.duration; } this.velocity = velocityConstrains; }