private void UseWeapon(BEAT beat) { var tDir = new Vector2(); switch (beat) { case BEAT.TRIANGLE: tDir = Vector2.up; break; case BEAT.SQUARE: tDir = Vector2.left; break; case BEAT.CIRCLE: tDir = Vector2.right; break; case BEAT.X: tDir = Vector2.down; break; } var tProj = GameObject.Instantiate(projectile, new Vector3(this.transform.position.x + (tDir.x * sr.bounds.size.x), this.transform.position.y + (tDir.y * sr.bounds.size.y), 0), Quaternion.identity); tProj.Shoot(tDir); }
public void addBeat(BEAT beat) { AudioSource.PlayClipAtPoint(clips[beat], player.transform.position); Debug.Log(beat); if (beat < BEAT.CIRCLE || beats.Count >= 4) { beats.Clear(); } else { var beatString = ""; beats.Add(beat); if (beats.Count == 4) { //creating beat string out of the 4 beats pressed foreach (BEAT b in beats) { beatString += b; } //comparing with all known attacks to see if it will work foreach (string s in attacks) { if (s == beatString) { Debug.Log("attack"); beats.Clear(); } } //if there wasn't an attack, get rid of the if (beats.Count > 0) { beats.RemoveAt(0); } } } }