private void ComparerObjets(GameObject objCree, GameObject objRef, axes axeChoisi) { float compareCree = 0; float compareRef = precision + 1; switch (axeChoisi) //selon l'axe choisi pour le traitement, on récupère les valeurs pour l'objet et sa référence { case axes.x: compareCree = objCree.transform.position.x; compareRef = objRef.transform.position.x; break; case axes.y: compareCree = objCree.transform.position.y; compareRef = objRef.transform.position.y; break; case axes.z: compareCree = objCree.transform.position.z; compareRef = objRef.transform.position.z; break; case axes.rho: compareCree = objCree.transform.rotation.x; compareRef = objRef.transform.rotation.x; break; case axes.theta: compareCree = objCree.transform.rotation.y; compareRef = objRef.transform.rotation.y; break; case axes.phi: compareCree = objCree.transform.rotation.z; compareRef = objRef.transform.rotation.z; break; default: compareCree = precision + 1; compareRef = 0; break; } if (Math.Abs(compareCree - compareRef) < precision) { //on affiche le nom de l'objet s'il est bien construit str += objCree.name + " OK\n"; } }
void Update() { if (!gameOver && !paused) { if (Input.anyKey) { // this is good for OK movement // smoother movement requires more complicated code switch (axis) { case axes.horizontal: if (Input.GetKey(keys["Up"])) { dir = Vector3.up; axis = axes.vertical; } if (Input.GetKey(keys["Down"])) { dir = Vector3.down; axis = axes.vertical; } break; case axes.vertical: if (Input.GetKey(keys["Right"])) { dir = Vector3.right; axis = axes.horizontal; } if (Input.GetKey(keys["Left"])) { dir = Vector3.left; axis = axes.horizontal; } break; } } } ColorMySnake(); if (scoreValue >= 10 && scoreValue < 20) { speed = 5f; } else if (scoreValue >= 20 && scoreValue < 30) { speed = 6f; } else if (scoreValue >= 30 && scoreValue < 40) { speed = 7f; } else if (scoreValue >= 40 && scoreValue < 50) { speed = 8f; } else if (scoreValue >= 50 && scoreValue < 60) { speed = 9f; } else if (scoreValue >= 60 && scoreValue < 70) { speed = 10f; } else if (scoreValue >= 70 && scoreValue < 80) { speed = 11f; } else if (scoreValue >= 80 && scoreValue < 90) { speed = 12f; } else if (scoreValue >= 90) { speed = 13f; } }