add prettier config and fix files
This commit is contained in:
parent
698967c987
commit
1d2473dae8
6
.prettierrc
Normal file
6
.prettierrc
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"trailingComma": "es5",
|
||||
"tabWidth": 4,
|
||||
"semi": true,
|
||||
"singleQuote": true
|
||||
}
|
@ -1,19 +1,19 @@
|
||||
import * as PIXI from "pixi.js";
|
||||
import { MissionDefinition } from "./Definitions";
|
||||
import * as PIXI from 'pixi.js';
|
||||
import { MissionDefinition } from './Definitions';
|
||||
|
||||
export default class Assets {
|
||||
public static async LoadAssets() {
|
||||
console.log("Loading Texture Assets");
|
||||
console.log('Loading Texture Assets');
|
||||
Assets.ButtonTexture = await PIXI.Assets.load({
|
||||
src: "/assets/gui/button_02.png",
|
||||
src: '/assets/gui/button_02.png',
|
||||
});
|
||||
console.log("Loading Missions");
|
||||
console.log('Loading Missions');
|
||||
await this.LoadMissions();
|
||||
}
|
||||
|
||||
private static async LoadMissions() {
|
||||
Assets.Missions = [
|
||||
await this.LoadMission("/assets/missions/mission_01.json"),
|
||||
await this.LoadMission('/assets/missions/mission_01.json'),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import GameObject from "./GameObject";
|
||||
import Assets from "./Assets";
|
||||
import * as PIXI from "pixi.js";
|
||||
import GameObject from './GameObject';
|
||||
import Assets from './Assets';
|
||||
import * as PIXI from 'pixi.js';
|
||||
|
||||
export default class Button extends GameObject {
|
||||
private caption: string;
|
||||
@ -63,9 +63,9 @@ export default class Button extends GameObject {
|
||||
text.y = this.bounds.height / 2;
|
||||
this.container.x = this.bounds.x;
|
||||
this.container.y = this.bounds.y;
|
||||
this.container.on("click", () => {
|
||||
this.container.on('click', () => {
|
||||
if (!this.enabled) return;
|
||||
this.events.emit("click");
|
||||
this.events.emit('click');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import MainMenu from "../scenes/MainMenu";
|
||||
import MissionMenuSelect from "../scenes/MissionSelectMenu";
|
||||
import GameScene from "../scenes/GameScene";
|
||||
import GameObject from "./GameObject";
|
||||
import * as PIXI from "pixi.js";
|
||||
import SceneBase from "../scenes/SceneBase";
|
||||
import MainMenu from '../scenes/MainMenu';
|
||||
import MissionMenuSelect from '../scenes/MissionSelectMenu';
|
||||
import GameScene from '../scenes/GameScene';
|
||||
import GameObject from './GameObject';
|
||||
import * as PIXI from 'pixi.js';
|
||||
import SceneBase from '../scenes/SceneBase';
|
||||
|
||||
export default class Game extends GameObject {
|
||||
private _currentScene: SceneBase | null = null;
|
||||
@ -15,8 +15,8 @@ export default class Game extends GameObject {
|
||||
|
||||
private onMainMenu() {
|
||||
const mainScene = new MainMenu(this.bounds);
|
||||
mainScene.events.on("newGame", this.onNewGame);
|
||||
mainScene.events.on("settings", this.onSettings);
|
||||
mainScene.events.on('newGame', this.onNewGame);
|
||||
mainScene.events.on('settings', this.onSettings);
|
||||
this.setScene(mainScene);
|
||||
}
|
||||
|
||||
@ -26,30 +26,35 @@ export default class Game extends GameObject {
|
||||
this._currentScene.destroy();
|
||||
}
|
||||
this._currentScene = scene;
|
||||
console.log("Setting scene", this._currentScene.constructor);
|
||||
console.log('Setting scene', this._currentScene.constructor);
|
||||
this.container.addChild(scene.container);
|
||||
}
|
||||
|
||||
private onNewGame = () => {
|
||||
console.log("New Game");
|
||||
console.log('New Game');
|
||||
const missionSelectScene = new MissionMenuSelect(this.bounds);
|
||||
missionSelectScene.events.on("mission", (mission) => {
|
||||
console.log("Mission selected", mission);
|
||||
missionSelectScene.events.on('mission', (mission) => {
|
||||
console.log('Mission selected', mission);
|
||||
this.setScene(new GameScene(mission, this.bounds));
|
||||
});
|
||||
missionSelectScene.events.on("back", () => {
|
||||
missionSelectScene.events.on('back', () => {
|
||||
this.onMainMenu();
|
||||
});
|
||||
this.setScene(missionSelectScene);
|
||||
};
|
||||
|
||||
private onSettings = () => {
|
||||
console.log("Settings");
|
||||
console.log('Settings');
|
||||
};
|
||||
|
||||
protected triggerBoundsChanged(): void {
|
||||
if (this._currentScene) {
|
||||
this._currentScene.setBounds(0, 0, this.bounds.width, this.bounds.height);
|
||||
this._currentScene.setBounds(
|
||||
0,
|
||||
0,
|
||||
this.bounds.width,
|
||||
this.bounds.height
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as PIXI from "pixi.js";
|
||||
import * as PIXI from 'pixi.js';
|
||||
export default abstract class GameObject {
|
||||
protected _container: PIXI.Container;
|
||||
|
||||
|
15
src/components/Creep.ts
Normal file
15
src/components/Creep.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import GameObject from '../base/GameObject';
|
||||
import * as PIXI from 'pixi.js';
|
||||
|
||||
export class Creep extends GameObject {
|
||||
constructor(bounds?: PIXI.Rectangle) {
|
||||
super(bounds);
|
||||
}
|
||||
|
||||
protected draw() {
|
||||
this.container.removeChildren();
|
||||
|
||||
this.container.x = this.bounds.x;
|
||||
this.container.y = this.bounds.y;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import * as PIXI from "pixi.js";
|
||||
import GameObject from "../base/GameObject";
|
||||
import { GameMapDefinition, TerrainType } from "../base/Definitions";
|
||||
import * as PIXI from 'pixi.js';
|
||||
import GameObject from '../base/GameObject';
|
||||
import { GameMapDefinition, TerrainType } from '../base/Definitions';
|
||||
|
||||
export class Cell extends GameObject {
|
||||
public type: TerrainType;
|
||||
@ -65,7 +65,7 @@ export class Grid extends GameObject {
|
||||
}
|
||||
|
||||
protected draw() {
|
||||
console.log("Drawing Grid", this.bounds);
|
||||
console.log('Drawing Grid', this.bounds);
|
||||
this.container.removeChildren();
|
||||
let g = new PIXI.Graphics();
|
||||
g.rect(0, 0, this.bounds.width, this.bounds.height);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import GameObject from "../base/GameObject";
|
||||
import * as PIXI from "pixi.js";
|
||||
import GameObject from '../base/GameObject';
|
||||
import * as PIXI from 'pixi.js';
|
||||
|
||||
export default class MissionStats extends GameObject {
|
||||
private hp: number = 100;
|
||||
@ -15,7 +15,11 @@ export default class MissionStats extends GameObject {
|
||||
this.draw();
|
||||
}
|
||||
|
||||
constructor(initialHP: number, initialGold: number, bounds?: PIXI.Rectangle) {
|
||||
constructor(
|
||||
initialHP: number,
|
||||
initialGold: number,
|
||||
bounds?: PIXI.Rectangle
|
||||
) {
|
||||
super(bounds);
|
||||
this.hp = initialHP;
|
||||
this.gold = initialGold;
|
||||
@ -31,7 +35,7 @@ export default class MissionStats extends GameObject {
|
||||
const text = new PIXI.Text({
|
||||
text: `HP: ${this.hp}\nGold: ${this.gold}`,
|
||||
style: new PIXI.TextStyle({
|
||||
fill: "white",
|
||||
fill: 'white',
|
||||
fontSize: 24,
|
||||
}),
|
||||
});
|
||||
|
@ -1,9 +1,9 @@
|
||||
import Button from "../base/Button";
|
||||
import { MissionDefinition } from "../base/Definitions";
|
||||
import { Grid } from "../components/Grid";
|
||||
import MissionStats from "../components/MissionStats";
|
||||
import SceneBase from "./SceneBase";
|
||||
import * as PIXI from "pixi.js";
|
||||
import Button from '../base/Button';
|
||||
import { MissionDefinition } from '../base/Definitions';
|
||||
import { Grid } from '../components/Grid';
|
||||
import MissionStats from '../components/MissionStats';
|
||||
import SceneBase from './SceneBase';
|
||||
import * as PIXI from 'pixi.js';
|
||||
|
||||
export default class GameScene extends SceneBase {
|
||||
private ticker: PIXI.Ticker;
|
||||
@ -47,7 +47,7 @@ export default class GameScene extends SceneBase {
|
||||
public update() {}
|
||||
|
||||
protected draw() {
|
||||
console.log("Drawing Game Scene ", this.bounds);
|
||||
console.log('Drawing Game Scene ', this.bounds);
|
||||
this.container.removeChildren();
|
||||
const g = new PIXI.Graphics();
|
||||
g.rect(0, 0, this.bounds.width, this.bounds.height);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Button from "../base/Button";
|
||||
import SceneBase from "./SceneBase";
|
||||
import * as PIXI from "pixi.js";
|
||||
import Button from '../base/Button';
|
||||
import SceneBase from './SceneBase';
|
||||
import * as PIXI from 'pixi.js';
|
||||
|
||||
export default class MainMenu extends SceneBase {
|
||||
private _newGameButton: Button;
|
||||
@ -8,19 +8,19 @@ export default class MainMenu extends SceneBase {
|
||||
|
||||
constructor(bounds?: PIXI.Rectangle) {
|
||||
super(bounds);
|
||||
this._newGameButton = new Button("New Game", new PIXI.Color("blue"));
|
||||
this._newGameButton.events.on("click", () => {
|
||||
this.events.emit("newGame");
|
||||
this._newGameButton = new Button('New Game', new PIXI.Color('blue'));
|
||||
this._newGameButton.events.on('click', () => {
|
||||
this.events.emit('newGame');
|
||||
});
|
||||
this._settingsButton = new Button("Settings", new PIXI.Color("gray"));
|
||||
this._settingsButton.events.on("click", () => {
|
||||
this.events.emit("settings");
|
||||
this._settingsButton = new Button('Settings', new PIXI.Color('gray'));
|
||||
this._settingsButton.events.on('click', () => {
|
||||
this.events.emit('settings');
|
||||
});
|
||||
this.draw();
|
||||
}
|
||||
|
||||
protected draw() {
|
||||
console.log("Creating main menu scene", this.bounds);
|
||||
console.log('Creating main menu scene', this.bounds);
|
||||
this.container.removeChildren();
|
||||
const g = new PIXI.Graphics();
|
||||
g.rect(0, 0, this.bounds.width, this.bounds.height);
|
||||
|
@ -1,8 +1,8 @@
|
||||
import Assets from "../base/Assets";
|
||||
import Button from "../base/Button";
|
||||
import { MissionDefinition } from "../base/Definitions";
|
||||
import SceneBase from "./SceneBase";
|
||||
import * as PIXI from "pixi.js";
|
||||
import Assets from '../base/Assets';
|
||||
import Button from '../base/Button';
|
||||
import { MissionDefinition } from '../base/Definitions';
|
||||
import SceneBase from './SceneBase';
|
||||
import * as PIXI from 'pixi.js';
|
||||
|
||||
export default class MissionMenuSelect extends SceneBase {
|
||||
private _buttons: Button[] = [];
|
||||
@ -12,8 +12,8 @@ export default class MissionMenuSelect extends SceneBase {
|
||||
for (const mission of Assets.Missions) {
|
||||
this.addMission(mission);
|
||||
}
|
||||
this.addButton("Back", () => {
|
||||
this.events.emit("back");
|
||||
this.addButton('Back', () => {
|
||||
this.events.emit('back');
|
||||
});
|
||||
this.draw();
|
||||
}
|
||||
@ -36,13 +36,13 @@ export default class MissionMenuSelect extends SceneBase {
|
||||
|
||||
private addMission(mission: MissionDefinition) {
|
||||
this.addButton(mission.name, () => {
|
||||
this.events.emit("mission", mission);
|
||||
this.events.emit('mission', mission);
|
||||
});
|
||||
}
|
||||
|
||||
private addButton(caption: string, onClick: () => void) {
|
||||
const button = new Button(caption, new PIXI.Color("white"));
|
||||
button.events.on("click", onClick);
|
||||
const button = new Button(caption, new PIXI.Color('white'));
|
||||
button.events.on('click', onClick);
|
||||
this._buttons.push(button);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as PIXI from "pixi.js";
|
||||
import GameObject from "../base/GameObject";
|
||||
import * as PIXI from 'pixi.js';
|
||||
import GameObject from '../base/GameObject';
|
||||
export default abstract class SceneBase extends GameObject {
|
||||
constructor(bounds: PIXI.Rectangle) {
|
||||
super(bounds);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Button from "../base/Button";
|
||||
import SceneBase from "./SceneBase";
|
||||
import * as PIXI from "pixi.js";
|
||||
import Button from '../base/Button';
|
||||
import SceneBase from './SceneBase';
|
||||
import * as PIXI from 'pixi.js';
|
||||
|
||||
export default class SettingsMenu extends SceneBase {
|
||||
constructor(bounds: PIXI.Rectangle) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user