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

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