Add balloon and drumroll notes

This commit is contained in:
LoveEevee
2018-09-15 17:34:53 +03:00
parent 1d0fc88374
commit 749e657027
13 changed files with 1220 additions and 1218 deletions

View File

@@ -5,18 +5,25 @@ class P2Connection{
this.msgCallbacks = {}
this.closeCallbacks = new Set()
this.openCallbacks = new Set()
this.notes = []
this.otherConnected = false
this.onmessage("gamestart", () => {
this.otherConnected = true
this.notes = []
this.drumrollPace = 45
this.results = false
})
this.onmessage("gameend", () => {
this.otherConnected = false
})
this.onmessage("gameresults", response => {
this.results = response
})
this.onmessage("note", response => {
this.notes.push(response)
})
this.onmessage("drumroll", response => {
this.drumrollPace = response.pace
})
}
open(){
this.closed = false
@@ -92,7 +99,7 @@ class P2Connection{
this.msgCallbacks[data.type].forEach(obj => {
obj.callback(data.value)
if(obj.once){
delete this.msgCallbacks[obj]
this.msgCallbacks[data.type].delete(obj)
}
})
}
@@ -113,7 +120,10 @@ class P2Connection{
}
play(circle, mekadon){
if(this.otherConnected || this.notes.length > 0){
if(this.notes.length == 0){
var type = circle.getType()
if(type == "balloon"|| type == "drumroll" || type == "daiDrumroll"){
mekadon.playDrumrollAt(circle, 0, this.drumrollPace)
}else if(this.notes.length == 0){
mekadon.play(circle)
}else{
var note = this.notes[0]