//初期設定
function StartPlural()
{
	SetCommonData("plural", 1);
}

//初期位置設定
function InitPosition(x, y)
{
	if( GetCommonDataDefault("plural", 0) || GetCommonDataDefault("stage", 0) ){
		SetMovePosition02(x, y, 60);
	}
	else{
		SetX(x);
		SetY(y);
	}
}

//開始時設定
function StartSetting(time, score, name)
{
	SetTimer(time);
	if( score > 0 ){
		SetScore(score);
		CutIn(YOUMU, name, "", 0, 0, 0, 0);
	}
	T_CountDown();
}

//カウントダウン効果音を鳴らす
task T_CountDown()
{
	let c_time = GetTimer();
	let b_time = c_time;
	loop{
		c_time = GetTimer();
		if( c_time != b_time ){
			b_time = c_time;
			if( c_time <= 9 ){
				PlaySE(se_countdown);
			}
		}
		yield;
	}
}

//移動関数その１
function MoveActA(ymin, ymax)
{
	let x;
	let y;

	if( GetX() < GetPlayerX() ){
		x = min(GetX() + rand(50, 80), GetClipMaxX() - 64);
	}
	else{
		x = max(GetX() - rand(50, 80), GetClipMinX() + 64);
	}
	y = max(ymin, min(ymax, GetY() + rand(-30, 30)));
	SetMovePositionDC(x, y, 30);
}

//移動関数その２
function MoveActB(move_count, ymin, ymax)
{
	let x;
	let y;

	if( GetX() < GetPlayerX() ){
		x = min(GetX() + rand(50, 80), GetClipMaxX() - 64);
	}
	else{
		x = max(GetX() - rand(50, 80), GetClipMinX() + 64);
	}
	y = max(ymin, min(ymax, GetY() + rand(-30, 30)));
	SetMovePositionDC(x, y, move_count);
}

//移動タスクその１
task T_MoveActA(wait, ymin, ymax)
{
	loop{
		let x;
		let y;

		if( GetX() < GetPlayerX() ){
			x = min(GetX() + rand(50, 80), GetClipMaxX() - 64);
		}
		else{
			x = max(GetX() - rand(50, 80), GetClipMinX() + 64);
		}
		y = max(ymin, min(ymax, GetY() + rand(-30, 30)));
		SetMovePositionDC(x, y, 30);
		Wait(wait);
	}
}

//移動タスクその２
task T_MoveActB(wait, ymin, ymax)
{
	loop{
		let x;
		let y;

		if( GetX() < GetPlayerX() ){
			x = min(min(GetPlayerX(), GetX() + 60), GetClipMaxX() - 64);
		}
		else{
			x = max(max(GetPlayerX(), GetX() - 60), GetClipMinX() + 64);
		}
		y = max(ymin, min(ymax, GetY() + rand(-10, 10)));
		SetMovePositionDC(x, y, 10);
		Wait(wait);
	}
}

//移動タスクその３
task T_MoveActC(wait)
{
	loop{
		SetMovePosition02(GetPlayerX(), GetY(), wait);
		Wait(wait);
	}
}
