class Dialog {
constructor() {
this.dialogElem = document.getElementById('dialog')
this.dialogTextElem = document.getElementById('dialog-text')
this.controlsElem = document.getElementById('controls')
this.currentDialogIndex = 0
this.dialogOrder = ['intro', 'controls', 'resume']
this.dialogMap = {
'intro': 'Hello! Welcome to my Interactive Portfolio!
Press ENTER to continue, or click the links below for quick access to my Resume & Projects.',
'controls': 'Use ARROW KEYS or WASD or VIM keys (HJKL) to move around.
Press the ENTER key to interact with what you see on the screen.
',
'resume': 'Walk over to the DESK and click on my RESUME.
The RESUME is marked by the flashing red indicator light.
',
'portfolio': 'Thanks for looking at my Resume!
Check out my PORTFOLIO by clicking on the BOOKSHELF.
',
'other': 'Now that you have looked through my Porfolio, go explore the rest of the site!
- Click on the GUITAR to hear my music.
- Mess around on the Terminal on the COMPUTER
- And before you leave, go to the TV and play some of the games I have made!
Thanks for stopping by!'
}
this.resumeIndicator = document.getElementById('resume-indicator')
}
dialogListener(event) {
console.log(event)
if (event.key === 'Enter' || event.type === 'click' || event.type === 'touchend') {
event.currentTarget.self.startIntroDialogSequence()
}
}
startIntroDialogSequence() {
document.removeEventListener("keydown", this.dialogListener);
document.removeEventListener('click', this.dialogListener)
document.removeEventListener('touchend', this.dialogListener)
if (this.currentDialogIndex > this.dialogOrder.length - 1) {
this.dialogElem.style.display = 'none'
dialogMode = false
} else {
var dialog = this.dialogOrder[this.currentDialogIndex]
this.display(dialog)
if (this.dialogOrder[this.currentDialogIndex] in indicator.indicatorMap) {
indicator.show(this.dialogOrder[this.currentDialogIndex])
}
this.currentDialogIndex++
}
}
display(dialog) {
dialogMode = true
dialog = this.dialogMap[dialog]
this.dialogElem.style.display = 'block'
this.dialogTextElem.innerHTML = dialog
var self = this
document.addEventListener('keydown', this.dialogListener)
if (controlsMode) {
console.log('hello')
document.addEventListener('click', this.dialogListener)
document.addEventListener('touchend', this.dialogListener)
}
document.self = self
}
}