script_shot I_Item
{//アイスアイテム
	let cx=GetCenterX();//STGシーンの中心x座標を取得
	let cy=GetCenterY();//STGシーンの中心y座標を取得
	let imgItem=GetCurrentScriptDirectory~"img\effect_tiny.png";
	let power33	=GetCurrentScriptDirectory~"\SE\power33.wav";
	let Large = GetArgument;	//0なら小型、1なら大型
	let D_angle=0;
	let speed=3;
	@Initialize
	{
		SetAngle(-90);
		SetBombResist;
                Tmain;
	}
	
	@MainLoop
	{
		yield;
	}

        task Tmain{
		Move;
		loop{
			if(GetX<=GetPlayerX+38&&
			   GetX>=GetPlayerX-38&&
			   GetY<=GetPlayerY+38&&
			   GetY>=GetPlayerY-38){
				GetMove(5);
				break;
			}
			if(GetPlayerY<=150){//上部回収
				GetMove(12);
				break;
			}
			yield;
		}
        }
	task Move{//自由落下
		loop{
             		if(GetY>GetClipMaxY+32){End;}
			if(speed>=-2){speed-=0.04;}
			SetSpeed(speed);
			yield;
		}
	}
	task GetMove(Mspeed){//アイテム吸収モーション
		speed=-Mspeed;//同時に自由落下停止
		loop{
			SetAngle(GetAngleToPlayer+180);
			if(GetX<=GetPlayerX+18&&
			   GetX>=GetPlayerX-18&&
		 	   GetY<=GetPlayerY+18&&
			   GetY>=GetPlayerY-18){
				let Ice = GetCommonData("GetIce");
				let P_Ice = 0;
				PlaySE("seScore.wav");	//効果音
				alternative(Large)
				case( 0){
					P_Ice =200;
				}
				case( 1){
					P_Ice =400;
				}
				SetCommonData("GetIce",Ice+P_Ice);
				End;
			}
			yield;
		}
	}

	@Finalize
	{

	}
	
	@DrawLoop
	{//描画
		SetTexture(imgItem);
		SetGraphicRect(1,1,22,23);
		SetGraphicAngle(0,0,D_angle);
		alternative(Large)
		case( 0){SetGraphicScale(1.2,1.2);}
		case( 1){SetGraphicScale(1.8,1.8);}
		D_angle+=2;
		DrawGraphic(GetX(),GetY());
	}

}