Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
izure committed Feb 14, 2021
1 parent 387e649 commit b63a891
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 30 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@eriengine/plugin-dialogue": "^1.0.2",
"@eriengine/plugin-fog-of-war": "^1.0.2",
"@eriengine/plugin-isometric-cursor": "^1.1.3",
"@eriengine/plugin-isometric-scene": "^1.1.0",
"@eriengine/plugin-isometric-scene": "^1.1.1",
"add-filename-increment": "^1.0.0",
"an-array-of-english-words": "2.0.0",
"command-exists": "^1.2.9",
Expand Down
46 changes: 36 additions & 10 deletions src/Renderer/components/Manager/Data/Scene/Map/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@
</p>
<v-text-field
v-model="propertyAlias"
type="number"
@keydown.stop
type="text"
filled
rounded
dense
Expand All @@ -175,6 +176,7 @@
</p>
<v-text-field
v-model="propertyScale"
@keydown.stop
:rules="[ propertyOnlyPositiveNumber ]"
type="number"
filled
Expand Down Expand Up @@ -609,23 +611,47 @@ export default class SceneMapEditor extends Vue {
return
}
let alias: string = ''
let scale: number = 1
let isSensor: boolean = false
let alias: string
let scale: number
let isSensor: boolean
const size: number = this.scene.selectionWalls.size
if (size === 0) {
this.$store.dispatch('snackbar', '먼저 대상을 선택해주세요')
return
}
else if (size === 1) {
const target = [ ...this.scene.selectionWalls ][0]
alias = ''
scale = target.scale
isSensor = target.isSensor()
else {
const std = [ ...this.scene.selectionWalls ][0]
let isOverlap: boolean = true
for (const wall of this.scene.selectionWalls) {
if (wall.data.get('alias') !== std.data.get('alias')) {
isOverlap = false
break
}
if (wall.scale !== std.scale) {
isOverlap = false
break
}
if (wall.isSensor() !== std.isSensor()) {
isOverlap = false
break
}
}
console.log(target)
// 선택된 모든 오브젝트의 속성이 완벽히 겹칠 경우
if (isOverlap) {
alias = std.data.get('alias') || ''
scale = std.scale
isSensor = std.isSensor()
}
// 하나의 오브젝트의 속성이라도 일치하지 않을 경우 기본값 보여주기
else {
alias = ''
scale = 1
isSensor = false
}
}
this.propertyAlias = alias
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default class PreviewScene extends Phaser.Scene {
}
}

return this.getIsometricSideFromWidth(width)
return this.getIsometricSideFromWidth(width / 2)
}

private setCameraMoving(): void {
Expand All @@ -123,12 +123,12 @@ export default class PreviewScene extends Phaser.Scene {

this.cameraControl = new Phaser.Cameras.Controls.SmoothedKeyControl({
camera,
left: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.A),
right: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.D),
up: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.W),
down: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.S),
zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q),
zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E),
left: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.A, false),
right: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.D, false),
up: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.W, false),
down: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.S, false),
zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q, false),
zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E, false),
acceleration,
drag,
maxSpeed
Expand Down Expand Up @@ -166,11 +166,9 @@ export default class PreviewScene extends Phaser.Scene {
return Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2))
}

private getIsometricSideFromWidth(size: number): number {
private getIsometricSideFromWidth(width: number): number {
const rad: number = Phaser.Math.DegToRad(26.57)
const w: number = size / 2
const h: number = w / 4
return this.getDiagonal(w, h)
return width / Math.cos(rad)
}

private unselectObjects(): void {
Expand Down Expand Up @@ -248,6 +246,7 @@ export default class PreviewScene extends Phaser.Scene {

wall.setScale(scale)
wall.setSensor(isSensor)
wall.data.set('alias', alias)

this.mapData.modifyWallData(wall)
}
Expand Down Expand Up @@ -323,13 +322,14 @@ export default class PreviewScene extends Phaser.Scene {
break

case 2: {
const wall = this.isometric.setWalltile(x, y, this.cursorSide, this.disposeBrush!.key, undefined, animsKey)
const wall = this.isometric.setWalltile(x, y, this.disposeBrush!.key, undefined, animsKey)
wall.setDataEnabled()
this.mapData.insertWallData(wall)
break
}

case 3: {
const floor = this.isometric.setFloortile(x, y, this.cursorSide, this.disposeBrush!.key, undefined, animsKey)
const floor = this.isometric.setFloortile(x, y, this.disposeBrush!.key, undefined, animsKey)
this.mapData.insertFloorData(floor)
break
}
Expand Down Expand Up @@ -493,8 +493,6 @@ export default class PreviewScene extends Phaser.Scene {
return
}

console.log(this)

// 맵 파일 감지 시작
this.generateWatcher()
this.generateAnimation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class SceneMapManager implements Engine.GameProject.SceneMap {

private createWallData(object: Phaser.Physics.Matter.Sprite): Engine.GameProject.SceneMapWall {
const { x, y, scale } = object
const alias: string = '' // TODO
const alias: string = object.data.get('alias') || ''
const isSensor: boolean = object.isSensor()

return { key: object.texture.key, alias, x, y, scale, isSensor }
Expand Down

0 comments on commit b63a891

Please sign in to comment.