public int RemainedExpForNextLevel(int currentExp) { int clampedExp = MathFunc.Clamp(currentExp, 0, CapExp()); int currentLevel = LevelForExp(clampedExp); int nextLevelExp = ExpForLevel(currentLevel + 1); return(nextLevelExp - clampedExp); }
public static float GetLunarNoise(Vector2 p, float CraterSize, float CraterHeight, float CraterDepth, FastNoise noise, int seed = 0) //crater size: 0.86, crater height: 0.2, crater depth: 2.5 { float n = MathFunc.InverseLerp(CraterSize, 1f, MathFunc.Clamp((1f - OTNM.Tools.Accessing.GetCellularNoise(new XnaGeometry.Vector2(p.x, p.y), CraterSize, noise, seed)), CraterSize, 1f)); //0.36 if (n > CraterHeight) { n += (CraterHeight - n) * CraterDepth; } return(n); }
/// <summary> /// 加深程度 /// </summary> /// <param name="val">Value.</param> public void Extend(float val) { degree += val; degree = MathFunc.Clamp(degree, 0, max); if (level != _lastLevel) { onLevelChange(level); _lastLevel = level; } }
public float GetNoiseValue(int TerrainNoiseIndex, Vector2 Position) { if (TerrainNoiseIndex != MathFunc.Clamp(TerrainNoiseIndex, 0, TerrainNoises.Count - 1)) { return(0f); } else { return(TerrainNoises[TerrainNoiseIndex].GetNoiseValue(Position)); } }
public TerrainNoiseError Remove(int Index) { if (Index != MathFunc.Clamp(Index, 0, TerrainNoises.Count - 1)) { return(new TerrainNoiseError("Couldn't remove the TerrainNoise at Index, the Index was out of range.", TerrainNoiseError.ErrorTypes.Warning)); } else { TerrainNoises.RemoveAt(Index); return(null); } }
public float GetNoiseValue(int TerrainNoiseIndex, Vector2 Position, out TerrainNoiseError Error) { Error = null; if (TerrainNoiseIndex != MathFunc.Clamp(TerrainNoiseIndex, 0, TerrainNoises.Count - 1)) { Error = new TerrainNoiseError("Couldn't get the value of the TerrainNoise at Index, the Index was out of range.", TerrainNoiseError.ErrorTypes.Warning); return(0f); } else { return(TerrainNoises[TerrainNoiseIndex].GetNoiseValue(Position, out Error)); } }
public int ExpToNextLevel(int currentLevel) { int clampedLevel = MathFunc.Clamp(currentLevel, 1, this.levelCap); if (clampedLevel == 1) { return(this.levelExpDictionary[clampedLevel + 1] - this.levelExpDictionary[clampedLevel]); } if (clampedLevel == this.levelCap) { return(0); } return(this.levelExpDictionary[clampedLevel + 1] - this.levelExpDictionary[clampedLevel]); }
public int LevelForExp(int exp) { int clampedExp = MathFunc.Clamp(exp, 0, CapExp()); if (clampedExp == 0) { return(1); } if (clampedExp == CapExp()) { return(levelCap); } for (int i = 1; i < levelCap; i++) { int curExp = this.levelExpDictionary[i]; int nextExp = this.levelExpDictionary[i + 1]; if (clampedExp >= curExp && clampedExp < nextExp) { return(i); } } throw new Exception("Error in LevelForExp for exp: {0}".f(exp)); }
public static float Repeat(float t, float length) { return(MathFunc.Clamp(t - MathFunc.Floor(t / length) * length, 0f, length)); }
public int ExpForLevel(int level) { int clampedLevel = MathFunc.Clamp(level, 1, levelCap); return(this.levelExpDictionary[clampedLevel]); }