//add buttons, set text for each upgrade and set to MAX when fully upgraded void Start() { upgradeManager = GameObject.FindGameObjectWithTag("UpgradeManager").GetComponent <upgradeManager>(); sceneManager = GameObject.FindGameObjectWithTag("SceneManager").GetComponent <sceneManager>(); scoreText.text = upgradeManager.getPlayerScore().ToString(); updateMaxBoostsButton(); updateGroundSpeedReductionButton(); updateLaunchForceButton(); updateEnemySpeedReductionButton(); updateTruckFrequencyButton(); updateBombEnemyFrequencyButton(); initializeMenuButtons(); }
public IEnumerator die() { upgradeManager.setPlayerScore(upgradeManager.getPlayerScore() + pointValue); Sprite explosion = explosions[Random.Range(0, explosions.Length)]; transform.localScale = Vector3.zero; render.sprite = explosion; isDead = true; yield return(new WaitForSeconds(.27f)); gameController.getActiveEnemies().Remove(this.gameObject); if (!isSpecial) { render.sprite = enemySprite; this.gameObject.SetActive(false); gameController.decrementNumberActiveEnemies(); } else { killSpecial(); } }
void FixedUpdate() { scoreText.text = upgradeManager.getPlayerScore().ToString(); if (rb.velocity.x < 0 || (rb.velocity.y < 0 && isCollidingWithGround)) { gameController.gameOver(); } if (isInTruck) { if (Time.time > truckTime && isInTruck) { leaveTruck(); } } else { groundForce = rb.velocity.x / 46f; float zAngle = Mathf.Atan2(rb.velocity.y, rb.velocity.x) * Mathf.Rad2Deg; childSprite.transform.eulerAngles = new Vector3(transform.rotation.x, transform.rotation.y, zAngle); /* * if (Input.GetKeyDown(KeyCode.B) && catapult.getIsShot() && numBoosts > 0 && !isBoosting && !isCollidingWithGround) * { * boost(); * } */ if (Input.touchCount == 1 && catapult.getIsShot() && numBoosts > 0 && !isBoosting && !isCollidingWithGround) { if (Input.GetTouch(0).phase == TouchPhase.Began) { boost(); } } } }
public void upgradeMaxBoosts() { if (upgradeManager.getPlayerScore() >= maxBoostsUpgradeCosts[upgradeManager.maxBoostsIndex] && upgradeManager.maxBoostsIndex <= 3) { upgradeManager.maxBoosts = maxBoostsUpgradeValues[upgradeManager.maxBoostsIndex]; upgradeManager.setPlayerScore(upgradeManager.getPlayerScore() - maxBoostsUpgradeCosts[upgradeManager.maxBoostsIndex]); upgradeManager.maxBoostsIndex += 1; updateMaxBoostsButton(); scoreText.text = upgradeManager.getPlayerScore().ToString(); //push data to backend } }