-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(decorations): add tree decoration
- Loading branch information
1 parent
149436d
commit 5cbc2ed
Showing
15 changed files
with
233 additions
and
30 deletions.
There are no files selected for viewing
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,25 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_327047008") | ||
|
||
// add field | ||
collection.fields.addAt(5, new Field({ | ||
"hidden": false, | ||
"id": "json1404804573", | ||
"maxSize": 0, | ||
"name": "decorations", | ||
"presentable": false, | ||
"required": false, | ||
"system": false, | ||
"type": "json" | ||
})) | ||
|
||
return app.save(collection) | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_327047008") | ||
|
||
// remove field | ||
collection.fields.removeById("json1404804573") | ||
|
||
return app.save(collection) | ||
}) |
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,81 @@ | ||
import { | ||
Actor, | ||
type Engine, | ||
type Vector, | ||
vec, | ||
GraphicsGroup, | ||
CircleCollider, | ||
ColliderComponent, | ||
CollisionType, | ||
Sprite, | ||
Color | ||
} from 'excalibur'; | ||
import { ScreenManager } from '../utils/screen-manager'; | ||
import { Resources } from '../resources'; | ||
import { Config } from '../config'; | ||
|
||
export class Decoration extends Actor { | ||
constructor(position: Vector, type: 'tree', sizeRatio: number) { | ||
const treeSize = (sizeRatio / 100) * Config.DECORATION_TREE_SIZE; | ||
const shadowSize = (sizeRatio / 100) * Resources.TreeShadow.width; | ||
super({ | ||
anchor: vec(0, 0), | ||
pos: position, | ||
height: treeSize, | ||
width: treeSize, | ||
collisionType: CollisionType.Active, | ||
z: treeSize, | ||
color: Color.Pink | ||
}); | ||
|
||
this.collider = new ColliderComponent(new CircleCollider({ radius: treeSize })); | ||
|
||
/* | ||
const graphicsGroup = new GraphicsGroup({ | ||
members: [ | ||
{ | ||
graphic: new Sprite({ | ||
image: Resources.TreeShadow, | ||
destSize: { | ||
width: shadowSize, | ||
height: shadowSize | ||
} | ||
}), | ||
useBounds: false, | ||
offset: vec(0, - (shadowSize - treeSize)) | ||
}, | ||
{ | ||
graphic: new Sprite({ | ||
image: Resources.Tree, | ||
destSize: { | ||
width: treeSize, | ||
height: treeSize | ||
} | ||
}), | ||
offset: vec(0, 0) | ||
} | ||
] | ||
}); | ||
this.graphics.use(graphicsGroup); | ||
*/ | ||
|
||
this.listenExitViewportEvent(); | ||
} | ||
|
||
override update(): void { | ||
if (ScreenManager.isNearScreen(this, this.scene!.camera) && !this.children?.length) { | ||
// this.buildSpectators(); | ||
} | ||
} | ||
|
||
private listenExitViewportEvent(): void { | ||
this.on('exitviewport', () => this.checkForKill()); | ||
} | ||
|
||
private checkForKill(): void { | ||
if (ScreenManager.isBehind(this.scene!.camera.pos, this.pos)) { | ||
this.kill(); | ||
} | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,13 @@ | ||
export class StockableDecoration { | ||
public x: number; | ||
public y: number; | ||
public type: 'tree'; | ||
public sizeRatio: number; | ||
|
||
constructor(x: number, y: number, type: 'tree', sizeRatio: number) { | ||
this.x = x; | ||
this.y = y; | ||
this.type = type; | ||
this.sizeRatio = sizeRatio; | ||
} | ||
} |
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
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
Oops, something went wrong.