@ -1,11 +1,130 @@ |
|||||||
function DialogueSequence(){ |
function DialogueSequence( sequence ){ |
||||||
|
|
||||||
|
var targetStory = story[sequence].slice(0); |
||||||
|
|
||||||
return { |
return { |
||||||
next: function(){ |
next: function(){ |
||||||
return story.shift().split(": ")[1]; |
return targetStory.shift().split(": ")[1]; |
||||||
}, |
}, |
||||||
more: function(){ |
more: function(){ |
||||||
return story.length > 0; |
return targetStory.length > 0; |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
|
function DialogUI( stage, gameState ){ |
||||||
|
var that = this; |
||||||
|
// Dialog States
|
||||||
|
var DIALOG_RECEDING = 0; |
||||||
|
var DIALOG_SHOWING = 1; |
||||||
|
var DIALOG_PAUSING = 2; |
||||||
|
var MILLIS_PER_CHAR = 100; |
||||||
|
|
||||||
|
this.dialogSpeed = 30; |
||||||
|
this.dialogState = DIALOG_PAUSING; |
||||||
|
|
||||||
|
this.dialogMotionQueue = [DIALOG_RECEDING]; |
||||||
|
this.currDialogueSeq = new DialogueSequence("Null"); |
||||||
|
dialogQueue = []; |
||||||
|
|
||||||
|
this.dialogBox = new createjs.Bitmap("res/DialogueBox.png"); |
||||||
|
this.dialogBox.x = 10; |
||||||
|
this.dialogBox.y = 675; |
||||||
|
|
||||||
|
this.textContent = new createjs.Text( "", "24px Arial", "#00000000" ); |
||||||
|
this.textContent.x = 205; |
||||||
|
this.textContent.y = 705; |
||||||
|
this.textContent.lineWidth = 565; |
||||||
|
this.textContent.lineHeight = 30; |
||||||
|
this.textContent.textBaseline = "alphabetic"; |
||||||
|
|
||||||
|
this.dialogBox.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; } ); |
||||||
|
this.dialogBox.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; } ); |
||||||
|
this.dialogBox.addEventListener( "click", function(){ setTimeout( clickEvent, 100); }); |
||||||
|
|
||||||
|
this.textContent.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; } ); |
||||||
|
this.textContent.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; } ); |
||||||
|
this.textContent.addEventListener( "click", function(){ setTimeout( clickEvent, 100); }); |
||||||
|
|
||||||
|
this.showDialog= function( textSeq ){ |
||||||
|
that.currDialogueSeq = new DialogueSequence( textSeq.seq ); |
||||||
|
that.textContent.text=that.currDialogueSeq.next(); |
||||||
|
that.autoAdvance = textSeq.autoAdvance; |
||||||
|
that.dialogMotionQueue = [DIALOG_SHOWING]; |
||||||
|
} |
||||||
|
|
||||||
|
gameState.pubsub.subscribe( "ShowDialog", this.showDialog ); |
||||||
|
|
||||||
|
// negate double setTimeout if clicked
|
||||||
|
var oldTime = new Date().getTime(); |
||||||
|
var delayCounter = 0; |
||||||
|
var clickEvent = function( timer ){ |
||||||
|
|
||||||
|
// if there is more dialogue text, then keep going, otherwise, recede
|
||||||
|
if( that.currDialogueSeq.more() ){ |
||||||
|
setTimeout( function(){ that.dialogMotionQueue.push(DIALOG_SHOWING) }, 500); |
||||||
|
that.textContent.text=that.currDialogueSeq.next(); |
||||||
|
delayCounter = 0; |
||||||
|
oldTime = new Date().getTime() |
||||||
|
}else{ |
||||||
|
// pause and close dialog
|
||||||
|
setTimeout( function(){that.dialogMotionQueue.push(DIALOG_RECEDING)}, 500 ); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
stage.addChild( this.dialogBox ); |
||||||
|
stage.addChild( this.textContent ); |
||||||
|
|
||||||
|
return { |
||||||
|
tick: function(){ |
||||||
|
delayCounter = new Date().getTime() - oldTime; |
||||||
|
|
||||||
|
if( that.autoAdvance == true && that.dialogBox.y ==435 && delayCounter > ( that.textContent.text.length * MILLIS_PER_CHAR ) ){ |
||||||
|
clickEvent(); |
||||||
|
} |
||||||
|
|
||||||
|
if( that.dialogState == DIALOG_RECEDING ){ |
||||||
|
that.dialogBox.y+=that.dialogSpeed; |
||||||
|
that.textContent.y +=that.dialogSpeed; |
||||||
|
console.log( "Receding" + that.dialogBox.y ); |
||||||
|
} |
||||||
|
if( that.dialogState == DIALOG_SHOWING ){ |
||||||
|
that.dialogBox.y-=that.dialogSpeed; |
||||||
|
that.textContent.y -=that.dialogSpeed; |
||||||
|
console.log( "Advancing" + that.dialogBox.y ); |
||||||
|
} |
||||||
|
|
||||||
|
// toggle states
|
||||||
|
if( that.dialogBox.y > 675 && that.dialogState == DIALOG_RECEDING ){ |
||||||
|
that.dialogBox.y = 675; |
||||||
|
that.textContent.y = 735; |
||||||
|
that.dialogState = DIALOG_PAUSING; |
||||||
|
console.log( "Pausing on recede" + that.dialogBox.y ); |
||||||
|
|
||||||
|
} |
||||||
|
if( that.dialogBox.y < 435 && that.dialogState == DIALOG_SHOWING ){ |
||||||
|
that.dialogBox.y = 435; |
||||||
|
that.textContent.y = 480; |
||||||
|
that.dialogState = DIALOG_PAUSING; |
||||||
|
console.log( "Pausing on showing" + that.dialogBox.y ); |
||||||
|
} |
||||||
|
|
||||||
|
/* next states if there are any on the queue */ |
||||||
|
if( that.dialogMotionQueue.length > 0 && that.dialogState == DIALOG_PAUSING ){ |
||||||
|
that.dialogState = that.dialogMotionQueue.shift(); |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
minDialog: function(){ |
||||||
|
that.dialogMotionQueue.push( DIALOG_RECEDING ); |
||||||
|
}, |
||||||
|
|
||||||
|
maxDialog: function(){ |
||||||
|
that.dialogMotionQueue.push( DIALOG_SHOWING ); |
||||||
|
}, |
||||||
|
render: function(){ |
||||||
|
stage.addChild( that.dialogBox ); |
||||||
|
stage.addChild( that.textContent ); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,101 @@ |
|||||||
|
function SoundInstance( soundObj, loop ){ |
||||||
|
this.soundObj = soundObj; |
||||||
|
} |
||||||
|
function SoundManager( gameState ){ |
||||||
|
var that = this; |
||||||
|
var soundCache = []; |
||||||
|
|
||||||
|
var AUDIO_OUT = 1; |
||||||
|
var AUDIO_IN = 2; |
||||||
|
var AUDIO_STABLE = 0; |
||||||
|
|
||||||
|
this.audioState = AUDIO_STABLE; |
||||||
|
|
||||||
|
// Register all sounds loaded in gameState
|
||||||
|
createjs.Sound.registerSound("res/sound/turkey_in_the_straw.mp3", "TitleMusic"); |
||||||
|
createjs.Sound.registerSound("res/sound/supermarket.mp3", "MarketBackgroundSound"); |
||||||
|
createjs.Sound.registerSound("res/sound/Music/Waterford.mp3", "MarketMusic"); |
||||||
|
createjs.Sound.registerSound("res/sound/GUI/pop.mp3", "Pop"); |
||||||
|
createjs.Sound.registerSound("res/sound/GUI/lowclick.mp3", "LowClick"); |
||||||
|
createjs.Sound.registerSound("res/sound/GUI/click.mp3", "Click"); |
||||||
|
createjs.Sound.registerSound("res/sound/GUI/buzz.mp3", "Error"); |
||||||
|
createjs.Sound.registerSound("res/sound/Store/buy.mp3", "Buy"); |
||||||
|
createjs.Sound.registerSound("res/sound/Store/entrance.mp3", "Entrance"); |
||||||
|
createjs.Sound.registerSound("res/sound/Store/backgroundSound.mp3", "MarketSound"); |
||||||
|
|
||||||
|
|
||||||
|
this.backgroundSounds = []; |
||||||
|
this.backgroundSoundsQueue = []; |
||||||
|
this.fadeOut = function(){ |
||||||
|
for ( var i in that.backgroundSounds ){ |
||||||
|
that.backgroundSounds[i].audioState = AUDIO_OUT; |
||||||
|
} |
||||||
|
}; |
||||||
|
this.play = function( soundName ){ |
||||||
|
var channel = createjs.Sound.createInstance("Pop"); |
||||||
|
if( typeof soundName != "object" ){ |
||||||
|
channel = soundCache[soundName] ? soundCache[soundName] : soundCache[soundName] = createjs.Sound.createInstance(soundName); |
||||||
|
} |
||||||
|
else{ |
||||||
|
channel = soundCache[soundName.name] ? soundCache[soundName.name] : soundCache[soundName.name] = createjs.Sound.createInstance(soundName.name); |
||||||
|
channel.volume = soundName.volume; |
||||||
|
} |
||||||
|
channel.play(); |
||||||
|
}; |
||||||
|
|
||||||
|
this.backgroundLoop = function( soundName ){ |
||||||
|
var newBackgroundSound; |
||||||
|
if( typeof soundName != "object" ){ |
||||||
|
newBackgroundSound = soundCache[soundName] ? soundCache[soundName] : soundCache[soundName] = createjs.Sound.createInstance(soundName); |
||||||
|
} |
||||||
|
else{ |
||||||
|
newBackgroundSound = soundCache[soundName.name] ? soundCache[soundName.name] : soundCache[soundName.name] = createjs.Sound.createInstance( soundName.name ); |
||||||
|
newBackgroundSound.setPosition(soundName.pos || 0); |
||||||
|
newBackgroundSound.volume = soundName.volume || 1; |
||||||
|
newBackgroundSound.play(); |
||||||
|
|
||||||
|
// loop-de-loop
|
||||||
|
newBackgroundSound.addEventListener("complete", function(){ |
||||||
|
if( newBackgroundSound.volume == 0 ){ newBackgroundSound.stop(); return; } |
||||||
|
newBackgroundSound.setPosition(soundName.pos || 0); |
||||||
|
newBackgroundSound.volume = soundName.volume || 1; |
||||||
|
newBackgroundSound.play(); |
||||||
|
}); |
||||||
|
} |
||||||
|
that.backgroundSoundsQueue.push(newBackgroundSound); |
||||||
|
}; |
||||||
|
|
||||||
|
gameState.pubsub.subscribe( "Play", this.play ); |
||||||
|
gameState.pubsub.subscribe( "BackgroundLoop", this.backgroundLoop ); |
||||||
|
gameState.pubsub.subscribe( "FadeOut", this.fadeOut ); |
||||||
|
|
||||||
|
return { |
||||||
|
tick: function(){ |
||||||
|
for ( var i in that.backgroundSounds ){ |
||||||
|
if( that.backgroundSounds[i].audioState == AUDIO_OUT ){ |
||||||
|
that.backgroundSounds[i].volume -=0.03; |
||||||
|
} |
||||||
|
if( that.backgroundSounds[i].audioState == AUDIO_IN ){ |
||||||
|
that.backgroundSounds[i].volume +=0.03; |
||||||
|
} |
||||||
|
if( that.backgroundSounds[i].volume >= 1.0 ){ |
||||||
|
that.backgroundSounds[i].volume = 1; |
||||||
|
} |
||||||
|
if( that.backgroundSounds[i].volume <= 0.0 ){ |
||||||
|
that.backgroundSounds[i].volume = 0; |
||||||
|
that.backgroundSounds[i].stop(); |
||||||
|
that.backgroundSounds.splice( i, 1 ); |
||||||
|
} |
||||||
|
} |
||||||
|
if( that.backgroundSounds.length == 0 ){ |
||||||
|
for ( var i in that.backgroundSoundsQueue ){ |
||||||
|
var newSound = that.backgroundSoundsQueue[i]; |
||||||
|
newSound.audioState = AUDIO_IN; |
||||||
|
that.backgroundSounds.push( newSound ); |
||||||
|
} |
||||||
|
that.backgroundSoundsQueue = []; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
After Width: | Height: | Size: 324 KiB |
After Width: | Height: | Size: 324 KiB |
After Width: | Height: | Size: 240 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 6.8 KiB |
After Width: | Height: | Size: 96 KiB |
After Width: | Height: | Size: 103 KiB |
After Width: | Height: | Size: 106 KiB |
After Width: | Height: | Size: 100 KiB |
After Width: | Height: | Size: 111 KiB |
After Width: | Height: | Size: 593 KiB |
Before Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 2.0 MiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 518 KiB |
After Width: | Height: | Size: 94 KiB |
@ -0,0 +1,35 @@ |
|||||||
|
Unless Otherwise noted, all sounds and music are in the public Domain. |
||||||
|
|
||||||
|
--------------------------- |
||||||
|
|
||||||
|
<Turkey in the Straw> |
||||||
|
|
||||||
|
turkey_in_the_straw |
||||||
|
|
||||||
|
Composition Licence: Traditional, arr. first published between 1829 and 1834. This MP3 (or other media file) is in the public domain because its copyright has expired. This applies to the United States, where Works published prior to 1978 were copyright protected for a maximum of 75 years. See Circular 1 "COPYRIGHT BASICS" from the U.S. Copyright Office. Works published before 1924 are now in the public domain. |
||||||
|
|
||||||
|
This file is also in the public domain in countries that figure copyright from the date of death of the artist (post mortem auctoris in this case George Washington Dixon 1801? âMarch 2, 1861), and that most commonly runs for a period of 50 to 70 years from December 31 of that year. |
||||||
|
|
||||||
|
Performance Licence: The United States Air Force Band Web site is provided as a public service by the United States Air Force Band and Department of the Air Force. |
||||||
|
|
||||||
|
Information presented on the United States Air Force Band site is considered public information and may be distributed or copied. Use of appropriate byline/photo/image credits is requested. |
||||||
|
|
||||||
|
UPLOADED by Sookietex |
||||||
|
|
||||||
|
--------------------------- |
||||||
|
<Clicks> |
||||||
|
|
||||||
|
Freesound.org |
||||||
|
file name references the author name and file number. |
||||||
|
|
||||||
|
|
||||||
|
--------------------------- |
||||||
|
|
||||||
|
Title: Improved Ice Cream Truck |
||||||
|
Artist: Kevin MacLeod |
||||||
|
Genre: Folk |
||||||
|
Length: 0:51 |
||||||
|
Bitrate: 320 kbps |
||||||
|
Size: 1.93MB |
||||||
|
|
||||||
|
An improved version of a traditional Ice Cream Truck melody… whose actual title I forget. |