// Use this for initialization void Awake() { SetSelectedCharacter(); isPlaying = false; selectCubeBttn.SetActive(true); healthText.text = "Health: " + health; coins = 0; coinsText.text = "Coins: " + coins; box = GetComponent <BoxCollider> (); rend = GetComponent <Renderer> (); myBody = GetComponent <Rigidbody>(); position = transform.position; speed = 10; alphaColor = gameObject.GetComponent <MeshRenderer>().material.color; alphaColor.a = 0; cubeNumber = 1; cubeRotationSpeed = EnemyCarMove.getSpeed() * 12f; control = GameObject.FindGameObjectWithTag("GameControl").GetComponent <GameControlScript>(); controller = GetComponent <CharacterController> (); camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>(); }
// Update is called once per frame void Update() { if (GameControlScript.getScore() == 0) { EnemyCarMove.setSpeed(20f); cubeController.setSpeed(10); cubeController.cubeRotationSpeed = EnemyCarMove.getSpeed() * 12f; } delayTimer -= Time.deltaTime; if (delayTimer < 0 && GameControlScript.getScore() % 25 == 0 && GameControlScript.getScore() > 1) { switch (stageNum) { case 1: sPlane.GetComponent <Renderer>().material = Stage2; break; case 2: sPlane.GetComponent <Renderer>().material = Stage3; break; case 3: sPlane.GetComponent <Renderer>().material = Stage4; break; case 4: sPlane.GetComponent <Renderer>().material = Stage5; break; case 5: sPlane.GetComponent <Renderer>().material = Stage6; break; case 6: sPlane.GetComponent <Renderer>().material = Stage1; stageNum = 0; break; } incrementSpeed(); delayTimer = 3; totalStages++; stageNum++; greenCubeSpawner.stageChangeDelay(); yellowCoinSpawner.stageChangeDelay(); yellowCubeSpawner.stageChangeDelay(); orangeCubeSpawner.stageChangeDelay(); redCubeSpawner.stageChangeDelay(); blueCubeSpawner.stageChangeDelay(); } }
private void incrementSpeed() { if (totalStages <= stageToScaleSpeed) { EnemyCarMove.setSpeed(EnemyCarMove.getSpeed() + speedIncrease); cubeController.setSpeed(cubeController.getSpeed() + speedIncrease * 0.1f); } else { EnemyCarMove.setSpeed(EnemyCarMove.getSpeed() + (speedIncrease) / Mathf.Sqrt(totalStages)); cubeController.setSpeed(cubeController.getSpeed() + (speedIncrease) / Mathf.Sqrt(totalStages)); } cubeController.cubeRotationSpeed = EnemyCarMove.getSpeed() * 12f; }