public void HandlePortal(MovingCube blockToTeleport, Collider col) { if (portals.Count <= 1) { return; } if (blockToTeleport.canGoThruPortals) { print("handle portal"); blockToTeleport.canGoThruPortals = false; PortalCube currentPortal = col.GetComponent <PortalCube>(); List <PortalCube> allPortals = portals; List <PortalCube> potentialPortals = new List <PortalCube>(); for (int i = 0; i < allPortals.Count; i++) { if (allPortals[i] != currentPortal) { potentialPortals.Add(allPortals[i]); } } portalToComeOutOf = potentialPortals[Random.Range(0, potentialPortals.Count)]; StartCoroutine(portalBuffer(blockToTeleport)); } }
private IEnumerator portalBuffer(MovingCube blockToTeleport) { yield return(new WaitForSeconds(.5f)); blockToTeleport.transform.position = portalToComeOutOf.transform.position; yield return(new WaitForSeconds(1f)); blockToTeleport.canGoThruPortals = true; }
private void OnEnable() { //first cube that spawns automatically becomes the last cube if (LastCube == null) { //remember if you rename 'start' cube object in unity the whole game breaks LastCube = GameObject.Find("Start").GetComponent <MovingCube>(); } CurrentCube = this; }
private void OnEnable() { if (LastCube == null) { LastCube = GameObject.Find("Start").GetComponent <MovingCube>(); } CurrentCube = this; GetComponent <Renderer>().material.color = GetRandomColor(); }
private void OnEnable() { if (LastCube == null) { LastCube = GameObject.Find("Start").GetComponent <MovingCube>(); } CurrentCube = this; GetComponent <Renderer>().material.color = GetRandomColor(); transform.localScale = new Vector3(LastCube.transform.localScale.x, transform.localScale.y, transform.localScale.z); }
protected void OnEnable() { if (LastCube == null) { LastCube = GameObject.Find("Start Cube").GetComponent <MovingForwardCube>(); } Debug.Log(LastCube.ToString()); if (reversed) { moveSpeed *= -1; } CurrentCube = this; }
public void SpawnCube() { GameObject cube = Instantiate(cubePrefab); currentCube = cube.GetComponent <MovingCube>(); int index = Random.Range(0, cubeSpawnData.Length); Debug.Log("index = " + index); if (lastCube != null && lastCube.gameObject != GameObject.Find("Start")) { float x = cubeSpawnData[index].moveDirection == MoveDirection.X ? cubeSpawnData[index].spawnPoint.transform.position.x : lastCube.transform.position.x; float z = cubeSpawnData[index].moveDirection == MoveDirection.Z ? cubeSpawnData[index].spawnPoint.transform.position.z : lastCube.transform.position.z; cube.transform.position = new Vector3(x, lastCube.transform.position.y + cube.transform.localScale.y, z); } else { cube.transform.position = cubeSpawnData[index].spawnPoint.transform.position; } cube.GetComponent <MovingCube>().MoveDirection = cubeSpawnData[index].moveDirection; }
private void Awake() { //TODO: Move to Spawner CurrentCube = this; }
void Awake() { lastCube = GameObject.Find("Start").GetComponent <MovingCube>(); }