File size: 1,507 Bytes
4ee4376
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import Phaser from 'phaser';
import city from './city/city';
import viewport from './world/viewport';
import events from './world/events';
import debug from './debug/debug';
import palette from './import/palette';
import artwork from './import/artwork';
import * as CONST from './constants';
import ui from './ui/gui';

export default class world extends Phaser.Scene {
  constructor () {
    super({ key: 'world' });
  }
  

  preload () {
    this.sys.game.world = this;

    // load binary game assets from original SC2K
    this.load.binary(CONST.PAL_MSTR_BMP, CONST.ASSETS_PATH + CONST.FILE_PAL_MSTR_BMP);
    this.load.binary(CONST.LARGE_DAT,    CONST.ASSETS_PATH + CONST.FILE_LARGE_DAT);

    // start import once files are loaded
    this.load.once(CONST.E_LOAD_COMPLETE, () => {
      this.palette = new palette({ scene: this });
      this.artwork = new artwork({ scene: this });
      this.tiles = this.artwork.tiles;

      // initialize city
      this.city = new city({ scene: this });
    });
  }
  

  create () {
    // load default city
    this.city.load.loadDefaultCity().then(() => {
      this.start();
    });

    //this.ui = new ui({ scene: this });
    this.viewport = new viewport({ scene: this });
    this._events = new events({ scene: this });
    this.debug = new debug({ scene: this });
  }


  start () {
    this.city.create();
  }
  

  update (time, delta) {
    this.viewport.update(delta);
    this.city.update();
  }
  

  shutdown () {
    this.scene.destroy();
  }
}