home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 150
/
MOBICLIC150.ISO
/
pc
/
DATA
/
DSS150
/
DSS150_02
/
DSS150_02.swf
/
scripts
/
dss150
/
Memo.as
Wrap
Text File
|
2012-12-19
|
4KB
|
163 lines
package dss150
{
import com.milanpresse.engineaddons.facades.GameEngine;
import flash.net.SharedObject;
public class Memo
{
public static var NEW_GAME:String = "NEW_GAME";
public static var SAVED_GAME:String = "SAVED_GAME";
public static var ATTENTE:String = "ATTENTE";
private var _so:SharedObject;
private var _name:String;
private var game:GameEngine;
private var _savePoint:Object;
public var modules:Array;
public function Memo(game:GameEngine)
{
this.modules = [{
"no":0,
"succes":false,
"vu":true
},{
"no":1,
"succes":false,
"vu":false
},{
"no":2,
"succes":false,
"vu":false
},{
"no":3,
"succes":false,
"vu":false
},{
"no":4,
"succes":false,
"vu":false
}];
super();
this.game = game;
this._name = game.config.rubriqueName;
this._so = SharedObject.getLocal(this._name,"/");
if(this._so.data._savePoint == undefined)
{
this._savePoint = {
"moduleNum":this.module.no,
"status":NEW_GAME
};
this.save();
}
else
{
this.load();
}
}
public function clear() : void
{
this._so.clear();
this.modules = [{
"no":0,
"succes":false,
"vu":true
},{
"no":1,
"succes":false,
"vu":false
},{
"no":2,
"succes":false,
"vu":false
},{
"no":3,
"succes":false,
"vu":false
},{
"no":4,
"succes":false,
"vu":false
}];
this._savePoint = {
"moduleNum":this.module.no,
"status":NEW_GAME
};
this.save();
}
public function save() : void
{
this._so.data._savePoint = this._savePoint;
this._so.data.modules = this.modules;
this._so.flush();
}
public function load() : void
{
this._savePoint = this._so.data._savePoint;
this.modules = this._so.data.modules;
}
public function get allModulesFinished() : Boolean
{
for(var i:int = 0; i < this.modules.length; i++)
{
if(this.modules[i].vu == false)
{
return false;
}
}
return true;
}
public function get nbModulesFinished() : int
{
var nb:int = 0;
for(var i:int = 0; i < this.modules.length; i++)
{
if(this.modules[i].vu == true)
{
nb++;
}
}
return nb;
}
public function get module() : Object
{
return this.modules[this.game.config.moduleNum];
}
public function set savePoint(value:Object) : void
{
value.moduleNum = value.moduleNum == undefined ? this.module.no : value.moduleNum;
this._savePoint = value;
}
public function get savePoint() : Object
{
return this._savePoint;
}
public function toString() : String
{
var str:String = "";
for(var i:int = 0; i < this.modules.length; i++)
{
str += "\r\n" + i + " : " + this.modules[i].vu;
}
return str;
}
}
}