home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 150
/
MOBICLIC150.ISO
/
pc
/
DATA
/
DSS150
/
DSS150_04
/
DSS150_04.swf
/
scripts
/
dss150_04
/
Glace.as
< prev
next >
Wrap
Text File
|
2012-12-19
|
4KB
|
143 lines
package dss150_04
{
import com.milanpresse.engineaddons.facades.GameEngine;
import com.milanpresse.engineaddons.gamesprotos.Actor;
import com.milanpresse.engineaddons.gamesprotos.actors.actorClip.ActorClip;
import com.milanpresse.engineaddons.timers.TimerChild;
public class Glace extends Actor
{
public var actor:ActorClip;
protected var labels:Array;
private var _position:int = 0;
public var sens:int = 1;
public var directionInitiale:int = 1;
protected var timer:TimerChild;
public var speedMS:Number = 500;
public var hited:Boolean = false;
public var comment12_JEU_NIV3DejaJoue:Boolean = false;
public var alreadyLaunched:Boolean = false;
public var moveFinished:Boolean = true;
public function Glace(game:GameEngine, params:Object = null)
{
this.labels = ["G3","G2","G1","CENTRE","D1","D2","D3"];
super(game,null,params);
this.actor = addActor({"mc":params.mc});
this.init();
}
public static function create(game:GameEngine, params:*) : Glace
{
return new Glace(game,params);
}
protected function init() : void
{
this.speedMS = game.moduleConfig.GlaceDuree / 100;
this.position = 0;
this.sens = 1;
this.timer = game.mainTimer.addFromObj({
"delay":this.speedMS,
"onDelay":this.onDelay
});
this.timer.reset();
this.refresh();
}
protected function chooseDirection() : void
{
this.directionInitiale = Math.random() > 0.5 ? int(1) : int(-1);
this.sens = this.directionInitiale;
if(this.directionInitiale == 1)
{
this._position = 1;
}
else
{
this._position = this.actor.totalFrames;
}
this.refresh();
}
public function launch() : void
{
trace("glace.launch");
this.moveFinished = false;
this.chooseDirection();
this.timer.start();
if(this.comment12_JEU_NIV3DejaJoue == false)
{
this.comment12_JEU_NIV3DejaJoue = true;
game.commentPlay({
"code":"12_JEU_NIV3",
"zapBlock":"NOZAP_NOBLOCK"
});
}
}
public function stop() : void
{
this.alreadyLaunched = false;
this.hited = false;
this.moveFinished = true;
this.timer.stop();
}
public function reset() : void
{
this.stop();
this._position = 1;
this.refresh();
}
public function onDelay(timer:TimerChild) : void
{
trace("glaceOnDelay");
this.move();
}
protected function refresh() : void
{
this.actor.gotoAndStop(this._position);
}
protected function move() : void
{
trace("move",this.sens,this._position);
if(this.sens == 1 && this.position == this.actor.totalFrames || this.sens == -1 && this._position == 1)
{
this.stop();
}
else
{
this._position += this.sens;
}
this.refresh();
}
public function get position() : int
{
return this._position;
}
public function set position(value:int) : void
{
this._position = value;
this.refresh();
}
}
}