home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / hedgehog-launch.swf / scripts / frame_4 / DoAction.as
Encoding:
Text File  |  2008-09-11  |  13.1 KB  |  353 lines

  1. function initializeLevels()
  2. {
  3.    i = 1;
  4.    while(i <= 11)
  5.    {
  6.       setBlip("band",i,bandPrices,bandLevel);
  7.       setBlip("launch",i,launcherPrices,launcherLevel);
  8.       setBlip("rocket",i,rocketPackPrices,rocketPackLevel);
  9.       setBlip("lRocket",i,rocketSidesPrices,leftRocketLevel);
  10.       setBlip("rRocket",i,rocketSidesPrices,rightRocketLevel);
  11.       i++;
  12.    }
  13.    i = 1;
  14.    while(i <= 6)
  15.    {
  16.       setBlip("magnet",i,magnetPrices,magnetLevel);
  17.       i++;
  18.    }
  19.    i = 1;
  20.    while(i <= 4)
  21.    {
  22.       setBlip("eRocket",i,eRocketPrices,eRocketLevel);
  23.       setBlip("parachute",i,parachutePrices,parachuteLevel);
  24.       setBlip("goggles",i,gogglePrices,gogglesLevel);
  25.       setBlip("radar",i,radarPrices,radarLevel);
  26.       i++;
  27.    }
  28. }
  29. function setBlip(str, num, arr, lev)
  30. {
  31.    if(arr[num - 1] < totalCash)
  32.    {
  33.       _root[str + num].gotoAndStop(1);
  34.    }
  35.    else
  36.    {
  37.       _root[str + num].gotoAndStop(3);
  38.    }
  39.    if(lev >= num)
  40.    {
  41.       _root[str + num].gotoAndStop(2);
  42.    }
  43. }
  44. function disp()
  45. {
  46.    cashDisp = "$" + commaMonger(Math.floor(totalCash)) + formatCents(totalCash - Math.floor(totalCash));
  47. }
  48. function roll()
  49. {
  50.    i = 1;
  51.    while(i <= 11)
  52.    {
  53.       detectRoll("band",i,bandPrices,bandLevel);
  54.       detectRoll("launch",i,launcherPrices,launcherLevel);
  55.       detectRoll("rocket",i,rocketPackPrices,rocketPackLevel);
  56.       detectRoll("lRocket",i,rocketSidesPrices,leftRocketLevel);
  57.       detectRoll("rRocket",i,rocketSidesPrices,rightRocketLevel);
  58.       i++;
  59.    }
  60.    i = 1;
  61.    while(i <= 6)
  62.    {
  63.       detectRoll("magnet",i,magnetPrices,magnetLevel);
  64.       i++;
  65.    }
  66.    i = 1;
  67.    while(i <= 4)
  68.    {
  69.       detectRoll("eRocket",i,eRocketPrices,rRocketLevel);
  70.       detectRoll("parachute",i,parachutePrices,parachuteLevel);
  71.       detectRoll("goggles",i,gogglePrices,gogglesLevel);
  72.       detectRoll("radar",i,radarPrices,radarLevel);
  73.       i++;
  74.    }
  75.    costDisp = "$" + commaMonger(dollars) + formatCents(cents);
  76. }
  77. function detectRoll(str, num, arr, lev)
  78. {
  79.    if(_root[str + i].hitTest(_xmouse,_ymouse))
  80.    {
  81.       cost = arr[i - 1];
  82.       dollars = Math.floor(cost);
  83.       cents = cost - dollars;
  84.       curText = _root[str + "Desc"][i - 1];
  85.       _root[str + i].frame._visible = true;
  86.       focusPoint = _root[str + i];
  87.       focusCost = cost;
  88.       focusNum = i;
  89.       focusItem = str;
  90.       biddy._visible = true;
  91.    }
  92.    else
  93.    {
  94.       _root[str + i].frame._visible = false;
  95.    }
  96. }
  97. function formatCents(num)
  98. {
  99.    tempNumber = Math.floor(num * 100);
  100.    if(tempNumber < 10)
  101.    {
  102.       return ".0" + tempNumber;
  103.    }
  104.    if(tempNumber == 0)
  105.    {
  106.       return undefined;
  107.    }
  108.    return "." + tempNumber;
  109. }
  110. function commaMonger(num)
  111. {
  112.    if(num < 1000)
  113.    {
  114.       return String(num);
  115.    }
  116.    len = String(num).length;
  117.    var _loc1_ = new Array();
  118.    i = 0;
  119.    while(i < len)
  120.    {
  121.       _loc1_.push(String(num).charAt(len - 1 - i));
  122.       i++;
  123.    }
  124.    tempString = "";
  125.    i = 0;
  126.    while(i < len)
  127.    {
  128.       if(i % 3 == 0 && i != 0)
  129.       {
  130.          tempString = _loc1_[i] + "," + tempString;
  131.       }
  132.       else
  133.       {
  134.          tempString = _loc1_[i] + tempString;
  135.       }
  136.       i++;
  137.    }
  138.    return tempString;
  139. }
  140. stop();
  141. Mouse.hide();
  142. startDrag(cursor,1,15,55,530,430);
  143. var dayDisp = "Day " + day;
  144. var bandColors = new Array(0,2957663,1730103,811124,7503106,6626075,3431970,6952273,5189937,7948806,4210752);
  145. var bandPrices = new Array(3.25,24.5,54,124,213.25,430.75,890,1639,4592.5,9384.25);
  146. var launcherPrices = new Array(7.25,24.25,48.75,96.5,192.25,384.75,768.5,1536.25,3072,6839.25);
  147. var rocketPackPrices = new Array(15.25,56.25,133,210.75,520.75,760.25,1492.25,2034.75,3012.5,4148.25);
  148. var rocketSidesPrices = new Array(10.25,20.25,40.75,80.25,170.25,350.5,555.5,986,1200.5,1575.75);
  149. var eRocketPrices = new Array(500,1000,1500);
  150. var parachutePrices = new Array(250,500,750);
  151. var magnetPrices = new Array(500,1000,1500,2000,5000);
  152. var gogglePrices = new Array(12.5,46.25,150);
  153. var radarPrices = new Array(250,1000,2000);
  154. var bandDesc = new Array();
  155. bandDesc.push("Band Level 1:  Increases overall elasticity 10%");
  156. bandDesc.push("Band Level 2:  Increases overall elasticity 20%");
  157. bandDesc.push("Band Level 3:  Increases overall elasticity 30%");
  158. bandDesc.push("Band Level 4:  Increases overall elasticity 40%");
  159. bandDesc.push("Band Level 5:  Increases overall elasticity 50%");
  160. bandDesc.push("Band Level 6:  Increases overall elasticity 60%");
  161. bandDesc.push("Band Level 7:  Increases overall elasticity 70%");
  162. bandDesc.push("Band Level 8:  Increases overall elasticity 80%");
  163. bandDesc.push("Band Level 9:  Increases overall elasticity 90%");
  164. bandDesc.push("Band Level 10:  Increases overall elasticity 100%");
  165. var bandPower = new Array(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.1);
  166. var launchDesc = new Array();
  167. launchDesc.push("Launcher Level 1:  Increases launcher height to about 15 feet");
  168. launchDesc.push("Launcher Level 2:  Increases launcher height to about 20 feet");
  169. launchDesc.push("Launcher Level 3:  Increases launcher height to about 25 feet");
  170. launchDesc.push("Launcher Level 4:  Increases launcher height to about 30 feet");
  171. launchDesc.push("Launcher Level 5:  Increases launcher height to about 35 feet");
  172. launchDesc.push("Launcher Level 6:  Increases launcher height to about 40 feet");
  173. launchDesc.push("Launcher Level 7:  Increases launcher height to about 45 feet");
  174. launchDesc.push("Launcher Level 8:  Increases launcher height to about 50 feet");
  175. launchDesc.push("Launcher Level 9:  Increases launcher height to about 60 feet");
  176. launchDesc.push("Launcher Level 10:  Increases launcher height to about 70 feet");
  177. var launchSize = new Array(0,15,20,25,30,35,40,45,50,60,70);
  178. var rocketDesc = new Array();
  179. rocketDesc.push("Rocket Pack Level 1:  Decrease fuel consumption at a rate of 10% less");
  180. rocketDesc.push("Rocket Pack Level 2: Decrease fuel consumption at a rate of 20% less");
  181. rocketDesc.push("Rocket Pack Level 3:  Decrease fuel consumption at a rate of 35% less");
  182. rocketDesc.push("Rocket Pack Level 4:  Decrease fuel consumption at a rate of 60% less");
  183. rocketDesc.push("Rocket Pack Level 5:  Decrease fuel consumption at a rate of 100% less");
  184. rocketDesc.push("Rocket Pack Level 6:  Decrease fuel consumption at a rate of 200% less");
  185. rocketDesc.push("Rocket Pack Level 7:  Decrease fuel consumption at a rate of 300% less");
  186. rocketDesc.push("Rocket Pack Level 8:  Decrease fuel consumption at a rate of 400% less");
  187. rocketDesc.push("Rocket Pack Level 9:  Decrease fuel consumption at a rate of 500% less");
  188. rocketDesc.push("Rocket Pack Level 10:  Decrease fuel consumption at a rate of 800% less");
  189. var rocketSize = new Array(0,0.1,0.2,0.35,0.6,1,2,3,4,5,8);
  190. var lRocketDesc = new Array();
  191. lRocketDesc.push("Left Rocket Level 1:  Increase thrust 25%");
  192. lRocketDesc.push("Left Rocket Level 2: Increase thrust 50%");
  193. lRocketDesc.push("Left Rocket Level 3:  Increase thrust 75%");
  194. lRocketDesc.push("Left Rocket Level 4:  Increase thrust 100%");
  195. lRocketDesc.push("Left Rocket Level 5:  Increase thrust 150%");
  196. lRocketDesc.push("Left Rocket Level 6:  Increase thrust 200%");
  197. lRocketDesc.push("Left Rocket Level 7:  Increase thrust 250%");
  198. lRocketDesc.push("Left Rocket Level 8:  Increase thrust 300%");
  199. lRocketDesc.push("Left Rocket Level 9:  Increase thrust 350%");
  200. lRocketDesc.push("Left Rocket Level 10:  Increase thrust 400%");
  201. var lRocketSize = new Array(0,0.25,0.5,0.75,1,1.5,2,2.5,3,3.5,4);
  202. var rRocketSize = new Array(0,0.25,0.5,0.75,1,1.5,2,2.5,3,3.5,4);
  203. var rRocketDesc = new Array();
  204. rRocketDesc.push("Right Rocket Level 1:  Increase thrust 25%");
  205. rRocketDesc.push("Right Rocket Level 2: Increase thrust 50%");
  206. rRocketDesc.push("Right Rocket Level 3:  Increase thrust 75%");
  207. rRocketDesc.push("Right Rocket Level 4:  Increase thrust 100%");
  208. rRocketDesc.push("Right Rocket Level 5:  Increase thrust 150%");
  209. rRocketDesc.push("Right Rocket Level 6:  Increase thrust 200%");
  210. rRocketDesc.push("Right Rocket Level 7:  Increase thrust 250%");
  211. rRocketDesc.push("Right Rocket Level 8:  Increase thrust 300%");
  212. rRocketDesc.push("Right Rocket Level 9:  Increase thrust 350%");
  213. rRocketDesc.push("Right Rocket Level 10:  Increase thrust 400%");
  214. var magnetDesc = new Array();
  215. magnetDesc.push("Magnet Level 1:  Attract cash 1 foot away");
  216. magnetDesc.push("Magnet Level 2:  Attract cash 2 feet away");
  217. magnetDesc.push("Magnet Level 3:  Attract cash 3 feet away");
  218. magnetDesc.push("Magnet Level 4:  Attract cash 4 feet away");
  219. magnetDesc.push("Magnet Level 5:  Attract cash 5 feet away");
  220. var magnetSize = new Array(0,1,2,3,4,5);
  221. var gogglesDesc = new Array();
  222. gogglesDesc.push("Goggles Level 1:  Look stylish");
  223. gogglesDesc.push("Goggles Level 2:  Look attractive");
  224. gogglesDesc.push("Goggles Level 3:  Look stylish and attractive");
  225. var radarDesc = new Array();
  226. radarDesc.push("Radar Level 1:  See nearby blue launchers");
  227. radarDesc.push("Radar Level 2:  See all nearby launchers");
  228. radarDesc.push("Radar Level 3:  See all nearby launchers in colour");
  229. var eRocketDesc = new Array();
  230. eRocketDesc.push("Emergency Rocket Level 1:  Utilize a backup rocket to launch about 200 feet in the air.  Deploy with up key.  One use.  Recharges each day.");
  231. eRocketDesc.push("Emergency Rocket Level 2:  Use the emergency rocket up to 2 times.  Deploy with up key.  Recharges each day.");
  232. eRocketDesc.push("Emergency Rocket Level 3:  Use the emergency rocket up to 3 times.  Deploy with up key.  Recharges each day.");
  233. var parachuteDesc = new Array();
  234. parachuteDesc.push("Parachute Level 1:  Deploy a parachute to slow descent.  Deploy with down key.  Recharges each day.");
  235. parachuteDesc.push("Parachute Level 2:  Gain a second use of the parachute.  Deploy with down key.  Recharges each day.");
  236. parachuteDesc.push("Parachute Level 3:  Gain a third use of the parachute.  Deploy with down key.  Recharges each day.");
  237. onMouseDown = function()
  238. {
  239.    if(focusPoint.hitTest(_xmouse,_ymouse))
  240.    {
  241.       if(focusCost < totalCash)
  242.       {
  243.          switch(focusItem)
  244.          {
  245.             case "band":
  246.                if(bandLevel < focusNum)
  247.                {
  248.                   bandLevel = focusNum;
  249.                   totalCash -= focusCost;
  250.                   cashIn.start(0,1);
  251.                   initializeLevels();
  252.                }
  253.                break;
  254.             case "launch":
  255.                if(launcherLevel < focusNum)
  256.                {
  257.                   launcherLevel = focusNum;
  258.                   totalCash -= focusCost;
  259.                   cashIn.start(0,1);
  260.                   initializeLevels();
  261.                }
  262.                break;
  263.             case "rocket":
  264.                if(rocketPackLevel < focusNum)
  265.                {
  266.                   rocketPackLevel = focusNum;
  267.                   totalCash -= focusCost;
  268.                   cashIn.start(0,1);
  269.                   initializeLevels();
  270.                }
  271.                break;
  272.             case "lRocket":
  273.                if(leftRocketLevel < focusNum)
  274.                {
  275.                   leftRocketLevel = focusNum;
  276.                   totalCash -= focusCost;
  277.                   cashIn.start(0,1);
  278.                   initializeLevels();
  279.                }
  280.                break;
  281.             case "rRocket":
  282.                if(rightRocketLevel < focusNum)
  283.                {
  284.                   rightRocketLevel = focusNum;
  285.                   totalCash -= focusCost;
  286.                   cashIn.start(0,1);
  287.                   initializeLevels();
  288.                }
  289.                break;
  290.             case "eRocket":
  291.                if(eRocketLevel < focusNum)
  292.                {
  293.                   eRocketLevel = focusNum;
  294.                   totalCash -= focusCost;
  295.                   cashIn.start(0,1);
  296.                   initializeLevels();
  297.                }
  298.                break;
  299.             case "parachute":
  300.                if(parachuteLevel < focusNum)
  301.                {
  302.                   parachuteLevel = focusNum;
  303.                   totalCash -= focusCost;
  304.                   cashIn.start(0,1);
  305.                   initializeLevels();
  306.                }
  307.                break;
  308.             case "magnet":
  309.                if(magnetLevel < focusNum)
  310.                {
  311.                   magnetLevel = focusNum;
  312.                   totalCash -= focusCost;
  313.                   cashIn.start(0,1);
  314.                   initializeLevels();
  315.                }
  316.                break;
  317.             case "radar":
  318.                if(radarLevel < focusNum)
  319.                {
  320.                   radarLevel = focusNum;
  321.                   totalCash -= focusCost;
  322.                   cashIn.start(0,1);
  323.                   initializeLevels();
  324.                }
  325.                break;
  326.             case "goggles":
  327.                if(gogglesLevel < focusNum)
  328.                {
  329.                   gogglesLevel = focusNum;
  330.                   totalCash -= focusCost;
  331.                   cashIn.start(0,1);
  332.                   initializeLevels();
  333.                }
  334.          }
  335.       }
  336.       else
  337.       {
  338.          clicker.start(0,1);
  339.       }
  340.    }
  341. };
  342. var cashIn = new Sound(this);
  343. cashIn.attachSound("cashin");
  344. var clicker = new Sound(this);
  345. clicker.attachSound("click_x");
  346. initializeLevels();
  347. onEnterFrame = function()
  348. {
  349.    roll();
  350.    disp();
  351. };
  352. biddy._visible = false;
  353.