00.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. $(document).ready(function() {
  2. var way;
  3. var startTime;
  4. var timeUse;
  5. var timeStr;
  6. var timer;
  7. $(".start").bind("click", start);
  8. $(".go").bind("click", go);
  9. $(".more").bind("click", more);
  10. $(".reload").bind("click", reload);
  11. $(".help").bind("click", help);
  12. $(".xuanyao").bind("click", xuanyao);
  13. init();
  14. function init() {
  15. way = "R";
  16. for (var i = 1; i <= 3; i++) {
  17. var boy = new Avatar("boy");
  18. boy.land()
  19. };
  20. for (var i = 1; i <= 3; i++) {
  21. var girl = new Avatar("girl");
  22. girl.land()
  23. }
  24. };
  25. function Avatar(sex) {
  26. var div = $("<div></div>").addClass(sex);
  27. div.bind("click", click);
  28. this.land = land;
  29. this.boat = boat;
  30. function click() {
  31. var myWay = ($(this).parents(".L").size() == 1 ? "L": "R");
  32. var onBoat = ($(this).parents(".boat").size() == 1);
  33. var onLand = ($(this).parents(".land").size() == 1);
  34. if (onLand && myWay != way) return;
  35. if (onBoat) {
  36. land()
  37. } else {
  38. if (boatNum() < 2) boat()
  39. };
  40. if (boatNum() == 0) $(".go").hide();
  41. if (boatNum() > 0) $(".go").show();
  42. if (way == "L" && landNum() == 6) success()
  43. };
  44. function boatNum() {
  45. return $(".boat .boy, .boat .girl").size()
  46. };
  47. function landNum() {
  48. return $(".land." + way + " .boy, .land." + way + " .girl").size()
  49. };
  50. function boat() {
  51. var boat = $(".boat .seat:empty:first");
  52. boat.append(div)
  53. };
  54. function land() {
  55. var line = $(".land." + way + " .line_" + sex + ":empty:first");
  56. line.append(div)
  57. }
  58. };
  59. function go() {
  60. var ok = true;
  61. var boyNum = $(".land." + way + " .boy").size();
  62. var girlNum = $(".land." + way + " .girl").size();
  63. if (girlNum != 0 && boyNum > girlNum) ok = false;
  64. var toAni,
  65. toWay;
  66. if (way == "L") {
  67. toAni = {
  68. left: 160
  69. };
  70. toWay = "R"
  71. } else {
  72. toAni = {
  73. left: 0
  74. };
  75. toWay = "L"
  76. };
  77. way = "onTheWay";
  78. $(".boat").animate(toAni, "normal", "swing",
  79. function() {
  80. way = toWay;
  81. var boyNum = $(".land." + way + " .boy, .boat .boy").size();
  82. var girlNum = $(".land." + way + " .girl, .boat .girl").size();
  83. if (girlNum != 0 && boyNum > girlNum) ok = false;
  84. if (!ok) failure()
  85. })
  86. };
  87. function failure() {
  88. clearInterval(timer);
  89. $(".mask").show();
  90. $(".go").hide();
  91. $(".failure").show();
  92. $(".help").show();
  93. $(".reload").show();
  94. failHandler(timeUse)
  95. };
  96. function success() {
  97. clearInterval(timer);
  98. $(".mask").show();
  99. $(".go").hide();
  100. $(".time").hide();
  101. $(".success").show();
  102. $(".more").css("left", 150).css("top", 270).show();
  103. $(".reload").show();
  104. $(".result").text("你用了 " + timeStr + " 完成了任务!").show();
  105. successHandler( - 1, timeUse)
  106. };
  107. function start() {
  108. $(".mask").hide();
  109. $(".welcome").hide();
  110. $(".start").hide();
  111. $(".more").hide();
  112. $(".time").show();
  113. startTime = new Date();
  114. timer = setInterval(function() {
  115. timeUse = new Date() - startTime;
  116. var m = parseInt(timeUse / 1000 / 60);
  117. var s = (timeUse / 1000) % 60;
  118. timeStr = (m > 0 ? m + "分": "") + s.toFixed(2) + "秒";
  119. $(".time").text("用时:" + timeStr)
  120. },
  121. 25)
  122. };
  123. function reload() {
  124. $(".success").hide();
  125. $(".failure").hide();
  126. $(".reload").hide();
  127. $(".help").hide();
  128. $(".xuanyao").hide();
  129. $(".time").text("").hide();
  130. $(".result").text("").hide();
  131. $(".boat").css("left", 160);
  132. $(".welcome").show();
  133. $(".start").show();
  134. $(".more").css("left", 80).css("top", 250).show();
  135. $(".boy, .girl").remove();
  136. init()
  137. };
  138. function more() {
  139. moreHandler()
  140. };
  141. function help() {
  142. helpHandler(timeUse)
  143. };
  144. function xuanyao() {
  145. xuanyaoHandler(timeUse)
  146. }
  147. }); (function() {
  148. var ga = document.createElement('script');
  149. ga.type = 'text/javascript';
  150. ga.async = true;
  151. ga.src = 'http://game.ikongzhong.cn/games/';
  152. var s = document.getElementsByTagName('script')[0];
  153. s.parentNode.insertBefore(ga, s);
  154. ga.onload = function() {
  155. ga.parentNode.removeChild(ga)
  156. }
  157. })();
  158. var mebtnopenurl = 'http://mp.weixin.qq.com/s?__biz=MzI4MjA2MjE0MQ==&mid=246005295&idx=1&sn=490f8141976d607ba079d48f52a3fcd7#rd';
  159. window.shareData = {
  160. "imgUrl": "http://game.ikongzhong.cn/games/selang/icon.png",
  161. "timeLineLink": "http://game.ikongzhong.cn/games/selang/",
  162. "tTitle": "小心色狼-空中传媒游戏",
  163. "tContent": "小女生和怪蜀黍一起出游发生的事情"
  164. };
  165. var helpCount = 0;
  166. function successHandler(m, t) {
  167. helpCount = 0;
  168. $("#share img").attr("src", "2000.png");
  169. document.title = t / 1000 + "秒!空中传媒游戏《小心色狼》我刚通过了!你敢不敢和我比一下?";
  170. window.shareData.tTitle = document.title
  171. };
  172. function failHandler(t) {
  173. helpCount++;
  174. if (helpCount > 2) {
  175. if (confirm("是不是没有想象的那么简单?您有【一次机会】获得提示,点击关注公众号并回复【小心色狼怎么过】可以得到提示,是否需要提示?")) {
  176. location.href = "http://mp.weixin.qq.com/s?__biz=MzI4MjA2MjE0MQ==&mid=246005295&idx=1&sn=490f8141976d607ba079d48f52a3fcd7#rd"
  177. };
  178. helpCount = 0
  179. }
  180. };
  181. function helpHandler(t) {
  182. if (confirm("是否转发给朋友,让朋友一起帮你解决这个难题?")) {
  183. dp_shareHelp(t)
  184. }
  185. };
  186. function xuanyaoHandler(t) {
  187. dp_share(t)
  188. };
  189. function moreHandler() {
  190. window.location.href = "http://game.ikongzhong.cn/"
  191. };
  192. function dp_shareHelp(t) {
  193. $("#share img").attr("src", "share.png");
  194. document.title = "我花了" + t / 1000 + "秒!空中传媒游戏《小心色狼》还没解开!快来帮帮我吧!";
  195. document.getElementById("share").style.display = "";
  196. window.shareData.tTitle = document.title
  197. };
  198. function dp_share(t) {
  199. $("#share img").attr("src", "2000.png");
  200. document.title = t / 1000 + "秒!空中传媒游戏《小心色狼》我刚通过了!你敢不敢和我比一下?";
  201. document.getElementById("share").style.display = "";
  202. window.shareData.tTitle = document.title
  203. };
  204. function dp_Ranking() {
  205. window.location = mebtnopenurl
  206. };
  207. function showAd() {};
  208. function hideAd() {};
  209. document.addEventListener('WeixinJSBridgeReady',
  210. function onBridgeReady() {
  211. WeixinJSBridge.on('menu:share:appmessage',
  212. function(argv) {
  213. WeixinJSBridge.invoke('sendAppMessage', {
  214. "img_url": window.shareData.imgUrl,
  215. "link": window.shareData.timeLineLink,
  216. "desc": window.shareData.tContent,
  217. "title": window.shareData.tTitle
  218. },
  219. function(res) {
  220. document.location.href = mebtnopenurl
  221. })
  222. });
  223. WeixinJSBridge.on('menu:share:timeline',
  224. function(argv) {
  225. WeixinJSBridge.invoke('shareTimeline', {
  226. "img_url": window.shareData.imgUrl,
  227. "img_width": "640",
  228. "img_height": "640",
  229. "link": window.shareData.timeLineLink,
  230. "desc": window.shareData.tContent,
  231. "title": window.shareData.tTitle
  232. },
  233. function(res) {
  234. document.location.href = mebtnopenurl
  235. })
  236. })
  237. },
  238. false);