-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into bird_npc_city_map
- Loading branch information
Showing
17 changed files
with
1,311 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { scaleFactor } from '../../constants'; | ||
|
||
export const clerk = (k, map, spawnpoints) => { | ||
k.loadSprite('clerk', './assets/sprites/characters.png', { | ||
sliceX: 10, | ||
sliceY: 20, | ||
anims: { | ||
'idle-down': 160, | ||
'walk-down': { from: 184, to: 185, loop: true, speed: 4 }, | ||
'idle-side': 52, | ||
'walk-side': { from: 188, to: 190, loop: true, speed: 4 }, | ||
'idle-up': 181, | ||
'walk-up': { from: 186, to: 199, loop: true, speed: 4 }, | ||
}, | ||
}); | ||
|
||
return k.make([ | ||
k.sprite('clerk', { anim: 'idle-down' }), | ||
k.area({ | ||
shape: new k.Rect(k.vec2(0), 16, 16), | ||
}), | ||
k.body({ isStatic: true }), | ||
k.anchor('center'), | ||
k.pos( | ||
map.pos.x + spawnpoints.clerk.x / scaleFactor, | ||
map.pos.y + spawnpoints.clerk.y / scaleFactor | ||
), | ||
k.offscreen({ hide: true, distance: 10 }), | ||
'clerk', | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { clerk } from './clerk.gameObjects'; | ||
|
||
const gameObjects = [clerk]; | ||
|
||
export default gameObjects; |
5 changes: 5 additions & 0 deletions
5
src/interactions/map_extended_campus/enterMapRealtor.interactions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const enterMapRealtor = (player, k) => { | ||
player.onCollide('enter_map_realtor_office', () => { | ||
k.go('realtor'); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/interactions/map_realtor/behindDeskClerkInteraction.interactions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { interactionHandler } from '../handler.interactions'; | ||
import { displayDialogue } from '../../utils'; | ||
|
||
export const behindDeskClerkInteraction = (player, k) => { | ||
interactionHandler(player, 'behind_desk', k, async () => { | ||
displayDialogue({ | ||
k, | ||
player, | ||
text: [ | ||
"Uhh... You aren't supposed to be behind here", | ||
'Get out dude', | ||
], | ||
}); | ||
}); | ||
}; |
14 changes: 14 additions & 0 deletions
14
src/interactions/map_realtor/boxesInteraction.interactions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { interactionHandler } from '../handler.interactions'; | ||
import { displayDialogue } from '../../utils'; | ||
|
||
export const boxesInteraction = (player, k) => { | ||
interactionHandler(player, 'boxes', k, async () => { | ||
displayDialogue({ | ||
k, | ||
player, | ||
text: [ | ||
'Bunch of boxes here... nothing to see (Just an Xbox One laying in the corner hehehe)', | ||
], | ||
}); | ||
}); | ||
}; |
15 changes: 15 additions & 0 deletions
15
src/interactions/map_realtor/computerOneInteraction.interactions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { interactionHandler } from '../handler.interactions'; | ||
import { displayDialogue } from '../../utils'; | ||
|
||
export const computerOneInteraction = (player, k) => { | ||
interactionHandler(player, 'computer_1', k, async () => { | ||
displayDialogue({ | ||
k, | ||
player, | ||
text: [ | ||
'You currently see nothing that you understand what so ever on this computer', | ||
'It looks like so techy that you question your life choices', | ||
], | ||
}); | ||
}); | ||
}; |
16 changes: 16 additions & 0 deletions
16
src/interactions/map_realtor/computerTwoInteraction.interactions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { interactionHandler } from '../handler.interactions'; | ||
import { displayDialogue } from '../../utils'; | ||
|
||
export const computerTwoInteraction = (player, k) => { | ||
interactionHandler(player, 'computer_2', k, async () => { | ||
displayDialogue({ | ||
k, | ||
player, | ||
text: [ | ||
'You see "Hello, world!" printed on the screen in C++', | ||
"You think to yourself, wasn't the other screen way more complex?", | ||
"What's going on here?", | ||
], | ||
}); | ||
}); | ||
}; |
135 changes: 135 additions & 0 deletions
135
src/interactions/map_realtor/counterClerkInteraction.interactions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import { interactionHandler } from '../handler.interactions'; | ||
import { displayDialogue, displayPermissionBox } from '../../utils'; | ||
import { | ||
completeQuest, | ||
completeQuestObjective, | ||
recieveQuest, | ||
} from '../../utils/questHandler'; | ||
import { map_realtor } from '../quests/constants.quests'; | ||
|
||
export const counterClerkInteraction = (player, k) => { | ||
interactionHandler(player, 'counter_clerk', k, async () => { | ||
await displayDialogue({ | ||
k, | ||
player, | ||
characterName: 'Realtor Clerk', | ||
text: [ | ||
'Hello, we are a firm that gives out houses to residents attending Zero To Mastery.', | ||
'Would you like to purchase a house?', | ||
], | ||
}); | ||
recieveQuest(player, map_realtor['Buy a house!']); | ||
completeQuestObjective( | ||
player, | ||
'Buy a house!', | ||
'hasTalkedToRealtorClerk' | ||
); | ||
const answer = await displayPermissionBox({ k, player, text: [''] }); | ||
if (answer) { | ||
showCustomPrompt( | ||
'Which house would you like to buy?', | ||
['Orange House', 'Red House', "Neither, I've changed my mind"], | ||
(selectedOption) => { | ||
if (!selectedOption.split(' ').includes('House')) { | ||
displayDialogue({ | ||
k, | ||
player, | ||
characterName: 'Realtor Clerk', | ||
text: [ | ||
"Okay, well let me know if you change your mind and we'll see if we can set you up!", | ||
], | ||
}); | ||
return; | ||
} | ||
if (player.state.coinsCollected >= 100) { | ||
displayDialogue({ | ||
k, | ||
player, | ||
characterName: 'Realtor Clerk', | ||
text: [ | ||
'Congratulations!', | ||
`You now own the ${selectedOption}!`, | ||
], | ||
onDisplayEnd: () => { | ||
completeQuestObjective( | ||
player, | ||
'Buy a house!', | ||
'hasBoughtHouse' | ||
); | ||
completeQuest(player, 'Buy a house!'); | ||
}, | ||
}); | ||
} else { | ||
displayDialogue({ | ||
k, | ||
player, | ||
characterName: 'Realtor Clerk', | ||
text: [ | ||
"Oooooof, I'm sorry.", | ||
"It looks like you don't have enough coins for the house...", | ||
], | ||
}); | ||
} | ||
} | ||
); | ||
} else { | ||
await displayDialogue({ | ||
k, | ||
player, | ||
characterName: 'Realtor Clerk', | ||
text: [ | ||
"Okay, well let me know if you change your mind and we'll see if we can set you up!", | ||
], | ||
}); | ||
} | ||
}); | ||
}; | ||
|
||
function showCustomPrompt(message, options, callback) { | ||
// Set the prompt message | ||
document.getElementById('prompt-message').textContent = message; | ||
|
||
// Clear any existing options in the container | ||
const optionsContainer = document.getElementById('options-container'); | ||
optionsContainer.innerHTML = ''; | ||
|
||
// Create buttons for each option | ||
options.forEach((option) => { | ||
const button = document.createElement('button'); | ||
button.textContent = option; | ||
button.classList.add('option-btn'); | ||
button.setAttribute('tabindex', '0'); // Make the button focusable | ||
|
||
// Add click event for mouse interactions | ||
button.onclick = function () { | ||
callback(option); | ||
closeCustomPrompt(); | ||
}; | ||
|
||
// Add keyboard event listener for accessibility | ||
button.addEventListener('keydown', function (e) { | ||
if (e.key === 'Enter' || e.key === ' ') { | ||
// Enter or Space key | ||
e.preventDefault(); // Prevent the default behavior (e.g., form submission) | ||
callback(option); | ||
closeCustomPrompt(); | ||
} | ||
}); | ||
|
||
optionsContainer.appendChild(button); | ||
}); | ||
|
||
// Display the custom prompt | ||
document.getElementById('custom-prompt').style.display = 'flex'; | ||
|
||
// Set focus on the first button | ||
if (optionsContainer.children.length > 0) { | ||
optionsContainer.children[0].focus(); | ||
} | ||
} | ||
|
||
// Function to close the custom prompt | ||
function closeCustomPrompt() { | ||
// Hide the custom prompt | ||
document.getElementById('custom-prompt').style.display = 'none'; | ||
} |
5 changes: 5 additions & 0 deletions
5
src/interactions/map_realtor/enterMapExtendedCampus.interactions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const enterMapExtendedCampus = (player, k) => { | ||
player.onCollide('enter_map_extended_campus', () => { | ||
k.go('extended_campus', 'spawn_realtor_office'); | ||
}); | ||
}; |
14 changes: 14 additions & 0 deletions
14
src/interactions/map_realtor/fridgeInteraction.interactions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { interactionHandler } from '../handler.interactions'; | ||
import { displayDialogue } from '../../utils'; | ||
|
||
export const fridgeInteraction = (player, k) => { | ||
interactionHandler(player, 'fridge', k, async () => { | ||
displayDialogue({ | ||
k, | ||
player, | ||
text: [ | ||
'No, you cannot go looking for food here, this is for employees only...', | ||
], | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { behindDeskClerkInteraction } from './behindDeskClerkInteraction.interactions'; | ||
import { boxesInteraction } from './boxesInteraction.interactions'; | ||
import { computerOneInteraction } from './computerOneInteraction.interactions'; | ||
import { computerTwoInteraction } from './computerTwoInteraction.interactions'; | ||
import { fridgeInteraction } from './fridgeInteraction.interactions'; | ||
import { counterClerkInteraction } from './counterClerkInteraction.interactions'; | ||
import { enterMapExtendedCampus } from './enterMapExtendedCampus.interactions'; | ||
|
||
const interactions = [ | ||
enterMapExtendedCampus, | ||
behindDeskClerkInteraction, | ||
boxesInteraction, | ||
computerOneInteraction, | ||
computerTwoInteraction, | ||
counterClerkInteraction, | ||
fridgeInteraction, | ||
]; | ||
|
||
export default interactions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import gameObjects from '../gameObjects/map_realtor'; | ||
import { initMap } from '../init/map.init'; | ||
import interactions from '../interactions/map_realtor'; | ||
|
||
export async function realtor() { | ||
const objectConfig = { | ||
static: [ | ||
'map_boundaries', | ||
'building_boundaries', | ||
'enter_new_map_boundaries', | ||
], | ||
spawnpoints: ['spawnpoints'], | ||
interactionObjects: ['interaction_objects'], | ||
}; | ||
const [map, spawnpoint] = await initMap( | ||
objectConfig, | ||
'./exports/maps/map_realtor.png', | ||
'./maps/map_realtor.json' | ||
); | ||
|
||
return [map, spawnpoint, gameObjects, interactions]; | ||
} |