home *** CD-ROM | disk | FTP | other *** search
/ Mobiclic 150 / MOBICLIC150.ISO / pc / DATA / DSS150 / DSS150_04 / DSS150_04.swf / scripts / dss150_04 / CapsuleAlgo.as < prev    next >
Text File  |  2012-12-19  |  5KB  |  177 lines

  1. package dss150_04
  2. {
  3.    import com.milanpresse.engineaddons.facades.GameEngine;
  4.    import com.milanpresse.engineaddons.gamesprotos.Actor;
  5.    import com.milanpresse.engineaddons.gamesprotos.actors.actorClip.IActorClip;
  6.    import com.milanpresse.tools.debug.TestBox;
  7.    import dss150.Memo;
  8.    
  9.    public class CapsuleAlgo
  10.    {
  11.        
  12.       
  13.       protected var game:GameEngine;
  14.       
  15.       protected var mainTimeline:IActorClip;
  16.       
  17.       public var moduleConfig:ModuleConfig;
  18.       
  19.       protected var testBox:TestBox;
  20.       
  21.       protected var memo:Memo;
  22.       
  23.       public function CapsuleAlgo(game:GameEngine)
  24.       {
  25.          super();
  26.          this.game = game;
  27.          this.memo = game.memo as Memo;
  28.          this.memo.savePoint.moduleNum = game.config.moduleNum;
  29.          this.memo.save();
  30.          if(game.config.callerParameters.fromCodeRub == null)
  31.          {
  32.             this.memo.clear();
  33.          }
  34.          this.init();
  35.       }
  36.       
  37.       protected function init() : void
  38.       {
  39.          this.game.framerate = 24;
  40.          this.game.levelCZ = this.game.config.layers.content;
  41.          this.game.moduleConfig = new ModuleConfig(this.game.config.XmlConfig.Module.Config.Params);
  42.          trace(this.game.moduleConfig.toXMLString());
  43.          this.testBox = new TestBox(this.game.engine);
  44.          this.testBox.buttons = [{
  45.             "name":"BTN_ATTENTE",
  46.             "label":"ATTENTE"
  47.          },{
  48.             "name":"BTN_SUCCES",
  49.             "label":"SUCCES"
  50.          },{
  51.             "name":"BTN_FIN",
  52.             "label":"FIN"
  53.          }];
  54.          this.testBox.onClick = function(action:String):void
  55.          {
  56.             trace("TestBoxClick",action);
  57.             switch(action)
  58.             {
  59.                case "BTN_PAUSE":
  60.                   game.sleep();
  61.                   break;
  62.                case "BTN_WAKE":
  63.                   game.wake();
  64.                   break;
  65.                case "BTN_ATTENTE":
  66.                   game.commentStop();
  67.                   mainTimeline.gotoAndPlay("ATTENTE",{
  68.                      "labelLast":"FIN",
  69.                      "labelLastCallback":gameEnd
  70.                   });
  71.                   break;
  72.                case "BTN_SUCCES":
  73.                   if(game.getActor("jeu") != null)
  74.                   {
  75.                      game.getActor("jeu").destroy();
  76.                   }
  77.                   memo.module.succes = true;
  78.                   memo.save();
  79.                   mainTimeline.gotoAndPlay(mainTimeline["LABEL_SUCCES"],{
  80.                      "labelLast":"FIN",
  81.                      "labelLastCallback":gameEnd
  82.                   });
  83.                   break;
  84.                case "BTN_FIN":
  85.                   gameEnd();
  86.             }
  87.          };
  88.          this.testBox.visible = false;
  89.          this.mainTimeline = this.game.addActor({
  90.             "code":"A_" + this.game.config.moduleName,
  91.             "parent":this.game.config.layers.content
  92.          });
  93.          this.mainTimeline["LABEL_SUCCES"] = "WAIT_zanimJEU";
  94.          this.mainTimeline.onLabelEnter = this.onLabelEnter;
  95.          this.mainTimeline.onLabelExit = this.onLabelExit;
  96.       }
  97.       
  98.       public function gameEnd() : void
  99.       {
  100.          this.game.commentStop();
  101.          this.memo.module.vu = true;
  102.          this.memo.savePoint.moduleNum = 0;
  103.          this.memo.save();
  104.          this.game.changeModule({"numMod":0});
  105.       }
  106.       
  107.       public function start() : void
  108.       {
  109.          this.game.playMusic({"code":"MU"});
  110.          if(this.memo.module.succes)
  111.          {
  112.             this.mainTimeline.gotoAndPlay(this.mainTimeline["LABEL_SUCCES"],{
  113.                "labelLast":"FIN",
  114.                "labelLastCallback":this.gameEnd
  115.             });
  116.          }
  117.          else
  118.          {
  119.             this.mainTimeline.gotoAndPlay(this.mainTimeline.currentLabels[0].name,{
  120.                "labelLast":"FIN",
  121.                "labelLastCallback":this.gameEnd
  122.             });
  123.          }
  124.       }
  125.       
  126.       public function onLabelEnter(result:Object = null) : void
  127.       {
  128.          var jeuac:Actor = null;
  129.          var jeu:ATTENTE = null;
  130.          trace("onLabelEnter",result.label);
  131.          if(result.label.search(/^ATTENTE/) != -1)
  132.          {
  133.             jeuac = this.game.addActor(new Actor(this.game));
  134.             jeuac.name = "jeu";
  135.             jeu = new ATTENTE(this.game,this.mainTimeline);
  136.             jeu.onEvent = function(event:Object = null):void
  137.             {
  138.                game.noisePlay({"code":"B_SUCCES"});
  139.                mainTimeline.gotoAndPlay("_12_JEU_S",{
  140.                   "labelLast":"FIN",
  141.                   "labelLastCallback":gameEnd
  142.                });
  143.             };
  144.             jeuac.sleep = function():void
  145.             {
  146.                jeu.sleep();
  147.             };
  148.             jeuac.wake = function():void
  149.             {
  150.                jeu.wake();
  151.             };
  152.             jeuac.destroy = function():void
  153.             {
  154.                jeu.destroy();
  155.             };
  156.          }
  157.       }
  158.       
  159.       public function onLabelExit(result:Object = null) : void
  160.       {
  161.          trace("onLabelExit",result.label);
  162.       }
  163.       
  164.       public function sleep() : void
  165.       {
  166.       }
  167.       
  168.       public function wake() : void
  169.       {
  170.       }
  171.       
  172.       public function destroy() : void
  173.       {
  174.       }
  175.    }
  176. }
  177.