GameWin.js 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. FZ.Game.winState = new (FZ.newClass({
  2. StateName : FZ.StateDefs.GAME_STATE_GAME_WIN,
  3. CUR_UI_DEFS : ["YOU_WIN_BG",
  4. "NUM_STAGE_WIN_TOTAL_1","NUM_STAGE_WIN_TOTAL_2","NUM_STAGE_WIN_TOTAL_3","NUM_STAGE_WIN_TOTAL_4","NUM_STAGE_WIN_TOTAL_5",
  5. "NUM_STAGE_WIN_TOTAL_TIME_1","NUM_STAGE_WIN_TOTAL_TIME_2","NUM_STAGE_WIN_TOTAL_TIME_3","NUM_STAGE_WIN_TOTAL_TIME_4","NUM_STAGE_WIN_TOTAL_TIME_5",
  6. "NUM_STAGE_TOTAL_HINT_1","NUM_STAGE_TOTAL_HINT_2","NUM_STAGE_TOTAL_HINT_3","NUM_STAGE_TOTAL_HINT_4","NUM_STAGE_TOTAL_HINT_5"],
  7. UI_TOTAL_SCORE_START_INDEX: 1,
  8. UI_TOTAL_TIME_START_INDEX: 6,
  9. UI_TOTAL_HINT_START_INDEX: 11,
  10. TOTAL_SCORE: 5,
  11. TOTAL_TIME:5,
  12. TOTAL_HINT: 5,
  13. // BTN_MENU_AWARDS_INDEX : 0,
  14. BTN_MAIN_MENU_IDNEX : 0,
  15. //CUR_BTN_DEFS : [["BTN_AWARDS", "BTN_AWARDS_TOUCH",], ["BTN_MAIN_MENU_WIN", "BTN_MAIN_MENU_WIN_TOUCH",],],
  16. CUR_BTN_DEFS : [ ["BTN_MAIN_MENU", "BTN_MAIN_MENU_TOUCH",]],
  17. STR_LEFT_TIME_RECT : [100, 215, 50, 36],
  18. STR_LEFT_TIME_BONUS_RECT : [203, 215, 30, 36],
  19. STR_SCORE_RECT : [160, 277, 138, 36],
  20. m_load_ui : false,
  21. COLOR_YELLOW:"#F0D751",
  22. COLOR_BROWN:"#B97F00",
  23. COLOR_ORANGE:"#FFC72A",
  24. LABEL_TEXT_SIZE_SMALL:12,
  25. LABEL_TEXT_SIZE_MIDDLE:18,
  26. LABEL_TEXT_SIZE_LARGE:24,
  27. m_title_div:null,
  28. m_conten_div1:null,
  29. m_conten_div2:null,
  30. m_conten_div3:null,
  31. createLabelTitleTextSprite : function(x,y,w,h, text, color) {
  32. this.m_title_div = document.createElement("div");
  33. this.m_title_div.style.width = w + "px";
  34. this.m_title_div.style.height = h + "px";
  35. this.m_title_div.style.left = x + "px";
  36. this.m_title_div.style.top = y + "px";
  37. this.m_title_div.style.position = "absolute";
  38. this.m_ui_list[0].appendChild(this.m_title_div);
  39. this.m_title_div.style.zIndex = 300;
  40. var lnH = h-2;
  41. this.m_title_div.style.textAlign = "center";
  42. this.m_title_div.style.lineHeight = Math.round(lnH) + "px";;
  43. this.m_title_div.style.fontFamily = "Arial";
  44. this.m_title_div.style.fontWeight = "bolder";
  45. this.m_title_div.style.fontSize = Math.round(h-12) + "px";
  46. // add shadow from up down left and right
  47. this.m_title_div.style.textShadow = "-1px -1px 1px #4F5100, 1px 1px 1px #4F5100, 1px -1px 1px #4F5100, -1px 1px 1px #4F5100 ";
  48. this.m_title_div.style.color = color;
  49. this.m_title_div.innerHTML = text;
  50. },
  51. createLabelContentTextSprite : function(div,x,y,w,h, text, color) {
  52. div = document.createElement("div");
  53. div.style.width = w + "px";
  54. div.style.height = h + "px";
  55. div.style.left = x + "px";
  56. div.style.top = y + "px";
  57. div.style.position = "absolute";
  58. this.m_ui_list[0].appendChild(div);
  59. div.style.zIndex = 300;
  60. var lnH = h-2;
  61. div.style.textAlign = "center";
  62. div.style.lineHeight = Math.round(lnH) + "px";;
  63. div.style.fontFamily = "Arial";
  64. div.style.fontWeight = "900";
  65. div.style.fontSize = Math.round(lnH) + "px";
  66. // add shadow from up down left and right
  67. div.style.textShadow = "-1px -1px 1px #AE0000, 1px 1px 1px #AE0000, 1px -1px 1px #AE0000, -1px 1px 1px #AE0000 ";
  68. div.style.color = color;
  69. div.innerHTML = text;
  70. },
  71. createLabelContentTextSprite_ : function(div, x,y,w,h, text, color) {
  72. div = document.createElement("div");
  73. div.style.width = w + "px";
  74. div.style.height = h + "px";
  75. div.style.left = x + "px";
  76. div.style.top = y + "px";
  77. div.style.position = "absolute";
  78. this.m_ui_list[0].appendChild(div);
  79. div.style.zIndex = 300;
  80. var lnH = h-2;
  81. div.style.textAlign = "center";
  82. div.style.lineHeight = Math.round(lnH) + "px";;
  83. div.style.fontFamily = "Arial";
  84. div.style.fontWeight = "900";
  85. div.style.fontSize = Math.round(lnH) + "px";
  86. // add shadow from up down left and right
  87. div.style.textShadow = "-1px -1px 1px #054747, 1px 1px 1px #054747, 1px -1px 1px #054747, -1px 1px 1px #054747 ";
  88. div.style.color = color;
  89. div.innerHTML = text;
  90. },
  91. createBtnTextSprite: function(divSprite, text, color){
  92. var spr = divSprite;
  93. var h = spr.m_h;
  94. spr.m_div.style.textAlign="center";
  95. // spr.m_div.style.textIndent = -10+ "px";
  96. spr.m_div.style.lineHeight= spr.m_div.style.height;
  97. spr.m_div.style.fontFamily="Arial";
  98. spr.m_div.style.fontWeight="bold";
  99. spr.m_div.style.fontSize=Math.round(h/4)+"px";
  100. //add shadow from up down left and right
  101. spr.m_div.style.textShadow="-2px -2px 2px #7c2e1a, 2px 2px 2px #7c2e1a, 2px -2px 2px #7c2e1a, -2px 2px 2px #7c2e1a ";
  102. spr.m_div.style.color=color;
  103. spr.m_div.innerHTML=text;
  104. return spr;
  105. },
  106. preProcess : function(preState, curState, totalScore, totalUsedTime, totalUsedHint) {
  107. var index = 0;
  108. // var img = null;
  109. var btn = null;
  110. var info = null;
  111. var infoDown = null;
  112. var ctx = null;
  113. var mySelf = this;
  114. if(!this.m_load_ui) {
  115. this.createUIs(this.CUR_UI_DEFS);
  116. var x = (320 - parseInt((this.m_ui_list[0].style.width).substr(0,3)))/2;
  117. var w = parseInt((this.m_ui_list[0].style.width).substr(0,3));
  118. this.createLabelTitleTextSprite(x,5,w-20,40, FZ.GameText.TEXT_GAME_COMPLETE, "#BEEB36");
  119. this.createLabelContentTextSprite_(this.m_conten_div1,x,50,w,25,FZ.GameText.TEXT_TOTAL_SCORE, "#67F1F0");
  120. this.createLabelContentTextSprite(this.m_conten_div2,x,110,w,25, FZ.GameText.TEXT_USED_TIME, "#FBCE1A");
  121. this.createLabelContentTextSprite_(this.m_conten_div3,x,172,w,25,FZ.GameText.TEXT_USED_HINTS, "#67F1F0");
  122. this.createBtns(this.CUR_BTN_DEFS, true);
  123. this.createBtnTextSprite(this.m_btn_list[this.BTN_MAIN_MENU_IDNEX], FZ.GameText.TEXT_MAIN_MENU, this.COLOR_ORANGE);
  124. // this.createStrScoreDiv();
  125. // this.createStrLeftTimeDiv();
  126. FZ.DivManager.addChild(this.m_main_div);
  127. this.m_load_ui = true;
  128. }
  129. else {
  130. this.m_main_div.style.display = "inline";
  131. }
  132. // this.m_last_left_time_div.innerHTML = "" + totalScore;
  133. // this.m_last_score_div.innerHTML = "" + levelScore;
  134. var scoreNum = FZ.AG.SearchSpecialPath.setScoreNum(totalScore);
  135. for(var index = 0; index < scoreNum.length; index++){
  136. this.m_ui_list[this.UI_TOTAL_SCORE_START_INDEX + this.TOTAL_SCORE - scoreNum.length + index].style.backgroundImage = "url(imgs/number_score_" + scoreNum[scoreNum.length - 1- index] + ".png)";
  137. }
  138. if(scoreNum.length < this.TOTAL_SCORE){
  139. for(var index = 0; index < this.TOTAL_SCORE - scoreNum.length ; index++){
  140. this.m_ui_list[this.UI_TOTAL_SCORE_START_INDEX + index].style.backgroundImage = "url(imgs/number_score_0.png)";
  141. }
  142. }
  143. scoreNum = FZ.AG.SearchSpecialPath.setScoreNum(totalUsedTime);
  144. for(var index = 0; index < scoreNum.length; index++){
  145. this.m_ui_list[this.UI_TOTAL_TIME_START_INDEX + this.TOTAL_TIME - scoreNum.length + index].style.backgroundImage = "url(imgs/number_score_" + scoreNum[scoreNum.length - 1- index] + ".png)";
  146. }
  147. if(scoreNum.length < this.TOTAL_TIME){
  148. for(var index = 0; index < this.TOTAL_TIME - scoreNum.length ; index++){
  149. this.m_ui_list[this.UI_TOTAL_TIME_START_INDEX + index].style.backgroundImage = "url(imgs/number_score_0.png)";
  150. }
  151. }
  152. scoreNum = FZ.AG.SearchSpecialPath.setScoreNum(totalUsedHint);
  153. for(var index = 0; index < scoreNum.length; index++){
  154. this.m_ui_list[this.UI_TOTAL_HINT_START_INDEX + this.TOTAL_HINT - scoreNum.length + index].style.backgroundImage = "url(imgs/number_score_" + scoreNum[scoreNum.length - 1- index] + ".png)";
  155. }
  156. if(scoreNum.length < this.TOTAL_HINT){
  157. for(var index = 0; index < this.TOTAL_HINT - scoreNum.length ; index++){
  158. this.m_ui_list[this.UI_TOTAL_HINT_START_INDEX + index].style.backgroundImage = "url(imgs/number_score_0.png)";
  159. }
  160. }
  161. setTimeout(function() {
  162. mySelf.fade_in.call(mySelf, 2000, 1);
  163. }, 10);
  164. FZ.GameBase.SaveObject.m_gamein = false;
  165. FZ.GameBase.saveGame();
  166. },
  167. createStrLeftTimeDiv : function() {
  168. this.m_last_left_time_div = document.createElement("div");
  169. this.m_last_left_time_div.style.position = "absolute";
  170. this.m_last_left_time_div.style.width = this.STR_LEFT_TIME_RECT[2] + "px";
  171. this.m_last_left_time_div.style.height = this.STR_LEFT_TIME_RECT[3] + "px";
  172. this.m_last_left_time_div.style.left = this.STR_LEFT_TIME_RECT[0] + "px";
  173. this.m_last_left_time_div.style.top = this.STR_LEFT_TIME_RECT[1] + "px";
  174. this.m_last_left_time_div.style.color = "#fff";
  175. this.m_last_left_time_div.style.fontSize = FZ.GameDefs.STATS_FONT_SIZE + "px";
  176. this.m_last_left_time_div.style.fontFamily = "Arial";
  177. this.m_last_left_time_div.style.lineHeight = this.STR_LEFT_TIME_RECT[3] + "px";
  178. this.m_last_left_time_div.style.textAlign = "left";
  179. this.m_main_div.appendChild(this.m_last_left_time_div);
  180. },
  181. createStrScoreDiv : function() {
  182. this.m_last_score_div = document.createElement("div");
  183. this.m_last_score_div.style.position = "absolute";
  184. this.m_last_score_div.style.width = this.STR_SCORE_RECT[2] + "px";
  185. this.m_last_score_div.style.height = this.STR_SCORE_RECT[3] + "px";
  186. this.m_last_score_div.style.left = this.STR_SCORE_RECT[0] + "px";
  187. this.m_last_score_div.style.top = this.STR_SCORE_RECT[1] + "px";
  188. this.m_last_score_div.style.color = "#fff";
  189. this.m_last_score_div.style.fontSize = FZ.GameDefs.STATS_FONT_SIZE + "px";
  190. this.m_last_score_div.style.fontFamily = "Arial";
  191. this.m_last_score_div.style.lineHeight = this.STR_SCORE_RECT[3] + "px";
  192. this.m_last_score_div.style.textAlign = "left";
  193. this.m_main_div.appendChild(this.m_last_score_div);
  194. },
  195. postProcess : function() {
  196. this.fade_out(2000, 0, 0);
  197. },
  198. buttonClick : function(btn) {
  199. // if (this.m_btn_list[this.BTN_MENU_AWARDS_INDEX] === btn) {
  200. // FZ.GameBase.switchToState(FZ.StateDefs.GAME_STATE_CREDITS);
  201. // }
  202. if (this.m_btn_list[this.BTN_MAIN_MENU_IDNEX] === btn) {
  203. FZ.GameBase.switchToState(FZ.StateDefs.GAME_STATE_MAINMEN);
  204. FZ.Game.GameState.m_main_div.style.display = "none";
  205. FZ.Game.GameState.fade_out(2000, 0, 0);
  206. }
  207. }
  208. }, FZ.BaseState))();