home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 159
/
MOBICLIC159.ISO
/
mac
/
DATA
/
DSS159
/
DSS159_01
/
DSS159_01.swf
/
scripts
/
dss159_01
/
ATTENTE.as
< prev
next >
Wrap
Text File
|
2013-11-19
|
40KB
|
1,044 lines
package dss159_01
{
import com.milanpresse.engine.events.GenericEvent;
import com.milanpresse.tools.GlobalesFunctions;
import dss159_01.engineaddons.facades.GameEngine;
import dss159_01.engineaddons.gamesprotos.Actor;
import dss159_01.engineaddons.gamesprotos.actors.actorClip.ActorClip;
import dss159_01.engineaddons.timers.TimerChild;
import dss159_01.engineaddons.visuals.SimpleBitmapData;
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedClassName;
import flash.utils.getTimer;
public class ATTENTE extends Actor
{
public var onEvent:Function = null;
private var _container:ActorClip;
private var mainLoop:TimerChild;
private var LIMITES:ActorClip;
private var level:int;
private var levelConfig:Object;
private var launcherManager:LauncherManager;
private var OBJECTS_CONTAINER:ActorClip;
private var plans:Actor;
private var mapNum:int = 1;
private var animSucces:ActorClip;
private var controller;
private var btRejouer:ActorClip;
private var btRetour:ActorClip;
private var elementsActor:Actor;
private var SCORE:Score;
private var demos:ActorClip;
private var trailerLimitClip1:Sprite;
private var _elements:Array;
private var startTime:Number;
private var lastTime:Number;
private var delayTime:Number;
private var elapsedTime:Number;
private var noises:Array;
private var ratio:Point;
private var trailerClip:Sprite;
private var trailerRunning:Boolean = false;
private var endFlag:Object;
private var perso:ActorClip;
private var persoJumpHeight;
var pt:Point;
var pt2:Point;
var marker1:Sprite;
var marker2:Sprite;
public function ATTENTE(param1:GameEngine, param2:ActorClip)
{
this.trailerLimitClip1 = new Sprite();
this._elements = [];
this.noises = [];
this.ratio = new Point();
this.trailerClip = new Sprite();
this.endFlag = {"globalX":1000000000000000000};
this.pt2 = new Point(0,0);
this.marker1 = new Sprite();
this.marker2 = new Sprite();
super(param1);
this._container = param2;
this.init();
}
private function scoreInit() : void
{
var _loc1_:ActorClip = null;
this.SCORE = addActor(new Score(game,this._container.getChildByName("SCORE") as MovieClip));
this.SCORE["TXT_FLEURS"] = game.showTextBloc({
"text":"00",
"model":this.SCORE.clip.getChildByName("TXT_FLEURS") as TextField,
"idStyle":"LM.LM_SCORE01"
});
var _loc2_:int = 1;
while(_loc2_ <= 3)
{
_loc1_ = this.SCORE.addActor({"mc":this._container.getChildByName("SCORE.VIES.VIE_0" + _loc2_)});
_loc2_++;
}
this.SCORE["CLIP_TEMPS"] = addActor({"mc":this.SCORE.clip.getChildByName("TEMPS")});
this.SCORE["CLIP_TEMPS"].speed = -0.1;
this.SCORE["CLIP_TEMPS"].gotoAndStop(100);
this.SCORE.clip.parent.setChildIndex(this.SCORE.clip.clip,this.SCORE.clip.parent.numChildren - 1);
this.SCORE.setPoints("fleur",0);
this.SCORE.setPoints("vie",3);
this.SCORE.setPoints("temps",100);
}
private function init() : void
{
this.level = game.memo.levelNo;
this.levelConfig = game.moduleConfig.levels[this.level - 1];
this.elementsActor = addActor();
this.noises["B_COURT"] = game.getNoise({"code":"B_COURT"});
this.animSucces = addActor({"mc":this._container.getChildByName("ANIM_SUCCES")});
this.btRejouer = addActor({
"mc":this._container.getChildByName("BT_REJOUER"),
"onRollOverState":{
"label":"E2",
"ibId":"IB_REJOUE"
},
"onRollOutState":{"label":"E1"},
"onClick":function(param1:ActorClip):void
{
btRejouer.visible = false;
animSucces.visible = false;
perso.gotoAndStop("E1");
perso.visible = true;
scoreReset();
startLevel(1);
},
"enabled":true,
"visible":false
});
this.trailerInit();
this.getElementsList();
this.persoInit();
this.scoreInit();
this.demosInit();
this._container.enabled = false;
this._container.clip.mouseChildren = true;
this.controller = new KeyController(stage);
this.mainLoop = game.mainTimer.addFromObj({
"delay":10,
"onDelay":this.loop
});
this.start();
}
private function demosInit() : void
{
this.demos = addActor({"mc":this._container.getChildByName("DEMOS")});
this.demos.parent = null;
}
private function trailerInit() : void
{
var _loc2_:SimpleBitmapData = null;
var _loc3_:DisplayObjectContainer = null;
this.plans = addActor();
var _loc1_:Number = 4;
_loc2_ = new SimpleBitmapData(game);
_loc2_.createFromMovieClip(this._container.getChildByName("DECOR.PLAN_CIEL"));
_loc2_.parent = this._container.clip;
this.plans["CIEL"] = this.plans.addActor(_loc2_);
this.plans["CIEL"].speed = -0.3 * _loc1_;
_loc2_ = new SimpleBitmapData(game);
_loc2_.createFromMovieClip(this._container.getChildByName("DECOR.PLAN_FORET"));
_loc2_.parent = this._container.clip;
this.plans["FORET"] = this.plans.addActor(_loc2_);
this.plans["FORET"].speed = -0.9 * _loc1_;
_loc2_ = new SimpleBitmapData(game);
_loc2_.createFromMovieClip(this._container.getChildByName("DECOR.PLAN_CHEMIN"));
_loc2_.parent = this._container.clip;
this.plans["CHEMIN"] = this.plans.addActor(_loc2_);
this.plans["CHEMIN"].speed = -1 * _loc1_;
this._container.clip.addChild(this.trailerClip);
this.trailerClip.x = 0;
this.trailerClip.addChild(this.trailerLimitClip1);
_loc3_ = this._container.getChildByName("DECOR.PLAN_CHEMIN2") as DisplayObjectContainer;
_loc3_.visible = false;
this._container.clip.removeChild(this._container.getChildByName("DECOR"));
this._container.clip.DECOR = null;
this.marker1.graphics.beginFill(65280,1);
this.marker1.graphics.drawCircle(0,0,10);
this.marker1.graphics.endFill();
this.marker1.visible = false;
this.marker2.graphics.beginFill(255,1);
this.marker2.graphics.drawRect(0,0,10,10);
this.marker2.graphics.endFill();
this.marker2.visible = false;
}
public function getClass(param1:Object) : Class
{
return Class(getDefinitionByName(getQualifiedClassName(param1)));
}
private function getElementsList() : void
{
var _loc1_:MovieClip = null;
var _loc2_:* = undefined;
var _loc3_:Class = null;
var _loc7_:TextField = null;
var _loc8_:Array = null;
game.mapNum = this.mapNum;
switch(this.mapNum)
{
case 1:
_loc1_ = new Level1() as MovieClip;
break;
case 2:
_loc1_ = new Level2() as MovieClip;
break;
case 3:
_loc1_ = new Level3() as MovieClip;
}
var _loc4_:int = _loc1_.numChildren;
var _loc5_:int = 0;
while(_loc5_ < _loc4_)
{
_loc2_ = _loc1_.getChildAt(_loc5_);
_loc3_ = this.getClass(_loc2_);
if(_loc3_ == MovieClip)
{
if(_loc2_.getChildByName("_infos") != null)
{
_loc8_ = (_loc7_ = _loc2_.getChildByName("_infos") as TextField).text.split("\n");
}
else if(_loc2_.name.search(/^instance/) == -1)
{
if(_loc2_.name.search(/^_helper/) == -1)
{
this._elements.push({
"launched":false,
"type":_loc2_.name,
"clip":_loc2_,
"time":0,
"x":_loc2_.x,
"y":_loc2_.y,
"width":_loc2_.width,
"height":_loc2_.height
});
}
}
}
else if(_loc3_ != Perso)
{
this._elements.push({
"launched":false,
"type":_loc3_,
"clip":_loc2_,
"time":0,
"x":_loc2_.x,
"y":_loc2_.y,
"width":_loc2_.width,
"height":_loc2_.height
});
}
_loc5_++;
}
this._elements = this._elements.sortOn("x",Array.NUMERIC);
var _loc6_:int = this._elements.length;
this.ratio.x = this.ratio.y = 600 / 218;
_loc5_ = 0;
while(_loc5_ < _loc6_)
{
this._elements[_loc5_].time = this._elements[_loc5_].x * 10;
if(this._elements[_loc5_].type == "FINISH")
{
this._elements[_loc5_].clip.scaleX *= this.ratio.x;
this._elements[_loc5_].clip.scaleY *= this.ratio.x;
this._elements[_loc5_].clip.x = this._elements[_loc5_].x * this.ratio.x;
this._elements[_loc5_].clip.y = this._elements[_loc5_].y * this.ratio.y;
this._elements[_loc5_].launched = false;
this._elements[_loc5_].passed = false;
this._elements[_loc5_].speed = this.plans["CHEMIN"].speed;
this._elements[_loc5_].clip.visible = false;
this._elements[_loc5_].infos = game.moduleConfig.elementsInfos["Finish"];
this.endFlag = this._elements[_loc5_];
}
else if(this._elements[_loc5_].type is Class)
{
if(game.moduleConfig.modeDisplay == "bitmap")
{
this._elements[_loc5_].actor = this.elementsActor.addActor({
"type":BitmapAnimClip,
"clip":new this._elements[_loc5_].type()
});
}
else
{
this._elements[_loc5_].actor = this.elementsActor.addActor({
"type":ActorClip,
"mc":new this._elements[_loc5_].type()
});
this._elements[_loc5_].actor.gotoLabel = this._elements[_loc5_].actor.gotoAndStop;
}
this._elements[_loc5_].actor.scaleX = this._elements[_loc5_].clip.scaleX * this.ratio.x;
this._elements[_loc5_].actor.scaleY = this._elements[_loc5_].clip.scaleY * this.ratio.x;
this._elements[_loc5_].actor.x = this._elements[_loc5_].x * this.ratio.x;
this._elements[_loc5_].actor.y = this._elements[_loc5_].y * this.ratio.y;
this._elements[_loc5_].actor.gotoLabel("E1");
this._elements[_loc5_].speed = this.plans["CHEMIN"].speed;
this._elements[_loc5_].launched = false;
this._elements[_loc5_].passed = false;
this._elements[_loc5_].clip = this._elements[_loc5_].actor.clip;
this._elements[_loc5_].infos = game.moduleConfig.elementsInfos[getQualifiedClassName(this._elements[_loc5_].type)];
}
_loc5_++;
}
}
private function objectsReset() : void
{
this.trailerClip.x = 0;
var _loc1_:int = 0;
while(_loc1_ < this._elements.length)
{
if(this._elements[_loc1_].infos.type == "finish")
{
this._elements[_loc1_].launched = false;
this._elements[_loc1_].passed = false;
this._elements[_loc1_].hitted = false;
this._elements[_loc1_].speed = this.plans["CHEMIN"].speed;
this._elements[_loc1_].clip.visible = false;
this.endFlag = this._elements[_loc1_];
}
else
{
this._elements[_loc1_].clip.x = this._elements[_loc1_].x * this.ratio.x;
this._elements[_loc1_].clip.y = this._elements[_loc1_].y * this.ratio.y;
this._elements[_loc1_].speed = this.plans["CHEMIN"].speed;
this._elements[_loc1_].hitted = false;
this._elements[_loc1_].launched = false;
this._elements[_loc1_].passed = false;
this._elements[_loc1_].actor.visible = true;
this._elements[_loc1_].actor.gotoLabel("E1");
}
_loc1_++;
}
}
override public function start() : void
{
this.startLevel();
}
private function startLevel(param1:int = -1) : void
{
var noMap:int = param1;
if(noMap != -1 && noMap != this.mapNum)
{
this.mapNum = noMap;
this.createLevel();
}
if(this.mapNum == 2)
{
this.demos.gotoAndStop("D2");
this.demos.visible = true;
this.demos.parent = this._container.clip;
this.SCORE["CLIP_TEMPS"].visible = false;
game.commentPlay({
"code":"DEMO_N2",
"callback":function():void
{
startLevelSuite();
}
});
}
else if(this.mapNum == 3)
{
this.demos.gotoAndStop("D3_01");
this.demos.visible = true;
this.demos.parent = this._container.clip;
this.SCORE.setPoints("temps",100);
this.SCORE["CLIP_TEMPS"].visible = true;
game.commentPlay({
"code":"DEMO_N3_01",
"callback":function():void
{
demos.gotoAndStop("D3_02");
game.commentPlay({
"code":"DEMO_N3_02",
"callback":function():void
{
startLevelSuite();
}
});
}
});
}
else
{
this.SCORE["CLIP_TEMPS"].visible = false;
this.startLevelSuite();
}
this.perso.jumping = 0;
this.perso.isDown = false;
this.controller.enabled = true;
}
private function startLevelSuite() : void
{
this.demos.parent = null;
this.demos.gotoAndStop(1);
this.allReset();
this.startTime = this.lastTime = getTimer();
this.elapsedTime = this.delayTime = 0;
this.perso.jumpScale = this.mapNum == 3 ? 0.6 : 1;
this.perso.refY = this.perso.restY;
this.perso.gotoAndStop("E1");
game.mainTimer.start();
this.mainLoop.start();
this.trailerRunning = true;
this.perso.enabled = false;
game.noisePlayIfNotPlaying(this.noises["B_COURT"]);
this.controller.addEventListener(GenericEvent.SELECT,this.onControllerAction);
this._container.enabled = false;
this.controller.enabled = true;
}
private function onControllerAction(param1:GenericEvent) : void
{
if(param1.toolType == "38" && this.perso.isDown != true)
{
this.controller.enabled = false;
this.perso.enabled = false;
this._container.enabled = false;
this.perso.gotoAndStop("E4");
this.perso.jumping = "up";
this.perso.typeJump = !!this.perso.inDistancePasserelleJump ? 2 : 1;
this.perso.anim = this.perso.getChildByName("CLIP") as MovieClip;
this.perso.topJumpTimeTemp = 0;
this.perso.IMAGE = 1;
this.perso.anim.gotoAndStop(1);
this.noises["B_COURT"].stop();
game.noisePlay({"code":"B_SAUT"});
}
else if(param1.toolType == "40" && this.perso.jumping == 0 && this.perso.isDown != true)
{
this.perso.enabled = false;
this._container.enabled = false;
this.perso.isDown = true;
this.perso.gotoAndStop("E3");
this.noises["B_COURT"].stop();
game.noisePlay({"code":"B_BAISSE"});
}
else if(param1.toolType == null)
{
if(this.perso.isDown)
{
this.perso.isDown = false;
this.perso.gotoAndStop("E1");
}
}
}
private function createLevel() : void
{
this.elementsActor.destroyChildren();
this._elements.length = 0;
this.getElementsList();
}
private function loop(param1:TimerChild) : void
{
if(!this.mainLoop.running)
{
return;
}
this.delayTime = getTimer() - this.lastTime;
this.lastTime = getTimer();
this.elapsedTime = this.lastTime - this.startTime;
this.trailerMove();
this.persoMove();
}
private function trailerMove() : void
{
if(!this.trailerRunning)
{
return;
}
this.plans.foreach(function(param1:*):void
{
if(param1.bitmap.x + param1.speed + param1.bitmap.width <= param1.initialBounds.x + param1.bitmap.width / 2)
{
param1.bitmap.x = param1.initialBounds.x;
}
else
{
param1.bitmap.x += param1.speed * perso.jumpSpeedXTemp;
}
});
this.trailerClip.x += this.plans["CHEMIN"].speed * this.perso.jumpSpeedXTemp;
var i:int = 0;
while(i < this._elements.length)
{
if(this._elements[i].passed == false && this._elements[i].launched == true && Math.abs(this.trailerClip.x) - 400 > this._elements[i].x * 600 / 218)
{
this._elements[i].actor.stop();
this.trailerClip.removeChild(this._elements[i].clip);
this._elements[i].passed = true;
}
else if(this._elements[i].passed == false && this._elements[i].launched == false && Math.abs(this.trailerClip.x) + 1400 > this._elements[i].x * 600 / 218)
{
if(this._elements[i].infos.type == "finish")
{
this.trailerClip.addChild(this._elements[i].clip);
this._elements[i].launched = true;
this.endFlag = this._elements[i];
this.endFlag.globalX = this._container.getObjectCoordToLocal(this._elements[i].clip).x;
return;
}
if(this._elements[i].infos.type == "decor")
{
this.trailerClip.addChildAt(this._elements[i].clip,0);
}
else
{
this.trailerClip.addChild(this._elements[i].clip);
}
this._elements[i].actor.gotoAndStop("E1");
this._elements[i].launched = true;
}
else if(this._elements[i].passed == false && this._elements[i].launched == true && this._elements[i].infos.type == "ennemy_aerien")
{
this._elements[i].clip.x -= 5;
}
i++;
}
}
private function persoInit() : void
{
this.perso = addActor({
"type":ActorClip,
"mc":new Perso(),
"parent":this._container.clip
});
this.perso.name = "PERSO";
this.perso.bringToFront();
var onClickBitmap:Function = function():void
{
perso.enabled = false;
_container.enabled = false;
perso.gotoLabel("E4");
perso.jumping = "up";
perso.topJumpTimeTemp = 0;
perso.typeJump = !!perso.inDistancePasserelleJump ? 2 : 1;
perso.IMAGE = 1;
};
var onClickActorClip:Function = function(param1:ActorClip):void
{
perso.enabled = false;
_container.enabled = false;
perso.gotoAndStop("E4");
perso.jumping = "up";
perso.typeJump = !!perso.inDistancePasserelleJump ? 2 : 1;
perso.anim = perso.getChildByName("CLIP") as MovieClip;
perso.topJumpTimeTemp = 0;
perso.IMAGE = 1;
perso.anim.gotoAndStop(1);
noises["B_COURT"].stop();
game.noisePlay({"code":"B_SAUT"});
};
this.perso.initAs();
this.perso.enabled = false;
this._container.enabled = false;
this.perso.restX = 103 * this.ratio.x;
this.perso.restY = 190 * this.ratio.y;
this.perso.x = this.perso.restX;
this.perso.y = this.perso.restY;
this.perso.gotoAndStop("E1");
this.perso.jumping = "0";
this.perso.jumpHeightInAsset = 100;
this.perso.jumpHeight = this.perso.jumpHeightInAsset * this.ratio.y;
this.perso.topJumpTime = 40;
this.perso.topJumpTimeTemp = 0;
this.perso.speed = 0.3;
this.perso.IMAGE = 1;
this.perso.jumpSpeedX = 1;
this.perso.jumpSpeedY = -10;
this.perso.jumpSpeedXTemp = 1;
this.perso.jumpSpeedYTemp = -1;
this.perso.restScale = this.perso.clip.scaleX;
this.perso.jumpScale = this.mapNum == 3 ? 0.6 : 1;
this.perso.jumpScaleTemp = 1;
var nb:Number = (this.perso.restY - this.perso.y) / this.perso.jumpSpeedYTemp;
var dx:Number = nb * this.plans["CHEMIN"].speed * this.perso.jumpSpeedXTemp;
this.perso.distanceJump = 100 * this.ratio.x;
}
private function persoAdaptScaleFromY() : void
{
if(this.perso.refY != this.perso.restY || this.perso.typeJump == 1)
{
return;
}
var _loc1_:Number = 1;
var _loc2_:Number = (this.perso.restY - this.perso.y) / this.perso.jumpHeight;
_loc1_ = 1 - (1 - this.perso.jumpScale) * _loc2_;
this.perso.clip.scaleX = this.perso.clip.scaleY = this.perso.restScale * _loc1_;
}
private function persoMove() : void
{
var pt:Point = null;
var tempElement:* = undefined;
this.SCORE.setPoints("temps",this.SCORE.getPoints("temps") + this.SCORE["CLIP_TEMPS"].speed);
this.SCORE["CLIP_TEMPS"].gotoAndStop(100 - Math.floor(this.SCORE.getPoints("temps")));
if(this.mapNum == 3 && this.SCORE.getPoints("temps") < 0)
{
this.onFail2();
return;
}
var origin:Point = this.perso.getPos();
this.marker1.x = origin.x;
this.marker1.y = origin.y;
if(!this.mainLoop.running)
{
return;
}
if(this.perso.isDown)
{
if(this.perso.x > this._container.getObjectCoordToLocal(this.endFlag.clip).x)
{
this.mainLoop.stop();
}
}
else if(this.perso.jumping == "0")
{
if(this.perso.currentLabel != "E1")
{
this.perso.gotoAndStop("E1");
}
game.noisePlayIfNotPlaying(this.noises["B_COURT"]);
this.perso.enabled = false;
this._container.enabled = false;
this.controller.enabled = true;
if(!(this.perso.isInPasserelleZone == true && this.perso.onPasserelleZone == true))
{
this.perso.onPasserelleZone = false;
this.perso.refY = this.perso.y = this.perso.restY;
this.perso.clip.scaleX = this.perso.clip.scaleY = this.perso.restScale;
}
this.perso.jumpSpeedXTemp = 1;
this.perso.jumpSpeedYTemp = -1;
if(this.perso.x > this._container.getObjectCoordToLocal(this.endFlag.clip).x)
{
this.mainLoop.stop();
}
}
else if(this.perso.jumping == "up")
{
this.perso.jumpHeightTemp = this.perso.refY == this.perso.restY ? this.perso.jumpHeight : this.perso.jumpHeight * this.perso.jumpScale;
this.perso.enabled = false;
this._container.enabled = false;
this.controller.enabled = false;
this.perso.onPasserelleZone = false;
if(this.perso.y < this.perso.refY - this.perso.jumpHeightTemp * 0.3)
{
if(this.perso.anim.currentLabel != "TOP")
{
this.perso.anim.gotoAndStop("TOP");
}
}
else if(this.perso.y < this.perso.refY - this.perso.jumpHeightTemp * 0.2)
{
if(this.perso.anim.currentLabel != "UP2")
{
this.perso.anim.gotoAndStop("UP2");
}
}
else if(this.perso.anim.currentLabel != "UP")
{
this.perso.anim.gotoAndStop("UP");
}
this.perso.jumpSpeedXTemp = this.perso.jumpSpeedX;
this.perso.jumpSpeedYTemp = this.perso.refY == this.perso.restY ? this.perso.jumpSpeedY : this.perso.jumpSpeedY * this.perso.jumpScale;
this.persoAdaptScaleFromY();
this.perso.y += this.perso.jumpSpeedYTemp;
if(this.perso.y < this.perso.refY - this.perso.jumpHeightTemp)
{
this.perso.jumping = "top";
}
}
else if(this.perso.jumping == "top")
{
this.perso.enabled = false;
this._container.enabled = false;
this.controller.enabled = false;
this.perso.onPasserelleZone = false;
if(this.perso.anim.currentLabel != "TOP")
{
this.perso.anim.gotoAndStop("TOP");
}
this.perso.topJumpTimeTemp += 1;
if(this.perso.topJumpTimeTemp > this.perso.topJumpTime)
{
this.perso.jumping = "down";
}
}
else if(this.perso.jumping == "down")
{
this.perso.enabled = false;
this._container.enabled = false;
this.controller.enabled = false;
this.perso.onPasserelleZone = false;
this.perso.inDistancePasserelleJump = false;
if(this.perso.y < this.perso.refY - this.perso.jumpHeight * 0.6)
{
if(this.perso.anim.currentLabel != "TOP")
{
this.perso.anim.gotoAndStop("TOP");
}
}
else if(this.perso.y < this.perso.refY - this.perso.jumpHeight * 0)
{
if(this.perso.anim.currentLabel != "DOWN2")
{
this.perso.anim.gotoAndStop("DOWN2");
}
}
this.perso.jumpSpeedXTemp = this.perso.jumpSpeedX;
this.perso.jumpSpeedYTemp = this.perso.refY == this.perso.restY ? this.perso.jumpSpeedY : this.perso.jumpSpeedY * this.perso.jumpScale;
this.persoAdaptScaleFromY();
this.perso.y -= this.perso.jumpSpeedYTemp;
if(this.perso.y >= this.perso.refY)
{
if(this.perso.refY != this.perso.restY)
{
this.perso.refY = this.perso.restY;
}
else
{
this.perso.jumping = "0";
}
}
else if(this.perso.isInPasserelleZone)
{
pt = new Point(0,this.perso.Passerelle.actor.getChildByName("FLOOR").y);
pt = this.perso.parent.globalToLocal(this.perso.Passerelle.actor.clip.localToGlobal(pt));
if(this.perso.y > pt.y - 20 && this.perso.y <= pt.y)
{
this.perso.refY = this.perso.y = pt.y;
this.perso.onPasserelleZone = true;
this.perso.jumping = "0";
}
}
}
this.perso.inDistancePasserelleJump = false;
this.perso.isInPasserelleZone = false;
var i:int = 0;
for(; i < this._elements.length; i++)
{
if(this._elements[i].infos.type == "Passerelle" && this.isCollided(this._elements[i]))
{
this.perso.isInPasserelleZone = true;
this.perso.Passerelle = this._elements[i];
}
if(this._elements[i].hitted != true && this._elements[i].passed == false && this._elements[i].launched == true && this.isCollided(this._elements[i]))
{
if(this._elements[i].infos.type != "Passerelle")
{
this.perso.enabled = false;
this._container.enabled = false;
this.controller.enabled = false;
this._elements[i].hitted = true;
tempElement = this._elements[i].actor;
if(this._elements[i].infos.type == "finish")
{
this.trailerClip.removeChild(this._elements[i].clip);
this.onSucces();
return;
}
if(this._elements[i].infos.type != "friandise")
{
if(this._elements[i].infos.type != "energy")
{
if(this._elements[i].infos.type != "decor")
{
if(this._elements[i].infos.type != "Passerelle")
{
this.mainLoop.stop();
this.SCORE.addPoints("vie",this._elements[i].infos.points);
tempElement.gotoAndStop("E2");
game.noisePlay({"code":"B_OUILLE"});
}
continue;
this.perso.gotoAndStop("E2",{"labelLastCallback":function():void
{
tempElement.visible = false;
perso.gotoAndStop("E1");
perso.jumping = "0";
perso.isDown = false;
mainLoop.start();
perso.enabled = false;
_container.enabled = false;
controller.enabled = true;
scoreRefresh();
}});
}
continue;
}
game.noisePlay({"code":"B_ENERGIE"});
this.SCORE.addPoints("temps",25);
tempElement.gotoAndStop("E2",{"labelLastCallback":function():void
{
tempElement.visible = false;
perso.enabled = false;
_container.enabled = false;
controller.enabled = true;
scoreRefresh();
}});
}
this.controller.enabled = true;
}
continue;
game.noisePlay({"code":"B_MIAM"});
this.SCORE.addPoints("fleur",this._elements[i].infos.points);
tempElement.gotoAndStop("E2",{"labelLastCallback":function():void
{
tempElement.visible = false;
perso.enabled = false;
_container.enabled = false;
controller.enabled = true;
scoreRefresh();
}});
continue;
continue;
return;
}
}
if(this.perso.isInPasserelleZone == false && this.perso.onPasserelleZone == true)
{
this.perso.refY = this.perso.restY;
this.perso.onPasserelleZone = false;
this.perso.jumping = "down";
}
}
private function isCollided(param1:*) : Boolean
{
var _loc5_:int = 0;
if(param1.infos.type == "finish")
{
return this.perso.clip.hitTestObject(param1.clip);
}
var _loc2_:Rectangle = param1.actor.getBounds(this.perso.parent);
var _loc3_:Rectangle = param1.actor.getBounds(stage);
var _loc4_:Rectangle = this.perso.clip.getBounds(this.perso.parent);
if(param1.infos.type == "Passerelle" && _loc2_.x - _loc4_.right < this.perso.distanceJump / 2)
{
this.perso.inDistancePasserelleJump = true;
}
if(param1.infos.type == "Passerelle" && _loc4_.right > _loc2_.x && _loc4_.x < _loc2_.x + _loc2_.width)
{
return true;
}
_loc5_ = 1;
while(_loc5_ <= 11)
{
this.pt2.x = this.perso.getChildByName("CLIP.REP" + GlobalesFunctions.gimme2digits(_loc5_)).x;
this.pt2.y = this.perso.getChildByName("CLIP.REP" + GlobalesFunctions.gimme2digits(_loc5_)).y;
this.pt2 = this.perso.clip.CLIP.localToGlobal(this.pt2);
if(param1.actor.clip.hitTestPoint(this.pt2.x,this.pt2.y,true))
{
if(param1.infos.type == "decor" || param1.infos.type == "Passerelle")
{
return false;
}
return true;
}
_loc5_++;
}
return false;
}
private function stop() : void
{
this.controller.removeEventListener(GenericEvent.SELECT,this.onControllerAction);
this.mainLoop.stop();
game.mainTimer.stop();
game.noiseStop();
}
private function allReset() : void
{
this.objectsReset();
}
private function scoreReset() : void
{
this.SCORE.setPoints("fleur",0);
if(this.mapNum == 3)
{
this.SCORE.setPoints("pomme",0);
}
this.SCORE.setPoints("vie",3);
this.SCORE.setPoints("temps",100);
this.scoreRefresh();
}
private function scoreRefresh() : void
{
this.SCORE["TXT_FLEURS"].text = GlobalesFunctions.gimme2digits(this.SCORE.getPoints("fleur"));
if(this.SCORE.getPoints("temps") >= 100)
{
this.SCORE.setPoints("temps",100);
}
if(this.SCORE.getPoints("temps") < 0)
{
this.SCORE.setPoints("temps",0);
}
this.SCORE["CLIP_TEMPS"].gotoAndStop(Math.floor(this.SCORE.getPoints("temps")));
var _loc1_:int = 1;
while(_loc1_ <= 3)
{
if(_loc1_ <= this.SCORE.getPoints("vie"))
{
this.SCORE.getActor("VIE_0" + _loc1_).gotoAndStop("E1");
}
else
{
this.SCORE.getActor("VIE_0" + _loc1_).gotoAndStop("E2");
}
_loc1_++;
}
if(this.SCORE.getPoints("vie") == 0)
{
this.onFail();
}
else if(this.mapNum == 3 && this.SCORE.getPoints("temps") <= 0)
{
this.onFail2();
}
}
private function onSucces() : void
{
this.stop();
if(this.level == 2 && this.mapNum < 2)
{
this.startLevel(this.mapNum + 1);
}
else if(this.level == 3 && this.mapNum < 3)
{
this.startLevel(this.mapNum + 1);
}
else
{
game.memo.setValue("RUBRIQUE.jeu3.ok",true);
game.memo.setValue("RUBRIQUE.jeu4.unlock",true);
this.SCORE.totalScoreCalculAndShow();
this.perso.gotoAndStop("FIN");
this.perso.visible = false;
this.animSucces.play(1,this.animSucces.totalFrames);
this.animSucces.bringToFront();
this.animSucces.visible = true;
this._container.enabled = false;
this._container.clip.mouseChildren = true;
game.commentPlay({
"code":"SUCCES",
"callback":function():void
{
btRejouer.visible = true;
btRejouer.bringToFront();
btRejouer.enabled = true;
}
});
}
}
private function onFail() : void
{
this.stop();
this.SCORE.totalScoreAdd(this.SCORE.levelPoints.jeuEchec);
this.perso.y = this.perso.restY;
this.perso.clip.scaleX = this.perso.clip.scaleY = this.perso.restScale;
this.perso.gotoAndStop("E5");
game.commentPlay({
"code":"ECHEC",
"callback":function():void
{
perso.gotoAndStop("E1");
scoreReset();
startLevel(1);
}
});
}
private function onFail2() : void
{
this.stop();
this.controller.enabled = false;
this.perso.y = this.perso.restY;
this.perso.clip.scaleX = this.perso.clip.scaleY = this.perso.restScale;
this.perso.gotoAndStop("E5");
game.commentPlay({
"code":"ENERGIE",
"callback":function():void
{
perso.gotoAndStop("E1");
scoreReset();
startLevel(1);
}
});
}
override protected function _destroy() : void
{
this.stop();
this._container.enabled = false;
this.controller.removeEventListener(GenericEvent.SELECT,this.onControllerAction);
super._destroy();
}
}
}