public static Manoeuvre ArcPattern(int nbPoint, int nbTurn, float baseDelay, Vector3 initialPosition, Vector3 direction, int wide) { int i = 0; float x, z, angle, realAngle, ratio = 360 / (float)wide, angleOrigine = Mathf.Atan2(direction.x - initialPosition.x, direction.z - initialPosition.z) - (((float)wide / 2) * (Mathf.PI / 180)); string spiralManoeuvreString = ""; angle = (360 / ((float)nbPoint * ratio)) * (Mathf.PI / 180); for (; nbTurn > 0; --nbTurn) { for (i = 0; i <= nbPoint; ++i) { realAngle = angleOrigine + (float)i * angle; x = initialPosition.x + 100 * Mathf.Sin(realAngle); z = initialPosition.z + 100 * Mathf.Cos(realAngle); spiralManoeuvreString += "TrajectoryLine#(" + initialPosition.x + ",0," + initialPosition.z + ")(" + x + ",0," + z + ")|"; } spiralManoeuvreString += spiralManoeuvreString.Remove(spiralManoeuvreString.Length - 1) + "=" + baseDelay + ";"; } spiralManoeuvreString = spiralManoeuvreString.Remove(spiralManoeuvreString.Length - 1); return(Manoeuvre.Create(spiralManoeuvreString)); }
void Start() { int i; List <string> patternsString; gameController = GetComponent <GameController>(); patternsString = LoadResources.LoadTxtAsListString("PatternLore"); manoeuvresLore = new List <Manoeuvre> (); for (i = 0; i < patternsString.Count; ++i) { manoeuvresLore.Add(Manoeuvre.Create(patternsString[i])); } patternsString = LoadResources.LoadTxtAsListString("PatternFoe"); manoeuvresEnemie = new List <Manoeuvre> (); for (i = 0; i < patternsString.Count; ++i) { manoeuvresEnemie.Add(Manoeuvre.Create(patternsString[i])); } patternsString = LoadResources.LoadTxtAsListString("PatternSpecialForce"); manoeuvresSpecialForce = new List <Manoeuvre> (); for (i = 0; i < patternsString.Count; ++i) { manoeuvresSpecialForce.Add(Manoeuvre.Create(patternsString[i])); } }
public static Manoeuvre SpiralPattern(int nbPoint, int nbTurn, float baseDelay, Vector3 initialPosition) { int i = 0; float x, z, angle, realAngle; string spiralManoeuvreString = ""; angle = (360 / (float)nbPoint) * (Mathf.PI / 180); for (; nbTurn > 0; --nbTurn) { for (i = 0; i < nbPoint; ++i) { realAngle = (float)i * angle; x = initialPosition.x + 100 * Mathf.Sin(realAngle); z = initialPosition.z + 100 * Mathf.Cos(realAngle); spiralManoeuvreString += "TrajectoryLine#(" + initialPosition.x + ",0," + initialPosition.z + ")(" + x + ",0," + z + ")=" + baseDelay + ";"; } } spiralManoeuvreString = spiralManoeuvreString.Remove(spiralManoeuvreString.Length - 1); return(Manoeuvre.Create(spiralManoeuvreString)); }