private void Awake() { _car = FindObjectOfType <Car>(); _enemyCarSpawner = FindObjectOfType <EnemyCarSpawner>(); _roadSpawner = FindObjectOfType <RoadSpawner>(); _sideTileSpawner = FindObjectOfType <SideTileSpawner>(); }
// Update is called once per frame void Update() { //todo worst idea to create new object each frame, u can cache this in global variable in awake, like this //private void Awake() //{ // main = Main.Instance; // roadSpawner = RoadSpawner.Instance; //} Main main = Main.Instance; RoadSpawner rs = RoadSpawner.Instance; Vector3 pos = transform.position; //Debug.Log(pos.y); //Road road = new Road(); //todo introduce local variable to avoid double property access, like this // var bounds = boxCollider2D.bounds; // roadHeight = bounds.max.y - bounds.min.y; roadHeight = boxCollider2D.bounds.max.y - boxCollider2D.bounds.min.y; //todo never compare float values u can lost some data, coz its FKN FLOAT when u set value as 1.2f its can me 1.200000000000000000001f, so do something like this // if (Math.Abs(boxCollider2D.bounds.min.y - main.minY) < TOLERANCE) if (boxCollider2D.bounds.min.y == main.minY) { //OnObjectSpawn(); rs.spawn = true; } pos.y -= speed * Time.deltaTime; transform.position = pos; }
void Start() { roadSpawner = GetComponent <RoadSpawner>(); carSpawner = GetComponent <CarSpawner>(); pickUpSpawner = GetComponent <PickUpSpawner>(); enemySpawner = GetComponent <EnemySpawner>(); environmentSpawner = GetComponent <EnvironmentSpawn>(); }
public void InitLevel() { //if (_player != null) Destroy(_player); PlayerCreator playerCreator = new PlayerCreator(_settings.PlayerConstructSettings); _player = playerCreator.CreatePlayer(); GateSpawner gateSpawner = new GateSpawner(_player.GetComponent <IRotatable>(), _settings.GateSettings); gateSpawner.CreateGatePools(); _roadSpawner = new RoadSpawner(_settings.RoadSettings); _roadSpawner.Init(gateSpawner.GatePools); _cameraSettings.Init(_player.GetComponent <ICameraControllable>()); }
void FixedUpdate() { var position = transform.position; position.z -= carSpeed * Time.fixedDeltaTime; position.x = RoadSpawner.GetRoadOffset() - carOffset; if (position.z < -20) { position.z += 64; mesh.enabled = true; } transform.position = position; if (Vector3.Distance(position, player_pos) < 2.5f) { mesh.enabled = false; Instantiate(crashParticles, this.transform); } }
void Start() { limo = GameObject.Find("Limo"); Level = PlayerPrefs.GetInt("level", 1); levelText.GetComponent <Text>().text = "Level: " + Level; LimoHealth = 2; healthText.GetComponent <Text>().text = "Health: " + LimoHealth; gameStarted = false; distText = DistanceText.GetComponent <Text>(); tempDistance = Random.Range(50, 100) * Level; distance = Mathf.RoundToInt(tempDistance); distText.text = "Distance: " + distance; roadSpawner = GameObject.Find("SpawnManager").GetComponent <RoadSpawner>(); plotSpawner = GameObject.Find("SpawnManager").GetComponent <PlotSpawner>(); initAmount = roadSpawner.roads.Count; tempChildCount = limo.transform.childCount; }
private void Awake() { Instance = this; }
void Start() { roadSpawner = GetComponent <RoadSpawner>(); }
private void Awake() { _roadSpawner = FindObjectOfType <RoadSpawner>(); }
private void Start() { roadSpawner = GameObject.Find ("Road Spawner").GetComponent<RoadSpawner> (); }
// Start is called before the first frame update void Start() { roadSpawner = GetComponent <RoadSpawner>(); camera = GameObject.FindGameObjectWithTag("MainCamera").transform; //obstacleSpawner = GetComponent<ObstacleSpawner>(); }