// IEnumerator Shoot() { // if (!dead) { // yield return new WaitForSeconds (Random.Range (1f, 4f)); // Instantiate (enemyBullet, transform.position+transform.right*spd, Quaternion.Euler (0, 0, Geo.ToAng (player.position - transform.position))); // StartCoroutine (Shoot ()); // } // } void OnShot() { health--; //GetComponent<Collider2D> ().enabled=false; //splat.Play (); if (health <= 0) { dead = true; GameManager.me.killCount += 1; if (GameManager.me.comboIsActive == false) { GameManager.me.playerScore += deathScore; textMesh.text = "+" + deathScore + "!"; } else { GameManager.me.playerScore += deathScore * 2; textMesh.text = "+" + deathScore * 2 + "!"; } GameManager.me.ResetComboTimer(); cam.shakeCamera(.3f, .5f); Instantiate(enemyDeath, transform.position, Quaternion.identity); Instantiate(deathText, new Vector2(transform.position.x, transform.position.y + 3), Quaternion.identity); Flasher.me.ScoreUp(); soundScript.me.Play(powerDown2); } }
// IEnumerator Shoot() { // if (!dead) { // yield return new WaitForSeconds (Random.Range (1f, 4f)); // Instantiate (enemyBullet, transform.position+transform.right*spd, Quaternion.Euler (0, 0, Geo.ToAng (player.position - transform.position))); // StartCoroutine (Shoot ()); // } // } void OnShot() { health--; //GetComponent<Collider2D> ().enabled=false; //splat.Play (); if (health <= 0) { dead = true; GameManager.me.killCount += 1; if (GameManager.me.comboIsActive == false) { GameManager.me.playerScore += deathScore; textMesh.text = "+" + deathScore + "!"; } else { GameManager.me.playerScore += deathScore * 2; textMesh.text = "+" + deathScore * 2 + "!"; } GameManager.me.ResetComboTimer(); // int numberSelect = Random.Range (0, 2); // Instantiate (randomEnemy [numberSelect], (Vector2)transform.position+new Vector2 (3,0), Quaternion.identity); // print (randomEnemy[numberSelect].transform.position); Instantiate(deathEffect, transform.position, Quaternion.identity); Instantiate(deathText, new Vector2(transform.position.x, transform.position.y + 3), Quaternion.identity); cam.shakeCamera(.25f, .25f); Flasher.me.ScoreUp(); } }
void Update() { timeAlive += 1 * Time.deltaTime; print("this is the timealive" + timeAlive); bulletCount = GameObject.FindGameObjectsWithTag("bullet").Length; //print ("is dashing" + isDashing); if (bulletCount == 1) { bulletPos = bigBulletBOI.transform.position; } if (Input.GetMouseButtonDown(0)) { cam.shakeCamera(.1f, .1f); if (bulletCount == 0) { bulletCount++; bigBulletBOI = Instantiate(bullet, transform.position + ((cursor.position - transform.position).normalized * 2f), Quaternion.Euler(0, 0, Geo.ToAng(cursor.position - transform.position))); bulletPos = bigBulletBOI.transform.position; sounds.Play(shot, .75f); } } //print (bulletPos); if (Input.GetMouseButtonDown(1) && bulletCount == 1) { bulletCount = 0; cam.shakeCamera(.3f, .3f); sounds.Play(pullBack, .75f); } dir = (bulletPos - (Vector2)transform.position).normalized; if (Input.GetKeyDown(KeyCode.Space) && isDashing == false && bulletCount > 0) { isDashing = true; soundScript.me.Play(dashSound); Instantiate(dashEffect, transform.position, Quaternion.identity); } if (Vector2.Distance(bulletPos, transform.position) == 0 && isDashing == true) { isDashing = false; } }