private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { GameObject plane = new GameObject(); plane.name = "InstantiatedPlane"; Quaternion quater = new Quaternion(0, 0, 0, 0); if (direction == "down") { PLT.playerWentDown(); PLT.BeenHereBefore(); if (PLT.newTerrain) { Vector3 terrainSize = new Vector3(0, 0, 28); Vector3 newPosition = CurrentTerain.transform.position - terrainSize; plane = Instantiate(newPlane, newPosition, quater); AssignGate(plane); WMS.AddTile(plane); GenerateTerrainObjects(plane); } else { WMS.Tiles[PLT.GetLocationIndex()].SetActive(true); } } if (direction == "up") { PLT.playerWentUp(); PLT.BeenHereBefore(); if (PLT.newTerrain) { Vector3 terrainSize = new Vector3(0, 0, 28); Vector3 newPosition = CurrentTerain.transform.position + terrainSize; plane = Instantiate(newPlane, newPosition, quater); AssignGate(plane); WMS.AddTile(plane); GenerateTerrainObjects(plane); } else { WMS.Tiles[PLT.GetLocationIndex()].SetActive(true); } } if (direction == "left") { PLT.playerWentLeft(); PLT.BeenHereBefore(); if (PLT.newTerrain) { Vector3 terrainSize = new Vector3(28, 0, 0); Vector3 newPosition = CurrentTerain.transform.position - terrainSize; plane = Instantiate(newPlane, newPosition, quater); AssignGate(plane); WMS.AddTile(plane); GenerateTerrainObjects(plane); } else { WMS.Tiles[PLT.GetLocationIndex()].SetActive(true); } } if (direction == "right") { PLT.playerWentRight(); PLT.BeenHereBefore(); if (PLT.newTerrain) { Vector3 terrainSize = new Vector3(28, 0, 0); Vector3 newPosition = CurrentTerain.transform.position + terrainSize; plane = Instantiate(newPlane, newPosition, quater); AssignGate(plane); WMS.AddTile(plane); GenerateTerrainObjects(plane); } else { WMS.Tiles[PLT.GetLocationIndex()].SetActive(true); } } CurrentTerain.SetActive(false); } }
// Start is called before the first frame update void Start() { locationList.Add(new int[] { 0, 0 }); WMScript = GameObject.Find("WorldManager").GetComponent <WorldManagerScript>(); WMScript.AddTile(GameObject.FindGameObjectWithTag("StartTile")); }