PHP网页游戏学习之Xnova(ogame)源码解读(七)

十、基础数值(vars.php)

vars.php文件中定义游戏中关键的基础数值,全部以数组形式定义;PHP中的数组实际上是一个有序图。我们下面将以代码注释的方式进行说明,可能有不正确的理解,希望大家自己也仔细看看,有问题请提出来!如果对这段数值理解了,那么你就可以创造新的单位了,比如新的科技(可以看我服的殖民技术)、新的船舰等。

// 玩家消息类型定义,具体含义请看messages.mo
$messfields = array (
0 => "mnl_spy",
1 => "mnl_joueur",
2 => "mnl_alliance",
3 => "mnl_attaque",
4 => "mnl_exploit",
5 => "mnl_transport",
15 => "mnl_expedition",
97 => "mnl_general",
99 => "mnl_buildlist",
100 => "new_message"
);
// 所有游戏单位类型定义,其实就是数据库表中字段
$resource = array(
 //建筑单位
 1 => "metal_mine",
 2 => "crystal_mine",
 3 => "deuterium_sintetizer",
 4 => "solar_plant",
 12 => "fusion_plant",
 14 => "robot_factory",
 15 => "nano_factory",
 21 => "hangar",
 22 => "metal_store",
 23 => "crystal_store",
 24 => "deuterium_store",
 31 => "laboratory",
 33 => "terraformer",
 34 => "ally_deposit",
 41 => "mondbasis",
 42 => "phalanx",
 43 => "sprungtor",
 44 => "silo",
//科技研究单位
106 => "spy_tech",
108 => "computer_tech",
109 => "military_tech",
110 => "defence_tech",
111 => "shield_tech",
113 => "energy_tech",
114 => "hyperspace_tech",
115 => "combustion_tech",
117 => "impulse_motor_tech",
118 => "hyperspace_motor_tech",
120 => "laser_tech",
121 => "ionic_tech",
122 => "buster_tech",
123 => "intergalactic_tech",
124 => "expedition_tech",
199 => "graviton_tech",
//船舰单位
202 => "small_ship_cargo",
203 => "big_ship_cargo",
204 => "light_hunter",
205 => "heavy_hunter",
206 => "crusher",
207 => "battle_ship",
208 => "colonizer",
209 => "recycler",
210 => "spy_sonde",
211 => "bomber_ship",
212 => "solar_satelit",
213 => "destructor",
214 => "dearth_star",
215 => "battleship",
//防御单位
401 => "misil_launcher",
402 => "small_laser",
403 => "big_laser",
404 => "gauss_canyon",
405 => "ionic_canyon",
406 => "buster_canyon",
407 => "small_protection_shield",
408 => "big_protection_shield",
502 => "interceptor_misil",
503 => "interplanetary_misil",
//专家单位
601 => "rpg_geologue",
602 => "rpg_amiral",
603 => "rpg_ingenieur",
604 => "rpg_technocrate",
605 => "rpg_constructeur",
606 => "rpg_scientifique",
607 => "rpg_stockeur",
608 => "rpg_defenseur",
609 => "rpg_bunker",
610 => "rpg_espion",
611 => "rpg_commandant",
612 => "rpg_destructeur",
613 => "rpg_general",
614 => "rpg_raideur",
615 => "rpg_empereur",
);
//部分单位的前置升级条件定义
//很多都是多个前置条件,可以从科技树里面看到
$requeriments = array(
 // 建筑
 12 => array(  3 =>  5, 113 =>  3),
 15 => array( 14 => 10, 108 => 10),
 21 => array( 14 =>  2),
 33 => array( 15 =>  1, 113 => 12),
 // 月球建筑
 42 => array( 41 =>  1),
 43 => array( 41 =>  1, 114 =>  7),
 // 科技研究
 106 => array( 31 =>  3),
 108 => array( 31 =>  1),
 109 => array( 31 =>  4),
 110 => array( 113 =>  3, 31 =>  6),
 111 => array( 31 =>  2),
 113 => array( 31 =>  1),
 114 => array( 113 =>  5, 110 =>  5, 31 =>  7),
 115 => array( 113 =>  1, 31 =>  1),
 117 => array( 113 =>  1, 31 =>  2),
 118 => array( 114 =>  3, 31 =>  7),
 120 => array( 31 =>  1, 113 =>  2),
 121 => array( 31 =>  4, 120 =>  5, 113 =>  4),
 122 => array( 31 =>  5, 113 =>  8, 120 => 10, 121 =>  5),
 123 => array( 31 => 10, 108 =>  8, 114 =>  8),
 124 => array( 31 =>  3, 108 =>  4, 117 =>  3),
 199 => array( 31 => 12),
 // 船舰
 202 => array( 21 =>  2, 115 =>  2),
 203 => array( 21 =>  4, 115 =>  6),
 204 => array( 21 =>  1, 115 =>  1),
 205 => array( 21 =>  3, 111 =>  2, 117 =>  2),
 206 => array( 21 =>  5, 117 =>  4, 121 =>  2),
 207 => array( 21 =>  7, 118 =>  4),
 208 => array( 21 =>  4, 117 =>  3),
 209 => array( 21 =>  4, 115 =>  6, 110 =>  2),
 210 => array( 21 =>  3, 115 =>  3, 106 =>  2),
 211 => array( 117 =>  6, 21 =>  8, 122 =>  5),
 212 => array( 21 =>  1),
 213 => array( 21 =>  9, 118 =>  6, 114 =>  5),
 214 => array( 21 => 12, 118 =>  7, 114 =>  6, 199 =>  1),
 215 => array( 114 =>  5, 120 => 12, 118 =>  5, 21 =>  8),
 // 防御
 401 => array( 21 =>  1),
 402 => array( 113 =>  1, 21 =>  2, 120 =>  3),
 403 => array( 113 =>  3, 21 =>  4, 120 =>  6),
 404 => array( 21 =>  6, 113 =>  6, 109 =>  3, 110 =>  1),
 405 => array( 21 =>  4, 121 =>  4),
 406 => array( 21 =>  8, 122 =>  7),
 407 => array( 110 =>  2, 21 =>  1),
 408 => array( 110 =>  6, 21 =>  6),
 502 => array( 44 =>  2),
 503 => array( 44 =>  4),
 // 专家
 603 => array( 601 =>  5),
 604 => array( 602 =>  5),
 605 => array( 601 => 10, 603 =>  2),
 606 => array( 601 => 10, 603 =>  2),
 607 => array( 605 =>  1),
 608 => array( 606 =>  1),
 609 => array( 601 => 20, 603 => 10, 605 =>  3, 606 =>  3, 607 =>  2, 608 =>  2),
 610 => array( 602 => 10, 604 =>  5),
 611 => array( 602 => 10, 604 =>  5),
 612 => array( 610 =>  1),
 613 => array( 611 =>  1),
 614 => array( 602 => 20, 604 => 10, 610 =>  2, 611 =>  2, 612 =>  1, 613 =>  3),
 615 => array( 614 =>  1, 609 =>  1),
);
//所有单位造价定义
//'metal' =>金属, 'crystal' =>晶体, 'deuterium' =>重氢, 'energy' =>能量, 'factor' =>步进值
//'consumption' =>HH消耗, 'consumption2' =>HH消耗, 'speed' =>第一速度, 'speed2' =>第二速度, 'capacity' =>装载量
//'max' =>最高等级
$pricelist = array(
  1 => array ( 'metal' =>   60, 'crystal' =>   15, 'deuterium' =>    0, 'energy' =>  0, 'factor' => 3/2),
  2 => array ( 'metal' =>   48, 'crystal' =>   24, 'deuterium' =>    0, 'energy' =>  0, 'factor' => 1.6),
  3 => array ( 'metal' =>   225, 'crystal' =>   75, 'deuterium' =>    0, 'energy' =>  0, 'factor' => 3/2),
  4 => array ( 'metal' =>   75, 'crystal' =>   30, 'deuterium' =>    0, 'energy' =>  0, 'factor' => 3/2),
 12 => array ( 'metal' =>   900, 'crystal' =>   360, 'deuterium' =>   180, 'energy' =>  0, 'factor' => 1.8),
 14 => array ( 'metal' =>   400, 'crystal' =>   120, 'deuterium' =>   200, 'energy' =>  0, 'factor' =>  2),
 15 => array ( 'metal' => 1000000, 'crystal' => 500000, 'deuterium' => 100000, 'energy' =>  0, 'factor' =>  2),
 21 => array ( 'metal' =>   400, 'crystal' =>   200, 'deuterium' =>   100, 'energy' =>  0, 'factor' =>  2),
 22 => array ( 'metal' =>  2000, 'crystal' =>    0, 'deuterium' =>    0, 'energy' =>  0, 'factor' =>  2),
 23 => array ( 'metal' =>  2000, 'crystal' =>  1000, 'deuterium' =>    0, 'energy' =>  0, 'factor' =>  2),
 24 => array ( 'metal' =>  2000, 'crystal' =>  2000, 'deuterium' =>    0, 'energy' =>  0, 'factor' =>  2),
 31 => array ( 'metal' =>   200, 'crystal' =>   400, 'deuterium' =>   200, 'energy' =>  0, 'factor' =>  2),
 33 => array ( 'metal' =>    0, 'crystal' =>  50000, 'deuterium' => 100000, 'energy' => 1000, 'factor' =>  2),
 34 => array ( 'metal' =>  20000, 'crystal' =>  40000, 'deuterium' =>    0, 'energy' =>  0, 'factor' =>  2),
 41 => array ( 'metal' =>  20000, 'crystal' =>  40000, 'deuterium' =>  20000, 'energy' =>  0, 'factor' =>  2),
 42 => array ( 'metal' =>  20000, 'crystal' =>  40000, 'deuterium' =>  20000, 'energy' =>  0, 'factor' =>  2),
 43 => array ( 'metal' => 2000000, 'crystal' => 4000000, 'deuterium' => 2000000, 'energy' =>  0, 'factor' =>  2),
 44 => array ( 'metal' =>  20000, 'crystal' =>  20000, 'deuterium' =>  1000, 'energy' =>  0, 'factor' =>  2),
 106 => array ( 'metal' =>   200, 'crystal' =>  1000, 'deuterium' =>   200, 'energy' =>  0, 'factor' =>  2),
 108 => array ( 'metal' =>    0, 'crystal' =>   400, 'deuterium' =>   600, 'energy' =>  0, 'factor' =>  2),
 109 => array ( 'metal' =>   800, 'crystal' =>   200, 'deuterium' =>    0, 'energy' =>  0, 'factor' =>  2),
 110 => array ( 'metal' =>   200, 'crystal' =>   600, 'deuterium' =>    0, 'energy' =>  0, 'factor' =>  2),
 111 => array ( 'metal' =>  1000, 'crystal' =>    0, 'deuterium' =>    0, 'energy' =>  0, 'factor' =>  2),
 113 => array ( 'metal' =>    0, 'crystal' =>   800, 'deuterium' =>   400, 'energy' =>  0, 'factor' =>  2),
 114 => array ( 'metal' =>    0, 'crystal' =>  4000, 'deuterium' =>  2000, 'energy' =>  0, 'factor' =>  2),
 115 => array ( 'metal' =>   400, 'crystal' =>    0, 'deuterium' =>   600, 'energy' =>  0, 'factor' =>  2),
 117 => array ( 'metal' =>  2000, 'crystal' =>  4000, 'deuterium' =>  6000, 'energy' =>  0, 'factor' =>  2),
 118 => array ( 'metal' =>  10000, 'crystal' =>  20000, 'deuterium' =>  6000, 'energy' =>  0, 'factor' =>  2),
 120 => array ( 'metal' =>   200, 'crystal' =>   100, 'deuterium' =>    0, 'energy' =>  0, 'factor' =>  2),
 121 => array ( 'metal' =>  1000, 'crystal' =>   300, 'deuterium' =>   100, 'energy' =>  0, 'factor' =>  2),
 122 => array ( 'metal' =>  2000, 'crystal' =>  4000, 'deuterium' =>  1000, 'energy' =>  0, 'factor' =>  2),
 123 => array ( 'metal' => 240000, 'crystal' => 400000, 'deuterium' => 160000, 'energy' =>  0, 'factor' =>  2),
 124 => array ( 'metal' =>  4000, 'crystal' =>  8000, 'deuterium' =>  4000, 'energy' =>  0, 'factor' =>  2),
 199 => array ( 'metal' =>    0, 'crystal' =>    0, 'deuterium' =>    0, 'energy_max' => 300000, 'factor' =>  3),
 202 => array ( 'metal' =>  2000, 'crystal' =>  2000, 'deuterium' =>    0, 'energy' => 0, 'factor' => 1, 'consumption' => 20 , 'consumption2' => 40 , 'speed' =>   5000, 'speed2' =>   10000, 'capacity' =>  5000 ),
 203 => array ( 'metal' =>  6000, 'crystal' =>  6000, 'deuterium' =>    0, 'energy' => 0, 'factor' => 1, 'consumption' => 50 , 'consumption2' => 50 , 'speed' =>   7500, 'speed2' =>   7500, 'capacity' =>  25000 ),
 204 => array ( 'metal' =>  3000, 'crystal' =>  1000, 'deuterium' =>    0, 'energy' => 0, 'factor' => 1, 'consumption' => 20 , 'consumption2' => 20 , 'speed' =>   12500, 'speed2' =>   12500, 'capacity' =>   50 ),
 205 => array ( 'metal' =>  6000, 'crystal' =>  4000, 'deuterium' =>    0, 'energy' => 0, 'factor' => 1, 'consumption' => 75 , 'consumption2' => 75 , 'speed' =>   10000, 'speed2' =>   15000, 'capacity' =>   100 ),
 206 => array ( 'metal' =>  20000, 'crystal' =>  7000, 'deuterium' =>  2000, 'energy' => 0, 'factor' => 1, 'consumption' => 300 , 'consumption2' => 300 , 'speed' =>   15000, 'speed2' =>   15000, 'capacity' =>   800 ),
 207 => array ( 'metal' =>  45000, 'crystal' =>  15000, 'deuterium' =>    0, 'energy' => 0, 'factor' => 1, 'consumption' => 500 , 'consumption2' => 500 , 'speed' =>   10000, 'speed2' =>   10000, 'capacity' =>  1500 ),
 208 => array ( 'metal' =>  10000, 'crystal' =>  20000, 'deuterium' =>  10000, 'energy' => 0, 'factor' => 1, 'consumption' => 1000, 'consumption2' => 1000, 'speed' =>   2500, 'speed2' =>   2500, 'capacity' =>  7500 ),
 209 => array ( 'metal' =>  10000, 'crystal' =>  6000, 'deuterium' =>  2000, 'energy' => 0, 'factor' => 1, 'consumption' => 300 , 'consumption2' => 300 , 'speed' =>   2000, 'speed2' =>   2000, 'capacity' =>  20000 ),
 210 => array ( 'metal' =>    0, 'crystal' =>  1000, 'deuterium' =>    0, 'energy' => 0, 'factor' => 1, 'consumption' => 1  , 'consumption2' => 1  , 'speed' => 100000000, 'speed2' => 100000000, 'capacity' =>    5 ),
 211 => array ( 'metal' =>  50000, 'crystal' =>  25000, 'deuterium' =>  15000, 'energy' => 0, 'factor' => 1, 'consumption' => 1000, 'consumption2' => 1000, 'speed' =>   4000, 'speed2' =>   5000, 'capacity' =>   500 ),
 212 => array ( 'metal' =>    0, 'crystal' =>  2000, 'deuterium' =>   500, 'energy' => 0, 'factor' => 1, 'consumption' => 0  , 'consumption2' => 0  , 'speed' =>     0, 'speed2' =>     0, 'capacity' =>    0 ),
 213 => array ( 'metal' =>  60000, 'crystal' =>  50000, 'deuterium' =>  15000, 'energy' => 0, 'factor' => 1, 'consumption' => 1000, 'consumption2' => 1000, 'speed' =>   5000, 'speed2' =>   5000, 'capacity' =>  2000 ),
 214 => array ( 'metal' => 5000000, 'crystal' => 4000000, 'deuterium' => 1000000, 'energy' => 0, 'factor' => 1, 'consumption' => 1  , 'consumption2' => 1  , 'speed' =>    100, 'speed2' =>    100, 'capacity' => 1000000 ),
 215 => array ( 'metal' =>  30000, 'crystal' =>  40000, 'deuterium' =>  15000, 'energy' => 0, 'factor' => 1, 'consumption' => 250 , 'consumption2' => 250 , 'speed' =>   10000, 'speed2' =>   10000, 'capacity' =>   750 ),
 401 => array ( 'metal' =>  2000, 'crystal' =>    0, 'deuterium' =>    0, 'energy' => 0, 'factor' => 1 ),
 402 => array ( 'metal' =>  1500, 'crystal' =>   500, 'deuterium' =>    0, 'energy' => 0, 'factor' => 1 ),
 403 => array ( 'metal' =>  6000, 'crystal' =>  2000, 'deuterium' =>    0, 'energy' => 0, 'factor' => 1 ),
 404 => array ( 'metal' =>  20000, 'crystal' =>  15000, 'deuterium' =>  2000, 'energy' => 0, 'factor' => 1 ),
 405 => array ( 'metal' =>  2000, 'crystal' =>  6000, 'deuterium' =>    0, 'energy' => 0, 'factor' => 1 ),
 406 => array ( 'metal' =>  50000, 'crystal' =>  50000, 'deuterium' =>  30000, 'energy' => 0, 'factor' => 1 ),
 407 => array ( 'metal' =>  10000, 'crystal' =>  10000, 'deuterium' =>    0, 'energy' => 0, 'factor' => 1 ),
 408 => array ( 'metal' =>  50000, 'crystal' =>  50000, 'deuterium' =>    0, 'energy' => 0, 'factor' => 1 ),
 502 => array ( 'metal' =>  8000, 'crystal' =>  2000, 'deuterium' =>    0, 'energy' => 0, 'factor' => 1 ),
 503 => array ( 'metal' =>  12500, 'crystal' =>  2500, 'deuterium' =>  10000, 'energy' => 0, 'factor' => 1 ),
 601 => array ( 'max' => 20),
 602 => array ( 'max' => 20),
 603 => array ( 'max' => 10),
 604 => array ( 'max' => 10),
 605 => array ( 'max' =>  3),
 606 => array ( 'max' =>  3),
 607 => array ( 'max' =>  2),
 608 => array ( 'max' =>  2),
 609 => array ( 'max' =>  1),
 610 => array ( 'max' =>  2),
 611 => array ( 'max' =>  2),
 612 => array ( 'max' =>  1),
 613 => array ( 'max' =>  3),
 614 => array ( 'max' =>  1),
 615 => array ( 'max' =>  1),
);
//船舰和防御战斗数值定义
//'shield' =>护盾强度, 'attack' =>攻击强度, 'sd' =>速射值
$CombatCaps = array(
 202 => array ( 'shield' =>  10, 'attack' =>   5, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  5, 213 =>  1, 214 =>  1, 215 =>  1, 401 =>  1, 402 =>  1, 403 =>  1, 404 =>  1, 405 =>  1, 406 =>  1, 407 =>  1, 408 =>  1 )),
 203 => array ( 'shield' =>  25, 'attack' =>   5, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  5, 213 =>  1, 214 =>  1, 215 =>  1, 401 =>  1, 402 =>  1, 403 =>  1, 404 =>  1, 405 =>  1, 406 =>  1, 407 =>  1, 408 =>  1 )),
 204 => array ( 'shield' =>  10, 'attack' =>   50, 'sd' => array (202 =>  2, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  5, 213 =>  1, 214 =>  1, 215 =>  1, 401 =>  1, 402 =>  1, 403 =>  1, 404 =>  1, 405 =>  1, 406 =>  1, 407 =>  1, 408 =>  1 )),
 205 => array ( 'shield' =>  25, 'attack' =>  150, 'sd' => array (202 =>  3, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  5, 213 =>  1, 214 =>  1, 215 =>  1, 401 =>  1, 402 =>  1, 403 =>  1, 404 =>  1, 405 =>  1, 406 =>  1, 407 =>  1, 408 =>  1 )),
 206 => array ( 'shield' =>  50, 'attack' =>  400, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  6, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  5, 213 =>  1, 214 =>  1, 215 =>  1, 401 => 10, 402 =>  1, 403 =>  1, 404 =>  1, 405 =>  1, 406 =>  1, 407 =>  1, 408 =>  1 )),
 207 => array ( 'shield' =>  200, 'attack' =>  1000, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  5, 213 =>  1, 214 =>  1, 215 =>  1, 401 =>  8, 402 =>  1, 403 =>  1, 404 =>  1, 405 =>  1, 406 =>  1, 407 =>  1, 408 =>  1 )),
 208 => array ( 'shield' =>  100, 'attack' =>   50, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  5, 213 =>  1, 214 =>  1, 215 =>  1, 401 =>  1, 402 =>  1, 403 =>  1, 404 =>  1, 405 =>  1, 406 =>  1, 407 =>  1, 408 =>  1 )),
 209 => array ( 'shield' =>  10, 'attack' =>   1, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  5, 213 =>  1, 214 =>  1, 215 =>  1, 401 =>  1, 402 =>  1, 403 =>  1, 404 =>  1, 405 =>  1, 406 =>  1, 407 =>  1, 408 =>  1 )),
 210 => array ( 'shield' =>   0, 'attack' =>   0, 'sd' => array (202 =>  0, 203 =>  0, 204 =>  0, 205 =>  0, 206 =>  0, 207 =>  0, 208 =>  0, 209 =>  0, 210 =>  0, 211 =>  0, 212 =>  0, 213 =>  0, 214 =>  0, 215 =>  0, 401 =>  0, 402 =>  0, 403 =>  0, 404 =>  0, 405 =>  0, 406 =>  0, 407 =>  0, 408 =>  0 )),
 211 => array ( 'shield' =>  500, 'attack' =>  1000, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  5, 213 =>  1, 214 =>  1, 215 =>  1, 401 => 20, 402 => 20, 403 => 10, 404 =>  1, 405 => 10, 406 =>  1, 407 =>  1, 408 =>  1 )),
 212 => array ( 'shield' =>  10, 'attack' =>   1, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  1, 211 =>  1, 212 =>  0, 213 =>  1, 214 =>  1, 215 =>  1, 401 =>  1, 402 =>  1, 403 =>  1, 404 =>  1, 405 =>  1, 406 =>  1, 407 =>  1, 408 =>  1 )),
 213 => array ( 'shield' =>  500, 'attack' =>  2000, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  5, 213 =>  1, 214 =>  1, 215 =>  2, 401 =>  1, 402 => 10, 403 =>  1, 404 =>  1, 405 =>  1, 406 =>  1, 407 =>  1, 408 =>  1 )),
 214 => array ( 'shield' => 50000, 'attack' => 200000, 'sd' => array (202 => 250, 203 => 250, 204 => 200, 205 => 100, 206 => 33, 207 => 30, 208 => 250, 209 => 250, 210 => 1250, 211 => 25, 212 => 1250, 213 =>  5, 214 =>  1, 215 => 15, 401 => 200, 402 => 200, 403 => 100, 404 => 50, 405 => 100, 406 =>  1, 407 =>  1, 408 =>  1 )),
 215 => array ( 'shield' =>  400, 'attack' =>  700, 'sd' => array (202 =>  3, 203 =>  3, 204 =>  1, 205 =>  4, 206 =>  4, 207 =>  7, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  5, 213 =>  1, 214 =>  1, 215 =>  1, 401 =>  1, 402 =>  1, 403 =>  1, 404 =>  1, 405 =>  1, 406 =>  1, 407 =>  1, 408 =>  1 )),
 401 => array ( 'shield' =>  20, 'attack' =>   80, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  0, 213 =>  1, 214 =>  1, 215 =>  1) ),
 402 => array ( 'shield' =>  25, 'attack' =>  100, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  0, 213 =>  1, 214 =>  1, 215 =>  1) ),
 403 => array ( 'shield' =>  100, 'attack' =>  250, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  0, 213 =>  1, 214 =>  1, 215 =>  1) ),
 404 => array ( 'shield' =>  200, 'attack' =>  1100, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  0, 213 =>  1, 214 =>  1, 215 =>  1) ),
 405 => array ( 'shield' =>  500, 'attack' =>  150, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  0, 213 =>  1, 214 =>  1, 215 =>  1) ),
 406 => array ( 'shield' =>  300, 'attack' =>  3000, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  0, 213 =>  1, 214 =>  1, 215 =>  1) ),
 407 => array ( 'shield' => 2000, 'attack' =>   1, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  0, 213 =>  1, 214 =>  1, 215 =>  1) ),
 408 => array ( 'shield' => 2000, 'attack' =>   1, 'sd' => array (202 =>  1, 203 =>  1, 204 =>  1, 205 =>  1, 206 =>  1, 207 =>  1, 208 =>  1, 209 =>  1, 210 =>  5, 211 =>  1, 212 =>  0, 213 =>  1, 214 =>  1, 215 =>  1) ),
 502 => array ( 'shield' =>   1, 'attack' =>   1 ),
 503 => array ( 'shield' =>   1, 'attack' => 12000 )
);
//资源生产和能量消耗公式
$ProdGrid = array(
 // 金属矿
 1  => array( 'metal' =>  40, 'crystal' =>  10, 'deuterium' =>  0, 'energy' => 0, 'factor' => 3/2,
 'formule' => array(
  'metal'   => 'return  (30 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);',
  'crystal'  => 'return  "0";',
  'deuterium' => 'return  "0";',
  'energy'  => 'return - (10 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);')
 ),
 // 晶体矿
 2  => array( 'metal' =>  30, 'crystal' =>  15, 'deuterium' =>  0, 'energy' => 0, 'factor' => 1.6,
 'formule' => array(
  'metal'   => 'return  "0";',
  'crystal'  => 'return  (20 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);',
  'deuterium' => 'return  "0";',
  'energy'  => 'return - (10 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);')
 ),
 // HH矿
 3  => array( 'metal' => 150, 'crystal' =>  50, 'deuterium' =>  0, 'energy' => 0, 'factor' => 3/2,
 'formule' => array(
  'metal'   => 'return  "0";',
  'crystal'  => 'return  "0";',
  'deuterium' => 'return ((10 * $BuildLevel * pow((1.1), $BuildLevel)) * (-0.002 * $BuildTemp + 1.28)) * (0.1 * $BuildLevelFactor);',
  'energy'  => 'return - (30 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);')
 ),
 // 太阳能
 4  => array( 'metal' =>  50, 'crystal' =>  20, 'deuterium' =>  0, 'energy' => 0, 'factor' => 3/2,
 'formule' => array(
  'metal'   => 'return  "0";',
  'crystal'  => 'return  "0";',
  'deuterium' => 'return  "0";',
  'energy'  => 'return  (20 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);')
 ),
 // 核电厂
 12 => array( 'metal' => 500, 'crystal' => 200, 'deuterium' => 100, 'energy' => 0, 'factor' => 1.8,
 'formule' => array(
  'metal'   => 'return  "0";',
  'crystal'  => 'return  "0";',
  'deuterium' => 'return - (10 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);',
  'energy'  => 'return  (50 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);')
 ),
 // 太阳能卫星
 212 => array( 'metal' =>  0, 'crystal' => 2000, 'deuterium' => 500, 'energy' => 0, 'factor' => 0.5,
 'formule' => array(
  'metal'   => 'return  "0";',
  'crystal'  => 'return  "0";',
  'deuterium' => 'return  "0";',
  'energy'  => 'return (($BuildTemp / 4) + 20) * $BuildLevel * (0.1 * $BuildLevelFactor);')
 )
);
//所有单位是否启用定义
//即使前面定义了的单位,这里如果不加入,也是不起作用的
$reslist['build']  = array (  1,  2,  3,  4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 44, 41, 42, 43 );
$reslist['tech']   = array ( 106, 108, 109, 110, 111, 113, 114, 115, 117, 118, 120, 121, 122, 123, 124, 199 );
$reslist['fleet']  = array ( 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215 );
$reslist['defense'] = array ( 401, 402, 403, 404, 405, 406, 407, 408, 502, 503 );
$reslist['officier'] = array ( 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615);
$reslist['prod']   = array (  1,  2,  3,  4, 12, 212 ); 
(0)

相关推荐

  • PHP网页游戏学习之Xnova(ogame)源码解读(十四)

    十七.资源更新(PlanetResourceUpdate.php页面) 前面基本把重要的功能讲解完了,这章节我们分析重要的一个函数PlanetResourceUpdate,主要功能是更新资源.制造船舰和防御单位:代码很有条理,下面是详细的说明: 1.计算星球的最大存储空间,包括系统设置的浮动值 2.计算星球三种资源的产量和能量消耗总量,包括专家的加成 3.如果星球是月球,以上计算的产量和能量直接为0 4.计算上次更新资源到现在的时间 5.计算由于能量比率而引起的产量变化,能量为0的时候,只有基本

  • PHP网页游戏学习之Xnova(ogame)源码解读(八)

    十一.公共函数(functions.php) 本来打算写建筑页面的分析,但是建筑页面东西比较多,一天时间也写不完:而且我们还有很多函数要经常用到,先简单介绍下这些函数还是有必要的:下面我们还是以注释方式说明. // ------------------------------ // //检查用户是否假期模式,这个函数没有被调用过 // function check_urlaubmodus ($user) //输出目前登陆用户假期模式剩余时间,这个函数没有被调用过 function check_u

  • PHP网页游戏学习之Xnova(ogame)源码解读(九)

    十二.舰队相关函数(unlocalised.php) 本节将把舰队派遣相关的函数做个说明,继续以注释方式说明:由于这次涉及的函数比较多,需要花不少时间来整理消化. // ------------------------------------------------------------------- // // 以下是舰队派遣需要用到的函数列表 // // -------------------------------------------------------------------

  • PHP网页游戏学习之Xnova(ogame)源码解读(十二)

    十五.研究页面(ResearchBuildingPage.php) 研究因为没有队列,所以相对简单一些:但是也有一些比较特殊的东西.我们先看研究之前的一个处理函数HandleTechnologieBuild(). 这个函数是处理现在的科技研究的,其中b_tech_planet字段是研究的星球ID,b_tech字段是完成研究的时间点,b_tech_id字段是研究的具体科技字段名.函数逻辑不难,我就不仔细讲解了,大家自己看看,下面正式进入研究页面: 首先要检查当前星球是否有研究所. 然后检查当前星球

  • PHP网页游戏学习之Xnova(ogame)源码解读(十三)

    十六.造船和防御(FleetBuildingPage.php与DefensesBuildingPage.php页面) 先说造船厂页面,其实这个页面中并没有真正的造船,只是把要造的船和数量保存到数据库中:产生船舰的代码在另外一个函数里面.下面我们开始分析这个页面,并且也按照前面的思路,先讲解构造页面的代码. 首先判断本星球是否已有造船厂,没有当然要提示. 下面使用循环语句,构造出每种船舰的建造页面,这段代码我觉得不需要再详细讲解了. 接下来是要显示正在制造的船舰列表,要脚本动态显示,实际上是假像:

  • PHP网页游戏学习之Xnova(ogame)源码解读(十)

    十三. 建造总览(buildings.php) 从这篇文章开始,对xnova的研究重点放在流程上面,其实就是大量的函数:至于页面的构造将不再仔细解释. buildings.php文件不只是处理建筑金属矿产等,而是包括了建筑.研究.造船厂.防御四个功能:通过传递不同的参数来决定进入哪个功能,所以这个文件其实是一个导航文件.下面我们简单解释下这个文件. //更新当前星球的建筑队列,比较复杂 UpdatePlanetBatimentQueueList ( $planetrow, $user ); //

  • PHP网页游戏学习之Xnova(ogame)源码解读(四)

    五. 用户登录(login.php) 在开始的时候,我们说过游戏的入口是index.php文件:我们已经安装好了,自然转向登录流程,开始看. 前面照例是一段我们前进介绍过的代码,我们就不再详细讲了:不同的是使用的语言文件是login.mo,还有一个LOGIN的常量.如下 define('INSIDE' , true); define('INSTALL' , false); define('LOGIN' , true); $InLogin = true; $xnova_root_path = '.

  • PHP网页游戏学习之Xnova(ogame)源码解读(五)

    六. 游戏主界面(frames.php) frames.php文件功能就是显示游戏主界面,先看下面的代码: $InLogin = false; $XNova_Host = $_SERVER['HTTP_HOST']; $XNova_Script = $_SERVER['SCRIPT_NAME']; $Uri_Array = explode ('/', $XNova_Script); // On vire le script array_pop($Uri_Array); $XNova_URI =

  • PHP网页游戏学习之Xnova(ogame)源码解读(十一)

    十四.建筑页面(BatimentBuildingPage.php) 现在开始解析真正的建筑页面,里面用到的函数不少,不过都不难,我们一起来看. 一开始先检查星球的已使用空间并更新,使用函数CheckPlanetUsedFields,这个函数前面讲过,实现也不难. 接下来这个是我们前面重点讲过的结构,就是判断是否输入:所以我们先跳到这段代码的后面看,但是这里有几个函数是处理一些建筑队列的. 1. SetNextQueueElementOnTop:我们讲过,处理队列中的下一个建筑 2. ShowBu

  • PHP网页游戏学习之Xnova(ogame)源码解读(六)

    九.公共代码(common.php) Common.php是Xnova的公共代码,几乎每次点击都会被执行,所以这里要是优化的好,那么整个程序的效率都会有提升:当然这个文件调用的其他代码也要一并优化才行. $game_config = array(); $user = array(); $lang = array(); $link = ""; $IsUserChecked = false; 变量$game_config存放整个游戏的参数数据,每次都要读数据库,可以优化,优化方式比如保存在

随机推荐