public void GetHole(float speed, int oldFloor) { holeToActive = HolePool.Instance.GetHoles(speed, false); holeBehaviour = holeToActive.GetComponent <HoleBehaviour>(); holeBehaviour.Floor = oldFloor; if (speed > 0) { holeBehaviour.Floor--; if (holeBehaviour.Floor < 0) { holeBehaviour.Floor = lanesPosition.Length - 1; } posToSpawnHole.x = -7.66f; posToSpawnHole.y = lanesPosition[holeBehaviour.Floor].transform.localPosition.y; holeBehaviour.HorizontalSpeed = speed; holeToActive.transform.localPosition = posToSpawnHole; } else { holeBehaviour.Floor++; if (holeBehaviour.Floor >= lanesPosition.Length) { holeBehaviour.Floor = 0; } posToSpawnHole.x = 7.66f; posToSpawnHole.y = lanesPosition[holeBehaviour.Floor].transform.localPosition.y; holeBehaviour.HorizontalSpeed = speed; holeToActive.transform.localPosition = posToSpawnHole; } }
public void GetStartHoles() { holeToActive = HolePool.Instance.GetHoles(initialSpeed, false); initialSpeed *= -1; posToSpawnHole.x = Random.Range(-7.66f, 7.66f); posToSpawnHole.y = lanesPosition[floor].transform.localPosition.y; holeToActive.transform.localPosition = posToSpawnHole; holeBehaviour = holeToActive.GetComponent <HoleBehaviour>(); holeBehaviour.Floor = floor; holesUnits++; }
public void GetNewHole() { if (holesUnits < 8) { floor = Random.Range(0, lanesPosition.Length); holeToActive = HolePool.Instance.GetHoles(0, true); posToSpawnHole.x = Random.Range(-7.66f, 7.66f); posToSpawnHole.y = lanesPosition[Floor].transform.localPosition.y; holeToActive.transform.localPosition = posToSpawnHole; holeBehaviour = holeToActive.GetComponent <HoleBehaviour>(); holeBehaviour.Floor = Floor; holesUnits++; } }
private GameObject QuantityHoles(float speed, bool assignSpeed) { holeToActivate = holesList[holesList.Count - 1]; holesList.RemoveAt(holesList.Count - 1); holeBehaviour = holeToActivate.GetComponent <HoleBehaviour>(); if (assignSpeed) { holeBehaviour.HorizontalSpeed = speedDirection[Random.Range(0, 2)]; } else { holeBehaviour.HorizontalSpeed = speed; } holeToActivate.gameObject.SetActive(true); return(holeToActivate); }
// Update is called once per frame void Update() { Debug.DrawRay(weapon.position, weapon.forward, Color.red, 0f, false); if (Input.GetMouseButtonDown(0)) { if (Physics.Raycast(weapon.position, weapon.forward, out RaycastHit hit, 100f, wallLayer, QueryTriggerInteraction.Ignore)) { if (hit.transform.CompareTag("Destructable")) { HoleBehaviour hole = Instantiate(holePrefab, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal)).GetComponent <HoleBehaviour>(); hole.ConfigureHole(hit.collider, transform, entitiesLayer); Debug.Log("Destroyed."); } else { Debug.Log("Non-destroyable obstacle."); } } } }