home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / cannonballfollier3.swf / scripts / frame_1 / DoAction_5.as < prev    next >
Encoding:
Text File  |  2007-10-01  |  6.9 KB  |  299 lines

  1. function cGame()
  2. {
  3.    this.piLevel = 0;
  4.    this.piMaxLevel = 15;
  5.    this.piShotCount = 0;
  6.    _root.giTotalShots = 0;
  7.    _root.gems = 0;
  8.    this.piAngle = 0;
  9.    this.piPower = 0;
  10.    this.piMaxPower = 15;
  11.    this.pbActive = false;
  12.    this.pbRedBallActive = false;
  13.    this.poBall = new cBall("cannonball");
  14.    this.paLevelStarts = [[],[-300,0],[-200,0],[-300,0],[-300,100],[-200,0],[0,0],[-200,0],[-250,0],[-300,0],[-340,0],[-300,0],[-200,0],[-100,0],[-390,0],[-200,0]];
  15. }
  16. cGame.prototype.mNextLevel = function()
  17. {
  18.    this.piLevel = this.piLevel + 1;
  19.    this.psLevel = "level" + this.piLevel;
  20.    _root.map_clip.map.gotoAndPlay(this.psLevel);
  21. };
  22. cGame.prototype.mUpdateLevel = function()
  23. {
  24.    this.mSetLevelStartPos();
  25.    if(this.piLevel < 10)
  26.    {
  27.       var lsLevel = "0" + this.piLevel;
  28.    }
  29.    else
  30.    {
  31.       var lsLevel = "" + this.piLevel;
  32.    }
  33.    _root.gsLevel = lsLevel;
  34.    this.piShotCount = 0;
  35.    this.mUpdateShots();
  36.    this.mUpdateBonus();
  37.    this.mUpdateAngle();
  38.    this.mUpdatePower();
  39.    _root.action_layer.level_clip.gotoAndPlay(this.psLevel);
  40. };
  41. cGame.prototype.mSetLevelStartPos = function()
  42. {
  43.    var laStart = this.paLevelStarts[this.piLevel];
  44.    _root.action_layer._x = laStart[0];
  45.    _root.action_layer._y = laStart[1];
  46. };
  47. cGame.prototype.mShowInstructions = function()
  48. {
  49.    if(this.piMaxLevel >= this.piLevel)
  50.    {
  51.       _root.instructions_clip.gotoAndPlay(this.psLevel);
  52.    }
  53. };
  54. cGame.prototype.mStartLevel = function()
  55. {
  56.    this.pbGem = false;
  57.    _root.action_layer.level_clip.level.mStart();
  58.    this.mActivate();
  59. };
  60. cGame.prototype.mAdvanceEarly = function()
  61. {
  62.    if(_root.gbTestMode)
  63.    {
  64.       this.mLevelComplete();
  65.    }
  66. };
  67. cGame.prototype.mLevelComplete = function()
  68. {
  69.    this.mPlaySound;
  70.    this.mDeactivate();
  71.    var liBonus = 10 - (this.piShotCount - 1);
  72.    if(liBonus < 0)
  73.    {
  74.       liBonus = 0;
  75.    }
  76.    if(10 < liBonus)
  77.    {
  78.       liBonus = 10;
  79.    }
  80.    var lsBonus = "bonus" + liBonus;
  81.    var liGemBonus = 1;
  82.    if(this.pbGem == true)
  83.    {
  84.       liGemBonus = 2;
  85.    }
  86.    this.piScore += liBonus * 1000 * liGemBonus;
  87.    this.mUpdateScore();
  88.    this.piPower = 0;
  89.    this.piAngle = 0;
  90.    this.mUpdatePower();
  91.    this.mUpdateAngle();
  92.    _root.bonus_clip.gotoAndPlay(lsBonus);
  93.    if(this.pbGem)
  94.    {
  95.       _root.bonus_clip.times2.gotoAndPlay(2);
  96.    }
  97. };
  98. cGame.prototype.mUpdateScore = function()
  99. {
  100.    var lsTemp = "" + this.piScore;
  101.    var liZeroes = 6 - lsTemp.length;
  102.    var lsScore = "";
  103.    if(liZeroes < 0)
  104.    {
  105.       liZeroes = 0;
  106.    }
  107.    i = 0;
  108.    while(i < liZeroes)
  109.    {
  110.       lsScore += "0";
  111.       i++;
  112.    }
  113.    lsScore += this.piScore;
  114.    _root.gScore = lsScore;
  115. };
  116. cGame.prototype.mActivate = function()
  117. {
  118.    _root.controller_clip2.gotoAndPlay("on");
  119.    _root.action_layer.sam_clip.cannon_clip.gotoAndPlay("on");
  120.    _root.action_layer.pbReturn = true;
  121.    _root.action_layer.level_clip.level.mReset();
  122.    this.pbActive = true;
  123. };
  124. cGame.prototype.mDeactivate = function()
  125. {
  126.    _root.controller_clip2.gotoAndPlay("off");
  127.    _root.action_layer.sam_clip.cannon_clip.gotoAndPlay("off");
  128.    this.pbActive = false;
  129. };
  130. cGame.prototype.mFire = function()
  131. {
  132.    if(this.pbActive)
  133.    {
  134.       this.pbGreyBallActive = true;
  135.       this.pbRedBallActive = false;
  136.       this.mDeactivate();
  137.       this.piShotCount = this.piShotCount + 1;
  138.       _root.giTotalShots = _root.giTotalShots + 1;
  139.       this.mUpdateShots();
  140.       var liBonus = 10000 - (this.piShotCount - 1) * 1000;
  141.       if(0 >= liBonus)
  142.       {
  143.          liBonus = 0;
  144.          _root.gsBonus = "0000";
  145.       }
  146.       else
  147.       {
  148.          _root.gsBonus = "" + liBonus;
  149.       }
  150.       _root.action_layer.sam_clip.sam.play();
  151.       _root.action_layer.sam_clip.cannon_clip.gotoAndPlay("fire");
  152.       this.poBall.mFire(this.piAngle * -1,13 + this.piPower);
  153.    }
  154. };
  155. cGame.prototype.mSplash = function()
  156. {
  157.    _root.action_layer.splash_clip._x = this.poBall.pmClip._x;
  158.    _root.action_layer.splash_clip.gotoAndPlay("splash");
  159.    this.poBall.mHide();
  160. };
  161. cGame.prototype.mRedBallSplash = function(x)
  162. {
  163.    _root.action_layer.splash2_clip._x = x + 400;
  164.    _root.action_layer.splash2_clip.gotoAndPlay("splash");
  165. };
  166. cGame.prototype.mRedSplashResume = function()
  167. {
  168.    this.pbRedBallActive = false;
  169.    _root.action_layer.level_clip.redball.mReset();
  170.    if(this.pbGreyBallActive == false)
  171.    {
  172.       this.mActivate();
  173.    }
  174. };
  175. cGame.prototype.mSplashResume = function()
  176. {
  177.    this.pbGreyBallActive = false;
  178.    if(this.pbRedBallActive == false)
  179.    {
  180.       this.mActivate();
  181.    }
  182. };
  183. cGame.prototype.mLessPower = function()
  184. {
  185.    if(this.pbActive)
  186.    {
  187.       if(0 < this.piPower)
  188.       {
  189.          this.piPower--;
  190.          this.mPlaySound("eyebrow");
  191.       }
  192.       this.mUpdatePower();
  193.    }
  194. };
  195. cGame.prototype.mMorePower = function()
  196. {
  197.    if(this.pbActive)
  198.    {
  199.       if(this.piPower < this.piMaxPower)
  200.       {
  201.          this.piPower = this.piPower + 1;
  202.          this.mPlaySound("eyebrow");
  203.       }
  204.       this.mUpdatePower();
  205.    }
  206. };
  207. cGame.prototype.mUpdatePower = function()
  208. {
  209.    _root.interface_clip.power.gotoAndStop(this.piPower + 1);
  210. };
  211. cGame.prototype.mLessAngle = function()
  212. {
  213.    if(this.pbActive)
  214.    {
  215.       if(0 < this.piAngle)
  216.       {
  217.          this.piAngle -= 5;
  218.          this.mPlaySound("eyebrow");
  219.       }
  220.       this.mUpdateAngle();
  221.    }
  222. };
  223. cGame.prototype.mMoreAngle = function()
  224. {
  225.    if(this.pbActive)
  226.    {
  227.       if(this.piAngle < 90)
  228.       {
  229.          this.piAngle += 5;
  230.          this.mPlaySound("eyebrow");
  231.       }
  232.       this.mUpdateAngle();
  233.    }
  234. };
  235. cGame.prototype.mUpdateAngle = function()
  236. {
  237.    _root.action_layer.sam_clip.cannon_clip._rotation = this.piAngle * -1;
  238. };
  239. cGame.prototype.mUpdateBonus = function()
  240. {
  241.    var liIndex = 10 - this.piShotCount;
  242.    if(liIndex < 0)
  243.    {
  244.       liIndex = 0;
  245.    }
  246.    var liBonus = 1000 * liIndex;
  247.    _root.gsBonus = liBonus;
  248. };
  249. cGame.prototype.mUpdateShots = function()
  250. {
  251.    if(this.piShotCount < 10)
  252.    {
  253.       var lsShots = "00" + this.piShotCount;
  254.    }
  255.    else if(this.piShotCount < 100)
  256.    {
  257.       var lsShots = "0" + this.piShotCount;
  258.    }
  259.    else
  260.    {
  261.       var lsShots = "" + this.piShotCount;
  262.    }
  263.    _root.gsShot = lsShots;
  264. };
  265. cGame.prototype.mPlaySound = function(lsSound)
  266. {
  267.    loSound = new Sound();
  268.    loSound.attachSound(lsSound);
  269.    loSound.start();
  270. };
  271. cGame.prototype.mSoundOn = function()
  272. {
  273.    _root.gbSound = true;
  274.    _root.goSound = new Sound();
  275.    _root.goSound.setVolume(_root.giOldVolume);
  276. };
  277. cGame.prototype.mSoundOff = function()
  278. {
  279.    _root.gbSound = false;
  280.    _root.goSound = new Sound();
  281.    if(_root.giOldVolume == undefined)
  282.    {
  283.       _root.giOldVolume = _root.goSound.getVolume();
  284.    }
  285.    _root.goSound.setVolume(0);
  286. };
  287. cGame.prototype.mShowMiniHelp = function()
  288. {
  289.    _root.minihelp.gotoAndPlay(2);
  290. };
  291. cGame.prototype.mHelpDone = function()
  292. {
  293. };
  294. cGame.prototype.mCollectCrystal = function()
  295. {
  296.    _root.gems = _root.gems + 1;
  297.    this.pbGem = true;
  298. };
  299.