// Update is called once per frame void Update() { GameObject PlayerScore = GameObject.Find("InvPlayer"); backendScores ScoreCount = PlayerScore.GetComponent <backendScores>(); if ((ScoreCount.isGameover == 1 && rb.useGravity == true) || (ScoreCount.isGameover == 2)) { rb.useGravity = false; // rb.AddForce(new Vector3(0, -2f, 0)); rb.velocity = new Vector3(0, 0, 0); //stop moving completly rb.position = new Vector3(rb.position.x, 190, rb.position.z); } else if (ScoreCount.isGameover == 0 && rb.useGravity == false) { rb.useGravity = true; } scoreTabber = ScoreCount.playerScore; if (scoreTabber > 10000) //spawn a challenge { scoreTabber = 0; dificultyIncreaser++; } if (ScoreCount.FleetHull <= 0) //reset because player died... { scoreTabber = 0; dificultyIncreaser = 0; } }
// Update is called once per frame void Update() { GameObject PlayerScore = GameObject.Find("InvPlayer"); backendScores ScoreCount = PlayerScore.GetComponent <backendScores>(); if ((ScoreCount.isGameover == 1 && rb.useGravity == true) || (ScoreCount.isGameover == 2)) { rb.useGravity = false; // rb.AddForce(new Vector3(0, -2f, 0)); rb.velocity = new Vector3(0, 0, 0); //stop moving completly rb.position = new Vector3(rb.position.x, 190, rb.position.z); } else if (ScoreCount.isGameover == 0 && rb.useGravity == false) { rb.useGravity = true; } /* below old idea that needs work on if used in future projects.. * scoreTabber = ScoreCount.playerScore-subScoreTab; //keep the ratio mantained * if ((scoreTabber>200)&&(nutSpawn==0)) //spawn a challenge * { * subScoreTab = ScoreCount.playerScore; * nutSpawn=1;//the nut has been spawned * GameObject sirNutiful = GameObject.Find("SirNut"); * sirNutiful.gameObject.transform.position = new Vector3(0, 130, 0); * scoreTabber = 0; * // AudioSource.PlayClipAtPoint(nut, new Vector3(rb.position.x, rb.position.y, rb.position.z)); * dificultyIncreaser++; * * } * else if (scoreTabber>100&&nutSpawn==1) * { * subScoreTab = ScoreCount.playerScore; * scoreTabber = 0; * GameObject sirNutiful = GameObject.Find("SirNut"); * // sirNutiful.gameObject.transform.position = new Vector3(0, 777, 0); * nutSpawn = 0; * } * */ if (ScoreCount.FleetHull <= 0) //reset because player died... { // scoreTabber = 0; // dificultyIncreaser = 0; } }
void FixedUpdate() { GameObject PlayerDead = GameObject.Find("InvPlayer"); backendScores CheckPlayer = PlayerDead.GetComponent <backendScores>(); if (CheckPlayer.isGameover == 0) { if (Input.GetButton("Fire1") && isShot == false) { //HOW TO FIND INFORMATION FROM OTHER SCRIPTS GameObject PlayerLocation = GameObject.Find("InvPlayer"); movementPlayer enemyHealth = PlayerLocation.GetComponent <movementPlayer>(); float beamX; float beamZ; beamX = enemyHealth.PlayerLocationX; beamZ = enemyHealth.PlayerLocationZ; rb.position = new Vector3(beamX, 0, beamZ + .5f); rb.AddForce(new Vector3(0.0f, 777.777f, 0.0f) * 44); isShot = true; AudioSource.PlayClipAtPoint(shot, new Vector3(rb.position.x, 0, rb.position.z), volume: .20f); } /* * else * { * rb.position = new Vector3(0f, 75f, -55.5f); * } * */ if (isShot == true) { if (rb.position.y > 175.7f) { rb.AddForce(new Vector3(0.0f, -777.777f, 0.0f) * 44); rb.position = new Vector3(0.0f, -500.0f, 0.0f); isShot = false; } } } }
void LateUpdate() { //turnVal += Time.deltaTime; turnVal = .03125f; //orginal value .03125f; rotationValue = new Vector3(Camera.main.transform.rotation.eulerAngles.x, Camera.main.transform.rotation.eulerAngles.y + turnVal, Camera.main.transform.rotation.eulerAngles.z); transform.rotation = Quaternion.Euler(rotationValue); GameObject checkStats = GameObject.Find("InvPlayer"); backendScores reallyStat = checkStats.GetComponent <backendScores>(); if (reallyStat.FleetHull < 0) //the game is over { Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView, 60, .75f * Time.deltaTime); reallyStat.isGameover = 1; } else if (reallyStat.FleetHull >= 0 && reallyStat.FleetHull <= 100) //reset everything back into place { Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView, 170, .75f * Time.deltaTime); reallyStat.isGameover = 0; } //could change when game over and go back, possibly change fov at start and end? // Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView, 60, 1 * Time.deltaTime); }
void OnTriggerEnter(Collider other) { //for backend scores and calculating of perchents GameObject PlayerScore = GameObject.Find("InvPlayer"); backendScores ScoreCount = PlayerScore.GetComponent <backendScores>(); if (ScoreCount.isGameover == 1 && rb.useGravity == true) { rb.useGravity = false; rb.AddForce(new Vector3(0, -2, 0)); } else if (ScoreCount.isGameover == 0 && rb.useGravity == false) { rb.useGravity = true; } if (other.gameObject.CompareTag("Player")) { Debug.Log("ff"); ScoreCount.FleetHull = ScoreCount.FleetHull - 9999; } if (other.gameObject.CompareTag("BottomCollision")) { int tempHit = Random.Range(0, ScoreCount.FleetHull); //as more objects are let through, the smaller the more likely the hits will continue if (tempHit < 50 + hp * 5) { if (ScoreCount.FleetHull != 1001) { ScoreCount.FleetHull = ScoreCount.FleetHull - Random.Range(0, hp); AudioSource.PlayClipAtPoint(hit, new Vector3(rb.position.x, rb.position.y, rb.position.z)); } } count++; float arg = Random.Range(-49, 49); //player space is really 100, though this is for extra space to help avoid clipping float darg = Random.Range(-49, 49); Debug.Log(count); rb.position = new Vector3(arg, 175.7f, darg); rb.AddForce(0, 1000, 0); hp = ogHp; hp = Random.Range(ogHp, ogHp + 5); rb.mass = Random.Range(6, 12) + (dificultyIncreaser * 2); ScoreCount.itemsLetThrough++; //increase the items let through count // 175.7 } if (other.gameObject.CompareTag("PlayerBeam")) { //fancy explosion mabye?! //HOW TO FIND INFORMATION FROM OTHER SCRIPTS GameObject PlayerLocation = GameObject.Find("Kapow_Explosion"); KapowExplosion ExplosionWhere = PlayerLocation.GetComponent <KapowExplosion>(); ExplosionWhere.powX = rb.position.x; ExplosionWhere.powY = rb.position.y; ExplosionWhere.powZ = rb.position.z; AudioSource.PlayClipAtPoint(asteroidHit, new Vector3(rb.position.x, rb.position.y, rb.position.z)); hp--; if (hp < 1) { AudioSource.PlayClipAtPoint(asteroidDef, new Vector3(rb.position.x, rb.position.y, rb.position.z)); int tempMass = (int)rb.mass; //how to cast from float to int <---- yay :) ScoreCount.totItemsHit++; //increase the items hit to dipslay hp = ogHp; hp = Random.Range(ogHp, ogHp + 5); ScoreCount.playerScore = ScoreCount.playerScore + (ogHp * 7) * tempMass; float arg = Random.Range(-49, 49); //player space is really 100, though this is for extra space to help avoid clipping float darg = Random.Range(-49, 49); rb.position = new Vector3(arg, 175.7f, darg); rb.AddForce(0, 1000, 0); ScoreCount.FleetHull = ScoreCount.FleetHull + Random.Range(ogHp, ogHp + 10 * (tempMass)); //fleet gets health back for destroyed asteroids, the faster the asteroid the more health that is returned // rb.mass = Random.Range(1,5); rb.mass = Random.Range(6, 12) + (dificultyIncreaser * 2); } else { ScoreCount.playerScore = ScoreCount.playerScore + hp * 7; } } }