開発中
開発中
/*
開発中
*/
package {
import flash.display.*;
import caurina.transitions.*;
import caurina.transitions.properties.*;
import flash.filters.*;
import flash.text.*;
import flash.events.*;
import flash.utils.Timer;
[SWF(backgroundColor="#000000", width="465", height="465", frameRate="60")]
public class main extends Sprite {
private var panelArray:Array = [];
private var flag:Boolean = false;
private const interval:int = 1000;
private var tmc:TimeCircle;
private var total:int = 0;
private var score:int = 0;
private var qnum:int = 0;
private var stg:Sprite = new Sprite();
private var scsp:Sprite = new Sprite();
private var stf:TextField = new TextField();
private var tf:TextField = new TextField();
private var stff:TextFormat = new TextFormat();
private var gosp:Sprite = new Sprite();
private var gotf:TextField = new TextField();
private var rstf:TextField = new TextField();
private var gotff:TextFormat = new TextFormat();
public function main(){
this.graphics.beginFill(0x000000);
this.graphics.drawRect(0,0,this.stage.stageWidth,this.stage.stageHeight);
FilterShortcuts.init();
stage.addChild(stg);
var oFilter:GlowFilter = new GlowFilter(0xFF0000,1,2,2,16,1);
var iFilter:GlowFilter = new GlowFilter(0xFFFFFF,1,2,2,16,1);
var blur:BlurFilter = new BlurFilter(2,2,2);
setParam([stff,gotff],[["size",30,50],["align","right","right"],["color",0xFFFFFF,0xFFFFFF]]);
setParam([stf,tf,gotf,rstf],[["defaultTextFormat",stff,stff,gotff,stff],["text",score.toString(),"SCORE","GAME OVER","click to restart"],["autoSize","none","left","left","left"],["x",0,0,0,65],["y",40,0,0,70],["selectable",false,false,false,false]]);
setParam([stf],[["width",100],["height",50]]);
scsp.addChild(tf);
scsp.addChild(stf);
setParam([scsp,gosp],[["x",150,80],["y",350,100],["filters",[blur],[]]]);
stage.addChild(scsp);
gosp.addChild(rstf);
gosp.addChild(gotf);
Tweener.addTween(gosp,{alpha:0, _Blur_blurX:50, _Blur_blurY:50, time:0,transition:"linear"});
for(var i:int = 0;i < 36;i ++){
var panel:Panel = new Panel();
setParam([panel],[["x",(i%6)*55 + 5],["y",int(i/6)*55 + 5]]);
if(i > 23){
setParam([panel],[["cnt",Math.floor(Math.random() * 9) + 1],["clr",0x000000]]);
panel.addEventListener(MouseEvent.CLICK,clickpanel);
}else{
panel.cnt = 0;
}
panel.update();
panel.filters = [blur,iFilter,oFilter];
stg.addChild(panel);
panelArray.push(panel);
}
tmc = new TimeCircle();
setParam([tmc.tff],[["color",0xFFFFFF],["bold",true]]);
setParam([tmc],[["interval",interval],["x",58],["y",400],["colorB",0x000000],["key",tmc.changeKey(tmc.key)],["filters",[blur]]]);
tmc.setColor();
stg.addChild(tmc);
gamestart();
}
public static function setParam(ar1:Array,ar2:Array):Array{
for(var l:int = 0;l < ar1.length;l ++){
for(var a:int = 0;a < ar2.length;a ++){
ar1[l][ar2[a][0]] = ar2[a][l + 1] != undefined ? ar2[a][l + 1]:ar1[l][ar2[a][0]];
}
}
return ar1;
}
private function init(e:Event = null):void{
stage.addChild(stg);
Tweener.addTween(stg,{alpha:1, _Blur_blurX:0, _Blur_blurY:0, time:1,transition:"linear",onComplete:gamestart()});
Tweener.addTween(gosp,{alpha:0, _Blur_blurX:50, _Blur_blurY:50, time:0.5,transition:"linear",onComplete:function():void{stage.removeChild(gosp);}});
setParam([this],[["flag",false],["score",0],["qnum",0]]);
stf.text = score.toString();
setParam([tmc],[["interval",interval],["x",58],["y",400],["colorB",0x000000],["key",tmc.changeKey(tmc.key)]]);
tmc.setColor();
tmc.tff.color = 0xFFFFFF;
for(var i:int = 0;i < 36;i ++){
var panel:Panel = panelArray[i];
if(i > 23){
setParam([panel],[["cnt",Math.floor(Math.random() * 9) + 1],["clr",0x000000],["isclicked",false]]);
}else{
setParam([panel],[["cnt",0],["clr",0xa0a0a0],["isclicked",false]]);
panel.removeEventListener(MouseEvent.CLICK,clickpanel);
}
panel.update();
}
}
private function gamestart():void{
tmc.start();
stage.addEventListener(Event.ENTER_FRAME,countDown);
}
private function countDown(e:Event = null):void{
if(total == tmc.key){
var ca:Array = getClickedPanel();
ca.forEach(initpanel);
total = 0;
tmc.interval -= 2;
score += ca.length * (1001 - tmc.interval);
stf.text = score.toString();
}
if(flag == tmc.changekey){
}else if (flag){
flag = tmc.changekey;
var i:int = searchZero();
if(i > -1){
setParam([panelArray[i]],[["cnt",Math.floor(Math.random() * 9) + 1],["clr",0x000000]]);
panelArray[i].addEventListener(MouseEvent.CLICK,clickpanel);
panelArray[i].update();
}else{
gameover();
}
}else if(!flag){
flag = tmc.changekey;
}
}
private function clickpanel(e:Event = null):void{
var p:Panel = Panel(e.currentTarget);
var sp:Sprite = new Sprite();
var cf:Boolean = p.isclicked;
sp.graphics.beginFill(0xFF0000);
sp.graphics.drawRect(0,0,50,50);
sp.x = p.x;
sp.y = p.y;
stage.addChild(sp);
Tweener.addTween(sp,{time:0.5,alpha:0,transition:"linear",onComplete:function():void{stage.removeChild(sp);}});
setParam([p],[["clr",int(cf?0x000000:0xFF0000)],["isclicked",!cf]]);
p.update();
gettotal();
}
private function searchZero():int{
var l:int = panelArray.length;
var res:int = -1;
for(var i:int = 0;i < l;i ++){
res = panelArray[i].cnt != 0?res:i;
}
return res;
}
private function getClickedPanel():Array{
var l:int = panelArray.length;
var res:Array = [];
for(var i:int = 0;i < l;i ++){
if(panelArray[i].isclicked){
res.push(panelArray[i]);
}
}
return res;
}
private function gettotal():void{
var a:Array = getClickedPanel();
var l:int = a.length;
var res:int = 0;
for(var i:int = 0;i < l;i ++){
res += a[i].cnt;
}
total = res;
}
private function initpanel(p:Panel,i:int,a:Array):void{
var sp:Sprite = new Sprite();
sp.graphics.beginFill(0xFFFFFF);
sp.graphics.drawRect(0,0,50,50);
sp.x = p.x;
sp.y = p.y;
stage.addChild(sp);
Tweener.addTween(sp,{time:0.5,alpha:0,transition:"linear",onComplete:function():void{stage.removeChild(sp);}});
setParam([p],[["cnt",0],["clr",0xa0a0a0],["isclicked",false]]);
p.removeEventListener(MouseEvent.CLICK,clickpanel);
p.update();
}
private function gameover():void{
tmc.stop();
stage.removeEventListener(Event.ENTER_FRAME,countDown);
Tweener.addTween(stg,{alpha:0, _Blur_blurX:50, _Blur_blurY:50, time:2,transition:"linear",onComplete:function():void{stage.removeChild(stg);}});
stage.addChild(gosp);
Tweener.addTween(gosp,{alpha:1, _Blur_blurX:2, _Blur_blurY:2, time:2,transition:"linear"});
gosp.addEventListener(MouseEvent.CLICK,init);
}
}
}
import flash.display.Sprite;
import flash.text.*;
class Panel extends Sprite{
public var tf:TextField;
public var cnt:int = 0;
public var clr:int = 0xa0a0a0;
public var isclicked:Boolean = false;
private var txf:TextFormat = new TextFormat();
public function Panel(){
this.mouseChildren = false;
this.buttonMode = true;
this.graphics.beginFill(0xa0a0a0);
this.graphics.drawRect(0,0,50,50);
this.tf = new TextField();
this.txf.size = 40;
this.txf.color = 0xFFFFFF;
main.setParam([tf],[["x",3],["defaultTextFormat",txf],["autoSize","left"],["selectable",false],["text",cnt.toString()]]);
this.addChild(tf);
}
public function update():void{
this.graphics.clear();
this.graphics.beginFill(clr);
this.graphics.drawRect(0,0,50,50);
this.tf.text = cnt?cnt.toString():"";
this.tf.x = (this.width - this.tf.width)/2;
}
}
import flash.display.Sprite;
import flash.events.*;
import flash.text.TextFormat;
import flash.text.TextField;
class TimeCircle extends Sprite{
public var colorA:int = 0xFF0000;
public var colorB:int = 0xFFFFFF;
public var center:int;
public var key:int = 0;
public var tff:TextFormat = new TextFormat();
public var interval:int = 1000;
private var n:Date;
private var tf:TextField = new TextField();
private var cntTime:int;
private var lstTime:int;
private var isstart:Boolean = false;
private var colorAry:Array = [];
private const startAngle:int = 270;
public var changekey:Boolean = false;
public function TimeCircle(radius:int = 50,count:Boolean = true){
cntTime = (lstTime = (n = new Date).time) + 1;
center = radius;
colorAry = [colorA,colorB];
main.setParam([tf],[["autoSize","left"],["selectable",false],["defaultTextFormat",tff]]);
if(count){
this.addChild(tf);
}
}
public function update(e:Event = null):void{
n = new Date;
var dl:int = lstTime + interval;
if(dl <= cntTime){
var newcolor:int = colorAry[0];
colorAry.push(newcolor);
colorAry = colorAry.splice(1,2);
key = key != 0 && changekey?changeKey(key):key;
changekey = !changekey;
lstTime = n.time;
}
cntTime = n.time;
tff.size = int(center*0.8);
tf.defaultTextFormat = tff;
tf.text = key > 0?key.toString():int(dl/100).toString();
tf.y = -tf.height/2;
tf.x = -tf.width/2;
this.graphics.clear();
this.graphics.beginFill(colorAry[0]);
this.graphics.drawCircle(0,0,center-0.1);
this.graphics.beginFill(colorAry[1]);
this.graphics.moveTo(0,0);
dl = n.time - lstTime;
for(var r:Number = startAngle;r < (360 * (dl / interval)) + startAngle;r += 1){
var rad:Number = r * Math.PI / 180;
this.graphics.lineTo(Math.cos(rad) * center,Math.sin(rad) * center);
}
this.graphics.lineTo(Math.cos(rad = ((360 * (dl / interval)) + startAngle) * Math.PI / 180) * ((center)/2),Math.sin(rad) * ((center)/2));
this.graphics.beginFill(colorB);
this.graphics.drawCircle(0,0,center/2);
}
public function changeKey(k:int):int{
do{
var kk:int = Math.floor(Math.random() * 12) + 7;
}while(k == kk);
return kk;
}
public function setColor():void{
colorAry = [colorA,colorB];
}
public function start():void{
if(!isstart){
this.addEventListener(Event.ENTER_FRAME,update);
isstart = true;
}
}
public function stop():void{
if(isstart){
this.removeEventListener(Event.ENTER_FRAME,update);
isstart = false;
}
}
}