//------------------------------------------------------------------------------
// 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 "Enemy/Gelaim/GelaimStandState.h"
#include "Enemy/System/Enemy.h"
#include "Stage/System/Stage.h"

#include "Enemy/Gelaim/GelaimRunState.h"
#include "Enemy/Gelaim/GelaimAttackState.h"

//------------------------------------------------------------------------------
// 生成、破棄
//------------------------------------------------------------------------------
// コンストラクタ
GelaimStandState::GelaimStandState(Gelaim* gelaim) : GelaimState(gelaim){
}
//------------------------------------------------------------------------------
// デストラクタ
GelaimStandState::~GelaimStandState(){
}
//------------------------------------------------------------------------------
// 実行
//------------------------------------------------------------------------------
// 初期化
void GelaimStandState::initialize(){
	// アニメーションシーケンス設定
	getAnimation()->setSequence(1);
}
//------------------------------------------------------------------------------
// 後始末
void GelaimStandState::finalize(){
}
//------------------------------------------------------------------------------
// 実行
void GelaimStandState::run(){
	// 定数
	float animationScale = 1.f;

	// ステート変更
	if(!isDamaged()){
		if((getRandom().get() % 60) == 0){
			getEnemy()->setState(new GelaimRunState(getGelaim()));
		}else if((getPlayerDistance().getLength() < 15.f) &&
			((getRandom().get() % 120) == 0)){
			getEnemy()->setState(new GelaimAttackState(getGelaim()));
		}
	}

	// 位置と速度の計算
	calcVelocityAndPosition();

	// 向きの設定
	setDirection(getPlayerDirection());

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

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