void Dash() { /*if (Input.GetKeyDown(KeyCode.K)) * { * currentDashTime = 0; * } * if (currentDashTime < maxDashTime) * { * moveDirection = transform.forward * dashDistance; * currentDashTime += dashStoppingSpeed; * } * else * { * moveDirection = Vector2.zero; * } * //rb.velocity = moveDirection * Time.deltaTime * dashSpeed; * * transform.position = moveDirection * Time.deltaTime * dashSpeed;*/ if (Input.GetKeyDown(KeyCode.D) && Input.GetKey(KeyCode.K) || Input.GetKeyDown(KeyCode.K) && Input.GetKey(KeyCode.D)) { transform.position += new Vector3(dashSpeed * Time.deltaTime, 0, 0.0f); shake.CamShake(); } if (Input.GetKeyDown(KeyCode.A) && Input.GetKey(KeyCode.K) || Input.GetKeyDown(KeyCode.K) && Input.GetKey(KeyCode.A)) { transform.position -= new Vector3(dashSpeed * Time.deltaTime, 0, 0.0f); shake.CamShake(); } if (Input.GetKeyDown(KeyCode.W) && Input.GetKey(KeyCode.K) || Input.GetKeyDown(KeyCode.K) && Input.GetKey(KeyCode.W)) { transform.position += new Vector3(0, dashSpeed * Time.deltaTime, 0.0f); shake.CamShake(); } if (Input.GetKeyDown(KeyCode.S) && Input.GetKey(KeyCode.K) || Input.GetKeyDown(KeyCode.K) && Input.GetKey(KeyCode.S)) { transform.position -= new Vector3(0, dashSpeed * Time.deltaTime, 0.0f); shake.CamShake(); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("Asteriod")) { health = health - (health / 2); //Destroy(other.gameObject); if (Player.health <= 0) { GameOver(); } } else if (other.gameObject.CompareTag("Bullet")) { health -= 20f; Destroy(other.gameObject); Shake.CamShake(); if (Player.health <= 0) { GameOver(); } } else if (other.gameObject.CompareTag("Enemy")) { health -= 5.0f; bulletCount++; if (Player.health <= 0) { GameOver(); } } else if (other.gameObject.CompareTag("Health") && health < 100f) { if (health <= 90) { health += 10f; } else if (health > 90) { health = maxHealth; } Destroy(other.gameObject); } }