//------------------------------------------------------------------------------
// 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/Gelaim.h"
#include "Game/System/GameSystem.h"
#include "Game/Rendering/RenderingSystem.h"
#include "Game/Animation/AnimationSystem.h"
#include "Game/Sound/SoundSystem.h"
#include "Load/System/LoadTask.h"
#include "Game/Input/GamePad.h"
#include "Enemy/Gelaim/GelaimStandState.h"

//------------------------------------------------------------------------------
// コンストラクタ
Gelaim::Gelaim(int health, u_int randomSeed) : Enemy(health, randomSeed){
	String name("Gelaim");
	// モデルの初期化
	initializeModel(name, "Front2", "Center", SceneObject::copyMaterial);

	// アニメーションの初期化
	initializeAnimation(name);

	// コリジョンノードの初期化
	initializeCollision(name, 4.f, 6.f);

	// 初期状態の設定
	GelaimState* state = new GelaimStandState(this);
	setState(state);

	// マテリアルのランダマイズ
	BasicMaterial* material =
		getModel()->getMesh(0)->getMaterial()->castBasicMaterial();
	material->setDiffuseColor(Color3f(
		getRandom().getUnsignedFloat(),
		getRandom().getUnsignedFloat(),
		getRandom().getUnsignedFloat()));
	material->setSpecularColor(Color3f(
		getRandom().getUnsignedFloat() + 0.5f,
		getRandom().getUnsignedFloat() + 0.5f,
		getRandom().getUnsignedFloat() + 0.5f));
	material->setAlpha(getRandom().getUnsignedFloat() * 0.5f + 0.5f);

	// 生成音
	getSoundSystem()->play("GelaimGenerate");
}
//------------------------------------------------------------------------------
// デストラクタ
Gelaim::~Gelaim(){
}
//------------------------------------------------------------------------------
// ロード
void Gelaim::load(SceneNode* enemyNode){
	LoadTask* loadTask = getGameSystem()->getLoadTask();
	// ロードタスクの登録
	loadTask->requestScene(
		"Media/Enemy/Gelaim/Gelaim.bsn", getScene(), enemyNode);
	loadTask->requestAnimation("Media/Enemy/Gelaim/Gelaim.bam",
		getAnimationManager(), getScene());
}
//------------------------------------------------------------------------------
