public void selectFithstClass() { if (lastButtonClicked != "5") { hud.SetActive(false); path = GameObject.Find("Path" + lastButtonClicked + "_5").GetComponent <EditorPathScript>(); lastButtonClicked = "5"; playerOnShip = true; } }
//if button one is clicked public void selectFirstClass() { //if player is not on the same Island if (lastButtonClicked != "1") { hud.SetActive(false); // set path to the island on that the player is to island 1 path = GameObject.Find("Path" + lastButtonClicked + "_1").GetComponent <EditorPathScript>(); lastButtonClicked = "1"; playerOnShip = true; } }
private void Move() { //The Player is not actually moving to prevent big coordinates when the game is running for a while //The Tiles are moving in the opposite direction that the Player is supposed to move to //So determine the Distance between the Player and the Waypoint he is currently aiming for and the direction it is in float distance = Vector3.Distance(PathToFollow.path_objects[currentWayPointID].position, transform.position); Vector3 direction = transform.position - PathToFollow.path_objects[currentWayPointID].position; //Tell the TileManager in which direction the Tiles should move TileManager.Instance.setDirection(direction); //////////// //Turn the Player so the Camera is facing in the correct direction var rotation = Quaternion.LookRotation(PathToFollow.path_objects[currentWayPointID].position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, rotation, (Time.deltaTime * rotationSpeed) / distance); //if the Player has Reached the next waypoint (+-Tolerance) increase the WaypointID if (distance <= reachDistance) { currentWayPointID++; } //if the Path the Player is currently following is ending, get the current List of Tiles and get the path //of the next one //Initialise the removal of the last Tile and Spawn a new one if (currentWayPointID >= PathToFollow.path_objects.Count) { currentWayPointID = 1; index++; TileManager.Instance.Delete(); TileManager.Instance.SpawnTile(); List <GameObject> tilesList = TileManager.Instance.getTilesList(); PathToFollow = tilesList[index].transform.GetChild(1).GetComponent(typeof(EditorPathScript)) as EditorPathScript; } }
// Use this for initialization void Start() { PathToFollow = GameObject.Find(pathName).GetComponent <EditorPathScript>(); lastPosition = transform.position; }
// Use this for initialization void Start() { pathRoute = GameObject.Find(pathName).GetComponent <EditorPathScript>(); //lastPosition = transform.position; }
// Use this for initialization void Start() { PathToFollow = GameObject.Find(pathName).GetComponent <EditorPathScript>(); }
void Start() { PathToFollow = GameObject.Find(pathName).GetComponent <EditorPathScript>(); prevPos = transform.position; drone = GetComponent <Rigidbody>(); }
//Fill the Given Path with Crystals according to the Status of the Tutorial and the Scriptinternal counter public void SpawnCrystals(EditorPathScript currentSpawnPath) { //set the length of the chain according to the given parameters in GameSettings int randomLength = UnityEngine.Random.Range(minLength, maxLength + 1); //if the Tutorial is Running, always set the SpawnLength to 1 to decrease delay caused by prespawned Crystals if (GameSettings.Instance.ShowTutorial) { randomLength = 1; } //As long as the Tile is not filled, spawn a Crystal for (int i = 0; i < currentSpawnPath.path_objects.Count; i++) { GameObject lastCrystal; //if the number of Crystals already spawned on the current path exceeds the allowed length of the chain //set the counter to zero and choose a new chain length on another position if (index >= randomLength) { index = 0; randomLength = UnityEngine.Random.Range(minLength, maxLength + 1); lastDirection = spawnDirection; //do so ifthe Tutorial is not running (anymore) if (GameSettings.Instance.TutorialAlreadyOver) { while (spawnDirection == lastDirection) { spawnDirection = UnityEngine.Random.Range(0, 3) - 1; } } //if the Tutorial is running, set the Spawndirection according to it's current status else { spawnDirection = GameSettings.Instance.status - 1; } } //If the Tutorial isn't running and the Crystals are set to spawn in an Sin-curve, determine the color they should have //---bbb----------------------bbb---------------------- //bbb----ggg---------------bbb---ggg---------------bbb- //----------ggg---------ggg---------ggg---------ggg---- //-------------rrr---ggg---------------rrr---ggg------- //----------------rrr---------------------rrr---------- if (GameSettings.Instance.SinusActivted && !GameSettings.Instance.ShowTutorial) { float maxIndex = 2 / GameSettings.Instance.sinFrequency; if ((sinIndex > 0.25f * maxIndex && sinIndex < 0.5f * maxIndex) || (sinIndex > 0.75f * maxIndex && sinIndex < maxIndex)) { lastCrystal = (GameObject)Instantiate(crystal_green, currentSpawnPath.path_objects[i].position, currentSpawnPath.path_objects[i].rotation); } else if (sinIndex >= 0.5f * maxIndex && sinIndex <= 0.75f * maxIndex) { lastCrystal = (GameObject)Instantiate(crystal_blue, currentSpawnPath.path_objects[i].position, currentSpawnPath.path_objects[i].rotation); } else { lastCrystal = (GameObject)Instantiate(crystal_red, currentSpawnPath.path_objects[i].position, currentSpawnPath.path_objects[i].rotation); } } //if Sinus-Spawn is deactivated, determine the color according to the SpawnDirection //left=blue,middle=green,right=red else { if (spawnDirection == 0) { lastCrystal = (GameObject)Instantiate(crystal_green, currentSpawnPath.path_objects[i].position, currentSpawnPath.path_objects[i].rotation); } else if (spawnDirection == 1) { lastCrystal = (GameObject)Instantiate(crystal_red, currentSpawnPath.path_objects[i].position, currentSpawnPath.path_objects[i].rotation); } else { lastCrystal = (GameObject)Instantiate(crystal_blue, currentSpawnPath.path_objects[i].position, currentSpawnPath.path_objects[i].rotation); } } //set the Tile the crystal was spawned in as parent of it lastCrystal.transform.parent = currentSpawnPath.transform.parent.transform; //set the Rotation according to the Path, so the offset can later be applied correctly lastCrystal.transform.rotation = currentSpawnPath.path_objects[i].rotation; //Determine the offset from the center if it's supposed to be Sinus //(If the Tutorial has ended) if (GameSettings.Instance.SinusActivted && !GameSettings.Instance.ShowTutorial) { float a = GameSettings.Instance.sinFrequency * Mathf.PI; lastCrystal.transform.Translate(Mathf.Sin(sinIndex * a) * new Vector3(distance, 0, 0)); sinIndex++; if (sinIndex >= 2 * Mathf.PI / a) { sinIndex = 0; } } //Determine Offset without Sinus applied else { lastCrystal.transform.Translate(spawnDirection * new Vector3(distance, 0, 0)); } lastCrystal.transform.localScale = new Vector3(1, 1, 1); lastCrystal.transform.position += new Vector3(0, SpawnHeight, 0); lastCrystal.transform.GetChild(0).GetComponent <OnCrystalCollect>().direction = spawnDirection; index++; } }