Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add every igloo #23

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
444 changes: 444 additions & 0 deletions src/data/igloos.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/engine/loaders/GridViewLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class GridViewLoader extends BaseLoader {

let item = page[index]

if (item) {
if (item || item === 0) {
slot.setInteractive()
slot.visible = true
this.loadItem(item, scale)
Expand Down
11 changes: 7 additions & 4 deletions src/engine/world/room/RoomFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ export default class RoomFactory {

createIgloo(args) {
let config = this.igloos[args.type]
let key = `${config.key}-igloo`
if (!config) return console.error(`Igloo type ${args.type} not found`)


if (config.key in this.scene.manager.keys) {
this.scene.start(config.key, { args: args })
if (key in this.scene.manager.keys) {
this.scene.start(key, { args: args })

return this.scene.get(config.key)
return this.scene.get(key)

} else {
return this.scene.add(config.key, config.scene, true, { args: args })
return this.scene.add(key, config.scene, true, { args: args })
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/scenes/components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ export default class Button extends SimpleButton {

onOver() {
if (!this.lockFrame) {
this.gameObject.setFrame(`${this.spriteName}-hover`)
this.gameObject.setFrame(`${this.spriteName}-hover`, false, false)
}

super.onOver()
}

onOut() {
if (!this.lockFrame) {
this.gameObject.setFrame(this.spriteName)
this.gameObject.setFrame(this.spriteName, false, false)
}

super.onOut()
Expand All @@ -72,9 +72,9 @@ export default class Button extends SimpleButton {
}

if (this.activeFrame) {
this.gameObject.setFrame(`${this.spriteName}-active`)
this.gameObject.setFrame(`${this.spriteName}-active`, false, false)
} else {
this.gameObject.setFrame(`${this.spriteName}-hover`)
this.gameObject.setFrame(`${this.spriteName}-hover`, false, false)
}
}

Expand All @@ -84,9 +84,9 @@ export default class Button extends SimpleButton {
}

if (this.activeFrame) {
this.gameObject.setFrame(this.spriteName)
this.gameObject.setFrame(this.spriteName, false, false)
} else {
this.gameObject.setFrame(`${this.spriteName}-hover`)
this.gameObject.setFrame(`${this.spriteName}-hover`, false, false)
}

super.onUp(pointer)
Expand Down
11 changes: 9 additions & 2 deletions src/scenes/igloos/IglooScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import WallCrate from './crates/WallCrate'
export default class IglooScene extends RoomScene {

constructor(key) {
super(key)
super(`${key}-igloo`)

this.isIgloo = true
this.editBg
Expand Down Expand Up @@ -88,7 +88,7 @@ export default class IglooScene extends RoomScene {
}

super.create()
this.floor.depth = -2
if (this.floor) this.floor.depth = -2

if (this.args.flooring) this.addFlooring(this.args.flooring)
this.addLocation()
Expand Down Expand Up @@ -276,6 +276,13 @@ export default class IglooScene extends RoomScene {

/*========== Physics ==========*/

get roomPhysics() {
let key = this.key.toLowerCase()
let baseKey = this.crumbs.scenes.igloos[this.id].key.toLowerCase()

return this.cache.json.get(`${key}-physics`) || this.cache.json.get(`${baseKey}-physics`)
}

addPhysics() {
super.addPhysics()

Expand Down
60 changes: 60 additions & 0 deletions src/scenes/igloos/backyard/Backyard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import IglooScene from '../IglooScene'
import {Button, MoveTo} from '@components/components'

/* START OF COMPILED CODE */

export default class Backyard extends IglooScene {

constructor() {
super("Backyard");

/** @type {Phaser.GameObjects.Image} */
this.floor;


/* START-USER-CTR-CODE */

this.roomTriggers = {
map: () => this.interface.main.onMapClick()
}

this.floorSpawn = [1080, 490]
this.wallSpawn = [970, 200]
this.wallBounds = [410, 1110]
this.floorFrame = 3

/* END-USER-CTR-CODE */
}

/** @returns {void} */
_preload() {

this.load.pack("backyard-igloo-pack", "assets/media/igloos/buildings/sprites/backyard/backyard-igloo-pack.json");
}

/** @returns {void} */
_create() {

// floor
const floor = this.add.image(760, 480, "backyard-igloo", "bg");

// door
const door = this.add.image(677.7786964525617, 314.9572825204803, "backyard-igloo", "door");
door.setOrigin(0.39645371736436524, 0.8507561659638476);

// door (components)
const doorButton = new Button(door);
doorButton.spriteName = "door";;
new MoveTo(door);

this.floor = floor;

this.events.emit("scene-awake");
}


/* START-USER-CODE */
/* END-USER-CODE */
}

/* END OF COMPILED CODE */
57 changes: 57 additions & 0 deletions src/scenes/igloos/backyard/Backyard.scene
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"id": "bc81fc61-6d61-4fbf-801c-3fee7407dc8e",
"sceneType": "SCENE",
"settings": {
"compilerInsertSpaces": true,
"javaScriptInitFieldsInConstructor": true,
"exportClass": true,
"superClassName": "IglooScene",
"preloadMethodName": "_preload",
"preloadPackFiles": [
"yukon/assets/media/igloos/buildings/sprites/backyard/backyard-igloo-pack.json"
],
"createMethodName": "_create",
"sceneKey": "Backyard",
"borderWidth": 1520,
"borderHeight": 960
},
"displayList": [
{
"type": "Image",
"id": "e416b6bc-de6c-45ae-a0bb-b817b975c338",
"label": "floor",
"scope": "CLASS",
"texture": {
"key": "backyard-igloo",
"frame": "bg"
},
"x": 760,
"y": 480
},
{
"type": "Image",
"id": "4b7ede61-736d-4872-8519-1f177d2fbe45",
"label": "door",
"components": [
"Button",
"MoveTo"
],
"Button.spriteName": "door",
"texture": {
"key": "backyard-igloo",
"frame": "door"
},
"x": 677.7786964525617,
"y": 314.9572825204803,
"originX": 0.39645371736436524,
"originY": 0.8507561659638476
}
],
"plainObjects": [],
"meta": {
"app": "Phaser Editor 2D - Scene Editor",
"url": "https://phasereditor2d.com",
"contentType": "phasereditor2d.core.scene.SceneContentType",
"version": 4
}
}
15 changes: 13 additions & 2 deletions src/scenes/igloos/bamboohut/BambooHut.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import IglooScene from '../IglooScene'
import {Button, MoveTo} from '@components/components'


/* START OF COMPILED CODE */
Expand All @@ -14,6 +15,10 @@ export default class BambooHut extends IglooScene {

/* START-USER-CTR-CODE */

this.roomTriggers = {
triggers: () => this.interface.main.onMapClick()
}

this.floorSpawn = [770, 750]
this.wallSpawn = [790, 400]
this.wallBounds = [520, 1050]
Expand All @@ -36,13 +41,19 @@ export default class BambooHut extends IglooScene {
floor.setOrigin(0.5004468275245755, 0.5017421602787456);

// door
const door = this.add.image(424, 474, "bamboohut", "door");
door.setOrigin(0.5054945054945055, 0.5);
const door = this.add.image(428, 591, "bamboohut", "door");
door.setOrigin(0.5494505494505495, 0.9301470588235294);

// wall
const wall = this.add.image(760, 402, "bamboohut", "wall");
wall.setOrigin(0.5004101722723544, 0.5);

// door (components)
new MoveTo(door);
const doorButton = new Button(door);
doorButton.spriteName = "door";
doorButton.activeFrame = false;

this.floor = floor;

this.events.emit("scene-awake");
Expand Down
18 changes: 11 additions & 7 deletions src/scenes/igloos/bamboohut/BambooHut.scene
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"id": "509aab3a-26ae-49bf-a03f-275324831814",
"label": "floor",
"scope": "CLASS",
"components": [],
"texture": {
"key": "bamboohut",
"frame": "floor"
Expand All @@ -35,20 +34,25 @@
"type": "Image",
"id": "06fe3266-0d8b-4b51-8183-45d6455d6abe",
"label": "door",
"components": [],
"components": [
"MoveTo",
"Button"
],
"Button.spriteName": "door",
"Button.activeFrame": false,
"texture": {
"key": "bamboohut",
"frame": "door"
},
"x": 424,
"y": 474,
"originX": 0.5054945054945055
"x": 428,
"y": 591,
"originX": 0.5494505494505495,
"originY": 0.9301470588235294
},
{
"type": "Image",
"id": "915b4812-cd1b-4d09-8484-152726e4ada3",
"label": "wall",
"components": [],
"texture": {
"key": "bamboohut",
"frame": "wall"
Expand All @@ -63,6 +67,6 @@
"app": "Phaser Editor 2D - Scene Editor",
"url": "https://phasereditor2d.com",
"contentType": "phasereditor2d.core.scene.SceneContentType",
"version": 3
"version": 5
}
}
14 changes: 13 additions & 1 deletion src/scenes/igloos/basic/Basic.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import IglooScene from '../IglooScene'
import {Button, MoveTo} from '@components/components'


/* START OF COMPILED CODE */
Expand All @@ -14,6 +15,10 @@ export default class Basic extends IglooScene {

/* START-USER-CTR-CODE */

this.roomTriggers = {
triggers: () => this.interface.main.onMapClick()
}

this.floorSpawn = [760, 760]
this.wallSpawn = [750, 320]
this.wallBounds = [580, 1000]
Expand Down Expand Up @@ -51,7 +56,14 @@ export default class Basic extends IglooScene {
window.setOrigin(0.5014164305949008, 0.5);

// door
this.add.image(491, 467, "basic", "door");
const door = this.add.image(499, 550, "basic", "door");
door.setOrigin(0.5727272727272728, 0.9029126213592233);

// door (components)
new MoveTo(door);
const doorButton = new Button(door);
doorButton.spriteName = "door";
doorButton.activeFrame = false;

this.floor = floor;

Expand Down
Loading