1
0
Fork 0
spacetac/src/ui/Preload.ts

122 lines
5.3 KiB
TypeScript
Raw Normal View History

2015-04-07 00:00:00 +00:00
/// <reference path="BaseView.ts"/>
2017-02-09 00:00:35 +00:00
module TS.SpaceTac.UI {
2015-04-07 00:00:00 +00:00
export class Preload extends BaseView {
2017-01-22 17:00:59 +00:00
private preloadBar: Phaser.Image;
2014-12-29 00:00:00 +00:00
preload() {
// Add preload sprite
2017-01-22 17:00:59 +00:00
let bg = this.add.image(678, 426, "preload-background");
this.preloadBar = this.add.image(684, bg.y + 166, "preload-bar");
this.load.setPreloadSprite(this.preloadBar);
2015-02-16 00:00:00 +00:00
// Load images
2017-06-01 22:37:43 +00:00
this.loadSheet("common/particles.png", 32);
2017-05-03 18:12:13 +00:00
this.loadImage("common/transparent.png");
this.loadImage("common/debug.png");
2017-09-10 21:43:27 +00:00
this.loadAnimation("common/waiting.png", 128, 128, 6);
this.loadImage("common/arrow.png");
this.loadImage("common/button-ok.png");
this.loadImage("common/button-cancel.png");
2017-07-06 22:55:29 +00:00
this.loadImage("common/dialog.png");
this.loadSheet("common/dialog-textbutton.png", 316, 59);
2017-06-08 17:32:57 +00:00
this.loadSheet("common/dialog-close.png", 92, 82);
this.loadImage("menu/title.png");
this.loadImage("menu/button.png");
this.loadImage("menu/button-hover.png");
this.loadImage("menu/load-bg.png");
this.loadImage("options/background.png");
this.loadSheet("options/button.png", 497, 134);
this.loadSheet("options/options.png", 128, 128);
this.loadSheet("options/toggle.png", 149, 149);
2017-07-20 23:09:17 +00:00
this.loadSheet("battle/splash/base.png", 853, 210);
this.loadSheet("battle/splash/shipcard.png", 99, 114);
this.loadImage("battle/background.jpg");
2017-06-08 17:32:57 +00:00
this.loadImage("battle/actionbar/background.png");
this.loadSheet("battle/actionbar/button-menu.png", 79, 132);
2017-05-15 18:30:44 +00:00
this.loadImage("battle/arena/background.png");
this.loadImage("battle/arena/blast.png");
2017-06-08 17:32:57 +00:00
this.loadImage("battle/shiplist/background.png");
this.loadImage("battle/shiplist/item-background.png");
this.loadImage("battle/shiplist/damage.png");
this.loadImage("battle/shiplist/hover.png");
this.loadImage("battle/shiplist/info-button.png");
2017-01-26 00:01:31 +00:00
this.loadImage("map/starsystem-background.png");
this.loadImage("map/name.png");
2017-06-05 22:05:34 +00:00
this.loadImage("map/subname.png");
this.loadSheet("map/action.png", 323, 192);
2017-06-05 17:53:27 +00:00
this.loadImage("map/orbit.png");
this.loadImage("map/boundaries.png");
2017-06-08 17:32:57 +00:00
this.loadSheet("map/buttons.png", 115, 191);
2017-07-06 22:55:29 +00:00
this.loadSheet("map/mission-action.png", 192, 56);
2017-02-27 23:36:12 +00:00
this.loadImage("character/sheet.png");
this.loadImage("character/close.png");
this.loadImage("character/ship.png");
this.loadImage("character/ship-selected.png");
2017-03-17 00:07:00 +00:00
this.loadImage("character/skill-upgrade.png");
2017-02-27 23:36:12 +00:00
this.loadImage("character/cargo-slot.png");
this.loadImage("character/equipment-slot.png");
this.loadSheet("character/slots.png", 52);
this.loadImage("character/upgrade-available.png");
2017-03-23 18:58:09 +00:00
this.loadImage("character/price-tag.png");
2017-05-09 17:19:26 +00:00
this.loadImage("character/experience.png");
2015-02-16 00:00:00 +00:00
2017-07-26 22:54:56 +00:00
// Load image atlases
// TODO automatic range
range(3).forEach(i => this.loadAtlas(i + 1));
2015-02-16 00:00:00 +00:00
// Load sounds
2017-07-19 23:22:18 +00:00
this.loadSound("ui/button-down.wav");
this.loadSound("ui/button-up.wav");
this.loadSound("ui/button-click.wav");
this.loadSound("ui/dialog-open.wav");
this.loadSound("ui/dialog-close.wav");
this.loadSound("ui/drag.wav");
this.loadSound("ui/drop.wav");
2015-02-16 00:00:00 +00:00
this.loadSound("battle/ship-change.wav");
2015-02-20 00:00:00 +00:00
this.loadSound("battle/weapon-bullets.wav");
2017-05-17 16:21:14 +00:00
this.loadSound("battle/weapon-missile-launch.wav");
this.loadSound("battle/weapon-missile-explosion.wav");
this.loadSound("battle/drone-deploy.wav");
this.loadSound("battle/drone-destroy.wav");
this.loadSound("battle/drone-activate.wav");
// Load musics
2017-06-01 22:37:43 +00:00
this.loadSound("music/division.mp3");
this.loadSound("music/mechanolith.mp3");
this.loadSound("music/spring-thaw.mp3");
this.loadSound("music/supernatural.mp3");
2017-01-22 17:00:59 +00:00
this.load.start();
2014-12-29 00:00:00 +00:00
}
create() {
this.game.state.start("mainmenu");
2014-12-29 00:00:00 +00:00
}
2015-02-04 00:00:00 +00:00
2017-06-01 22:37:43 +00:00
static getKey(path: string): string {
return path.replace(/\//g, "-").replace(/\.[a-z0-9]+$/, '');
}
2017-07-26 22:54:56 +00:00
loadAtlas(index: number) {
this.load.atlasJSONHash(`atlas-${index}`, `assets/atlas-${index}.png`, `assets/atlas-${index}.json`);
}
2017-06-01 22:37:43 +00:00
loadSheet(path: string, frame_width: number, frame_height = frame_width) {
this.load.spritesheet(Preload.getKey(path), "assets/images/" + path, frame_width, frame_height);
}
2017-09-10 21:43:27 +00:00
loadAnimation(path: string, frame_width: number, frame_height = frame_width, count?: number) {
this.load.spritesheet(Preload.getKey(path), "assets/images/" + path, frame_width, frame_height, count);
}
2017-02-10 00:08:28 +00:00
loadImage(path: string) {
2017-06-01 22:37:43 +00:00
this.load.image(Preload.getKey(path), "assets/images/" + path);
2015-02-04 00:00:00 +00:00
}
2015-02-16 00:00:00 +00:00
2017-02-10 00:08:28 +00:00
loadSound(path: string) {
2017-06-01 22:37:43 +00:00
this.load.audio(Preload.getKey(path), "assets/sounds/" + path);
2015-02-16 00:00:00 +00:00
}
2014-12-29 00:00:00 +00:00
}
}