Skip to content

Commit

Permalink
Merge pull request #7 from wizguin/develop
Browse files Browse the repository at this point in the history
1.5.0-beta
  • Loading branch information
wizguin authored Nov 7, 2022
2 parents 848792f + b2569b9 commit 806017e
Show file tree
Hide file tree
Showing 39 changed files with 1,420 additions and 773 deletions.
943 changes: 451 additions & 492 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yukon",
"version": "1.4.0-beta",
"version": "1.5.0-beta",
"scripts": {
"dev": "webpack serve",
"editor": "phasereditor2d-launcher -project . -max-number-files 5000",
Expand All @@ -18,21 +18,21 @@
},
"homepage": "https://github.com/wizguin/yukon#readme",
"devDependencies": {
"@babel/core": "^7.18.13",
"@babel/preset-env": "^7.18.10",
"babel-loader": "^8.2.5",
"@babel/core": "^7.20.2",
"@babel/preset-env": "^7.20.2",
"babel-loader": "^8.3.0",
"compression-webpack-plugin": "^10.0.0",
"core-js": "^3.24.1",
"core-js": "^3.26.0",
"howler": "^2.2.3",
"html-webpack-plugin": "^5.5.0",
"javascript-obfuscator": "^4.0.0",
"phasereditor2d-launcher": "^3.34.0",
"phasereditor2d-launcher": "^3.35.1",
"phasereditor2d-ninepatch-plugin": "^1.2.0",
"socket.io-client": "^4.5.1",
"socket.io-client": "^4.5.3",
"source-map": "^0.7.4",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.10.0",
"webpack-dev-server": "^4.11.1",
"webpack-obfuscator": "^3.5.1"
}
}
3 changes: 3 additions & 0 deletions src/Game.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Boot from '@engine/boot/Boot'
import Network from '@engine/network/Network'
import registerNinePatchContainerFactory from '@engine/utils/ninepatch/registerNinePatchContainerFactory'
import SoundManager from '@engine/sound/SoundManager'

import game from './data/game'
Expand All @@ -19,6 +20,8 @@ export default class Game extends Phaser.Game {
// howler.js based sound manager
this.soundManager = new SoundManager(this)

registerNinePatchContainerFactory()

this.scene.add('Boot', Boot, true)
}

Expand Down
4 changes: 4 additions & 0 deletions src/engine/boot/Preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import Servers from '@scenes/interface/menus/servers/Servers'
import Main from '@scenes/interface/game/main/Main'
import IglooEdit from '@scenes/interface/game/iglooedit/IglooEdit'

import generateItemsToFrames from '@engine/world/penguin/frames/generateItemsToFrames'


export default class Preload extends BaseScene {

Expand Down Expand Up @@ -38,6 +40,8 @@ export default class Preload extends BaseScene {
...crumbs
}

this.game.crumbs.itemsToFrames = generateItemsToFrames(crumbs.secret_frames)

// Start
this.interface.hideLoading()

Expand Down
2 changes: 1 addition & 1 deletion src/engine/interface/InterfaceController.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BaseScene from '@scenes/base/BaseScene'

import Hint from '@engine/interface/hint/Hint'
import Hint from '@scenes/interface/game/hint/Hint'
import MetricsManager from './metrics/MetricsManager'
import PromptController from './prompt/PromptController'

Expand Down
2 changes: 1 addition & 1 deletion src/engine/interface/snowball/SnowballFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class SnowballFactory {
let penguin = this.world.room.penguins[id]
if (!penguin || penguin.isTweening) return

if (this.balls.length > 9) this.removeOldestBall()
if (this.balls.length > 10) this.removeOldestBall()

let ball = this.createBall(penguin)
x += Phaser.Math.Between(-20, 20)
Expand Down
22 changes: 20 additions & 2 deletions src/engine/loaders/BaseLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export default class BaseLoader extends Phaser.Loader.LoaderPlugin {

constructor(scene) {
super(scene)

this.globalLoadQueue = scene.world.globalLoadQueue
}

get crumbs() {
Expand Down Expand Up @@ -42,13 +44,29 @@ export default class BaseLoader extends Phaser.Loader.LoaderPlugin {

}

checkComplete(type, key, callback) {
checkComplete(type, key, callback = () => {}) {
if (this.textureExists(key)) {
callback()
return true
}

this.once(`filecomplete-${type}-${key}`, callback)
let event = `filecomplete-${type}-${key}`

if (key in this.globalLoadQueue) {
let loader = this.globalLoadQueue[key]
loader.once(event, callback)

return true
}

this.globalLoadQueue[key] = this

this.once(event, () => {
callback()
delete this.globalLoadQueue[key]
})

return false
}

textureExists(key) {
Expand Down
46 changes: 40 additions & 6 deletions src/engine/loaders/ClothingLoader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import BaseLoader from './BaseLoader'

import PenguinSpriteFactory from './PenguinSpriteFactory'
import SecretFramesLoader from './SecretFramesLoader'

import adjustRedemptionItem from '@engine/world/penguin/frames/adjustRedemptionItem'


export default class ClothingLoader extends BaseLoader {
Expand All @@ -14,6 +17,8 @@ export default class ClothingLoader extends BaseLoader {

this.baseURL = '/assets/media/clothing/sprites/'
this.keyPrefix = 'clothing/sprites/'

this.framesLoader = new SecretFramesLoader(penguin.room)
}

loadItems() {
Expand All @@ -40,39 +45,68 @@ export default class ClothingLoader extends BaseLoader {
let key = this.getKey(item)

if (this.checkComplete('json', key, () => {
this.onFileComplete(key, slot)
this.onFileComplete(item, key, slot)
})) {
return
}

this.multiatlas(key, `${item}.json`)
}

onFileComplete(key, slot) {
onFileComplete(item, key, slot) {
if (!this.textureExists(key)) {
return
}

let item = this.equipped[slot]
if (item.sprite) {
let check = adjustRedemptionItem(item)

// Checks secret frames
let secretFrames = this.crumbs.itemsToFrames[check]

if (secretFrames) {
return this.loadSecretFrames(secretFrames, slot, item)
}

this.addItem(slot, item)
}

loadSecretFrames(secretFrames, slot, item) {
this.framesLoader.loadFrames(secretFrames, () => {
this.addItem(slot, item)
})
}

addItem(slot, item) {
let equipped = this.equipped[slot]

if (item != equipped.id) {
return
}

let key = this.getKey(item)

if (equipped.sprite) {
this.removeItem(slot)
}

// item.depth + 1 to ensure items are loaded on top of penguin body
item.sprite = PenguinSpriteFactory.create(this.penguin, key, item.depth + 1)
// depth + 1 to ensure items are loaded on top of penguin body
equipped.sprite = PenguinSpriteFactory.create(this.penguin, key, equipped.depth + 1)

this.penguin.sort('depth')
this.penguin.playFrame(this.penguin.frame)
}

removeItem(slot) {
let item = this.equipped[slot]

if (!item || !item.sprite) {
return
}

item.sprite.destroy()
item.sprite = null

this.penguin.playFrame(this.penguin.frame)
}

}
4 changes: 2 additions & 2 deletions src/engine/loaders/InventoryLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export default class InventoryLoader extends BaseLoader {
this.page
this.validSlots = ['large-box', 'large-box-hover']

this.baseURL = '/assets/media/clothing/icon/'
this.keyPrefix = 'clothing/icon/'
this.baseURL = '/assets/media/clothing/icon/120/'
this.keyPrefix = 'clothing/icon/120/'

this.attachErrorListener()
}
Expand Down
29 changes: 15 additions & 14 deletions src/engine/loaders/ItemPromptLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,30 @@ export default class ItemPromptLoader extends BaseLoader {
super(scene)

this.prompt = prompt

this.config = {
clothing: {
baseURL: '/assets/media/clothing/icon/240/',
keyPrefix: 'clothing/icon/240/'
},
furniture: {
baseURL: '/assets/media/furniture/icon/@5x/',
keyPrefix: 'furniture/icon/@5x/',
scale: 0.65
}
}
}

get baseURL() {
return (this.prompt.type == 'furniture')
? '/assets/media/furniture/icon/@5x/'
: '/assets/media/clothing/icon/large/'
return this.config[this.prompt.type].baseURL
}

get keyPrefix() {
return (this.prompt.type == 'furniture')
? 'furniture/icon/@5x/'
: 'clothing/icon/large/'
return this.config[this.prompt.type].keyPrefix
}

get scale() {
switch (this.prompt.type) {
case 'clothing':
return 0.75
case 'furniture':
return 0.65
default:
return 1
}
return this.config[this.prompt.type].scale || 1
}

loadIcon(item) {
Expand Down
Loading

0 comments on commit 806017e

Please sign in to comment.