package{
import flash.display.Sprite;
[SWF(width="480",height="360",frameRate="60",backgroundColor="0x000000")]
public class Main extends Sprite{
private var eclair:Eclair;
public function Main(){
eclair=new Eclair();
addChild(eclair);
}
}
}
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Shape;
import flash.display.Sprite;
import flash.display.StageQuality;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.events.SecurityErrorEvent;
import flash.net.SharedObject;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.system.System;
import flash.system.Capabilities;
import flash.utils.ByteArray;
class Eclair extends MovieClip{
public const TITLE_FILE_REQUEST:URLRequest=new URLRequest("http://susisu.ktkr.net/contents/do/quad/title.xml");
public const DOS_FILE_REQUEST:URLRequest=new URLRequest("http://susisu.ktkr.net/contents/do/quad/dos.xml");
public const MUSIC_FILE_REQUEST:URLRequest=new URLRequest("http://susisu.ktkr.net/contents/do/quad/music2.swf");
public const BGA_FILE_REQUEST:URLRequest=new URLRequest("bga.swf");
private var titleLoader:URLLoader;
private var dosLoader:URLLoader;
private var musicLoader:Loader;
private var bgaLoader:Loader;
//flags
private var musicLoaded:Boolean;
private var musicError:Boolean;
private var bgaLoaded:Boolean;
//data
public static var titleData:XML;
public static var dos:XML;
public static var music:MovieClip;
public static var bga:MovieClip;
//title
public static var musicTitle:String;
public static var makerName:String;
public static var url:String;
//options
public static var normalOptions:Options;
public static var replayOptions:Options;
//shared object
private var sharedObject:SharedObject;
//game
public var game:Game;
public static var hiScore:Score;
public static var replayMode:Boolean;
public static var replayData:Vector.<Vector.<int>>;
public static var freezeReplayData:Vector.<Vector.<int>>;
public static var particleImg:BitmapData;
//UI
private var loadingView:LoadingView;
private var title:Title;
private var over:Over;
public function Eclair(){
super();
stop();
System.useCodePage=false;
addEventListener(Event.ADDED_TO_STAGE,onAddedToStage);
}
private function onAddedToStage(e:Event):void{
stage.showDefaultContextMenu=false;
stage.quality=StageQuality.HIGH;
loadingView=new LoadingView();
addChild(loadingView);
addEventListener(Event.ENTER_FRAME,onSWFLoading);
}
private function onSWFLoading(e:Event):void{
var pc:Number=loaderInfo.bytesLoaded/loaderInfo.bytesTotal;
loadingView.message.text="Now Loading... "+Math.floor(pc*100).toString()+"%";
if(pc>=1){
removeEventListener(Event.ENTER_FRAME,onSWFLoading);
if(parseInt(Capabilities.version.split(" ")[1].split(",")[0])<11){
loadingView.message.text="This game requires FlashPlayer 11 or later.";
return;
}
init();
loadTitleFile();
}
}
private function init():void{
musicLoaded=false;
musicError=false;
bgaLoaded=false;
replayMode=false;
replayData=new Vector.<Vector.<int>>(5);
freezeReplayData=new Vector.<Vector.<int>>(5);
sharedObject=SharedObject.getLocal("eclair");
//sharedObject.clear();
if(sharedObject.data.hiScore!=undefined){
var soHiScore:Object=sharedObject.data.hiScore;
hiScore=new Score();
hiScore.options=new Options();
hiScore.options.difficultyNum=soHiScore.options.difficultyNum;
hiScore.options.speed=soHiScore.options.speed;
hiScore.options.scrollNum=soHiScore.options.scrollNum;
hiScore.options.appearanceNum=soHiScore.options.appearanceNum;
hiScore.options.darkNum=soHiScore.options.darkNum;
hiScore.options.barDrainNum=soHiScore.options.barDrainNum;
hiScore.replayData=soHiScore.replayData;
hiScore.freezeReplayData=soHiScore.freezeReplayData;
hiScore.arrowJudgements=soHiScore.arrowJudgements.slice();
hiScore.freezeArrowJudgements=soHiScore.freezeArrowJudgements.slice();
hiScore.combo=soHiScore.combo;
hiScore.freezeCombo=soHiScore.freezeCombo;
hiScore.maxCombo=soHiScore.maxCombo;
hiScore.maxFreezeCombo=soHiScore.maxFreezeCombo;
hiScore.scoreNum=soHiScore.scoreNum;
hiScore.rank=soHiScore.rank;
}
else{
hiScore=null
}
title=new Title();
Arrow.init();
Onigiri.init();
FreezeArrow.init();
Game.speed1x=2;
Game.moveLength=512;//512-64*2;
Game.totalFrame=9198;
Game.arrowClasses=[Arrow,Arrow,Arrow,Arrow,Onigiri];
Game.freezeArrowClasses=[FreezeArrow,FreezeArrow,FreezeArrow,FreezeArrow,FreezeArrow];
Game.stepClasses=[StepArrow,StepArrow,StepArrow,StepArrow,StepOnigiri];
game=new Game();
over=new Over();
particleImg=new BitmapData(32,32,true,0x00000000);
var shape:Shape=new Shape();
shape.graphics.beginFill(0x000000,0.5);
shape.graphics.drawCircle(16,16,16);
shape.graphics.endFill();
particleImg.draw(shape);
}
private function loadTitleFile():void{
titleLoader=new URLLoader();
titleLoader.load(TITLE_FILE_REQUEST);
titleLoader.addEventListener(Event.COMPLETE,onTitleComplete);
titleLoader.addEventListener(IOErrorEvent.IO_ERROR,onTitleIOError);
titleLoader.addEventListener(ProgressEvent.PROGRESS,onTitleProgress);
titleLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onTitleSecurityError);
}
private function onTitleComplete(e:Event):void{
titleLoader.removeEventListener(Event.COMPLETE,onTitleComplete);
titleLoader.removeEventListener(IOErrorEvent.IO_ERROR,onTitleIOError);
titleLoader.removeEventListener(ProgressEvent.PROGRESS,onTitleProgress);
titleLoader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onTitleSecurityError);
titleData=XML(titleLoader.data);
musicTitle=titleData.title[0].toString();
makerName=titleData.maker[0].toString();
url=titleData.page[0].toString();
loadDOSFile();
}
private function onTitleIOError(e:IOErrorEvent):void{
titleLoader.removeEventListener(Event.COMPLETE,onTitleComplete);
titleLoader.removeEventListener(IOErrorEvent.IO_ERROR,onTitleIOError);
titleLoader.removeEventListener(ProgressEvent.PROGRESS,onTitleProgress);
titleLoader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onTitleSecurityError);
loadingView.message.text="IO Error on loading Title file.";
}
private function onTitleProgress(e:ProgressEvent):void{
var pc:Number=e.bytesLoaded/e.bytesTotal;
loadingView.message.text="Loading title file... "+Math.floor(pc*100).toString()+"%";
}
private function onTitleSecurityError(e:SecurityErrorEvent):void{
titleLoader.removeEventListener(Event.COMPLETE,onTitleComplete);
titleLoader.removeEventListener(IOErrorEvent.IO_ERROR,onTitleIOError);
titleLoader.removeEventListener(ProgressEvent.PROGRESS,onTitleProgress);
titleLoader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onTitleSecurityError);
loadingView.message.text="Security Error on loading Title file.";
}
private function loadDOSFile():void{
dosLoader=new URLLoader();
dosLoader.load(DOS_FILE_REQUEST);
dosLoader.addEventListener(Event.COMPLETE,onDOSComplete);
dosLoader.addEventListener(IOErrorEvent.IO_ERROR,onDOSIOError);
dosLoader.addEventListener(ProgressEvent.PROGRESS,onDOSProgress);
dosLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onDOSSecurityError);
}
private function onDOSComplete(e:Event):void{
dosLoader.removeEventListener(Event.COMPLETE,onDOSComplete);
dosLoader.removeEventListener(IOErrorEvent.IO_ERROR,onDOSIOError);
dosLoader.removeEventListener(ProgressEvent.PROGRESS,onDOSProgress);
dosLoader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onDOSSecurityError);
dos=XML(dosLoader.data);
loadMusicFile();
initOptions();
removeChild(loadingView);
gotoTitle();
}
private function onDOSIOError(e:IOErrorEvent):void{
dosLoader.removeEventListener(Event.COMPLETE,onDOSComplete);
dosLoader.removeEventListener(IOErrorEvent.IO_ERROR,onDOSIOError);
dosLoader.removeEventListener(ProgressEvent.PROGRESS,onDOSProgress);
dosLoader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onDOSSecurityError);
loadingView.message.text="IO Error on loading DOS file.";
}
private function onDOSProgress(e:ProgressEvent):void{
var pc:Number=e.bytesLoaded/e.bytesTotal;
loadingView.message.text="Loading DOS file... "+Math.floor(pc*100).toString()+"%";
}
private function onDOSSecurityError(e:SecurityErrorEvent):void{
dosLoader.removeEventListener(Event.COMPLETE,onDOSComplete);
dosLoader.removeEventListener(IOErrorEvent.IO_ERROR,onDOSIOError);
dosLoader.removeEventListener(ProgressEvent.PROGRESS,onDOSProgress);
dosLoader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onDOSSecurityError);
loadingView.message.text="Security Error on loading DOS file.";
}
private function loadMusicFile():void{
musicLoader=new Loader();
musicLoader.load(MUSIC_FILE_REQUEST);
musicLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,onMusicInit);
musicLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onMusicIOError);
musicLoader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onMusicSecurityError);
}
private function onMusicInit(e:Event):void{
musicLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,onMusicInit);
musicLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,onMusicIOError);
musicLoader.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onMusicSecurityError);
music=MovieClip(musicLoader.content);
music.gotoAndStop(0);
musicLoaded=true;
}
private function onMusicIOError(e:IOErrorEvent):void{
musicLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,onMusicInit);
musicLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,onMusicIOError);
musicLoader.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onMusicSecurityError);
musicError=true;
}
private function onMusicSecurityError(e:SecurityErrorEvent):void{
musicLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,onMusicInit);
musicLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,onMusicIOError);
musicLoader.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onMusicSecurityError);
musicError=true;
}
private function initOptions():void{
normalOptions=new Options();
replayOptions=new Options();
//difficulty
Options.difficultyName=titleData.difficulty.@name.toXMLString().split("\n");
Options.speedLock=titleData.difficulty.@speedLock.toXMLString().split("\n");
Options.arrowColor=titleData.difficulty.@color.toXMLString().split("\n");
Options.freezeArrowColor=titleData.difficulty.@frzcolor.toXMLString().split("\n");
normalOptions.difficultyNum=0;
replayOptions.difficultyNum=0;
//speed
Options.minSpeed=1;
Options.maxSpeed=3;
normalOptions.speed=Options.speedLock[normalOptions.difficultyNum];
replayOptions.speed=Options.speedLock[replayOptions.difficultyNum];
//scroll
Options.scrollName=["Up","Down","Cross","3D"];
Options.scrollPattern=[
[1,1,1,1,1],
[-1,-1,-1,-1,-1],
[1,-1,1,-1,1],
[-1,-1,-1,-1,-1]
];
normalOptions.scrollNum=3;
replayOptions.scrollNum=3;
//appearance
Options.appearanceName=["Visible","Hidden","Sudden"];
normalOptions.appearanceNum=0;
replayOptions.appearanceNum=0;
//dark
Options.darkName=["None","StepZone","LifeGauge","Judgement","Triple"];
normalOptions.darkNum=0;
replayOptions.darkNum=0;
//bar drain
Options.barDrainName=["Standard","Practice","NoRecovery","SuddenDeath"];
Options.barDrainPattern=[
[25,2,0,-4,-6,4,-10],
[100,0,0,0,0,0,0],
[100,0,0,-4,-6,0,-10],
[100,0,0,-100,-100,0,-100]
];
normalOptions.barDrainNum=0;
replayOptions.barDrainNum=0;
//correction
Options.maxCorrection=15;
Options.correction=0;
//quality
Options.qualityNum=1;
Options.qualityName=[/*"AutoHigh",*/"Low","Medium","High"];
//effect
Options.effectNum=0;
Options.effectName=["Off"];
//key config
Options.keyConfig=new Vector.<int>(5);
Options.keyConfig[0]=37;
Options.keyConfig[1]=40;
Options.keyConfig[2]=38;
Options.keyConfig[3]=39;
Options.keyConfig[4]=32;
Options.keyName=new Array();
for(var i:int=0;i<300;i++){
Options.keyName[i]="";
}
Options.keyName[8]="BS";
Options.keyName[9]="Tab";
Options.keyName[12]="Clear";
Options.keyName[13]="Enter";
Options.keyName[16]="Shift";
Options.keyName[17]="Ctrl";
Options.keyName[18]="Alt";
Options.keyName[19]="Pause";
Options.keyName[27]="Esc";
Options.keyName[29]="noCh";
Options.keyName[32]="Space";
Options.keyName[33]="PgUp";
Options.keyName[34]="PgDn";
Options.keyName[35]="End";
Options.keyName[36]="Home";
Options.keyName[37]="←";
Options.keyName[38]="↑";
Options.keyName[39]="→";
Options.keyName[40]="↓";
Options.keyName[44]="PS";
Options.keyName[45]="Ins";
Options.keyName[46]="Del";
Options.keyName[47]="Help";
Options.keyName[48]="0";
Options.keyName[49]="1";
Options.keyName[50]="2";
Options.keyName[51]="3";
Options.keyName[52]="4";
Options.keyName[53]="5";
Options.keyName[54]="6";
Options.keyName[55]="7";
Options.keyName[56]="8";
Options.keyName[57]="9";
Options.keyName[65]="A";
Options.keyName[66]="B";
Options.keyName[67]="C";
Options.keyName[68]="D";
Options.keyName[69]="E";
Options.keyName[70]="F";
Options.keyName[71]="G";
Options.keyName[72]="H";
Options.keyName[73]="I";
Options.keyName[74]="J";
Options.keyName[75]="K";
Options.keyName[76]="L";
Options.keyName[77]="M";
Options.keyName[78]="N";
Options.keyName[79]="O";
Options.keyName[80]="P";
Options.keyName[81]="Q";
Options.keyName[82]="R";
Options.keyName[83]="S";
Options.keyName[84]="T";
Options.keyName[85]="U";
Options.keyName[86]="V";
Options.keyName[87]="W";
Options.keyName[88]="X";
Options.keyName[89]="Y";
Options.keyName[90]="Z";
Options.keyName[91]="Win";
Options.keyName[96]="T0";
Options.keyName[97]="T1";
Options.keyName[98]="T2";
Options.keyName[99]="T3";
Options.keyName[100]="T4";
Options.keyName[101]="T5";
Options.keyName[102]="T6";
Options.keyName[103]="T7";
Options.keyName[104]="T8";
Options.keyName[105]="T9";
Options.keyName[106]="T*";
Options.keyName[107]="T+";
Options.keyName[108]="TEnter";
Options.keyName[109]="T-";
Options.keyName[110]="T_";
Options.keyName[111]="T/";
Options.keyName[112]="F1";
Options.keyName[113]="F2";
Options.keyName[114]="F3";
Options.keyName[115]="F4";
Options.keyName[116]="F5";
Options.keyName[117]="F6";
Options.keyName[118]="F7";
Options.keyName[119]="F8";
Options.keyName[120]="F9";
Options.keyName[121]="F10";
Options.keyName[122]="F11";
Options.keyName[123]="F12";
Options.keyName[124]="F13";
Options.keyName[125]="F14";
Options.keyName[126]="F15";
Options.keyName[144]="NumLk";
Options.keyName[145]="SL";
Options.keyName[186]=": *";
Options.keyName[187]="; +";
Options.keyName[188]=", <";
Options.keyName[189]="- _";
Options.keyName[190]=". >";
Options.keyName[191]="/ ?";
Options.keyName[192]="@ `";
Options.keyName[216]="\\ _";
Options.keyName[219]="[ {";
Options.keyName[220]="| \\";
Options.keyName[221]="] }";
Options.keyName[222]="^ ~";
Options.keyName[229]="Z/H";
Options.keyName[240]="CapsLk";
}
private function gotoTitle():void{
addChild(title);
title.addEventListener(EclairEvent.GAME_START,onGameStart);
}
private function onGameStart(e:EclairEvent):void{
title.removeEventListener(EclairEvent.GAME_START,onGameStart);
removeChild(title);
gotoCalc();
}
private function gotoCalc():void{
addChild(loadingView);
loadDOSFile2();
loadingView.message.text="Now loading...";
}
private function loadDOSFile2():void{
dosLoader=new URLLoader();
dosLoader.load(DOS_FILE_REQUEST);
dosLoader.addEventListener(Event.COMPLETE,onDOSComplete2);
dosLoader.addEventListener(IOErrorEvent.IO_ERROR,onDOSIOError);
dosLoader.addEventListener(ProgressEvent.PROGRESS,onDOSProgress);
dosLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onDOSSecurityError);
}
private function onDOSComplete2(e:Event):void{
dosLoader.removeEventListener(Event.COMPLETE,onDOSComplete2);
dosLoader.removeEventListener(IOErrorEvent.IO_ERROR,onDOSIOError);
dosLoader.removeEventListener(ProgressEvent.PROGRESS,onDOSProgress);
dosLoader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onDOSSecurityError);
dos=XML(dosLoader.data);
if(musicLoaded){
calc();
}
else{
musicLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,onMusicInit);
musicLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,onMusicIOError);
musicLoader.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onMusicSecurityError);
if(musicError){
musicLoader.unload();
musicLoader=new Loader();
musicLoader.load(MUSIC_FILE_REQUEST);
}
musicLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,onMusicInit2);
musicLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onMusicIOError2);
musicLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onMusicProgress);
musicLoader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onMusicSecurityError2);
}
}
private function onMusicInit2(e:Event):void{
musicLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,onMusicInit2);
musicLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,onMusicIOError2);
musicLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,onMusicProgress);
musicLoader.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onMusicSecurityError2);
music=MovieClip(musicLoader.content);
music.gotoAndStop(0);
musicLoaded=true;
calc();
}
private function onMusicIOError2(e:IOErrorEvent):void{
musicLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,onMusicInit2);
musicLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,onMusicIOError2);
musicLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,onMusicProgress);
musicLoader.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onMusicSecurityError2);
loadingView.message.text="IO Error on loading Music file.";
}
private function onMusicProgress(e:ProgressEvent):void{
var pc:Number=e.bytesLoaded/e.bytesTotal;
loadingView.message.text="Loading Music file... "+Math.floor(pc*100).toString()+"%";
}
private function onMusicSecurityError2(e:SecurityErrorEvent):void{
musicLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,onMusicInit2);
musicLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,onMusicIOError2);
musicLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,onMusicProgress);
musicLoader.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,onMusicSecurityError2);
loadingView.message.text="Security Error on loading Music file.";
}
private function calc():void{
loadingView.message.text="Calculating... Please wait.";
game.replayMode=replayMode;
if(replayMode){
game.replayData=replayData;
game.freezeReplayData=freezeReplayData;
}
if(game.init()){
loadingView.message.text="Let's play!";
}
else{
loadingView.message.text="No book data in DOS file.";
return;
}
removeChild(loadingView);
gotoGame();
}
private function gotoGame():void{
addChild(game);
game.start();
music.play();
game.addEventListener(EclairEvent.GAME_RETRY,onGameRetry);
game.addEventListener(EclairEvent.GAME_QUIT,onGameQuit);
game.addEventListener(EclairEvent.GAME_OVER,onGameOver);
}
private function onGameRetry(e:EclairEvent):void{
game.removeEventListener(EclairEvent.GAME_OVER,onGameOver);
game.removeEventListener(EclairEvent.GAME_RETRY,onGameRetry);
game.removeEventListener(EclairEvent.GAME_QUIT,onGameQuit);
music.gotoAndStop(0);
removeChild(game);
gotoCalcFromGame();
}
private function gotoCalcFromGame():void{
addChild(loadingView);
loadingView.message.text="Now loading...";
game.kill();
gotoCalc();
}
private function onGameQuit(e:EclairEvent):void{
game.removeEventListener(EclairEvent.GAME_RETRY,onGameRetry);
game.removeEventListener(EclairEvent.GAME_QUIT,onGameQuit);
game.removeEventListener(EclairEvent.GAME_OVER,onGameOver);
music.gotoAndStop(0);
removeChild(game);
gotoTitleFromGame();
}
private function gotoTitleFromGame():void{
addChild(title);
game.kill();
gotoTitle();
}
private function onGameOver(e:EclairEvent):void{
game.removeEventListener(EclairEvent.GAME_RETRY,onGameRetry);
game.removeEventListener(EclairEvent.GAME_QUIT,onGameQuit);
game.removeEventListener(EclairEvent.GAME_OVER,onGameOver);
music.gotoAndStop(0);
if(game.score.combo>game.score.maxCombo){
game.score.maxCombo=game.score.combo;
}
if(game.score.freezeCombo>game.score.maxFreezeCombo){
game.score.maxFreezeCombo=game.score.freezeCombo;
}
game.score.calculateRank(game.failed);
game.score.replayData=Score.replayDataFromVector(game.replayData);
game.score.freezeReplayData=Score.freezeReplayDataFromVector(game.freezeReplayData);
if(!replayMode){
if(hiScore==null){
hiScore=game.score.clone();
}
else if(game.score.scoreNum>hiScore.scoreNum){
hiScore=game.score.clone();
}
sharedObject.data.hiScore=hiScore.clone();
}
removeChild(game);
gotoOver();
}
private function gotoOver():void{
addChild(over);
if(game.failed){
over.message.text="failed";
}
else{
over.message.text="cleared";
}
game.kill();
}
}
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.display.StageQuality;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.geom.Vector3D;
import away3d.cameras.Camera3D;
import away3d.containers.ObjectContainer3D;
import away3d.containers.Scene3D;
import away3d.containers.View3D;
import away3d.lights.DirectionalLight;
import away3d.lights.PointLight;
import away3d.materials.lightpickers.StaticLightPicker;
import away3d.primitives.WireframePlane;
class Game extends Sprite{
public static var speed1x:Number=2;
public static var moveLength:Number=300;
public static var totalFrame:int=160;
public static var arrowClasses:Array; //Class(IArrow)
public static var freezeArrowClasses:Array; //Class(IFreezeArrow)
public static var stepClasses:Array; //Class(IStep)
private var arrowBook:Vector.<Vector.<ArrowQueue>>;
private var freezeArrowBook:Vector.<Vector.<FreezeArrowQueue>>;
private var speedBook:Vector.<SpeedQueue>;
private var boostBook:Vector.<SpeedQueue>;
private var arrows:Vector.<Vector.<IArrow>>;
private var freezeArrows:Vector.<Vector.<IFreezeArrow>>;
private var arrowPool:Vector.<Vector.<IArrow>>;
private var freezeArrowPool:Vector.<Vector.<IFreezeArrow>>;
private var options:Options;
public var score:Score;
public var replayMode:Boolean;
public var replayData:Vector.<Vector.<int>>;
public var freezeReplayData:Vector.<Vector.<int>>;
public var replayIndex:Vector.<int>;
public var freezeReplayIndex:Vector.<int>;
private var keyCommand:uint;
private var life:Number;
private var currentFrame:int;
private var arrowIDs:Vector.<int>;
private var freezeArrowIDs:Vector.<int>;
private var currentSpeed:Number;
private var arrowQueue:Vector.<ArrowQueue>;
private var freezeArrowQueue:Vector.<FreezeArrowQueue>;
private var speedQueue:SpeedQueue;
private var keyIsDown:Vector.<Boolean>;
public var failed:Boolean;
private var view:View3D;
private var scene:Scene3D;
private var camera:Camera3D;
private var stageContainer:ObjectContainer3D;
private var stepZone:ObjectContainer3D;
private var steps:Vector.<IStep>;
private var lifeGauge:ILifeGauge;
private var particles:Vector.<Particle>;
private var particlePool:Vector.<Particle>;
private var timeGauge:TimeGauge;
public function Game(){
arrows=new Vector.<Vector.<IArrow>>(5);
freezeArrows=new Vector.<Vector.<IFreezeArrow>>(5);
arrowPool=new Vector.<Vector.<IArrow>>(5);
freezeArrowPool=new Vector.<Vector.<IFreezeArrow>>(5);
for(var i:int=0;i<5;i++){
arrows[i]=new Vector.<IArrow>();
freezeArrows[i]=new Vector.<IFreezeArrow>();
arrowPool[i]=new Vector.<IArrow>();
freezeArrowPool[i]=new Vector.<IFreezeArrow>();
}
arrowIDs=new Vector.<int>(5);
freezeArrowIDs=new Vector.<int>(5);
arrowQueue=new Vector.<ArrowQueue>(5);
freezeArrowQueue=new Vector.<FreezeArrowQueue>(5);
replayMode=false;
replayIndex=new Vector.<int>(5);
freezeReplayIndex=new Vector.<int>(5);
keyIsDown=new Vector.<Boolean>(5);
view=new View3D();
view.antiAlias=4;
view.backgroundColor=0x000000;
addChild(view);
scene=view.scene;
camera=view.camera;
camera.z=-512;
camera.lookAt(new Vector3D(0,0,0));
stageContainer=new ObjectContainer3D();
scene.addChild(stageContainer);
stepZone=new ObjectContainer3D();
stageContainer.addChild(stepZone);
steps=new Vector.<IStep>();
for(i=0;i<5;i++){
var step:IStep=new stepClasses[i]();
step.blendMode="add";
step.rotationZ=(i==0?0:(i==1?90:(i==2?-90:(i==3?180:0))));
step.x=-192+80*i+(i==4?32:0);
stepZone.addChild(step as ObjectContainer3D);
steps.push(step);
}
var wp:WireframePlane=new WireframePlane(512,512,10,10,0x808080,0.5,"xy");
wp.z=100;
stageContainer.addChild(wp);
lifeGauge=new LifeGauge();
lifeGauge.rotationY=45;
lifeGauge.x=-256-56;
lifeGauge.z=-64;
scene.addChild(lifeGauge as ObjectContainer3D);
particles=new Vector.<Particle>();
particlePool=new Vector.<Particle>();
timeGauge=new TimeGauge();
timeGauge.rotationY=45;
timeGauge.x=256+56;
timeGauge.z=-64;
timeGauge.time=0;
timeGauge.totalTime=totalFrame;
scene.addChild(timeGauge);
var light:PointLight=new PointLight();
light.z=-256;
scene.addChild(light);
var dlight:DirectionalLight=new DirectionalLight(0,0,1);
scene.addChild(dlight);
var picker:StaticLightPicker=new StaticLightPicker([light,dlight]);
(lifeGauge as LifeGauge).material.lightPicker=picker;
timeGauge.material.lightPicker=picker;
}
//initialize before starting game
public function init():Boolean{
//change options
if(replayMode){
options=Eclair.replayOptions;
for(var i:int=0;i<5;i++){
replayIndex[i]=0;
freezeReplayIndex[i]=0;
}
}
else{
options=Eclair.normalOptions;
replayData=new Vector.<Vector.<int>>(5);
freezeReplayData=new Vector.<Vector.<int>>(5);
for(i=0;i<5;i++){
replayData[i]=new Vector.<int>();
freezeReplayData[i]=new Vector.<int>();
}
}
//extract book data from DOS
var difName:String=Options.difficultyName[options.difficultyNum];
var bookData:XML=Eclair.dos.book.(@name==difName)[0];
if(bookData==null){
return false;
}
//cooking
//speed
var t:Array=(bookData.speed[0].toString()).split(",");
var l:int=t.length;
speedBook=new Vector.<SpeedQueue>();
for(i=0;i<l;i+=2){
if(t[i]!="" && t[i+1]!=undefined){
var spdQueue:SpeedQueue=new SpeedQueue(parseInt(t[i]),parseFloat(t[i+1]));
speedBook.push(spdQueue);
}
}
speedBook.unshift(new SpeedQueue(-(moveLength/speed1x>>0)-1,1));
sortQueueList(speedBook);
fixSpeedQueueList(speedBook);
//boost
t=(bookData.boost[0].toString()).split(",");
l=t.length;
boostBook=new Vector.<SpeedQueue>();
for(i=0;i<l;i+=2){
if(t[i]!="" && t[i+1]!=undefined){
spdQueue=new SpeedQueue(parseInt(t[i]),parseFloat(t[i+1]));
boostBook.push(spdQueue);
}
}
boostBook.unshift(new SpeedQueue(-(moveLength/speed1x>>0)-1,1));
sortQueueList(boostBook);
fixSpeedQueueList(boostBook);
//arrows
arrowBook=new Vector.<Vector.<ArrowQueue>>(5);
var arrowTemp:Vector.<Array>=new Vector.<Array>();
for(i=0;i<5;i++){
t=(bookData.arrow.(@id==i)[0].toString()).split(",");
if(t[0]==""){
t=new Array();
}
sortArray(t);
deleteSame(t);
arrowTemp.push(t);
}
//freeze arrows
freezeArrowBook=new Vector.<Vector.<FreezeArrowQueue>>(5);
var freezeArrowTemp:Vector.<Array>=new Vector.<Array>();
for(i=0;i<5;i++){
t=(bookData.frzarrow.(@id==i)[0].toString()).split(",");
if(t[0]==""){
t=new Array();
}
sortArray(t);
deleteSame(t);
if(t.length%2!=0){
t.pop();
}
freezeArrowTemp.push(t);
}
//calculate timings and differences
var spdi:int=0;
var spdl:int=speedBook.length;
var bsti:int=0;
var bstl:int=boostBook.length;
//arrows
for(i=0;i<5;i++){
arrowBook[i]=new Vector.<ArrowQueue>();
t=arrowTemp[i];
l=t.length;
spdi=0;
bsti=0;
for(var j:int=0;j<l;j++){
while(spdi<=spdl-1 && speedBook[spdi].frameNum<=t[j]){
spdi++;
}
spdi--;
while(bsti<=bstl-1 && boostBook[bsti].frameNum<=t[j]){
bsti++;
}
bsti--;
var frame:int=t[j];
var spdj:int=spdi;
var spdq:SpeedQueue=speedBook[spdj];
var bstq:SpeedQueue=boostBook[bsti];
var s:Number=0;
while(s<moveLength){
s+=speed1x*options.speed*spdq.speed*bstq.speed;
frame--;
if(frame<spdq.frameNum){
spdj--;
spdq=speedBook[spdj];
}
}
arrowBook[i].push(new ArrowQueue(j,frame,s-moveLength,bstq.speed,t[j]));
}
sortQueueList(arrowBook[i]);
}
//freeze arrows
for(i=0;i<5;i++){
freezeArrowBook[i]=new Vector.<FreezeArrowQueue>();
t=freezeArrowTemp[i];
l=t.length;
spdi=0;
bsti=0;
for(j=0;j<l;j+=2){
while(spdi<=spdl-1 && speedBook[spdi].frameNum<=t[j]){
spdi++;
}
spdi--;
while(bsti<=bstl-1 && boostBook[bsti].frameNum<=t[j]){
bsti++;
}
bsti--;
frame=t[j];
spdj=spdi;
spdq=speedBook[spdj];
bstq=boostBook[bsti];
s=0;
while(s<moveLength){
s+=speed1x*options.speed*spdq.speed*bstq.speed;
frame--;
if(frame<spdq.frameNum){
spdj--;
spdq=speedBook[spdj];
}
}
var s2:Number=0;
var frame2:int=t[j];
spdj=spdi;
spdq=speedBook[spdj];
while(frame2<t[j+1]){
s2+=speed1x*options.speed*spdq.speed*bstq.speed;
frame2++;
if(spdj<spdl-1 && frame2>=speedBook[spdj+1].frameNum){
spdj++;
spdq=speedBook[spdj];
}
}
freezeArrowBook[i].push(new FreezeArrowQueue(j/2,frame,s-moveLength,bstq.speed,t[j],t[j+1]-t[j],s2));
}
sortQueueList(freezeArrowBook[i]);
}
correctQueueList(speedBook);
for(i=0;i<5;i++){
correctQueueList(arrowBook[i]);
correctQueueList(freezeArrowBook[i]);
}
var topFrame:int=0;
for(i=0;i<5;i++){
var arrowTopFrame:int=0;
if(arrowBook[i].length>0){
arrowTopFrame=arrowBook[i][0].frameNum;
}
var freezeArrowTopFrame:int=0;
if(freezeArrowBook[i].length>0){
freezeArrowTopFrame=freezeArrowBook[i][0].frameNum;
}
topFrame=Math.min(topFrame,arrowTopFrame,freezeArrowTopFrame);
}
currentFrame=topFrame;
speedBook.reverse();
currentSpeed=speed1x*(speedBook.pop()).speed*options.speed;
if(speedBook.length>0){
speedQueue=speedBook.pop();
}
for(i=0;i<5;i++){
arrowIDs[i]=0;
arrowBook[i].reverse();
arrowQueue[i]=null;
if(arrowBook[i].length>0){
arrowQueue[i]=arrowBook[i].pop();
}
freezeArrowIDs[i]=0;
freezeArrowBook[i].reverse();
freezeArrowQueue[i]=null;
if(freezeArrowBook[i].length>0){
freezeArrowQueue[i]=freezeArrowBook[i].pop();
}
keyIsDown[i]=false;
steps[i].y=(256-64)*Options.scrollPattern[options.scrollNum][i];
}
score=new Score();
score.options=options.clone();
stageContainer.z=Options.scrollName[options.scrollNum]=="3D"?32:0;
stageContainer.rotationX=Options.scrollName[options.scrollNum]=="3D"?60:0;
stepZone.visible=(Options.darkName[options.darkNum]=="StepZone" ||
Options.darkName[options.darkNum]=="Triple")?false:true;
life=Options.barDrainPattern[options.barDrainNum][0];
lifeGauge.lifePoint=life/100;
lifeGauge.color=getLifegaugeColor();
lifeGauge.visible=(Options.darkName[options.darkNum]=="LifeGauge" ||
Options.darkName[options.darkNum]=="Triple")?false:true;
timeGauge.time=0;
failed=false;
keyCommand=0;
return true;
}
private function sortQueueList(list:*):void{
//the list should have been almost sorted
var l:int=list.length;
while(true){
var s:int=0;
for(var i:int=0;i<l-1;i++){
if(list[i].frameNum>list[i+1].frameNum){
var temp:Queue=list[i];
list[i]=list[i+1];
list[i+1]=temp;
s++;
}
}
if(s==0){
break;
}
}
}
private function fixSpeedQueueList(list:Vector.<SpeedQueue>):void{
var l:int=list.length;
for(var i:int=0;i<l-1;i++){
if(list[i].frameNum==list[i+1].frameNum){
list.splice(i,1);
i--;
l--;
}
}
for(i=0;i<l-1;i++){
if(list[i].speed==list[i+1].speed){
list.splice(i+1,1);
i--;
l--;
}
}
}
private function sortArray(array:Array):void{
var l:int=array.length;
while(true){
var s:int=0;
for(var i:int=0;i<l-1;i++){
if(array[i]>array[i+1]){
var temp:int=array[i];
array[i]=array[i+1];
array[i+1]=temp;
s++;
}
}
if(s==0){
break;
}
}
}
private function deleteSame(array:Array):void{
var l:int=array.length;
for(var i:int=0;i<l-1;i++){
if(array[i]==array[i+1]){
array.splice(i,1);
i--;
l--;
}
}
}
private function correctQueueList(list:*):void{
var l:int=list.length;
for(var i:int=0;i<l;i++){
list[i].frameNum+=Options.correction;
if(list[i] is ArrowQueue){
list[i].endFrame+=Options.correction;
}
}
}
//start game
public function start():void{
while(currentFrame<0){
move();
}
switch(Options.qualityName[Options.qualityNum]){
case "AutoHigh":
stage.quality="autohigh";
view.antiAlias=2;
break;
case "Low":
stage.quality=StageQuality.LOW;
view.antiAlias=0;
break;
case "Medium":
stage.quality=StageQuality.MEDIUM;
view.antiAlias=2;
break;
case "High":
stage.quality=StageQuality.HIGH;
view.antiAlias=4;
break;
}
addEventListener(Event.ENTER_FRAME,inPlayingEnterFrame);
stage.addEventListener(KeyboardEvent.KEY_DOWN,inPlayingKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP,inPlayingKeyUp);
stage.focus=stage;
}
private function inPlayingEnterFrame(e:Event):void{
move();
view.render();
}
public function quit():void{
stage.quality=StageQuality.HIGH;
removeEventListener(Event.ENTER_FRAME,inPlayingEnterFrame);
stage.removeEventListener(KeyboardEvent.KEY_DOWN,inPlayingKeyDown);
stage.removeEventListener(KeyboardEvent.KEY_UP,inPlayingKeyUp);
addEventListener(Event.ENTER_FRAME,outOfPlayingEnterFrame);
}
public function kill():void{
for(var i:int=0;i<5;i++){
var l:int=arrows[i].length;
while(l>0){
var arrow:IArrow=arrows[i].pop();
stageContainer.removeChild(arrow as ObjectContainer3D);
arrowPool[i].push(arrow);
l--;
}
l=freezeArrows[i].length;
while(l>0){
var freezeArrow:IFreezeArrow=freezeArrows[i].pop();
stageContainer.removeChild(freezeArrow as ObjectContainer3D);
freezeArrowPool[i].push(freezeArrow);
l--;
}
}
l=particles.length;
while(l>0){
var particle:Particle=particles.pop();
scene.removeChild(particle);
particlePool.push(particle);
l--;
}
removeEventListener(Event.ENTER_FRAME,outOfPlayingEnterFrame);
}
private function outOfPlayingEnterFrame(e:Event):void{
view.render();
}
public function move():void{
//speed
if(speedQueue!=null && currentFrame==speedQueue.frameNum){
currentSpeed=speed1x*speedQueue.speed*options.speed;
if(speedBook.length>0){
speedQueue=speedBook.pop();
}
else{
speedQueue=null;
}
}
for(var i:int=0;i<5;i++){
var scrollDir:int=Options.scrollPattern[options.scrollNum][i];
//move arrows
var at:Vector.<IArrow>=arrows[i];
var l:int=at.length;
for(var j:int=0;j<l;j++){
var arrow:IArrow=at[j];
arrow.frame++;
arrow.y+=currentSpeed*arrow.boost*scrollDir;
arrow.alpha=getAlpha((steps[i].y-arrow.y)*scrollDir);
if(arrow.frame>7){
//uwaan
score.judgeArrow(3);
judgeArrow(arrow,3);
if(!replayMode){
replayData[i].push(8);
}
else{
replayIndex[i]++;
}
arrows[i].splice(j,1);
j--;
l--;
arrowIDs[i]++;
stageContainer.removeChild(arrow as ObjectContainer3D);
arrowPool[i].push(arrow);
}
}
//move freeze arrows
var ft:Vector.<IFreezeArrow>=freezeArrows[i];
l=ft.length;
for(j=0;j<l;j++){
var freezeArrow:IFreezeArrow=ft[j];
freezeArrow.frame++;
if(freezeArrow.isHitting){
if(keyIsDown[i]){
freezeArrow.length-=currentSpeed*freezeArrow.boost;
freezeArrow.rest--;
if(freezeArrow.rest<=0){
//kita
score.judgeFreezeArrow(0);
judgeFreezeArrow(freezeArrow,0);
if(!replayMode){
freezeReplayData[i].push(freezeArrow.frame);
}
else{
keyIsDown[i]=false;
freezeReplayIndex[i]++;
}
freezeArrows[i].splice(j,1);
j--;
l--;
freezeArrowIDs[i]++;
stageContainer.removeChild(freezeArrow as ObjectContainer3D);
freezeArrowPool[i].push(freezeArrow);
}
}
else{
//ikunai
score.judgeFreezeArrow(1);
judgeFreezeArrow(freezeArrow,1);
if(!replayMode){
freezeReplayData[i].push(freezeArrow.frame);
}
else{
keyIsDown[i]=false;
}
freezeArrows[i].splice(j,1);
j--;
l--;
freezeArrowIDs[i]++;
stageContainer.removeChild(freezeArrow as ObjectContainer3D);
freezeArrowPool[i].push(freezeArrow);
}
}
else{
freezeArrow.y+=currentSpeed*freezeArrow.boost*scrollDir;
if(freezeArrow.frame>7){
//ikunai
score.judgeFreezeArrow(1);
judgeFreezeArrow(freezeArrow,1);
if(!replayMode){
freezeReplayData[i].push(8,0);
}
else{
freezeReplayIndex[i]+=2;
}
freezeArrows[i].splice(j,1);
j--;
l--;
freezeArrowIDs[i]++;
stageContainer.removeChild(freezeArrow as ObjectContainer3D);
freezeArrowPool[i].push(freezeArrow);
}
}
freezeArrow.alpha=getAlpha((steps[i].y-freezeArrow.y)*scrollDir);
}
//make arrow
if(arrowQueue[i]!=null && currentFrame==arrowQueue[i].frameNum){
var aq:ArrowQueue=arrowQueue[i];
var newArrow:IArrow;
if(arrowPool[i].length>0){
newArrow=arrowPool[i].pop();
}
else{
newArrow=new arrowClasses[i]();
}
newArrow.alpha=Options.appearanceName[options.appearanceNum]=="Sudden"?0:1;
newArrow.blendMode="add";
newArrow.boost=arrowQueue[i].boost;
newArrow.color=i==4?0xffffff:Options.arrowColor[options.difficultyNum];
newArrow.frame=aq.frameNum-aq.endFrame;
newArrow.id=aq.id;
newArrow.rotationZ=(i==0?0:(i==1?90:(i==2?-90:(i==3?180:0))));
newArrow.x=-192+80*i+(i==4?32:0);
newArrow.y=steps[i].y-scrollDir*(moveLength+aq.dif);
arrows[i].push(newArrow);
stageContainer.addChild(newArrow as ObjectContainer3D);
aq=null;
if(arrowBook[i].length>0){
arrowQueue[i]=arrowBook[i].pop();
}
else{
arrowQueue[i]=null;
}
}
//make freeze arrow
if(freezeArrowQueue[i]!=null && currentFrame==freezeArrowQueue[i].frameNum){
var faq:FreezeArrowQueue=freezeArrowQueue[i];
var newFreezeArrow:IFreezeArrow;
if(freezeArrowPool[i].length>0){
newFreezeArrow=freezeArrowPool[i].pop();
}
else{
newFreezeArrow=new freezeArrowClasses[i]();
}
newFreezeArrow.alpha=Options.appearanceName[options.appearanceNum]=="Sudden"?0:1;
newFreezeArrow.angle=scrollDir==-1?(i==1?2:(i==2?1:i)):i;
newFreezeArrow.blendMode="add";
newFreezeArrow.boost=faq.boost;
newFreezeArrow.color=Options.freezeArrowColor[options.difficultyNum];
newFreezeArrow.frame=faq.frameNum-faq.endFrame;
newFreezeArrow.id=faq.id;
newFreezeArrow.isHitting=false;
newFreezeArrow.length=faq.tail;
newFreezeArrow.rest=faq.length;
newFreezeArrow.rotationX=(scrollDir-1)/2*180;
newFreezeArrow.x=-192+80*i+(i==4?32:0);
newFreezeArrow.y=steps[i].y-scrollDir*(moveLength+faq.dif);
freezeArrows[i].push(newFreezeArrow);
stageContainer.addChild(newFreezeArrow as ObjectContainer3D);
faq=null;
if(freezeArrowBook[i].length>0){
freezeArrowQueue[i]=freezeArrowBook[i].pop();
}
else{
freezeArrowQueue[i]=null;
}
}
steps[i].animate();
}
l=particles.length;
for(i=0;i<l;i++){
var particle:Particle=particles[i];
particle.animate();
if(particle.frame>Particle.TIME){
lifeChange(particle.lifePoint);
particles.splice(i,1);
i--;
l--;
scene.removeChild(particle);
particlePool.push(particle);
}
}
lifeGauge.animate();
if(life<=0){
quit();
failed=true;
dispatchEvent(new EclairEvent(EclairEvent.GAME_OVER));
}
if(currentFrame>=totalFrame){
quit();
failed=false;
dispatchEvent(new EclairEvent(EclairEvent.GAME_OVER));
}
timeGauge.time=currentFrame;
currentFrame++;
//replay
if(replayMode){
for(i=0;i<5;i++){
if(replayIndex[i]<replayData[i].length){
at=arrows[i];
l=at.length;
for(j=0;j<l;j++){
arrow=at[j];
if(arrow.id==arrowIDs[i]){
if(arrow.frame==replayData[i][replayIndex[i]]){
steps[i].hit();
arrowHitTest(i);
replayIndex[i]++;
}
break;
}
}
}
if(freezeReplayIndex[i]<freezeReplayData[i].length){
ft=freezeArrows[i];
l=ft.length;
for(j=0;j<l;j++){
freezeArrow=ft[j];
if(freezeArrow.id==freezeArrowIDs[i]){
if(freezeReplayIndex[i]%2==0){
if(freezeArrow.frame==freezeReplayData[i][freezeReplayIndex[i]]){
steps[i].hit();
arrowHitTest(i);
keyIsDown[i]=true;
freezeReplayIndex[i]++;
}
}
else{
if(freezeArrow.frame==freezeReplayData[i][freezeReplayIndex[i]]){
keyIsDown[i]=false;
freezeReplayIndex[i]++;
}
}
break;
}
}
}
}
}
}
private function getAlpha(d:Number):Number{
var l:Number=512-64*2;//moveLength;
if(Options.appearanceName[options.appearanceNum]=="Visible"){
return 1;
}
else{
var k:Number;
if(l/4<d && d<l*3/4){
k=(d-l/4)/l*2
}
else if(d<=l/4){
k=0;
}
else{
k=1;
}
return Options.appearanceName[options.appearanceNum]=="Hidden"?k:1-k;
}
}
private function arrowHitTest(num:uint):void{
var at:Vector.<IArrow>=arrows[num];
var l:int=at.length;
for(var i:int=0;i<l;i++){
var arrow:IArrow=at[i];
var time:int=Math.abs(arrow.frame);
if(arrow.id==arrowIDs[num] && time<8){
if(time<3){
//ii
score.judgeArrow(0);
judgeArrow(arrow,0);
}
else if(time<5){
//mataari
score.judgeArrow(1);
judgeArrow(arrow,1);
}
else{
//shoboon
score.judgeArrow(2);
judgeArrow(arrow,2);
}
if(!replayMode){
replayData[num].push(arrow.frame);
}
at.splice(i,1);
arrowIDs[num]++;
stageContainer.removeChild(arrow as ObjectContainer3D);
arrowPool[num].push(arrow);
return;
}
}
var fat:Vector.<IFreezeArrow>=freezeArrows[num];
l=fat.length;
for(i=0;i<l;i++){
var freezeArrow:IFreezeArrow=fat[i];
time=Math.abs(freezeArrow.frame);
if(freezeArrow.id==freezeArrowIDs[num] && time<8
&& !freezeArrow.isHitting){
if(time<5){
freezeArrow.isHitting=true;
freezeArrow.length-=(freezeArrow.y-steps[num].y)*Options.scrollPattern[options.scrollNum][num];
freezeArrow.rest-=freezeArrow.frame;
freezeArrow.y=steps[num].y;
if(!replayMode){
freezeReplayData[num].push(freezeArrow.frame);
}
}
else{
//ikunai
score.judgeFreezeArrow(1);
judgeFreezeArrow(freezeArrow,1);
if(!replayMode){
freezeReplayData[num].push(freezeArrow.frame,0);
}
else{
freezeReplayIndex[i]++;
keyIsDown[i]=false;
}
fat.splice(i,1);
freezeArrowIDs[num]++;
stageContainer.removeChild(freezeArrow as ObjectContainer3D);
freezeArrowPool[num].push(freezeArrow);
}
return;
}
}
}
private function judgeArrow(arrow:IArrow,num:int):void{
var ao:ObjectContainer3D=arrow as ObjectContainer3D;
makeParticles(Options.barDrainPattern[options.barDrainNum][num+1],
getArrowJudgementColor(num),ao.scenePosition);
}
private function judgeFreezeArrow(freezeArrow:IFreezeArrow,num:int):void{
var fao:ObjectContainer3D=freezeArrow as ObjectContainer3D;
makeParticles(Options.barDrainPattern[options.barDrainNum][num+5],
getFreezeArrowJudgementColor(num),fao.scenePosition);
}
private function getArrowJudgementColor(num:int):uint{
if(Options.darkName[options.darkNum]=="Judgement" ||
Options.darkName[options.darkNum]=="Triple"){
return 0x808080;
}
if(num==0){
return 0x00ffff;
}
else if(num==1){
return 0xff8000;
}
else if(num==2){
return 0x0000ff;
}
else if(num==3){
return 0xff3000;
}
else{
return 0xffffff;
}
}
private function getFreezeArrowJudgementColor(num:int):uint{
if(Options.darkName[options.darkNum]=="Judgement" ||
Options.darkName[options.darkNum]=="Triple"){
return 0x808080;
}
if(num==0){
return 0xffff00;
}
else if(num==1){
return 0x00ff00;
}
else{
return 0xffffff;
}
}
private function lifeChange(point:Number):void{
life+=point;
lifeGauge.lifePoint=life/100;
//lifeGauge.x=-(1-life/100)*512/2
if(life>100){
life=100;
}
lifeGauge.color=getLifegaugeColor();
}
private function getLifegaugeColor():uint{
if(life<100){
var r:uint=life<25?(0x80+0x7f*life/25):(life>=50?0x00:0xff);
var g:uint=life<25?0x80:(life<50?0x80+0x7f*life/50:0xff);
var b:uint=life>=50?0xff*life/100:0x00;
return (r<<16)|(g<<8)|b;
}
else{
return 0xffffff;
}
}
private function makeParticles(point:Number,color:uint,start:Vector3D):void{
var p:Number=point/4;
var l:int=particlePool.length;
var ty:Number=(Options.darkName[options.darkNum]=="LifeGauge" ||
Options.darkName[options.darkNum]=="Triple")?240:life/100*480;
for(var i:int=0;i<4;i++){
var particle:Particle;
if(l>0){
particle=particlePool.pop();
particle.color=color;
l--;
}
else{
particle=new Particle(color);
}
var r:Number=Math.random()*192+64;
var a:Number=i*Math.PI/2;
var b:Number=Math.random()*Math.PI*2;
particle.init(
start.x+32*Math.cos(a),start.y+32*Math.sin(a)*Math.sin(b),start.z+32*Math.cos(b),
start.x+r*Math.cos(a),start.y+r*Math.sin(a)*Math.sin(b),start.z+r*Math.cos(b),
lifeGauge.x,lifeGauge.y-240+ty,lifeGauge.z,p);
scene.addChild(particle);
particles.push(particle);
}
}
private function inPlayingKeyDown(e:KeyboardEvent):void{
if(!replayMode){
for(var i:int=0;i<5;i++){
if(e.keyCode==Options.keyConfig[i]){
if(!keyIsDown[i]){
steps[i].hit();
arrowHitTest(i);
}
keyIsDown[i]=true;
return;
}
}
}
if(e.keyCode==8){
quit();
dispatchEvent(new EclairEvent(EclairEvent.GAME_RETRY));
}
else if(e.keyCode==46){
quit();
dispatchEvent(new EclairEvent(EclairEvent.GAME_QUIT));
}
}
private function inPlayingKeyUp(e:KeyboardEvent):void{
if(!replayMode){
for(var i:int=0;i<5;i++){
if(e.keyCode==Options.keyConfig[i]){
keyIsDown[i]=false;
break;
}
}
}
}
}
interface IArrow{
function get alpha():Number;
function set alpha(value:Number):void;
function get blendMode():String;
function set blendMode(value:String):void;
function get boost():Number;
function set boost(value:Number):void;
function get color():uint;
function set color(value:uint):void;
function get frame():int;
function set frame(value:int):void;
function get id():int;
function set id(value:int):void;
function get rotationX():Number;
function set rotationX(value:Number):void;
function get rotationY():Number;
function set rotationY(value:Number):void;
function get rotationZ():Number;
function set rotationZ(value:Number):void;
function get scaleX():Number;
function set scaleX(value:Number):void;
function get scaleY():Number;
function set scaleY(value:Number):void;
function get scaleZ():Number;
function set scaleZ(value:Number):void;
function get visible():Boolean;
function set visible(value:Boolean):void;
function get x():Number;
function set x(value:Number):void;
function get y():Number;
function set y(value:Number):void;
function get z():Number;
function set z(value:Number):void;
}
interface IBar{
function get alpha():Number;
function set alpha(value:Number):void;
function get height():Number;
function set height(value:Number):void;
function get width():Number;
function set width(value:Number):void;
function get x():Number;
function set x(value:Number):void;
function get y():Number;
function set y(value:Number):void;
function get z():Number;
function set z(value:Number):void;
}
interface IFreezeArrow extends IArrow{
function get angle():uint;
function set angle(value:uint):void;
function get isHitting():Boolean;
function set isHitting(value:Boolean):void;
function get length():Number;
function set length(value:Number):void;
function get rest():int;
function set rest(value:int):void;
}
interface ILifeGauge{
function animate():void;
function get alpha():Number;
function set alpha(value:Number):void;
function get color():uint;
function set color(value:uint):void;
function get lifePoint():Number;
function set lifePoint(value:Number):void;
function get rotationX():Number;
function set rotationX(value:Number):void;
function get rotationY():Number;
function set rotationY(value:Number):void;
function get rotationZ():Number;
function set rotationZ(value:Number):void;
function get scaleX():Number;
function set scaleX(value:Number):void;
function get scaleY():Number;
function set scaleY(value:Number):void;
function get scaleZ():Number;
function set scaleZ(value:Number):void;
function get visible():Boolean;
function set visible(value:Boolean):void;
function get x():Number;
function set x(value:Number):void;
function get y():Number;
function set y(value:Number):void;
function get z():Number;
function set z(value:Number):void;
}
interface IStep{
function hit():void;
function animate():void;
function get alpha():Number;
function set alpha(value:Number):void;
function get blendMode():String;
function set blendMode(value:String):void;
function get color():uint;
function set color(value:uint):void;
function get rotationX():Number;
function set rotationX(value:Number):void;
function get rotationY():Number;
function set rotationY(value:Number):void;
function get rotationZ():Number;
function set rotationZ(value:Number):void;
function get scaleX():Number;
function set scaleX(value:Number):void;
function get scaleY():Number;
function set scaleY(value:Number):void;
function get scaleZ():Number;
function set scaleZ(value:Number):void;
function get visible():Boolean;
function set visible(value:Boolean):void;
function get x():Number;
function set x(value:Number):void;
function get y():Number;
function set y(value:Number):void;
function get z():Number;
function set z(value:Number):void;
}
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
class LoadingView extends Sprite{
public var message:TextField;
public function LoadingView(){
message=new TextField();
message.width=480;
message.height=360;
message.defaultTextFormat=new TextFormat("_sans",16,0xffffff);
addChild(message);
}
}
class Options extends Object{
//difficulty
public static var difficultyName:Array; //String
public static var speedLock:Array; //Number
public static var arrowColor:Array; //uint;
public static var freezeArrowColor:Array; //uint
public var difficultyNum:int;
//speed
public static var minSpeed:Number;
public static var maxSpeed:Number;
public var speed:Number;
//scroll
public static var scrollName:Array; //String
public static var scrollPattern:Array; //Array int
public var scrollNum:int;
//appearance
public static var appearanceName:Array; //String
public var appearanceNum:int;
//dark
public static var darkName:Array; //String
public var darkNum:int;
//bar drain
public static var barDrainName:Array; //String
public static var barDrainPattern:Array; //Array Number
public var barDrainNum:int;
//correction
public static var maxCorrection:int;
public static var correction:int;
//quality
public static var qualityNum:int;
public static var qualityName:Array; //String
//effect
public static var effectNum:int;
public static var effectName:Array; //String
//key config
public static var keyConfig:Vector.<int>;
public static var keyName:Array; //String
public function Options(){
}
public function clone():Options{
var options:Options=new Options();
options.difficultyNum=difficultyNum;
options.speed=speed;
options.scrollNum=scrollNum;
options.appearanceNum=appearanceNum;
options.darkNum=darkNum;
options.barDrainNum=barDrainNum;
return options;
}
public static function fromString(str:String):Options{
var options:Options=new Options();
var arr:Array=str.split(",");
options.difficultyNum=parseInt(arr[0]);
options.speed=parseFloat(arr[1]);
options.scrollNum=parseInt(arr[2]);
options.appearanceNum=parseInt(arr[3]);
options.darkNum=parseInt(arr[4]);
options.barDrainNum=parseInt(arr[5]);
return options;
}
}
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
class Over extends Sprite{
public var message:TextField;
public function Over(){
message=new TextField();
message.width=480;
message.height=360;
message.defaultTextFormat=new TextFormat("_sans",16,0xffffff);
addChild(message);
}
}
class Score extends Object{
public var options:Options;
public var replayData:String;
public var freezeReplayData:String;
public var arrowJudgements:Vector.<int>;
public var freezeArrowJudgements:Vector.<int>;
public var combo:int;
public var freezeCombo:int;
public var maxCombo:int;
public var maxFreezeCombo:int;
public var scoreNum:int;
public var rank:String;
public function Score(){
options=null;
replayData="";
freezeReplayData="";
arrowJudgements=new Vector.<int>(4);
freezeArrowJudgements=new Vector.<int>(2);
combo=0;
freezeCombo=0;
maxCombo=0;
maxFreezeCombo=0;
scoreNum=0;
rank="";
}
public function clone():Score{
var score:Score=new Score();
score.options=options.clone();
score.replayData=replayData;
score.freezeReplayData=freezeReplayData;
score.arrowJudgements=arrowJudgements.slice();
score.freezeArrowJudgements=freezeArrowJudgements.slice();
score.combo=combo;
score.freezeCombo=freezeCombo;
score.maxCombo=maxCombo;
score.maxFreezeCombo=maxFreezeCombo;
score.scoreNum=scoreNum;
score.rank=rank;
return score;
}
public function judgeArrow(num:int):void{
if(num>=0 && num<4){
arrowJudgements[num]++;
if(num==0){
combo++;
scoreNum+=combo*200;
}
if(num==2 || num==3){
if(combo>maxCombo){
maxCombo=combo;
}
combo=0;
}
}
}
public function judgeFreezeArrow(num:int):void{
if(num>=0 && num<2){
freezeArrowJudgements[num]++;
if(num==0){
freezeCombo++;
scoreNum+=freezeCombo*500;
}
if(num==1){
if(freezeCombo>maxFreezeCombo){
maxFreezeCombo=freezeCombo;
}
freezeCombo=0;
}
}
}
public function makeResult():String{
var result:String="";
if(options==null){
return result;
}
result+="Music > "+Eclair.musicTitle+"\n";
result+="Maker > "+Eclair.makerName+"\n";
result+="Rank > "+rank.toString()+"\n";
result+="Difficulty > "+Options.difficultyName[options.difficultyNum]+"\n";
result+="Speed > x"+options.speed.toFixed(2)+"\n";
if(options.scrollNum>0){
result+="Scroll > "+Options.scrollName[options.scrollNum]+"\n";
}
if(options.appearanceNum>0){
result+="Appearance > "+Options.appearanceName[options.appearanceNum]+"\n";
}
if(options.darkNum>0){
result+="Dark > "+Options.darkName[options.darkNum]+"\n";
}
if(options.barDrainNum>0){
result+="BarDrain > "+Options.barDrainName[options.barDrainNum]+"\n";
}
result+="(・∀・)イイ!! > "+arrowJudgements[0].toString()+" , ";
result+="(´∀`)マターリ > "+arrowJudgements[1].toString()+"\n" ;
result+="(´・ω・`)ショボーン > "+arrowJudgements[2].toString()+" , ";
result+="(`Д´)ウワァン!! > "+arrowJudgements[3].toString()+"\n";
result+="MaxCombo > "+maxCombo.toString()+"\n";
result+="(゚∀゚)キター!! > "+freezeArrowJudgements[0].toString()+" , ";
result+="(・A・)イクナイ > "+freezeArrowJudgements[1].toString()+"\n";
result+="FreezeCombo > "+maxFreezeCombo.toString()+"\n";
result+="Score > "+scoreNum.toString();
return result;
}
public function makeTweet():String{
var tweet:String="";
if(options==null){
return tweet;
}
tweet+="【ダンおにったー】";
tweet+=Eclair.musicTitle;
tweet+="("+Eclair.makerName+")";
tweet+=Options.difficultyName[options.difficultyNum]+"/";
tweet+="Rank:"+rank;
tweet+="[";
for(var i:int=0;i<4;i++){
tweet+=arrowJudgements[i].toString()+",";
}
tweet+="MC:"+maxCombo.toString()+"]";
tweet+="[";
for(i=0;i<2;i++){
tweet+=freezeArrowJudgements[i].toString()+",";
}
tweet+="FC:"+maxFreezeCombo.toString()+"]";
tweet+="Score:"+scoreNum.toString()+" ";
tweet+="#danoni "+Eclair.url;
return tweet;
}
public function makeReplayText():String{
var replay:String="";
replay+="&";
replay+=Eclair.musicTitle+",";
replay+=Eclair.makerName;
replay+="&";
replay+=options.difficultyNum.toString()+",";
replay+=options.speed.toString()+",";
replay+=options.scrollNum.toString()+",";
replay+=options.appearanceNum.toString()+",";
replay+=options.darkNum.toString()+",";
replay+=options.barDrainNum.toString();
replay+="&";
replay+=replayData;
replay+="&";
replay+=freezeReplayData;
replay+="&";
return replay;
}
public function calculateRank(failed:Boolean):void{
if(failed){
rank="F";
}
else{
var totalArrowNum:int=
arrowJudgements[0]+arrowJudgements[1]+arrowJudgements[2]+arrowJudgements[3]+
freezeArrowJudgements[0]+freezeArrowJudgements[1];
var prop:Number=(arrowJudgements[0]+freezeArrowJudgements[0])/totalArrowNum;
if(prop==1)rank="PF";
else if(prop>0.9)rank="S";
else if(prop>0.8)rank="A";
else if(prop>0.7)rank="B";
else if(prop>0.6)rank="C";
else rank="D";
}
}
public static function replayDataFromVector(vector:Vector.<Vector.<int>>):String{
var str:String="";
for(var i:int=0;i<5;i++){
var l:int=vector[i].length;
for(var j:int=0;j<l;j++){
str+=(vector[i][j]+7).toString(16);
}
str+="/";
}
return str;
}
public static function freezeReplayDataFromVector(vector:Vector.<Vector.<int>>):String{
var str:String="";
for(var i:int=0;i<5;i++){
var l:int=vector[i].length;
if(l%2!=0){
vector[i].push(-8);
}
for(var j:int=0;j<l;j+=2){
str+=(vector[i][j]+7).toString(16)+",";
str+=vector[i][j+1].toString();
if(j!=l-2){
str+=",";
}
}
str+="/";
}
return str;
}
public static function vectorFromReplayData(data:String):Vector.<Vector.<int>>{
var vec:Vector.<Vector.<int>>=new Vector.<Vector.<int>>(5);
var arr:Array=data.split("/");
for(var i:int=0;i<5;i++){
vec[i]=new Vector.<int>();
var nums:Array=arr[i].split("");
var l:int=nums.length;
for(var j:int=0;j<l;j++){
vec[i].push(parseInt(nums[j],16)-7);
}
}
return vec;
}
public static function vectorFromFreezeReplayData(data:String):Vector.<Vector.<int>>{
var vec:Vector.<Vector.<int>>=new Vector.<Vector.<int>>(5);
var arr:Array=data.split("/");
for(var i:int=0;i<5;i++){
vec[i]=new Vector.<int>();
var nums:Array=arr[i].split(",");
var l:int=nums.length;
for(var j:int=0;j<l;j+=2){
vec[i].push(parseInt(nums[j],16)-7);
vec[i].push(parseInt(nums[j+1],10));
}
}
return vec;
}
}
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.text.TextField;
import flash.text.TextFormat;
class Title extends Sprite{
private var message:TextField;
public function Title(){
message=new TextField();
message.width=480;
message.height=360;
message.defaultTextFormat=new TextFormat("_sans",16,0xffffff);
message.text="Dancing Onigiri\nPress Space Key to Play";
addChild(message);
addEventListener(Event.ADDED_TO_STAGE,onAddedToStage);
addEventListener(Event.REMOVED_FROM_STAGE,onRemovedFromStage);
}
private function onAddedToStage(e:Event):void{
stage.addEventListener(KeyboardEvent.KEY_DOWN,onStageKeyDown);
}
private function onRemovedFromStage(e:Event):void{
stage.removeEventListener(KeyboardEvent.KEY_DOWN,onStageKeyDown);
}
private function onStageKeyDown(e:KeyboardEvent):void{
if(e.keyCode==32){
dispatchEvent(new EclairEvent(EclairEvent.GAME_START));
}
}
}
import flash.display.BlendMode;
import flash.geom.Vector3D;
import away3d.containers.ObjectContainer3D;
import away3d.core.base.Geometry;
import away3d.core.base.SubGeometry;
import away3d.entities.Mesh;
import away3d.entities.SegmentSet;
import away3d.materials.ColorMaterial;
import away3d.primitives.data.Segment;
import away3d.primitives.LineSegment;
class Arrow extends ObjectContainer3D implements IArrow{
private static var thickness:Number;
public static var vectors:Vector.<Vector3D>;
private static var vertices:Vector.<Number>;
private static var vertexNormals:Vector.<Number>;
private static var uvs:Vector.<Number>;
private static var indices:Vector.<uint>;
private var segments:SegmentSet;
private var lines:Vector.<LineSegment>;
private var geometry:Geometry;
private var material:ColorMaterial;
private var mesh:Mesh;
private var _alpha:Number;
private var _blendMode:String;
private var _boost:Number;
private var _color:uint;
private var _frame:int;
private var _id:int;
public function Arrow(){
_alpha=1;
_blendMode=BlendMode.NORMAL;
_boost=1;
_color=0xffffff;
_frame=0;
_id=0;
segments=new SegmentSet();
lines=new Vector.<LineSegment>();
drawLines();
addChild(segments);
geometry=new Geometry();
drawPlane();
material=new ColorMaterial(_color,0.5);
material.bothSides=true;
mesh=new Mesh(geometry,material);
addChild(mesh);
}
public static function init():void{
thickness=4;
vectors=new Vector.<Vector3D>();
vectors.push(new Vector3D(-32,0,0));
vectors.push(new Vector3D(0,32,0));
vectors.push(new Vector3D(0,8,0));
vectors.push(new Vector3D(32,8,0));
vectors.push(new Vector3D(32,-8,0));
vectors.push(new Vector3D(0,-8,0));
vectors.push(new Vector3D(0,-32,0));
vectors.push(null);
vectors.push(new Vector3D(-32+thickness*Math.SQRT2,0,0));
vectors.push(new Vector3D(-thickness,32-thickness/Math.tan(Math.PI/8),0));
vectors.push(new Vector3D(-thickness,8-thickness,0));
vectors.push(new Vector3D(32-thickness,8-thickness,0));
vectors.push(new Vector3D(32-thickness,-8+thickness,0));
vectors.push(new Vector3D(-thickness,-8+thickness,0));
vectors.push(new Vector3D(-thickness,-32+thickness/Math.tan(Math.PI/8),0));
vectors.push(null);
var vertices:Vector.<Number>=new Vector.<Number>();
var vertexNormals:Vector.<Number>=new Vector.<Number>();
var uvs:Vector.<Number>=new Vector.<Number>();
var l:int=vectors.length;
for(var i:int=0;i<l;i++){
var vec:Vector3D=vectors[i];
if(vec!=null){
vertices.push(vec.x,vec.y,vec.z);
vertexNormals.push(0,0,-1);
uvs.push((vec.x+32)/64,(vec.y+32)/64);
}
}
var indices:Vector.<uint>=new Vector.<uint>();
indices.push(0,1,7, 7,1,8, 8,1,2, 9,8,2, 9,2,3, 9,3,10, 10,3,4,
10,4,11, 11,4,5, 11,5,12, 12,5,6, 12,6,13, 13,6,7, 7,6,0);
Arrow.vertices=vertices;
Arrow.vertexNormals=vertexNormals;
Arrow.uvs=uvs;
Arrow.indices=indices;
}
private function drawLines():void{
var l:int=vectors.length;
if(l==0){
return;
}
var vs:Vector3D=vectors[0];
for(var i:int=0;i<l-1;i++){
var v1:Vector3D=vectors[i];
var v2:Vector3D=vectors[i+1];
if(v1==null){
vs=v2;
continue;
}
else if(v2==null){
var line:LineSegment=new LineSegment(v1,vs,_color,_color,1.5*_alpha);
segments.addSegment(line);
lines.push(line);
}
else{
line=new LineSegment(v1,v2,_color,_color,1.5*_alpha);
segments.addSegment(line);
lines.push(line);
}
}
}
private function drawPlane():void{
var sub:SubGeometry=new SubGeometry();
sub.updateVertexData(vertices);
sub.updateVertexNormalData(vertexNormals);
sub.updateUVData(uvs);
sub.updateIndexData(indices);
geometry.addSubGeometry(sub);
}
private function linesColorChange():void{
var l:int=lines.length;
for(var i:int=0;i<l;i++){
lines[i].startColor=_color;
lines[i].endColor=_color;
}
}
private function linesThicknessChange():void{
var l:int=lines.length;
for(var i:int=0;i<l;i++){
lines[i].thickness=1.5*_alpha;
}
}
public function get alpha():Number{
return _alpha;
}
public function set alpha(value:Number):void{
if(value<0){
value=0;
}
if(value>1){
value=1;
}
_alpha=value;
linesThicknessChange();
material.alpha=0.5*_alpha;
}
public function get blendMode():String{
return _blendMode;
}
public function set blendMode(value:String):void{
_blendMode=value;
segments.material.blendMode=_blendMode;
material.blendMode=_blendMode;
}
public function get boost():Number{
return _boost;
}
public function set boost(value:Number):void{
_boost=value;
}
public function get color():uint{
return _color;
}
public function set color(value:uint):void{
_color=value;
linesColorChange();
material.color=_color;
}
public function get frame():int{
return _frame;
}
public function set frame(value:int):void{
_frame=value;
}
public function get id():int{
return _id;
}
public function set id(value:int):void{
_id=value;
}
}
import flash.display.BlendMode;
import flash.geom.Vector3D;
import away3d.containers.ObjectContainer3D;
import away3d.core.base.Geometry;
import away3d.core.base.SubGeometry;
import away3d.entities.Mesh;
import away3d.entities.SegmentSet;
import away3d.materials.ColorMaterial;
import away3d.primitives.data.Segment;
import away3d.primitives.LineSegment;
class FreezeArrow extends ObjectContainer3D implements IFreezeArrow{
private static var thickness:Number;
private static var vectors:Vector.<Vector3D>;
private static var vertices:Vector.<Number>;
private static var vertexNormals:Vector.<Number>;
private static var uvs:Vector.<Number>;
private static var indices:Vector.<uint>;
private var localVectors:Vector.<Vector3D>;
private var segments:SegmentSet;
private var lines:Vector.<LineSegment>;
private var geometry:Geometry;
private var material:ColorMaterial;
private var mesh:Mesh;
private var _alpha:Number;
private var _angle:uint;
private var _blendMode:String;
private var _boost:Number;
private var _color:uint;
private var _frame:int;
private var _id:int;
private var _isHitting:Boolean;
private var _length:Number;
private var _rest:int;
public function FreezeArrow(){
_alpha=1;
_angle=0;
_blendMode=BlendMode.NORMAL;
_boost=1;
_color=0xffffff;
_frame=0;
_id=0;
_isHitting=false;
_length=0;
_rest=0;
localVectors=new Vector.<Vector3D>();
var l:int=vectors.length;
for(var i:int=0;i<l;i++){
if(vectors[i]!=null){
localVectors.push(vectors[i].clone());
}
else{
localVectors.push(null);
}
}
segments=new SegmentSet();
lines=new Vector.<LineSegment>();
drawLines();
addChild(segments);
geometry=new Geometry();
drawPlane();
material=new ColorMaterial(_color,0.5);
material.bothSides=true;
mesh=new Mesh(geometry,material);
addChild(mesh);
}
public static function init():void{
thickness=4;
vectors=new Vector.<Vector3D>();
vectors.push(new Vector3D(-32,0,0));
vectors.push(new Vector3D(0,32,0));
vectors.push(new Vector3D(0,32,0));
vectors.push(new Vector3D(0,8,0));
vectors.push(new Vector3D(32,8,0));
vectors.push(new Vector3D(32,-8,0));
vectors.push(new Vector3D(0,-8,0));
vectors.push(new Vector3D(0,-32,0));
vectors.push(new Vector3D(0,-32,0));
vectors.push(new Vector3D(-32,0,0));
vectors.push(null);
vectors.push(new Vector3D(-32+thickness*Math.SQRT2,0,0));
vectors.push(new Vector3D(-thickness,32-thickness/Math.tan(Math.PI/8),0));
vectors.push(new Vector3D(-thickness,8-thickness,0));
vectors.push(new Vector3D(32-thickness,8-thickness,0));
vectors.push(new Vector3D(32-thickness,-8+thickness,0));
vectors.push(new Vector3D(-thickness,-8+thickness,0));
vectors.push(new Vector3D(-thickness,-32+thickness/Math.tan(Math.PI/8),0));
vectors.push(null);
var vertices:Vector.<Number>=new Vector.<Number>();
var vertexNormals:Vector.<Number>=new Vector.<Number>();
var uvs:Vector.<Number>=new Vector.<Number>();
var l:int=vectors.length;
for(var i:int=0;i<l;i++){
var vec:Vector3D=vectors[i];
if(vec!=null){
vertices.push(vec.x,vec.y,vec.z);
vertexNormals.push(0,0,-1);
uvs.push((vec.x+32)/64,(vec.y+32)/64);
}
}
var indices:Vector.<uint>=new Vector.<uint>();
indices.push(0,1,10, 10,1,11, 1,2,11, 11,2,12, 12,2,3, 12,3,4, 12,4,13, 13,4,14,
14,4,5, 14,5,6, 14,6,15, 15,6,16, 16,6,7, 16,7,8, 16,8,9, 16,9,10, 10,9,0);
FreezeArrow.vertices=vertices;
FreezeArrow.vertexNormals=vertexNormals;
FreezeArrow.uvs=uvs;
FreezeArrow.indices=indices;
}
private function drawLines():void{
var l:int=localVectors.length;
if(l==0){
return;
}
var vs:Vector3D=localVectors[0];
for(var i:int=0;i<l-1;i++){
var v1:Vector3D=localVectors[i];
var v2:Vector3D=localVectors[i+1];
if(v1==null){
vs=v2;
continue;
}
else if(v2==null){
var line:LineSegment=new LineSegment(v1,vs,_color,_color,1.5*_alpha);
segments.addSegment(line);
lines.push(line);
}
else{
line=new LineSegment(v1,v2,_color,_color,1.5*_alpha);
segments.addSegment(line);
lines.push(line);
}
}
}
private function drawPlane():void{
var sub:SubGeometry=new SubGeometry();
sub.updateVertexData(vertices);
sub.updateVertexNormalData(vertexNormals);
sub.updateUVData(uvs);
sub.updateIndexData(indices);
geometry.addSubGeometry(sub);
}
private function linesColorChange():void{
var l:int=lines.length;
for(var i:int=0;i<l;i++){
lines[i].startColor=_color;
lines[i].endColor=_color;
}
}
private function linesThicknessChange():void{
var l:int=lines.length;
for(var i:int=0;i<l;i++){
lines[i].thickness=1.5*_alpha;
}
}
private function resetLocalVectors():void{
var l:int=vectors.length/2>>0;
for(var i:int=0;i<l;i++){
if(vectors[i]!=null){
var v:Vector3D=vectors[i];
var lv:Vector3D=localVectors[i];
lv.x=v.x;
lv.y=v.y;
lv.z=v.z;
}
}
}
private function makeBar():void{
segments.rotationZ=(_angle==0?0:(_angle==1?90:(_angle==2?-90:(_angle==3?180:0))));
mesh.rotationZ=(_angle==0?0:(_angle==1?90:(_angle==2?-90:(_angle==3?180:0))));
var vertices:Vector.<Number>=FreezeArrow.vertices.slice();
if(_angle==0 || _angle>3){
for(var i:int=5;i<10;i++){
localVectors[i].y=vectors[i].y-_length;
}
for(i=5*3+1;i<10*3;i+=3){
vertices[i]-=_length;
}
}
else if(_angle==1){
for(i=0;i<2;i++){
localVectors[i].x=vectors[i].x-_length;
}
for(i=8;i<10;i++){
localVectors[i].x=vectors[i].x-_length;
}
for(i=0*3;i<2*3;i+=3){
vertices[i]-=_length;
}
for(i=8*3;i<10*3;i+=3){
vertices[i]-=_length;
}
}
else if(_angle==2){
for(i=2;i<8;i++){
localVectors[i].x=vectors[i].x+_length;
}
for(i=2*3;i<8*3;i+=3){
vertices[i]+=_length;
}
}
else if(_angle==3){
for(i=0;i<5;i++){
localVectors[i].y=vectors[i].y+_length;
}
for(i=0*3+1;i<5*3;i+=3){
vertices[i]+=_length;
}
}
//dummy, calling lines redraw method?
linesThicknessChange();
var sub:SubGeometry=geometry.subGeometries[0];
sub.updateVertexData(vertices);
}
public function get alpha():Number{
return _alpha;
}
public function set alpha(value:Number):void{
if(value<0){
value=0;
}
if(value>1){
value=1;
}
_alpha=value;
linesThicknessChange();
material.alpha=0.5*_alpha;
}
public function get angle():uint{
return _angle;
}
public function set angle(value:uint):void{
_angle=value;
resetLocalVectors();
makeBar();
}
public function get blendMode():String{
return _blendMode;
}
public function set blendMode(value:String):void{
_blendMode=value;
segments.material.blendMode=_blendMode;
material.blendMode=_blendMode;
}
public function get boost():Number{
return _boost;
}
public function set boost(value:Number):void{
_boost=value;
}
public function get color():uint{
return _color;
}
public function set color(value:uint):void{
_color=value;
linesColorChange();
material.color=_color;
}
public function get frame():int{
return _frame;
}
public function set frame(value:int):void{
_frame=value;
}
public function get id():int{
return _id;
}
public function set id(value:int):void{
_id=value;
}
public function get isHitting():Boolean{
return _isHitting;
}
public function set isHitting(value:Boolean):void{
_isHitting=value;
}
public function get length():Number{
return _length;
}
public function set length(value:Number):void{
_length=value;
makeBar();
}
public function get rest():int{
return _rest;
}
public function set rest(value:int):void{
_rest=value;
}
}
import away3d.containers.ObjectContainer3D;
import away3d.entities.Mesh;
import away3d.materials.ColorMaterial;
import away3d.materials.MaterialBase;
import away3d.primitives.CubeGeometry;
import away3d.primitives.WireframeCube;
class LifeGauge extends ObjectContainer3D implements ILifeGauge{
private var _geometry:CubeGeometry;
private var _material:ColorMaterial;
private var _mesh:Mesh;
private var _frame:WireframeCube;
private var _alpha:Number;
private var _color:uint;
private var _lifePoint:Number;
private var alpha2:Number;
public function LifeGauge(){
_alpha=1;
_color=0xffffff;
_lifePoint=1;
alpha2=0.75;
_geometry=new CubeGeometry(32,480,32);
_material=new ColorMaterial(0x008000,alpha2);
_material.blendMode="add";
_mesh=new Mesh(_geometry,_material);
addChild(_mesh);
_frame=new WireframeCube(32,480,32,0xffffff,0.5);
addChild(_frame);
}
public function animate():void{
if(alpha2>0.75){
alpha2-=0.01;
if(alpha2<0.75){
alpha2=0.75;
}
_material.alpha=_alpha*alpha2;
}
}
public function get alpha():Number{
return _alpha;
}
public function set alpha(value:Number):void{
_alpha=value;
_material.alpha=_alpha*alpha2;
_frame.thickness=_alpha*0.5;
}
public function get color():uint{
return _color;
}
public function set color(value:uint):void{
_color=value;
_material.color=_color;
}
public function get lifePoint():Number{
return _lifePoint;
}
public function set lifePoint(value:Number):void{
_lifePoint=value;
alpha2=1;
_material.alpha=_alpha*alpha2;
_mesh.scaleY=lifePoint;
_mesh.y=-240+_lifePoint*240
}
public function get material():MaterialBase{
return _material;
}
}
import flash.display.BlendMode;
import flash.geom.Vector3D;
import away3d.containers.ObjectContainer3D;
import away3d.core.base.Geometry;
import away3d.core.base.SubGeometry;
import away3d.entities.Mesh;
import away3d.entities.SegmentSet;
import away3d.materials.ColorMaterial;
import away3d.primitives.data.Segment;
import away3d.primitives.LineSegment;
class Onigiri extends ObjectContainer3D implements IArrow{
private static var thickness:Number;
public static var vectors:Vector.<Vector3D>;
private static var vertices:Vector.<Number>;
private static var vertexNormals:Vector.<Number>;
private static var uvs:Vector.<Number>;
private static var indices:Vector.<uint>;
private var segments:SegmentSet;
private var lines:Vector.<LineSegment>;
private var geometry:Geometry;
private var material:ColorMaterial;
private var mesh:Mesh;
private var _alpha:Number;
private var _blendMode:String;
private var _boost:Number;
private var _color:uint;
private var _frame:int;
private var _id:int;
public function Onigiri(){
_alpha=1;
_blendMode=BlendMode.NORMAL;
_boost=1;
_color=0xffffff;
_frame=0;
_id=0;
segments=new SegmentSet();
lines=new Vector.<LineSegment>();
drawLines();
addChild(segments);
geometry=new Geometry();
drawPlane();
material=new ColorMaterial(_color,0.5);
material.bothSides=true;
mesh=new Mesh(geometry,material);
addChild(mesh);
}
public static function init():void{
thickness=3;
vectors=new Vector.<Vector3D>();
vectors.push(new Vector3D(12,32,0));
vectors.push(new Vector3D(12,8,0));
vectors.push(new Vector3D(-12,8,0));
vectors.push(new Vector3D(-12,32,0));
vectors.push(null);
vectors.push(new Vector3D(-20,32,0));
vectors.push(new Vector3D(-48,8,0));
vectors.push(new Vector3D(-48-thickness,8,0));
vectors.push(new Vector3D(-20-thickness,32,0));
vectors.push(null);
vectors.push(new Vector3D(20,32,0));
vectors.push(new Vector3D(48,8,0));
vectors.push(new Vector3D(48+thickness,8,0));
vectors.push(new Vector3D(20+thickness,32,0));
vectors.push(null);
vectors.push(new Vector3D(-24,-2,0));
vectors.push(new Vector3D(-32,-10,0));
vectors.push(new Vector3D(-32-thickness,-10,0));
vectors.push(new Vector3D(-24-thickness,-2,0));
vectors.push(null);
vectors.push(new Vector3D(24,-2,0));
vectors.push(new Vector3D(32,-10,0));
vectors.push(new Vector3D(32+thickness,-10,0));
vectors.push(new Vector3D(24+thickness,-2,0));
vectors.push(null);
vectors.push(new Vector3D(14,-4,0));
vectors.push(new Vector3D(0,-32,0));
vectors.push(new Vector3D(-14,-4,0));
vectors.push(new Vector3D(-14+thickness,-4,0));
vectors.push(new Vector3D(-11+thickness,-10,0));
vectors.push(new Vector3D(11-thickness,-10,0));
vectors.push(new Vector3D(14-thickness,-4,0));
vectors.push(null);
vectors.push(new Vector3D(14*(28-6-thickness)/28-thickness,-10-thickness,0));
vectors.push(new Vector3D(0,-32+2*thickness,0));
vectors.push(new Vector3D(-14*(28-6-thickness)/28+thickness,-10-thickness,0));
vectors.push(null);
vectors.push(new Vector3D(-48,-2,0));
vectors.push(new Vector3D(-56,-10,0));
vectors.push(new Vector3D(-56,-24,0));
vectors.push(new Vector3D(-48,-32,0));
vectors.push(new Vector3D(-48-thickness,-32,0));
vectors.push(new Vector3D(-56-thickness*Math.SQRT1_2,-24,0));
vectors.push(new Vector3D(-56-thickness*Math.SQRT1_2,-10,0));
vectors.push(new Vector3D(-48-thickness,-2,0));
vectors.push(null);
vectors.push(new Vector3D(48+thickness,-2,0));
vectors.push(new Vector3D(56+thickness*Math.SQRT1_2,-10,0));
vectors.push(new Vector3D(56+thickness*Math.SQRT1_2,-24,0));
vectors.push(new Vector3D(48+thickness,-32,0));
vectors.push(new Vector3D(48,-32,0));
vectors.push(new Vector3D(56,-24,0));
vectors.push(new Vector3D(56,-10,0));
vectors.push(new Vector3D(48,-2,0));
vectors.push(null);
var vertices:Vector.<Number>=new Vector.<Number>();
var vertexNormals:Vector.<Number>=new Vector.<Number>();
var uvs:Vector.<Number>=new Vector.<Number>();
var l:int=vectors.length;
for(var i:int=0;i<l;i++){
var vec:Vector3D=vectors[i];
if(vec!=null){
vertices.push(vec.x,vec.y,vec.z);
vertexNormals.push(0,0,-1);
uvs.push((vec.x+32)/64,(vec.y+32)/64);
}
}
var indices:Vector.<uint>=new Vector.<uint>();
indices.push(0,1,2, 0,2,3, 4,5,6, 4,6,7, 8,10,9, 8,11,10,
12,13,14, 12,14,15, 16,18,17, 16,19,18,
20,21,28, 20,28,26, 21,22,23, 21,23,28, 24,25,27, 24,27,29,
30,31,36, 30,36,37, 31,32,35, 31,35,36, 32,33,34, 32,34,35,
38,39,44, 38,44,45, 39,40,43, 39,43,44, 40,41,42, 40,42,43);
Onigiri.vertices=vertices;
Onigiri.vertexNormals=vertexNormals;
Onigiri.uvs=uvs;
Onigiri.indices=indices;
}
private function drawLines():void{
var l:int=vectors.length;
if(l==0){
return;
}
var vs:Vector3D=vectors[0];
for(var i:int=0;i<l-1;i++){
var v1:Vector3D=vectors[i];
var v2:Vector3D=vectors[i+1];
if(v1==null){
vs=v2;
continue;
}
else if(v2==null){
var line:LineSegment=new LineSegment(v1,vs,_color,_color,1.5*_alpha);
segments.addSegment(line);
lines.push(line);
}
else{
line=new LineSegment(v1,v2,_color,_color,1.5*_alpha);
segments.addSegment(line);
lines.push(line);
}
}
}
private function drawPlane():void{
var sub:SubGeometry=new SubGeometry();
sub.updateVertexData(vertices);
sub.updateVertexNormalData(vertexNormals);
sub.updateUVData(uvs);
sub.updateIndexData(indices);
geometry.addSubGeometry(sub);
}
private function linesColorChange():void{
var l:int=lines.length;
for(var i:int=0;i<l;i++){
lines[i].startColor=_color;
lines[i].endColor=_color;
}
}
private function linesThicknessChange():void{
var l:int=lines.length;
for(var i:int=0;i<l;i++){
lines[i].thickness=1.5*_alpha;
}
}
public function get alpha():Number{
return _alpha;
}
public function set alpha(value:Number):void{
if(value<0){
value=0;
}
if(value>1){
value=1;
}
_alpha=value;
linesThicknessChange();
material.alpha=0.5*_alpha;
}
public function get blendMode():String{
return _blendMode;
}
public function set blendMode(value:String):void{
_blendMode=value;
segments.material.blendMode=_blendMode;
material.blendMode=_blendMode;
}
public function get boost():Number{
return _boost;
}
public function set boost(value:Number):void{
_boost=value;
}
public function get color():uint{
return _color;
}
public function set color(value:uint):void{
_color=value;
linesColorChange();
material.color=_color;
}
public function get frame():int{
return _frame;
}
public function set frame(value:int):void{
_frame=value;
}
public function get id():int{
return _id;
}
public function set id(value:int):void{
_id=value;
}
}
import flash.display.BitmapData;
import flash.geom.ColorTransform;
import flash.geom.Vector3D;
import away3d.entities.Sprite3D;
import away3d.materials.TextureMaterial;
import away3d.primitives.PlaneGeometry;
import away3d.textures.BitmapTexture;
class Particle extends Sprite3D{
public static const TIME:int=48;
private var bmd:BitmapData;
private var texture:BitmapTexture;
private var colorTransform:ColorTransform;
private var _material:TextureMaterial;
private var _color:uint;
private var start:Vector3D;
private var anchor:Vector3D;
private var target:Vector3D;
private var _frame:int;
public var lifePoint:Number;
public function Particle(color:uint=0xffffff){
bmd=Eclair.particleImg.clone();
texture=new BitmapTexture(bmd);
colorTransform=new ColorTransform(1,1,1,1,
(color>>16)&0xff,(color>>8)&0xff,color&0xff);
_material=new TextureMaterial(texture);
_material.alphaBlending=true;
_material.alphaThreshold=0.1;
_material.blendMode="add";
_material.colorTransform=colorTransform;
super(_material,32,32);
_color=color;
start=new Vector3D(0,0,0);
anchor=new Vector3D(0,0,0);
target=new Vector3D(0,0,0);
_frame=0;
lifePoint=0;
}
public function init(startX:Number,startY:Number,startZ:Number,
anchorX:Number,anchorY:Number,anchorZ:Number,
targetX:Number,targetY:Number,targetZ:Number,lifePoint:Number):void{
x=startX;
y=startY;
z=startZ;
start.x=startX;
start.y=startY;
start.z=startZ;
anchor.x=anchorX;
anchor.y=anchorY;
anchor.z=anchorZ;
target.x=targetX;
target.y=targetY;
target.z=targetZ;
_frame=0;
this.lifePoint=lifePoint;
}
public function animate():void{
var t:Number=_frame/TIME;
x=(start.x*(1-t)+anchor.x*t)*(1-t)+(anchor.x*(1-t)+target.x*t)*t;
y=(start.y*(1-t)+anchor.y*t)*(1-t)+(anchor.y*(1-t)+target.y*t)*t;
z=(start.z*(1-t)+anchor.z*t)*(1-t)+(anchor.z*(1-t)+target.z*t)*t;
_frame++;
}
public function get color():uint{
return _color;
}
public function set color(value:uint):void{
_color=value;
colorTransform.redOffset=(_color>>16)&0xff;
colorTransform.greenOffset=(_color>>8)&0xff;
colorTransform.blueOffset=_color&0xff;
_material.colorTransform=colorTransform;
}
public function get frame():int{
return _frame;
}
}
import flash.display.BlendMode;
import flash.geom.Vector3D;
import away3d.containers.ObjectContainer3D;
import away3d.entities.SegmentSet;
import away3d.primitives.LineSegment;
class StepArrow extends ObjectContainer3D implements IStep{
private static var thickness:Number;
private static var vectors:Vector.<Vector3D>;
private var segments:SegmentSet;
private var lines:Vector.<LineSegment>;
private var _alpha:Number;
private var _blendMode:String;
private var _color:uint;
private var alpha2:Number;
public function StepArrow(){
_alpha=1;
_blendMode=BlendMode.NORMAL;
_color=0xffffff;
alpha2=0.3;
segments=new SegmentSet();
lines=new Vector.<LineSegment>();
drawLines();
addChild(segments);
}
private function drawLines():void{
var l:int=Arrow.vectors.length;
if(l==0){
return;
}
var vs:Vector3D=Arrow.vectors[0];
for(var i:int=0;i<l-1;i++){
var v1:Vector3D=Arrow.vectors[i];
var v2:Vector3D=Arrow.vectors[i+1];
if(v1==null){
vs=v2;
continue;
}
else if(v2==null){
var line:LineSegment=new LineSegment(v1,vs,_color,_color,1.5*_alpha*alpha2);
segments.addSegment(line);
lines.push(line);
}
else{
line=new LineSegment(v1,v2,_color,_color,1.5*_alpha*alpha2);
segments.addSegment(line);
lines.push(line);
}
}
}
public function hit():void{
alpha2=1;
linesThicknessChange();
}
public function animate():void{
if(alpha2>0.3){
alpha2-=0.1;
linesThicknessChange();
}
if(alpha2<0.3){
alpha2=0.3;
linesThicknessChange();
}
}
private function linesColorChange():void{
var l:int=lines.length;
for(var i:int=0;i<l;i++){
lines[i].startColor=_color;
lines[i].endColor=_color;
}
}
private function linesThicknessChange():void{
var l:int=lines.length;
for(var i:int=0;i<l;i++){
lines[i].thickness=1.5*_alpha*alpha2;
}
}
public function get alpha():Number{
return _alpha;
}
public function set alpha(value:Number):void{
if(value<0){
value=0;
}
if(value>1){
value=1;
}
_alpha=value;
linesThicknessChange();
}
public function get blendMode():String{
return _blendMode;
}
public function set blendMode(value:String):void{
_blendMode=value;
segments.material.blendMode=_blendMode;
}
public function get color():uint{
return _color;
}
public function set color(value:uint):void{
_color=value;
linesColorChange();
}
}
import flash.display.BlendMode;
import flash.geom.Vector3D;
import away3d.containers.ObjectContainer3D;
import away3d.entities.SegmentSet;
import away3d.primitives.LineSegment;
class StepOnigiri extends ObjectContainer3D implements IStep{
private static var thickness:Number;
private static var vectors:Vector.<Vector3D>;
private var segments:SegmentSet;
private var lines:Vector.<LineSegment>;
private var _alpha:Number;
private var _blendMode:String;
private var _color:uint;
private var alpha2:Number;
public function StepOnigiri(){
_alpha=1;
_blendMode=BlendMode.NORMAL;
_color=0xffffff;
alpha2=0.3;
segments=new SegmentSet();
lines=new Vector.<LineSegment>();
drawLines();
addChild(segments);
}
private function drawLines():void{
var l:int=Onigiri.vectors.length;
if(l==0){
return;
}
var vs:Vector3D=Onigiri.vectors[0];
for(var i:int=0;i<l-1;i++){
var v1:Vector3D=Onigiri.vectors[i];
var v2:Vector3D=Onigiri.vectors[i+1];
if(v1==null){
vs=v2;
continue;
}
else if(v2==null){
var line:LineSegment=new LineSegment(v1,vs,_color,_color,1.5*_alpha*alpha2);
segments.addSegment(line);
lines.push(line);
}
else{
line=new LineSegment(v1,v2,_color,_color,1.5*_alpha*alpha2);
segments.addSegment(line);
lines.push(line);
}
}
}
public function hit():void{
alpha2=1;
linesThicknessChange();
}
public function animate():void{
if(alpha2>0.3){
alpha2-=0.1;
linesThicknessChange();
}
if(alpha2<0.3){
alpha2=0.3;
linesThicknessChange();
}
}
private function linesColorChange():void{
var l:int=lines.length;
for(var i:int=0;i<l;i++){
lines[i].startColor=_color;
lines[i].endColor=_color;
}
}
private function linesThicknessChange():void{
var l:int=lines.length;
for(var i:int=0;i<l;i++){
lines[i].thickness=1.5*_alpha*alpha2;
}
}
public function get alpha():Number{
return _alpha;
}
public function set alpha(value:Number):void{
if(value<0){
value=0;
}
if(value>1){
value=1;
}
_alpha=value;
linesThicknessChange();
}
public function get blendMode():String{
return _blendMode;
}
public function set blendMode(value:String):void{
_blendMode=value;
segments.material.blendMode=_blendMode;
}
public function get color():uint{
return _color;
}
public function set color(value:uint):void{
_color=value;
linesColorChange();
}
}
import away3d.containers.ObjectContainer3D;
import away3d.entities.Mesh;
import away3d.materials.ColorMaterial;
import away3d.materials.MaterialBase;
import away3d.primitives.CubeGeometry;
import away3d.primitives.WireframeCube;
class TimeGauge extends ObjectContainer3D{
private var _geometry:CubeGeometry;
private var _material:ColorMaterial;
private var _mesh:Mesh;
private var _frame:WireframeCube;
private var _alpha:Number;
private var _color:uint;
private var _time:int;
private var _totalTime:int;
public function TimeGauge(){
_alpha=1;
_color=0xffffff;
_time=0;
_totalTime=1;
_geometry=new CubeGeometry(16,32,16);
_material=new ColorMaterial(0xffffff,0.75);
_material.blendMode="add";
_mesh=new Mesh(_geometry,_material);
_mesh.y=240-16;
addChild(_mesh);
_frame=new WireframeCube(16,480,16,0xffffff,0.5);
addChild(_frame);
}
public function get alpha():Number{
return _alpha;
}
public function set alpha(value:Number):void{
_alpha=value;
_material.alpha=_alpha*0.75;
_frame.thickness=_alpha*0.5;
}
public function get color():uint{
return _color;
}
public function set color(value:uint):void{
_color=value;
_material.color=_color;
}
public function get material():MaterialBase{
return _material;
}
public function get time():int{
return _time;
}
public function set time(value:int):void{
_time=value;
_mesh.y=240-16-(480-32)*_time/_totalTime;
}
public function get totalTime():int{
return _totalTime;
}
public function set totalTime(value:int):void{
_totalTime=value;
_mesh.y=240-16-(480-32)*_time/_totalTime;
}
}
import flash.events.Event;
class EclairEvent extends Event{
public static const BACK_TO_TITLE:String="backToTitle";
public static const GAME_OVER:String="gameOver";
public static const GAME_RETRY:String="gameRetry";
public static const GAME_START:String="gameStart";
public static const GAME_QUIT:String="gameQuit";
public function EclairEvent(type:String){
super(type);
}
override public function clone():Event{
return (new EclairEvent(type));
}
override public function toString():String{
return "[EclairEvent type="+type+"]";
}
}
class Queue extends Object{
public var frameNum:int;
public function Queue(){
}
}
class ArrowQueue extends Queue{
public var id:int;
public var dif:Number;
public var boost:Number;
public var endFrame:int;
public function ArrowQueue(id:int,frameNum:int,dif:Number=0,boost:Number=1,endFrame:int=0){
this.id=id;
this.frameNum=frameNum;
this.dif=dif;
this.boost=boost;
this.endFrame=endFrame;
}
public function toString():String{
return "[ArrowQueue frameNum="+frameNum.toString()+", dif="+dif.toString()+", boost="+boost.toString()+"]";
}
}
class FreezeArrowQueue extends ArrowQueue{
public var length:int;
public var tail:Number;
public function FreezeArrowQueue(id:int,frameNum:int,dif:Number=0,boost:Number=1,endFrame:int=0,length:int=0,tail:Number=0){
super(id,frameNum,dif,boost,endFrame);
this.length=length;
this.tail=tail;
}
override public function toString():String{
return "[FreezeArrowQueue frameNum="+frameNum.toString()+", length="+length.toString()+"]";
}
}
class SpeedQueue extends Queue{
public var speed:Number;
public function SpeedQueue(frameNum:int=0,speed:Number=1){
this.frameNum=frameNum;
this.speed=speed;
}
public function toString():String{
return "[SpeedQueue frameNum="+frameNum.toString()+", speed="+speed.toString()+"]";
}
}