home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 October / INTERNET108.ISO / pc / software / windows / multimed / falafel / falafel-king_eng.exe / scripts / frame_12 / DoAction.as
Encoding:
Text File  |  2002-07-22  |  6.7 KB  |  278 lines

  1. function clickPita()
  2. {
  3.    if(_root.pitaTaken == 0)
  4.    {
  5.       _root.pitaTaken = 1;
  6.       tellTarget("_root.R_Hand")
  7.       {
  8.          gotoAndStop("getting pita");
  9.          play();
  10.       }
  11.    }
  12. }
  13. function rolloverElement(whichClip)
  14. {
  15.    tellTarget("duchan.all_salads.all_" add whichClip._name)
  16.    {
  17.       if(_root.pitaTaken == 1)
  18.       {
  19.          gotoAndPlay("contor " add currentState);
  20.       }
  21.    }
  22. }
  23. function rolloutElement(whichClip)
  24. {
  25.    tellTarget("duchan.all_salads.all_" add whichClip._name)
  26.    {
  27.       gotoAndPlay(currentState);
  28.    }
  29. }
  30. function click_element(whichClip)
  31. {
  32.    if(_root.pitaTaken == 1)
  33.    {
  34.       if(eval("duchan.all_salads.all_" add whichClip._name add ".currentState") != "empty")
  35.       {
  36.          _root.manageElements(eval("duchan.all_salads.all_" add whichClip._name));
  37.          tellTarget("_root.L_Hand")
  38.          {
  39.             gotoAndPlay("getting " add whichClip._name);
  40.             theElement = whichClip;
  41.          }
  42.       }
  43.    }
  44. }
  45. function add_element(whichClip)
  46. {
  47.    whichClip.counter += 1;
  48.    if(whichClip.maxElements >= whichClip.counter)
  49.    {
  50.       whichClip.counterText = whichClip.maxElements - whichClip.counter;
  51.    }
  52.    else
  53.    {
  54.       whichClip.counterText = 0;
  55.    }
  56.    if(whichClip.maxElements < whichClip.counter)
  57.    {
  58.       _root.score -= 5;
  59.       showPoints("-5");
  60.       updateCharInterval();
  61.       _root.buzzSound.start();
  62.    }
  63.    else
  64.    {
  65.       _root.score += 1;
  66.       showPoints("+1");
  67.       updateCharInterval();
  68.    }
  69.    if(whichClip.counter == whichClip.maxElements)
  70.    {
  71.       theElement = "_root.R_Hand.pita." add whichClip._name add "_element";
  72.       eval(theElement)._visible = 1;
  73.       _root.R_Hand.pita.countElements += 1;
  74.       if(R_Hand.pita.countElements == 4)
  75.       {
  76.          _root.pitaIsFull = true;
  77.          _root.manaSound.start();
  78.       }
  79.    }
  80. }
  81. function click_person(whichClip)
  82. {
  83.    if(_root.pitaIsFull == true and _root.achmedIsOut == false)
  84.    {
  85.       _root.givePita(whichClip);
  86.    }
  87.    else
  88.    {
  89.       var checkStatus = 0;
  90.       i = 0;
  91.       while(i < _root.elementList.length)
  92.       {
  93.          theClip = "_root.duchan." add _root.elementList[i];
  94.          if(eval(theClip).counterText == 0)
  95.          {
  96.             checkStatus += 1;
  97.          }
  98.          i++;
  99.       }
  100.       if(checkStatus >= 4 and _root.achmedIsOut == false)
  101.       {
  102.          _root.givePita(whichClip);
  103.       }
  104.    }
  105. }
  106. function givePita(whichClip)
  107. {
  108.    tellTarget(_root.R_Hand)
  109.    {
  110.       gotoAndStop("giving pita");
  111.       play();
  112.       tellTarget(_root.R_Hand.pitaToGive)
  113.       {
  114.          gotoAndPlay("p" add whichClip.posX.charAt(whichClip.posX.length - 1));
  115.       }
  116.    }
  117.    _root.score += 5;
  118.    showPoints("+5");
  119.    tellTarget(whichClip)
  120.    {
  121.       gotoAndStop("with pita");
  122.       play();
  123.    }
  124.    _root.resetPita();
  125. }
  126. function resetPita()
  127. {
  128.    _root.pitaTaken = 0;
  129.    _root.pitaIsFull = false;
  130.    _root.pita.countElements = 0;
  131.    i = 0;
  132.    while(i < _root.elementList.length)
  133.    {
  134.       theClip = "_root.duchan." add _root.elementList[i];
  135.       theElement = "_root.pita." add _root.elementList[i] add "_element";
  136.       eval(theClip).maxElements = Number(findRandom(3));
  137.       eval(theClip).counter = 0;
  138.       eval(theClip).counterText = eval(theClip).maxElements;
  139.       eval(theElement)._visible = 0;
  140.       i++;
  141.    }
  142. }
  143. function updateCharInterval()
  144. {
  145.    if(_root.score < 20)
  146.    {
  147.       _root.charInterval = 10000;
  148.    }
  149.    else if(_root.score < 40)
  150.    {
  151.       _root.charInterval = 8000;
  152.    }
  153.    else if(_root.score < 60)
  154.    {
  155.       _root.charInterval = 5000;
  156.    }
  157.    else if(_root.score < 80)
  158.    {
  159.       _root.charInterval = 2000;
  160.    }
  161.    else if(_root.score >= 120)
  162.    {
  163.       _root.charInterval = 1000;
  164.    }
  165. }
  166. function manageFalafel()
  167. {
  168.    if(_root.L_Hand.falafel_fly1.falafelInAir == true)
  169.    {
  170.       if(_root.L_Hand.falafel_fly2.falafelInAir == true)
  171.       {
  172.          if(_root.L_Hand.falafel_fly3.falafelInAir != true)
  173.          {
  174.             tellTarget("_root.L_Hand.falafel_fly3")
  175.             {
  176.                _visible = 1;
  177.                play();
  178.             }
  179.          }
  180.       }
  181.       else
  182.       {
  183.          tellTarget("_root.L_Hand.falafel_fly2")
  184.          {
  185.             _visible = 1;
  186.             play();
  187.          }
  188.       }
  189.    }
  190.    else
  191.    {
  192.       tellTarget("_root.L_Hand.falafel_fly1")
  193.       {
  194.          _visible = 1;
  195.          play();
  196.       }
  197.    }
  198. }
  199. function manageElements(whichElement)
  200. {
  201.    if(0 < whichElement.quantity)
  202.    {
  203.       whichElement.quantity -= 1;
  204.    }
  205.    if(0.75 < whichElement.quantity / _root.fullQuantity)
  206.    {
  207.       whichElement.currentState = "full";
  208.       whichElement.currentStateNum = 4;
  209.       whichElement.currentPercent = "100%";
  210.    }
  211.    else if(0.5 < whichElement.quantity / _root.fullQuantity)
  212.    {
  213.       whichElement.currentState = "TQ";
  214.       whichElement.currentStateNum = 3;
  215.       whichElement.currentPercent = "75%";
  216.    }
  217.    else if(0.25 < whichElement.quantity / _root.fullQuantity)
  218.    {
  219.       whichElement.currentState = "Half";
  220.       whichElement.currentStateNum = 2;
  221.       whichElement.currentPercent = "50%";
  222.    }
  223.    else if(0 < whichElement.quantity / _root.fullQuantity)
  224.    {
  225.       whichElement.currentState = "QT";
  226.       whichElement.currentStateNum = 1;
  227.       whichElement.currentPercent = "25%";
  228.    }
  229.    else
  230.    {
  231.       whichElement.currentState = "empty";
  232.       whichElement.currentStateNum = 0;
  233.       whichElement.currentPercent = "0%";
  234.    }
  235.    tellTarget(whichElement)
  236.    {
  237.       gotoAndPlay(String(currentState));
  238.       percent_indicator.gotoAndPlay("n-" add currentState);
  239.    }
  240. }
  241. function fillUp(elementName)
  242. {
  243.    currentStateNum = eval("duchan.all_salads.all_" add elementName add ".currentStateNum");
  244.    if(currentStateNum < 4)
  245.    {
  246.       currentStateNum += 1;
  247.       quantity = currentStateNum * Math.round(_root.fullQuantity / 4);
  248.       if(currentStateNum == 4)
  249.       {
  250.          currentState = "full";
  251.       }
  252.       else if(currentStateNum == 3)
  253.       {
  254.          currentState = "TQ";
  255.       }
  256.       else if(currentStateNum == 2)
  257.       {
  258.          currentState = "Half";
  259.       }
  260.       else if(currentStateNum == 1)
  261.       {
  262.          currentState = "QT";
  263.       }
  264.       else
  265.       {
  266.          currentState = "Empty";
  267.       }
  268.       set("duchan.all_salads.all_" add elementName add ".quantity",quantity);
  269.       set("duchan.all_salads.all_" add elementName add ".currentState",currentState);
  270.       set("duchan.all_salads.all_" add elementName add ".currentStateNum",currentStateNum);
  271.       tellTarget("duchan.all_salads.all_" add elementName)
  272.       {
  273.          gotoAndPlay(String(currentState));
  274.          percent_indicator.gotoAndPlay("n-" add currentState);
  275.       }
  276.    }
  277. }
  278.