private void Update() { if (timer <= 0) { shake.C_Shake(.08f, .8f, .5f); GameObject instance = Instantiate(bulletIntantiate, shootPoint.position, shootPoint.rotation * new Quaternion(0f, 90f, 0f, 0f)); Instantiate(bullet, shootPoint.position, Quaternion.identity); timer = timeBtwSpawn; Destroy(instance, 1.2f); } else { timer -= Time.deltaTime; } if (health <= 0) { Destroy(gameObject); return; } if (Input.GetKeyDown(KeyCode.LeftAlt)) { Destroy(gameObject); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("DreamBus")) { health = 0; tempObj = Instantiate(destroyParticle, transform.position, new Quaternion(-90f, 0f, 0f, 0f)); controller.health -= 1; shake.C_Shake(.1f, 1f, 1f); } if (collision.CompareTag("TriangleBullet") || collision.CompareTag("ShieldBullet")) { shake.C_Shake(.1f, 2.5f, 1f); sm.score++; health = 0; } if (collision.CompareTag("Bullet1")) { damageParticleInstance = Instantiate(damageParticle, collision.transform.position, Quaternion.identity); health = 0; Destroy(collision.transform.gameObject); sm.score++; shake.C_Shake(.1f, 1f, 1f); } if (collision.CompareTag("Electric")) { Destroy(gameObject); shake.C_Shake(.1f, 1f, 1f); } }
private void Update() { if (bus == null) { return; } Vector2 direction = new Vector2(bus.position.x - transform.position.x, bus.position.y - transform.position.y); transform.right = -direction; if (timer <= 0) { animator.SetBool("isFire", true); shake.C_Shake(.1f, .5f, .5f); Instantiate(bullet, shootPoint.position, shootPoint.rotation); timer = timeBtwSpawn; } else { timer -= Time.deltaTime; } if (health <= 0) { Destroy(gameObject); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Bullet1")) { shake.C_Shake(.1f, 2f, 1f); health = 0; sm.score++; Destroy(collision.transform.gameObject); } if (collision.CompareTag("TriangleBullet") || collision.CompareTag("ShieldBullet")) { shake.C_Shake(.1f, 2.5f, 1f); health = 0; sm.score++; } if (collision.CompareTag("DreamBus")) { health = 0; shake.C_Shake(.1f, 2f, 1f); controller.health--; } if (collision.CompareTag("Electric")) { Destroy(gameObject); shake.C_Shake(.1f, 1f, 1f); } }
private void Update() { if (timer <= 0) { Instantiate(bullet[0], shootPoint[0].position, shootPoint[0].rotation); Instantiate(bullet[1], shootPoint[1].position, shootPoint[1].rotation); timer = timeBtwSpawn; } else { timer -= Time.deltaTime; } if (transform.position.x < -10f) { Destroy(gameObject); } if (health <= 0) { shake.C_Shake(.1f, 1f, 1f); GameObject instance = Instantiate(destroyParticle, transform.position, Quaternion.identity); Destroy(instance, 1.2f); Destroy(gameObject); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("DreamBus")) { eventType = 1; randomRotatePoint = Random.Range(0, RotatePoint.Length); shake.C_Shake(.1f, 3f, .7f); return; } if (collision.CompareTag("Bullet1") || collision.CompareTag("TriangleBullet") || collision.CompareTag("ShieldBullet")) { Destroy(collision.transform.gameObject); shake.C_Shake(.1f, 2.5f, 1f); StartCoroutine(HitFlash()); health -= 1; } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Bullet_1")) { animator.SetTrigger("Hit"); StartCoroutine(Flash()); shake.C_Shake(.1f, 1.5f, .8f); Destroy(collision.transform.gameObject); health -= 1; } if (collision.CompareTag("Bullet_2")) { animator.SetTrigger("Hit"); StartCoroutine(Flash()); shake.C_Shake(.1f, 1.5f, .8f); health -= 1; } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Bullet1")) { shake.C_Shake(.1f, 2f, .8f); Destroy(collision.transform.gameObject); Destroy(gameObject); } if (collision.CompareTag("TriangleBullet") || collision.CompareTag("ShieldBullet")) { shake.C_Shake(.1f, 1f, .8f); Destroy(gameObject); } if (collision.CompareTag("Electric")) { shake.C_Shake(.1f, 2f, .8f); Destroy(gameObject); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Bullet_1")) { DamageTrigger(); TriggerFlash(); Destroy(collision.transform.gameObject); shake.C_Shake(.1f, 2f, .8f); health = 0; } if (collision.CompareTag("Bullet_2")) { DamageTrigger(); TriggerFlash(); shake.C_Shake(.1f, 2f, .8f); health = 0; } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Bullet1")) { shake.C_Shake(.1f, 1f, 1f); damageInstance = Instantiate(damageParticle, collision.transform.position, Quaternion.identity); sm.score++; Destroy(collision.transform.gameObject); health -= 1; } if (collision.CompareTag("TriangleBullet") || collision.CompareTag("ShieldBullet")) { shake.C_Shake(.1f, 2.5f, 1f); sm.score++; health = 0; } if (collision.CompareTag("Electric")) { shake.C_Shake(.1f, 1f, 1f); Destroy(gameObject); } }
private void Update() { if (timer <= 0) { Instantiate(bullet[0], shootPoint[0].position, shootPoint[0].rotation); Instantiate(bullet[1], shootPoint[1].position, shootPoint[1].rotation); timer = timeBtwSpawn; } else { timer -= Time.deltaTime; } if (transform.position.x < -21f) { Destroy(gameObject); } if (health <= 0) { shake.C_Shake(.1f, 1f, 1f); Destroy(gameObject); } }
private void Update() { movement.x = Input.GetAxisRaw("Horizontal"); movement.y = Input.GetAxisRaw("Vertical"); mousePos = cam.ScreenToWorldPoint(Input.mousePosition); if (!Menu.isPause) { transform.position = mousePos; } transform.position = new Vector3(Mathf.Clamp(transform.position.x, x1, x2), Mathf.Clamp(transform.position.y, y1, y2), transform.position.z); // SHOOTING........ if (Input.GetMouseButton(0) && startTimeForShoot <= 0 && heatNum < 20f) { isDeHeat = false; shake.C_Shake(shakeDuration, shakeAmplitude, shakeFrequency); // StartCoroutine(Flash(flash[1])); GameObject instance = Instantiate(shootParticle, shootPoint.position, shootPoint.rotation * new Quaternion(0f, 90f, 0f, 0f)); Shoot(); Destroy(instance, 1f); startTimeForShoot = timeBtwShoot; if (heatTimer <= 0) { heatNum++; heatTimer = startHeatTimer; } else { heatTimer -= Time.deltaTime; } } else { startTimeForShoot -= Time.deltaTime; } if (Input.GetMouseButtonUp(0)) { if (isDeHeat == false) { StartCoroutine(DeHeat()); } } if (heatNum >= 19.5f && Input.GetMouseButton(0)) { HeatBarBorder.SetActive(true); } else { HeatBarBorder.SetActive(false); } if (startTimeForBullet <= 0) { bullet = bulletType[0]; } else { startTimeForBullet -= Time.deltaTime; } if (heatNum <= 0f) { heatNum = 0f; } if (bullet == bulletType[0]) { shootParticle = shootParticleType[0]; } else if (bullet == bulletType[1]) { shootParticle = shootParticleType[1]; } else if (bullet == bulletType[2]) { shootParticle = shootParticleType[2]; } heat.setHeatValue(heatNum); // END SHOOTING. if (health <= 0) { Destroy(gameObject); SceneManager.LoadScene(0); return; } if (health > 10) { health = 10; } if (Input.GetKeyDown(KeyCode.Space)) { health--; } if (Input.GetKeyDown(KeyCode.Q)) { health++; } // EVERYTHING RELATED TO BULLET SWITCHING.............. if (bullet == bulletType[0]) { timeBtwShoot = .3f; } else if (bullet == bulletType[1]) { timeBtwShoot = .4f; } else if (bullet == bulletType[2]) { timeBtwShoot = .15f; } // END OF EVERYTHING RELATED TO BULLET SWITCHING.............. // SCORE....... if (scoreTimer <= 0) { score += 1; scoreTimer = timeToIncreaseScore; } else { scoreTimer -= Time.deltaTime; } //END SCORE........ bar.setHealth(health); }
// +++++++ TRIGGER +++++++ \\ private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("DreamBus")) { shake.C_Shake(.07f, 2.5f, .8f); int randomEvent = Random.Range(1, 3); if (randomEvent == 1) { eventType = 1; } else if (randomEvent == 2) { eventType = 2; } // randomMovePoint = Random.Range(0, movePoints.Length); return; } if (collision.CompareTag("Bullet1")) { if (eventType == 3) { shake.C_Shake(.08f, 1f, .8f); StartCoroutine(hitFlash()); Destroy(collision.transform.gameObject); health -= 1; GameObject instance = Instantiate(damageParticle, collision.transform.position, Quaternion.identity); Destroy(instance, 1.2f); } if (eventType == 2) { shake.C_Shake(.08f, 1f, .8f); StartCoroutine(hitFlash()); Destroy(collision.transform.gameObject); health -= 1; eventType = 1; } if (health < 25) { if (secondStageEvent == 1) { shake.C_Shake(.8f, 1f, .8f); Destroy(collision.transform.gameObject); health -= 1; GameObject instance = Instantiate(damageParticle, collision.transform.position, Quaternion.identity); Destroy(instance, 1.2f); } if (secondStageEvent == 2) { shake.C_Shake(.8f, 1f, .8f); Destroy(collision.transform.gameObject); } } } if (collision.CompareTag("Electric")) { shake.C_Shake(.08f, 3f, .8f); Destroy(collision.transform.gameObject); health -= 5f; } }
// +++++++ TRIGGER +++++++ \\ private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Player")) { shake.C_Shake(.07f, 2.5f, .8f); int randomEvent = Random.Range(1, 3); eventType = 1; secondStageEvent = 1; } if (collision.CompareTag("Bullet_1")) { StartCoroutine(Flash()); Destroy(collision.transform.gameObject); shake.C_Shake(.1f, 1.5f, .8f); health -= 1f; } if (collision.CompareTag("Bullet_2")) { StartCoroutine(Flash()); Destroy(collision.transform.gameObject); shake.C_Shake(.1f, 1.5f, .8f); health -= 2f; } //if (collision.CompareTag("Bullet_1")) //{ // if (eventType == 3) // { // shake.C_Shake(.08f, 1f, .8f); // StartCoroutine(hitFlash()); // Destroy(collision.transform.gameObject); // health -= 1; // // GameObject instance = Instantiate(damageParticle, collision.transform.position, Quaternion.identity); // // Destroy(instance, 1.2f); // } // if (eventType == 2) // { // StartCoroutine(hitFlash()); // shake.C_Shake(.08f, 1f, .8f); // Destroy(collision.transform.gameObject); // health -= 1; // eventType = 1; // } // if (health < 25) // { // if (secondStageEvent == 1) // { // StartCoroutine(hitFlash()); // shake.C_Shake(.8f, 1f, .8f); // Destroy(collision.transform.gameObject); // health -= 1; // // GameObject instance = Instantiate(damageParticle, collision.transform.position, Quaternion.identity); // // Destroy(instance, 1.2f); // } // if (secondStageEvent == 2) // { // StartCoroutine(hitFlash()); // shake.C_Shake(.8f, 1f, .8f); // Destroy(collision.transform.gameObject); // } // } // } }
// TRIGGER. private void OnTriggerEnter2D(Collider2D collision) { // Triggers for detecting Hit.. if (collision.CompareTag("EnemyBullet")) { StartCoroutine(HitFlash()); Destroy(collision.transform.gameObject); shake.C_Shake(0.1f, 2f, 1f); health -= 1; } if (collision.CompareTag("EnemyBomb")) { Destroy(collision.transform.gameObject); shake.C_Shake(.1f, 2f, 1f); health -= 5; } if (collision.CompareTag("EnemyPoolBullet")) { StartCoroutine(HitFlash()); collision.transform.gameObject.SetActive(false); shake.C_Shake(.1f, 2f, 1f); health -= 1; } if (collision.CompareTag("VD1")) { StartCoroutine(HitFlash()); health -= 2; shake.C_Shake(.1f, 3f, .7f); } if (collision.CompareTag("Set_Boss")) { health -= 2; } // // Trigger for detecting Power up hit.. if (collision.CompareTag("Health")) { Destroy(collision.transform.gameObject); StartCoroutine(HealthFlash()); GameObject instance = Instantiate(healthParticle, transform.position, Quaternion.identity); health += 5; Destroy(instance, 1f); } if (collision.CompareTag("ExtraPowerUp")) { Destroy(collision.transform.gameObject); StartCoroutine(PowerFlash(color[4])); GameObject instance = Instantiate(extraPowerUpParticle, transform.position, Quaternion.identity); Destroy(instance, 1f); electricNumber++; } // /* bulletType[0] = Simple Bullet.. * bulletType[1] = Triangle Bullet.. * bulletType[2] = Shield Bullet.. */ if (collision.CompareTag("TriangleBulletPowerUp")) { timerObj.SetActive(true); GameObject instance = Instantiate(PowerUpTaken[0], transform.position, Quaternion.identity); StartCoroutine(PowerFlash(Color.red)); bullet = bulletType[1]; bulletParticle = bulletParticleType[1]; Destroy(collision.transform.gameObject); Destroy(instance, 1f); if (bullet == bulletType[0] || bullet == bulletType[2]) { timeStart = 20f; } else if (bullet == bulletType[1]) { timeStart += 20f; } } if (collision.CompareTag("ShieldBulletPowerUp")) { GameObject instance = Instantiate(PowerUpTaken[1], transform.position, Quaternion.identity); StartCoroutine(PowerFlash(Color.green)); bullet = bulletType[2]; Destroy(collision.transform.gameObject); Destroy(instance, 1f); if (bullet == bulletType[0] || bullet == bulletType[1]) { timeStart = 20f; } else if (bullet == bulletType[2]) { timeStart += 20f; } } }