//------------------------------------------------------------------------------
// Lamp : Open source game middleware
// Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//------------------------------------------------------------------------------

/** @file
 * アンズ起き上がり状態実装
 * @author Junpee
 */

#include "Core/Utility/stdafx.h"
#include "Player/Anzu/AnzuGetUpState.h"
#include "Game/Sound/SoundSystem.h"
#include "Player/System/Player.h"

#include "Player/Anzu/AnzuRunState.h"
#include "Player/Anzu/AnzuStandState.h"

//------------------------------------------------------------------------------
// 生成、破棄
//------------------------------------------------------------------------------
// コンストラクタ
AnzuGetUpState::AnzuGetUpState(Anzu* anzu) : AnzuState(anzu){
}
//------------------------------------------------------------------------------
// デストラクタ
AnzuGetUpState::~AnzuGetUpState(){
}
//------------------------------------------------------------------------------
// 実行
//------------------------------------------------------------------------------
// 初期化
void AnzuGetUpState::initialize(){
	// アニメーションシーケンス設定
	getAnimation()->setSequence(5);
	// 実行カウンタクリア
	runCounter_ = 0;
	// 攻撃コリジョンを有効にする
	getAttackCollision()->setEnabled(true);
	// 音を鳴らす
//	getSoundSystem()->play("AnzuGetUp");
}
//------------------------------------------------------------------------------
// 後始末
void AnzuGetUpState::finalize(){
	// 攻撃コリジョンを無効に戻す
	getAttackCollision()->setEnabled(false);
	// 無敵カウンタ設定
	setMatchlessCounter(60);
}
//------------------------------------------------------------------------------
// 実行
void AnzuGetUpState::run(){
	// 定数
	float animationScale = 1.f;

	// ステート変更
	if(runCounter_ == 60){
		Point2f moveStick = getMoveStick();
		if(moveStick != Point2f::zero){
			getPlayer()->setState(new AnzuRunState(getAnzu()));
		}else{
			getPlayer()->setState(new AnzuStandState(getAnzu()));
		}
	}

	// 位置と速度の計算
	calcVelocityAndPosition(getDirection() * 0.4f);

	// 地形コリジョン
	landCollide();

	// 描画セットアップ
	drawSetup(animationScale);

	// 攻撃
	attackCollide(getBodyBone(), Vector3(0.f, 0.f, 0.f), 10.f, 20);

	// 実行カウンタインクリメント
	runCounter_++;
}
//------------------------------------------------------------------------------
