private void OnTriggerEnter2D(Collider2D other) { RPGPlayer player; if (player = other.gameObject.GetComponent <RPGPlayer>()) { Manager.NotifyReachedExit(); ScoreManager.AddCurrentScore(ScoreManager.ScoreType.ExitBonus); } }
public virtual void Deactivate() { Tile tile = GetComponent <Tile>(); if (tile) { tile.IgnoreActive = true; } ScoreManager.AddCurrentScore(ScoreManager.ScoreType.Destructables); gameObject.SetActive(false); }
private void Dead() { //When Health drops below 50, start our smoke effect here //If Smoke effect is null, shows that this is the first time it has started if (health <= 50 && SmokeEffect == null) { SmokeEffect = VFXController.current.SpawnVFX(transform.position, Quaternion.identity, VFXController.VFX_TYPE.SMOKE_TYPE1); } //Else check if it is still active else if (health <= 50 && !SmokeEffect.activeInHierarchy) { SmokeEffect = VFXController.current.SpawnVFX(transform.position, Quaternion.identity, VFXController.VFX_TYPE.SMOKE_TYPE1); } //If enemy has 0 health, active will be set to false if (health == 0) { //Creating Explosion Effect VFXController.current.SpawnVFX(transform.position, Quaternion.identity, VFXController.VFX_TYPE.DEBRIS); VFXController.current.SpawnVFX(transform.position, Quaternion.identity, VFXController.VFX_TYPE.EXPLOSION_TYPE1); VFXController.current.SpawnVFX(transform.position, Quaternion.identity, VFXController.VFX_TYPE.EXPLOSIONSPARK_TYPE1); //Stop smoke effect if it is active if (SmokeEffect.activeInHierarchy) { SmokeEffect.SetActive(false); } ScoreManager.AddCurrentScore(ScoreManager.ScoreType.BossKill); //Disable the animations anim.enabled = false; aiming.SetActive(false); //Deactivate object gameObject.SetActive(false); if (shown == false) { if (ScoreManager.CurrentScore >= TextManager.Score[TextManager.Score.Count - 1]) { UIPanelManager.ShowUIPanel(UIPanelManager.UIPanel.NewHighscore); shown = true; } else { UIPanelManager.ShowUIPanel(UIPanelManager.UIPanel.GameOver); } } } }
void OnTriggerExit(Collider coll) { if (tileSpawnscript) { if (coll.tag == "Player") { Rigidbody rigid = transform.parent.GetComponent <Rigidbody>(); tileSpawnscript.DecreaseTileNumber(); rigid.useGravity = true; rigid.isKinematic = false; scoreManager.AddCurrentScore(1); Destroy(transform.parent.gameObject, 7); } } }
private void Dead() { //When Health drops below 50, start our smoke effect here //If Smoke effect is null, shows that this is the first time it has started if (health <= 50 && SmokeEffect == null) { SmokeEffect = VFXController.current.SpawnVFX(transform.position, Quaternion.identity, VFXController.VFX_TYPE.SMOKE_TYPE1); } //Else check if it is still active else if (health <= 50 && !SmokeEffect.activeInHierarchy) { SmokeEffect = VFXController.current.SpawnVFX(transform.position, Quaternion.identity, VFXController.VFX_TYPE.SMOKE_TYPE1); } //If enemy has 0 health, active will be set to false if (health == 0) { //Creating Explosion Effect VFXController.current.SpawnVFX(transform.position, Quaternion.identity, VFXController.VFX_TYPE.DEBRIS); VFXController.current.SpawnVFX(transform.position, Quaternion.identity, VFXController.VFX_TYPE.EXPLOSION_TYPE1); VFXController.current.SpawnVFX(transform.position, Quaternion.identity, VFXController.VFX_TYPE.EXPLOSIONSPARK_TYPE1); //Stop smoke effect if it is active if (SmokeEffect.activeInHierarchy) { SmokeEffect.SetActive(false); } //Display rumble DisplayRumble(); //Add score to the manager ScoreManager.AddCurrentScore(ScoreManager.ScoreType.EnemyKill); EnemyManager.updatedCount -= 1; //Disable the animations anim.enabled = false; aiming.SetActive(false); randomnumber = Random.Range(8, 11); //Deactivate object gameObject.SetActive(false); } }
private void Dead() { //If enemy has 0 health, active will be set to false if (health == 0) { //Creating Explosion Effect VFXController.current.SpawnVFX(transform.position, Quaternion.identity, VFXController.VFX_TYPE.DEBRIS); VFXController.current.SpawnVFX(transform.position, Quaternion.identity, VFXController.VFX_TYPE.EXPLOSION_TYPE1); VFXController.current.SpawnVFX(transform.position, Quaternion.identity, VFXController.VFX_TYPE.EXPLOSIONSPARK_TYPE1); //Increasing score as destroyed by player ScoreManager.AddCurrentScore(ScoreManager.ScoreType.MissileDestroyed); SoundManager.PlaySoundEffect(SoundManager.SoundEffect.DroneImpact); //Deactivate object gameObject.SetActive(false); } }
private void Fire() { // Minus bulet from ammosystem ammosystem.AmmoFire(); //Update the overheat bar overheat.OverheatbarUpdate(); //Creating Bullet Spread Vector3 FinalPosition = Input.mousePosition; randomnumber = Random.Range(0, firingimages.Count); GameObject firing = Instantiate(firingimages[randomnumber], PointerPosition, Quaternion.identity) as GameObject; firing.SetActive(true); firing.transform.SetParent(canvas.transform); //Wiimote detected and connected , Use Wiimote's IR Position Instead if (wiimote != null) { //Setting final position to IR's detected position float[] pointer = wiimote.Ir.GetPointingPosition(); //Mapping the position to screen FinalPosition.x = pointer[0] * Screen.width; FinalPosition.y = pointer[1] * Screen.height; } //print(FinalPosition); FinalPosition.x += Random.Range(-currentBulletSpread, currentBulletSpread); FinalPosition.y += Random.Range(-currentBulletSpread, currentBulletSpread); //Creating Ray based on final calculated position Ray ray = Camera.main.ScreenPointToRay(FinalPosition); RaycastHit hit; //Checking if Ray has hit if (Physics.Raycast(ray, out hit)) { EffectsHandler.EffectResponse(hit); //If it has a rigidbody if (hit.rigidbody != null) { hit.rigidbody.AddForce(((hit.point + hit.normal) - Camera.main.transform.position).normalized * BulletForce); } if (hit.collider.gameObject.GetComponent <Enemy>() != null) { //Hit the bottom of the tank for lesser points ScoreManager.AddCurrentScore(ScoreManager.ScoreType.BodyShot); SoundManager.PlaySoundEffect(SoundManager.SoundEffect.HitEnemy); ScoreManager.Multiply(); hit.transform.SendMessage("Injure", DamageOfBullet, SendMessageOptions.DontRequireReceiver); } else if (hit.collider.gameObject.GetComponent <EnemyBoss>() != null) { ScoreManager.Multiply(); hit.transform.SendMessage("Injure", DamageOfBullet, SendMessageOptions.DontRequireReceiver); } else if (hit.collider.gameObject.GetComponent <ShootingBarrel>() != null) { //Hit the top of the tank for more points ScoreManager.AddCurrentScore(ScoreManager.ScoreType.TopShot); SoundManager.PlaySoundEffect(SoundManager.SoundEffect.HitEnemy); ScoreManager.Multiply(); hit.transform.SendMessage("Injure", DamageOfBullet, SendMessageOptions.DontRequireReceiver); } else if (hit.collider.gameObject.tag == "TrafficLight") { //The trafficlight sound will only play by chance random = Random.Range(0, 11); if (random == 0) { SoundManager.PlaySoundEffect(SoundManager.SoundEffect.TrafficLight); } } else if (hit.collider.gameObject.GetComponent <Weakpoint>() != null) { //Hit the weakpoint of the tank ScoreManager.Multiply(); hit.transform.SendMessage("Cancel", 1, SendMessageOptions.DontRequireReceiver); } else { hit.transform.SendMessage("Injure", DamageOfBullet, SendMessageOptions.DontRequireReceiver); } } else { ScoreManager.ResetMultiplier(); } //Play the shooting sound effect SoundManager.PlaySoundEffect(SoundManager.SoundEffect.Fire); fireTimer = 0.0f; //Resetting the Timer currentBulletSpread += Time.deltaTime * SpreadIncreaseRate; //Increasing spread of bullet if (currentBulletSpread > MaxBulletSpreadRange) { currentBulletSpread = MaxBulletSpreadRange; } }
void Update() { TestState(); // If the game is in the play state, we want to continually check all the goals. If the functions returns true, the game ends if (state == GameState.Playing) { if (CheckGoals()) { state = GameState.DisplayingScore; } } // If the state is selection of language, we just enable the laser pointers else if (state == GameState.LanguageSelect) { GameObject[] lasers = GameObject.FindGameObjectsWithTag("LaserPointer"); foreach (GameObject g in lasers) { g.SetActive(true); } } else if (state == GameState.DisplayingScore) { // A boolean is necessary to avoid the score being continually added to the score list if (!scoreAdded) { scoreAdded = true; sm.AddCurrentScore(); } // Refresh the UI text RefreshScores(); timeOutTimer += 0.1f; if (timeOutTimer >= timeOut) { timeOutTimer = 0.0f; Reset(); } } else { Debug.Log("Error - Invalid state"); Rigidbody[] rigidbodies = FindObjectsOfType <Rigidbody>(); foreach (Rigidbody r in rigidbodies) { // Something was wrong so gotta make things explode r.AddForce(new Vector3(Random.Range(0.0f, 5000.0f), Random.Range(0.0f, 5000.0f), Random.Range(0.0f, 5000.0f))); } } if (showCasingObject) { foreach (SpriteRenderer sr in waitingSprites) { sr.color = new Color(1.0f, 1.0f, 1.0f, 1.0f); } } else { foreach (SpriteRenderer sr in waitingSprites) { sr.color = new Color(1.0f, 1.0f, 1.0f, 0.0f); } } }
private void OnTriggerEnter(Collider coll) { scoreManager.AddCurrentScore(5); anim.SetBool("destroy", true); myAudioSource.Play(); }