home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 145
/
MOBICLIC145.ISO
/
pc
/
DATA
/
DSS145
/
DSS145_06
/
DSS145_06.swf
/
scripts
/
dss145_06
/
CapsuleAlgo.as
< prev
Wrap
Text File
|
2012-07-18
|
23KB
|
663 lines
package dss145_06
{
import com.milanpresse.engine.Engine;
import com.milanpresse.engine.initmovieclip.InteractiveMovie;
import com.milanpresse.engine.managers.PauseManager;
import com.milanpresse.engine.managers.TimelineManager;
import com.milanpresse.engine.medias.MediaSwf;
import com.milanpresse.engine.timelines.Timeline;
import com.milanpresse.engine.timelines.TimelineLinear;
import com.milanpresse.engine.typeargument.CommentObject;
import com.milanpresse.engine.typeargument.NoiseObject;
import com.milanpresse.tools.GlobalesFunctions;
import flash.display.MovieClip;
import flash.geom.Point;
import flash.net.SharedObject;
public class CapsuleAlgo
{
private var menu:MediaSwf;
private var menuTimeline:MovieClip;
private var menuTL:Timeline;
private var mainClip:MediaSwf;
private var mainTimeline:MovieClip;
private var _engine:Engine;
private var labelList:Array;
private var _timeline_:TimelineLinear;
private var _timelineManager:TimelineManager;
private var _pauseManager:PauseManager;
private var labelsCallback:Object;
private var firstLabel:String;
private var so:SharedObject;
private var gListDone:Array;
private var gListeObjet:Array;
private var gListeCibles:Array;
private var gListeCurrentCibles:Array;
private var gDoneDepart:Boolean;
private var BT_RETOUR:BtRetour;
private var FLEUVE_01:MovieClip;
private var FLEUVE_02:MovieClip;
private var gListeDone:Array;
private var gPosFleuve1:int;
private var gPosFleuve2:int;
private var gDrag:MovieClip = null;
private var gObjet:MovieClip;
private var commentEchecNum:int = 1;
private var gOkBad:String;
private var gNumFleuve:int;
private var gNumObstacle:int;
private var gListeLM:Array;
private var gFirstTime:Boolean = true;
public function CapsuleAlgo(engine:Engine)
{
this.labelsCallback = {"_11":"prioAnim"};
this.gListeLM = [];
super();
this._engine = engine;
this._engine.playMusic({"code":"MU"});
this._engine.setSubtitles(this._engine.host.subtitlesOn);
this._engine.setFrameRate(12);
this.mainClip = this._engine.showSwf({
"code":"A_" + this._engine.config.moduleName,
"parent":this._engine.config.layers["content"]
});
this.mainTimeline = this.mainClip.swfContent;
this._timelineManager = new TimelineManager();
this._timeline_ = new TimelineLinear(this.mainTimeline,this._engine,this,this._timelineManager,this.labelsCallback);
this._engine.levelCZ = this._engine.config.layers["content"];
this.firstLabel = this.mainTimeline.currentLabels[0].name;
this._timeline_.GotoAndPlayUntil({"labelStop":this.firstLabel});
this.so = SharedObject.getLocal(this._engine.config.rubriqueName,"/");
this.gListDone = this.so.data.listDone;
this.gDoneDepart = this.gListDone[this._engine.config.moduleNum - 1] == 1;
this.BT_RETOUR = new BtRetour(this._engine,this._timelineManager,this.so);
}
public function labelATTENTE_JEU() : void
{
var i:int = 0;
var j:int = 0;
var myMc:InteractiveMovie = null;
if(this.gFirstTime == true)
{
this.gFirstTime = false;
this._engine.hideLM({"into":this.mainTimeline.LM_DEPOT_01_01});
this._engine.hideLM({"into":this.mainTimeline.LM_DEPOT_01_02});
this._engine.hideLM({"into":this.mainTimeline.LM_DEPOT_01_03});
this._engine.hideLM({"into":this.mainTimeline.LM_DEPOT_02_01});
this._engine.hideLM({"into":this.mainTimeline.LM_DEPOT_02_02});
this._engine.hideLM({"into":this.mainTimeline.LM_DEPOT_02_03});
}
else
{
for(i = 1; i <= 2; i++)
{
for(j = 1; j <= 3; j++)
{
if(this.gListeLM.indexOf("LM_DEPOT_0" + i + "_0" + j) !== -1)
{
this._engine.hideLM({"into":this.mainTimeline["LM_DEPOT_0" + i + "_0" + j]});
this.gListeLM.splice(this.gListeLM.indexOf("LM_DEPOT_0" + i + "_0" + j),1);
}
}
}
}
trace("labelATTENTE_JEU");
this.gListeDone = [[0,0,0],[0,0,0]];
this.gListeObjet = [[1,2,3],[4,5,6]];
this.gListeCibles = [[[],[],[]],[[],[],[]]];
this.gPosFleuve1 = 0;
this.gPosFleuve2 = 0;
this.FLEUVE_01 = new InteractiveMovie(this.mainTimeline["FLEUVE_01"],this._timelineManager);
this.FLEUVE_01.gotoAndStop("E" + this.gPosFleuve1);
this.FLEUVE_02 = new InteractiveMovie(this.mainTimeline["FLEUVE_02"],this._timelineManager);
this.FLEUVE_02.gotoAndStop("E" + this.gPosFleuve2);
for(i = 1; i <= 8; i++)
{
myMc = new InteractiveMovie(this.mainTimeline["OBJ_" + this.G2D(i)],this._timelineManager);
myMc.mc.pNum = i;
myMc.mc.pNoiseRoll = "B_" + this.G2D(i);
myMc.mc.pNoiseClic = "B_CLIC";
myMc.gotoAndStop("E1");
this.initMc(myMc);
}
for(i = 1; i <= 2; i++)
{
for(j = 1; j <= 3; j++)
{
myMc = new InteractiveMovie(this.mainTimeline["OK_" + this.G2D(i) + "_" + this.G2D(j)],this._timelineManager);
myMc.mc.pNumFleuve = i;
myMc.mc.pNum = j;
myMc.gotoAndStop("E0");
this.gListeCibles[i - 1][j - 1].push(myMc);
myMc = new InteractiveMovie(this.mainTimeline["BAD_" + this.G2D(i) + "_" + this.G2D(j)],this._timelineManager);
myMc.mc.pNumFleuve = i;
myMc.mc.pNum = j;
myMc.gotoAndStop("E0");
this.gListeCibles[i - 1][j - 1].push(myMc);
}
}
this.initCurrentCibles();
myMc = new InteractiveMovie(this.mainTimeline["BT_REJOUER"],this._timelineManager);
myMc.gotoAndStop("E1");
}
public function initCurrentCibles() : void
{
var pListe:Array = null;
var i:int = 0;
this.gListeCurrentCibles = [];
if(this.gPosFleuve1 < 3)
{
pListe = this.gListeCibles[0][this.gPosFleuve1];
for(i = 0; i <= 1; i++)
{
trace("pListe[i].mc",pListe[i].mc.name);
pListe[i].gotoAndStop("E1");
this.gListeCurrentCibles.push(pListe[i]);
}
}
if(this.gPosFleuve2 < 3)
{
pListe = this.gListeCibles[1][this.gPosFleuve2];
for(i = 0; i <= 1; i++)
{
trace("___ pListe[i].mc",pListe[i].mc.name);
pListe[i].gotoAndStop("E1");
this.gListeCurrentCibles.push(pListe[i]);
}
}
this._engine.playNoise(new NoiseObject({"code":"B_ZONE"}));
this.testShowLM();
}
public function initMc(myMc:MovieClip) : void
{
trace("myMc.mc",myMc.mc.name);
myMc.mc.onRollOver = function(p:Object):void
{
if(gDrag == null)
{
_engine.playNoise(new NoiseObject({"code":this.pNoiseRoll}));
}
};
myMc.mc.onRollOut = function(p:Object):void
{
if(gDrag == null)
{
_engine.stopNoise(new NoiseObject({"code":this.pNoiseRoll}));
}
};
myMc.mc.onMouseDown = function(p:Object):void
{
trace("DOWN",myMc.mc.name);
if(gDrag == null)
{
gDrag = this;
disableAll();
this.pCible = undefined;
_engine.stopNoise(new NoiseObject({"code":this.pNoiseRoll}));
_engine.playNoise(new NoiseObject({"code":this.pNoiseClic}));
this.alpha = 0.5;
}
};
myMc.mc.onMouseUp = function(p:Object):void
{
if(gDrag == this)
{
trace("UP",myMc.mc.name);
this.alpha = 1;
trace("this.name",this.name);
trace("this.pCible",this.pCible);
_engine.playNoise(new NoiseObject({"code":"B_DEPOT"}));
if(this.pCible == undefined)
{
this.returnOrigPoint();
this.timeline.GotoAndStop("E1");
}
else
{
gOkBad = this.pCible.mc.name.split("_")[0];
gNumFleuve = Number(this.pCible.mc.name.split("_")[1]);
gNumObstacle = Number(this.pCible.mc.name.split("_")[2]);
trace("testCasParticulier(this.pNum)",testCasParticulier(this.pNum));
trace("testCasParticulierInverse(this.pNum)",testCasParticulierInverse(this.pNum));
if(this.pNum == gListeObjet[gNumFleuve - 1][gNumObstacle - 1] && testCasParticulier(this.pNum) == false || testCasParticulierInverse(this.pNum) == true)
{
testHideLM();
gObjet = this;
this.timeline.GotoAndPlayUntilTheEnd("E3",finE3);
if(this.pNum == 6 || this.pNum == 8)
{
_engine.playNoise(new NoiseObject({"code":this.pNoiseRoll}));
}
desinitZones();
trace("bon objet",this.pNum + " " + gListeObjet[gNumFleuve - 1][gNumObstacle - 1]);
}
else
{
this.returnOrigPoint();
if(testCasParticulier(this.pNum))
{
_engine.playNoise(new NoiseObject({"code":"B_ERREUR"}));
}
else
{
trace("mauvais objet",this.pNum + " " + gListeObjet[gNumFleuve - 1][gNumObstacle - 1]);
_engine.playComment(new CommentObject({"code":"E" + G2D(gListeObjet[gNumFleuve - 1][gNumObstacle - 1])}));
}
this.pCible.gotoAndStop("E1");
this.timeline.GotoAndStop("E1");
}
}
}
ableAll();
gDrag = null;
};
myMc.mc.onEnterFrame = function(p:Object):void
{
var tpoint:Point = new Point(this.stage.mouseX,this.stage.mouseY);
var pLength:int = gListeCurrentCibles.length;
var lCibleFound:Boolean = false;
for(var i:int = 0; i < pLength; i++)
{
if(gListeCurrentCibles[i].mc.hitTestPoint(tpoint.x,tpoint.y,true))
{
lCibleFound = true;
if(this.pCible !== undefined)
{
trace("touche",gListeCurrentCibles[i].mc.name);
gListeCurrentCibles[i].gotoAndStop("E2");
if(this.pCible !== undefined)
{
this.pCible.gotoAndStop("E1");
}
_engine.playNoise(new NoiseObject({"code":"B_SURVOL"}));
this.pCible = gListeCurrentCibles[i];
break;
}
}
}
if(lCibleFound == false && this.pCible !== undefined)
{
_engine.stopNoise(new NoiseObject({"code":"B_SURVOL"}));
this.pCible.gotoAndStop("E1");
this.pCible = undefined;
}
};
myMc.activeDragAndDropMC();
}
public function ableAll() : void
{
var myMc:InteractiveMovie = null;
for(var i:int = 1; i <= 8; i++)
{
myMc = new InteractiveMovie(this.mainTimeline["OBJ_" + this.G2D(i)],this._timelineManager);
if(myMc.mc !== this.gDrag)
{
myMc.mc.active();
}
}
}
public function disableAll() : void
{
var myMc:InteractiveMovie = null;
for(var i:int = 1; i <= 8; i++)
{
myMc = new InteractiveMovie(this.mainTimeline["OBJ_" + this.G2D(i)],this._timelineManager);
if(myMc.mc !== this.gDrag)
{
myMc.mc.desactive();
}
}
}
public function testShowLM() : void
{
var pFleuveEtat:int = 0;
var pCodeLM:String = null;
trace("testShowLM()");
for(var i:int = 1; i <= 2; i++)
{
pFleuveEtat = this["gPosFleuve" + i] + 1;
if(pFleuveEtat <= 3)
{
pCodeLM = "LM_DEPOT_0" + i + "_0" + pFleuveEtat;
if(this.gListeLM.indexOf(pCodeLM) == -1)
{
this._engine.showLM({
"id":pCodeLM,
"findModelIn":this.mainTimeline
});
this.gListeLM.push(pCodeLM);
}
}
}
}
public function testHideLM() : void
{
if(this.gListeLM.indexOf("LM_DEPOT_0" + this.gNumFleuve + "_0" + this.gNumObstacle) !== -1)
{
this._engine.hideLM({"into":this.mainTimeline["LM_DEPOT_0" + this.gNumFleuve + "_0" + this.gNumObstacle]});
this.gListeLM.splice(this.gListeLM.indexOf("LM_DEPOT_0" + this.gNumFleuve + "_0" + this.gNumObstacle),1);
}
}
public function testCasParticulier(pNum:int) : Boolean
{
var pCasPartFound:Boolean = false;
if(this.gNumFleuve == 2 && this.gNumObstacle == 1 && this.gOkBad == "OK" && pNum == 7)
{
trace("cas 1");
pCasPartFound = true;
}
if(this.gNumFleuve == 2 && this.gNumObstacle == 1 && this.gOkBad == "BAD" && pNum == 4)
{
trace("cas 2");
pCasPartFound = true;
}
if(this.gNumFleuve == 2 && this.gNumObstacle == 3 && this.gOkBad == "OK" && pNum == 8)
{
trace("cas 3");
pCasPartFound = true;
}
if(this.gNumFleuve == 2 && this.gNumObstacle == 3 && this.gOkBad == "BAD" && pNum == 6)
{
trace("cas 4");
pCasPartFound = true;
}
return pCasPartFound;
}
public function testCasParticulierInverse(pNum:int) : Boolean
{
var pCasPartFound:Boolean = false;
if(this.gNumFleuve == 2 && this.gNumObstacle == 1 && this.gOkBad == "BAD" && pNum == 7)
{
trace("cas inverse 2");
pCasPartFound = true;
}
if(this.gNumFleuve == 2 && this.gNumObstacle == 3 && this.gOkBad == "BAD" && pNum == 8)
{
trace("cas inverse 4");
pCasPartFound = true;
}
return pCasPartFound;
}
public function finE3() : void
{
var mc:MovieClip = null;
var tl:Timeline = null;
var pLabelNum:int = 0;
var otherCible:MovieClip = null;
trace("finE3");
if(this.gObjet.pCible.hasLabel("E3"))
{
this.gObjet.pCible.gotoAndPlayUntilTheEnd("E3");
}
else
{
this.gObjet.pCible.gotoAndStop("E0");
}
this.gObjet.returnOrigPoint();
this.gObjet.timeline.GotoAndStop("E1");
if(this.gObjet.pNum == 6 || this.gObjet.pNum == 8)
{
this._engine.stopNoise(new NoiseObject({"code":this.gObjet.pNoiseRoll}));
}
if(this.gNumFleuve == 1)
{
if(this.gOkBad == "OK")
{
this.gPosFleuve1 += 1;
if(this.gNumObstacle < 3)
{
this._engine.playNoise(new NoiseObject({"code":"B_OK"}));
}
else
{
this._engine.playNoise(new NoiseObject({"code":"B_SUCCES"}));
}
otherCible = this.mainTimeline["BAD_" + this.G2D(this.gNumFleuve) + "_" + this.G2D(this.gNumObstacle)];
}
else
{
this.gPosFleuve1 += 4;
this._engine.playNoise(new NoiseObject({"code":"B_BAD"}));
otherCible = this.mainTimeline["OK_" + this.G2D(this.gNumFleuve) + "_" + this.G2D(this.gNumObstacle)];
}
otherCible.timeline.GotoAndStop("E0");
this.FLEUVE_01.gotoAndStop("E" + this.gPosFleuve1);
pLabelNum = Number(this.FLEUVE_01.mc.currentLabel.substr(1,1));
mc = this.FLEUVE_01.mc.anim;
tl = new Timeline(mc,this._timelineManager);
if(pLabelNum < 4)
{
tl.GotoAndPlayUntilTheEnd(1,this.nextEtapeF1);
}
else
{
tl.GotoAndPlayUntilTheEnd(1,this.perdu);
}
}
else
{
if(this.gOkBad == "OK")
{
this.gPosFleuve2 += 1;
if(this.gNumObstacle < 3)
{
this._engine.playNoise(new NoiseObject({"code":"B_OK"}));
}
else
{
this._engine.playNoise(new NoiseObject({"code":"B_SUCCES"}));
}
otherCible = this.mainTimeline["BAD_" + this.G2D(this.gNumFleuve) + "_" + this.G2D(this.gNumObstacle)];
}
else
{
this.gPosFleuve2 += 4;
this._engine.playNoise(new NoiseObject({"code":"B_BAD"}));
otherCible = this.mainTimeline["OK_" + this.G2D(this.gNumFleuve) + "_" + this.G2D(this.gNumObstacle)];
}
otherCible.timeline.GotoAndStop("E0");
this.FLEUVE_02.gotoAndStop("E" + this.gPosFleuve2);
pLabelNum = Number(this.FLEUVE_02.mc.currentLabel.substr(1,1));
mc = this.FLEUVE_02.mc.anim;
tl = new Timeline(mc,this._timelineManager);
if(pLabelNum < 4)
{
tl.GotoAndPlayUntilTheEnd(1,this.nextEtapeF2);
}
else
{
tl.GotoAndPlayUntilTheEnd(1,this.perdu);
}
}
}
public function desinitZones() : void
{
var myMc:InteractiveMovie = null;
for(var i:int = 1; i <= 8; i++)
{
myMc = new InteractiveMovie(this.mainTimeline["OBJ_" + this.G2D(i)],this._timelineManager);
myMc.desactive();
myMc.mc.mouseEnabled = false;
myMc.mc.mouseChildren = false;
}
}
public function initZones() : void
{
var myMc:InteractiveMovie = null;
for(var i:int = 1; i <= 8; i++)
{
myMc = new InteractiveMovie(this.mainTimeline["OBJ_" + this.G2D(i)],this._timelineManager);
myMc.active();
myMc.mc.mouseEnabled = true;
myMc.mc.mouseChildren = true;
}
}
public function nextEtapeF1() : void
{
trace("nextEtapeF1");
if(this.gPosFleuve1 < 3)
{
this.initCurrentCibles();
this.initZones();
}
else
{
trace("fleuve1 fini");
if(this.gPosFleuve2 == 3)
{
trace("tout fini");
this.save();
this._timeline_.GotoAndPlayUntil({"labelStop":"WAIT_GAGNE"});
}
else
{
this.initCurrentCibles();
this.initZones();
}
}
}
public function labelWAIT_GAGNE() : void
{
this.mainTimeline.LM_DEPOT_01_01.visible = false;
}
public function nextEtapeF2() : void
{
trace("nextEtapeF2");
if(this.gPosFleuve2 < 3)
{
this.initCurrentCibles();
this.initZones();
}
else
{
trace("fleuve2 fini");
if(this.gPosFleuve1 == 3)
{
trace("tout fini");
this.save();
this._timeline_.GotoAndPlayUntil({"labelStop":"WAIT_GAGNE"});
}
else
{
this.initCurrentCibles();
this.initZones();
}
}
}
public function perdu() : void
{
trace("perdu");
this._engine.playComment(new CommentObject({
"code":"B" + this.G2D(this.commentEchecNum),
"callback":this.labelATTENTE_JEU
}));
if(this.commentEchecNum == 3)
{
this.commentEchecNum = 1;
}
else
{
this.commentEchecNum += 1;
}
this.initZones();
}
public function G2D(value:int) : String
{
return GlobalesFunctions.gimme2digits(value);
}
public function save() : void
{
this.BT_RETOUR._gameWon = true;
this.gListDone[this._engine.config.moduleNum - 1] = 1;
if(this.gDoneDepart)
{
this.so.data.lastDone = 2;
}
else
{
this.so.data.lastDone = 1;
}
this.so.data.listDone = this.gListDone;
this.so.flush();
}
public function endMODULE() : void
{
trace("fin du module");
this._engine.host.changeModule({"numMod":0});
}
public function sleep() : void
{
this._pauseManager = new PauseManager(this._engine,this._timelineManager);
this._pauseManager.sleepMovie(this.mainTimeline);
}
public function wake() : void
{
if(this._pauseManager != null)
{
this._pauseManager.wakeMovie(this.mainTimeline);
}
}
public function destroy() : void
{
this._engine.stopAllSounds();
this._timeline_.kilListeners();
}
}
}