-
Notifications
You must be signed in to change notification settings - Fork 1
/
planet.js
80 lines (69 loc) · 3.09 KB
/
planet.js
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* This file is part of Mass Control Tycoon.
* Copyright 2013-2014 by MCT Team (see TEAM file) - All rights reserved.
* Project page @ https://github.com/mkelm/mct
* Author(s) Martin Kelm
*
* Mass Control Tycoon is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Mass Control Tycoon is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Mass Control Tycoon. If not, see <http://www.gnu.org/licenses/>.
*/
function displayScenePlanetAdd() {
baseGameInitPlanet();
var scene = new PIXI.DisplayObjectContainer();
// add rotating background
var planet = new PIXI.Sprite.fromFrame("mct_planet.png");
planet.anchor.x = 0.5;
planet.anchor.y = 0.5;
planet.scale.x = mct.pixi.screen.ratio;
planet.scale.y = mct.pixi.screen.ratio;
planet.position.x = (mct.pixi.screen.width / 2) + 130 * mct.pixi.screen.ratio;
planet.position.y = mct.pixi.screen.height / 2;
mct.pixi.animateCommands.push({object:planet,type:"rotation",value:0.0005});
scene.addChild(planet);
// set scene, for further planets scenes with planet keys are needed
mct.pixi.scenes.current = "planet";
mct.pixi.scenes.planet = scene;
mct.pixi.scenes.planet.visible = true;
mct.pixi.stage.addChild(mct.pixi.scenes.planet);
// first attempt to add a planet companies list
//displayScenePlanetCompaniesListAdd();
// second attempt to add a planet companies list by using a popup (builder)
var technologyFieldsForTypeElements = [];
// the following var contains types for each field for single type
// it has to be an object, because the properties depend on the parameter (element handle) of the parent layer
// to get the right menu elements in the new layer
var technologyFieldTypesElements = {};
var technologyFieldsForTypesElements = [];
for (var fp in mct.game.data.technologies.fields) {
if (mct.game.data.technologies.fields[fp].companies.for == 'type') {
technologyFieldsForTypeElements.push([fp, mct.game.data.technologies.fields[fp].title]);
technologyFieldTypesElements[fp] = [];
for (var tp in mct.game.data.technologies.fields[fp].types) {
technologyFieldTypesElements[fp].push([tp, mct.game.data.technologies.fields[fp].types[tp].title]);
}
} else {
technologyFieldsForTypesElements.push([fp, mct.game.data.technologies.fields[fp].title]);
}
}
console.log(technologyFieldTypesElements);
displayWindowAdd(
'planetcompanies',
'scenes/planet/windows/companies.json',
{}, // dynamic texts
{
"technologyfieldsfortype" : technologyFieldsForTypeElements,
"technologyfieldtypes" : technologyFieldTypesElements,
"technologyfieldsfortypes" : technologyFieldsForTypesElements
} // dynamic button elements
);
}