//@STATE=嶌惉拞
//@DESCRIPTION ---------------------------------------------------------------
// DispositionControl.cpp: DispositionControl 僋儔僗偺僀儞僾儕儊儞僥乕僔儑儞
//	棜楌丗
// $Log: DispositionControl.cpp,v $
// Revision 1.1  2001/10/28 21:40:35  fujiwara
// DLL偵暘妱
//
// Revision 1.7  2001/07/01 21:30:33  fujiwara
// 儊儌儕儕乕僋僠僃僢僋尒捈偟
//
// Revision 1.6  2001/07/01 01:03:43  fujiwara
// const 偺尒捈偟
// 攝抲僄僨傿僞偼搑拞宱夁
//
// Revision 1.5  2001/05/17 12:34:10  fujiwara
// 抧忋揋僒儞僾儖嶌惉
//
// Revision 1.4  2001/05/12 12:48:28  fujiwara
// 攝抲僄僨傿僞嶌惉偵敽偆曄峏丒捛壛
//
// Revision 1.3  2001/05/12 00:57:59  fujiwara
// (none)
//
//@DESCRIPTION_END -----------------------------------------------------------
//@AUTHOR=S.F.
// Copyright (C) 2000 Satoshi Fujiwara. All Rights Reserved.
///////////////////////////////////////////////////////////////////////////////
#pragma warning( disable : 4786 )	//STL偺寈崘奜偟

// SYSTEM INCLUDES //
// 儊儌儕乕儕乕僋専弌梡

#include "sfdebug.h"

#include <string>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <vector>
#include <map>


// PROJECT INCLUDES //

#include "exception.h"
#include "system.h"
#include "sound.h"
#include "console.h"
#include "Obj.h"
#include "Obj2D.h"
#include "ObjRectangle.h"
#include "ObjQuadrangle.h"
#include "Obj3DL.h"
#include "Background.h"
#include "input.h"
#include "Scene.h"
#include "main.h"
#include "AbstractScene.h"
#include "character.h"
#include "Hit.h"
#include "MyShip.h"
#include "Game.h"
#include "Enemys.h"
#include "Armys.h"
#include "ZK01.h"
#include "DispositionControl.h"
#include "DispositionEditor.h"

#ifdef _DEBUG
#ifndef _BORLAND
#define new DEBUG_NEW
#endif
#endif


//////////////////////////////////////////////////////////////////////
// 峔抸/徚柵
//////////////////////////////////////////////////////////////////////


using namespace sf::application::disposition;
using namespace sf;
using namespace sf::application::disposition::command;

// 僐儅儞僪楍 //
const std::string ControllerImpl::mCommand[command::MAX] = {
	"Reset",
	"SetScrollSpeed",
	"SetRestartPosition",
	"SetEnemy",
	"SetArmy"
};

const ControllerImpl::CreateFuncPtr ControllerImpl::mpCreateFunc[command::MAX] 
= {	&command::Reset::create,
	&command::SetScrollSpeed::create,
	&command::SetRestartPosition::create,
	&command::SetEnemy::create,
	&command::SetArmy::create
};

// 僐儞僗僩儔僋僞 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
ControllerImpl::ControllerImpl(){
}

// 僨僗僩儔僋僞 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
ControllerImpl::~ControllerImpl(){
	for(CommandList::iterator it = mData.begin();it != mData.end();++it)
	{
		delete (*it).second;
	}
	mData.clear();
}

// 僨乕僞偺傾儞儘乕僪 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void ControllerImpl::unload(void)
{
	for(CommandList::iterator it = mData.begin();it != mData.end();++it)
	{
		delete (*it).second;
	}
	mData.clear();

	// 揋僥僋僗僠儍偺傾儞儘乕僪
	sf::application::enemy::Enemys::instance()->unload();
}// unload()

// 攝抲僨乕僞偺儘乕僪 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void ControllerImpl::load(const char * const pFileName)
{
	mSerialNo = 0;
	unload();
	char err_loadstr[] = "ControllerImpl:load() Error!";
	
	std::fstream file(pFileName,std::ios::in);
	
	if(!file.is_open()){
		std::string  tmp;
		
		tmp += "File Open Error! ";
		tmp += "Disposition File ";
		tmp += pFileName;
		tmp += " Not Found!!";

		throw FatalErrorException(tmp,__FILE__,__LINE__);
	}
	
	mFileName = pFileName;
	
	int position,command_id;
	std::string command_str;

	while(!file.eof()){

			
		file >> position;
		
		if(file.fail())
			break;

		file >> command_str;
		command_id = findCommand(command_str);
		command_id--;
		
		command::Interface *pinterface = create((command::TYPE)command_id);
		pinterface->load(file);

		if(file.fail())
			throw FatalErrorException(err_loadstr,__FILE__,__LINE__);
		
		pinterface->game(game());
		insertCommand(position,pinterface);
	}
	mDataIter = mData.begin();
}//load()

// 僐儅儞僪傪僒乕僠偟丄偦偺僀儞僨僢僋僗傪曉偡 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
const int ControllerImpl::findCommand(const std::string &s)
{
	for(int i = 0;i < command::MAX;i++){
		if(s == mCommand[i]){
			i++;
			return i;
		}
	}
	throw FatalErrorException("ControllerImpl::findCommand() Command Parse Error!!",__FILE__,__LINE__);
	return 0;
}// findCommand()

// 僆僽僕僃僋僩惗惉 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
//command::Interface * ControllerImpl::create(command::TYPE command_id)
//{
//	return (mpCreateFunc[command_id])();
//}// create

// 儕僗僞乕僩埵抲偵僐儅儞僪傪偁傢偣傞 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void ControllerImpl::restart(const float position){
	mDataIter = mData.begin();
	
	if(mDataIter == mData.end()) return;

	while(mDataIter != mData.end() && mDataIter->first < position)
	{
		mDataIter++;
	};
}//restart();


// 僨乕僞偺僙乕僽 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void ControllerImpl::save(const char * const pMapFileName)
{
	std::string  err_savestr = "ControllerImpl:save() Error!";
	char *pfile_name;

	// 僼傽僀儖僱乕儉偑NULL偺応崌丄儘乕僪帪偺僼傽僀儖僱乕儉傪巊梡
	if(pMapFileName == NULL){
		if(mFileName.c_str() == NULL){
			throw FatalErrorException(err_savestr,__FILE__,__LINE__);
		} else {
			pfile_name = const_cast<char*>(mFileName.c_str());
		}
	} else {
		pfile_name = const_cast<char*>(pMapFileName);
	}

	std::fstream file(pfile_name,std::ios::out);
	
	if(!file.is_open()){
		std::string tmp ="";
		tmp += "File Open Error! ";
		tmp += "Disposition File ";
		tmp += pMapFileName;
		tmp += " Not Found!!";
		throw FatalErrorException(tmp,__FILE__,__LINE__);
	}

	bool bflag = false;
	
	for(CommandList::iterator it = mData.begin();
			it != mData.end(); it++)
	{
		if(bflag)
			file << std::endl;

		file << it->first << " ";
		file << mCommand[it->second->id()];
		
		it->second->save(file);
		
		bflag = true;
		if(file.fail())
			throw FatalErrorException(err_savestr,__FILE__,__LINE__);
	}
}// save()

// 僐儅儞僪偺幚峴 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void ControllerImpl::exec(const float position){
	
	if(mDataIter->first > position || mDataIter == mData.end())
		return;

	while(mDataIter->first <= position && mDataIter != mData.end()){
		mDataIter->second->exec(position);
		mDataIter++;
	}

}// exec()

// 揋偺嶍彍 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void ControllerImpl::deleteCommand(const float x,const float y,const float position,command::TYPE type)
{
	std::pair< CommandList::iterator, CommandList::iterator > it_pair
        = mData.equal_range( position );

	CommandList::iterator it = it_pair.first;
	
	command::SetEnemy *pe = NULL;
	command::SetArmy *pe1 = NULL;

	const int range = 6.0f;
	float tx,ty;

	while(it != it_pair.second){
		if(it->second->id() == type){
			switch(type){
			case SET_ENEMY:
				pe = dynamic_cast<command::SetEnemy *>(it->second);
				tx = pe->x() + game()->background()->startOffsetX();
				ty = pe->y() + game()->background()->startOffsetY();
				if(x > (tx - range) && x < (tx + range) && y > (ty - range) && y < (ty + range)){
					mData.erase(it);
					return;
				}
				break;
			case SET_ARMY:
				pe1 = dynamic_cast<command::SetArmy *>(it->second);
				tx = pe1->x() + game()->background()->startOffsetX();
				ty = pe1->y() + game()->background()->startOffsetY();
				if(x > (tx - range) && x < (tx + range) && y > (ty - range) && y < (ty + range)){
					mData.erase(it);
					return;
				}
				break;
			default:
				tx = sf::system::console::viewport::X + game()->background()->startOffsetX();
				ty = game()->background()->startOffsetY();
				if(x > (tx - range) && x < (tx + range) && y > (ty - range) && y < (ty + range)){
					mData.erase(it);
					return;
				}
				return;
			}
		}
		++it;
	}
}// deleteCommand()

// 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
// Abstract 
// 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅

void Abstract::draw(sf::application::scene::DispositionEditor *pEditor,float position,bool bMouse)
{
	if(sprite() == NULL)
		return;

	if(bMouse){
		pEditor->x(pEditor->mouseX());
		pEditor->y(pEditor->mouseY());
	} else {
		pEditor->x(sf::system::console::viewport::X + sf::system::console::viewport::WIDTH / 2.0f + game()->background()->startOffsetX());
		pEditor->y(game()->background()->startOffsetY()
			+ (game()->scrollY() - position));
	}

	if(position == game()->scrollY() && !bMouse)
		pEditor->specular(0x00208020);
	else
		pEditor->specular(0);
	
	pEditor->drawMode(sf::system::console::DRAW_TRANS);
	pEditor->color(0xffffffff);

	sprite()->draw(pEditor);
}// Abstract::draw()

// 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
// SetScrollSpeed 
// 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅

sf::system::console::sprite::PSprite SetScrollSpeed::mspSprite;

const sf::system::console::sprite::Info SetScrollSpeed::msSpriteInfo = 
{
	"media\\SetScrollSpeed.png",0.0f,0.0f,0.0f,0.0f,0xff000000,sf::system::console::sprite::SPRITE2D
};

// 儕僜乕僗偺儘乕僪 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetScrollSpeed::loadResource(void){
	using namespace sf::system::console::sprite;
	if(!mspSprite.get()){
		PSprite ptemp(sf::system::instance()->console()->createSprite(&msSpriteInfo)); 
		mspSprite = ptemp;
	}
}// SetScrollSpeed::loadResource()

// 儕僜乕僗偺傾儞儘乕僪 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetScrollSpeed::unloadResource(void){
	using namespace sf::system::console::sprite;
	PSprite ptmp(NULL);
	mspSprite = ptmp;
}// SetScrollSpeed::unloadResource()


// 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
// SetRestartPosition 
// 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
sf::system::console::sprite::PSprite SetRestartPosition::mspSprite;

const sf::system::console::sprite::Info SetRestartPosition::msSpriteInfo = 
{
	"media\\Restart.png",0.0f,0.0f,0.0f,0.0f,0xff000000,sf::system::console::sprite::SPRITE2D
};

// 儕僜乕僗偺儘乕僪 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetRestartPosition::loadResource(void){
	using namespace sf::system::console::sprite;
	if(!mspSprite.get()){
		PSprite ptemp(sf::system::instance()->console()->createSprite(&msSpriteInfo)); 
		mspSprite = ptemp;
	}
}// SetRestartPosition::loadResource()

// 儕僜乕僗偺傾儞儘乕僪 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetRestartPosition::unloadResource(void){
	using namespace sf::system::console::sprite;
	PSprite ptmp(NULL);
	mspSprite = ptmp;
}// SetRestartPosition::unloadResource()


// 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
// SetEnemy 
// 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅

sf::system::console::sprite::PSprite SetEnemy::mspSprites[sf::application::enemy::MAX_TYPE];
const sf::system::console::sprite::Info SetEnemy::msSpriteInfos[sf::application::enemy::MAX_TYPE] =
{
	{"media\\zk01.png",0.0f,0.0f,64.0f,64.0f,0xff000000,sf::system::console::sprite::SPRITE2D},
	{"media\\zk02.png",0.0f,0.0f,64.0f,64.0f,0xff000000,sf::system::console::sprite::SPRITE2D}
};


// 僆儁儗乕僞僆乕僶乕儔僀僪 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
std::ostream & operator <<
                ( std::ostream &rOStrm    // cStrStrm
                , const sf::application::scene::Game::DIFFICULTY &rDifficulty )    // cInt
{
	int temp = (int)rDifficulty;
    return rOStrm << temp;    // 婛懚偺娭悢傪屇傃弌偟傑偡丅
}

std::istream& operator >> ( std::istream& rIStrm, sf::application::scene::Game::DIFFICULTY &rDifficulty )
{
	int temp;
	rIStrm >> temp;
	rDifficulty = (sf::application::scene::Game::DIFFICULTY)temp;
	return rIStrm;
}


// 僐儞僗僩儔僋僞 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
SetEnemy::SetEnemy()
{	mX = mY = mZ = 0.0f;
	mEnemyNo = 0;
	mDifficulty = sf::application::scene::Game::EASY;
};

// 僨僗僩儔僋僞 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
SetEnemy::~SetEnemy(){;};

// 嵟戝悢傪曉偡 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
const int SetEnemy::max(void) const
{
	return sf::application::enemy::MAX_TYPE;
}

// 僐儅儞僪偺幚峴 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetEnemy::exec(const float position)
{
	if(mDifficulty <= game()->difficulty()){
		sf::application::enemy::Enemys::instance()->create(
			(sf::application::enemy::Enemys::TYPE)mEnemyNo,
			mX,mY,mZ,game()
			);
	}
};

// 僐儅儞僪偺儘乕僪 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetEnemy::load(std::istream &is){

	is >> mDifficulty;
	is >> mEnemyNo;
	is >> mX;
	is >> mY;
	is >> mZ;
	
	sf::application::enemy::Enemys::instance()->load(mEnemyNo);
};// load()

// 僐儅儞僪偺僙乕僽 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetEnemy::save(std::ostream &os){
	os << " " << mDifficulty;
	os << " " << mEnemyNo;
	os << " " << mX ;
	os << " " << mY;
	os << " " << mZ;
};// save();

// 儕僜乕僗偺儘乕僪 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetEnemy::loadResource(void){
	using namespace sf::system::console::sprite;
	for(int i = 0;i < sf::application::enemy::MAX_TYPE;i++){
		if(!mspSprites[i].get()){
			PSprite ptemp(sf::system::instance()->console()->createSprite(&msSpriteInfos[i])); 
			mspSprites[i] = ptemp;
		}
	}
}// SetEnemy::loadResource()

// 儕僜乕僗偺傾儞儘乕僪 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetEnemy::unloadResource(void){
	using namespace sf::system::console::sprite;
	for(int i = 0;i < sf::application::enemy::MAX_TYPE;i++){
		if(mspSprites[i].get()){
			PSprite ptmp(NULL);
			mspSprites[i] = ptmp;
		}
	}
}// SetEnemy::unloadResource()

// 揋儅乕僇乕偺昤夋 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetEnemy::draw(sf::application::scene::DispositionEditor * const pEditor
					,const float position,const bool bMouse)
{
	using namespace sf::application::scene;
	// 儅僂僗僇乕僜儖偵捛廬偡傞偐
	if(bMouse){
		pEditor->x(pEditor->mouseX());
		pEditor->y(pEditor->mouseY());
	} else {
		pEditor->x(x() + game()->background()->startOffsetX());
		pEditor->y(y() + game()->background()->startOffsetY()
			+ (game()->scrollY() - position));
	}

	if(position == game()->scrollY() && !bMouse)
		pEditor->specular(DispositionEditor::CURRENT_SPECULAR);
	else
		pEditor->specular(DispositionEditor::NORMAL_SPECULAR);
	
	pEditor->drawMode(sf::system::console::DRAW_TRANS);
	pEditor->color(0xffffffff);

	mspSprites[mEnemyNo]->draw(pEditor);

}// SetEnemy::draw()

// 僉乕墴壓帪偺張棟 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetEnemy::keyDown(const DWORD keyCode,const DWORD extKeyCode)
{
	switch((char)keyCode)
	{
	case '1':
		if(mEnemyNo > 0)
			mEnemyNo--;
		break;
	case '2':
		if(mEnemyNo < max() - 1)
			mEnemyNo++;
		break;
	}
}//keyDown();

// 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
// SetArmy 
// 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅

sf::system::console::sprite::PSprite SetArmy::mspSprites[sf::application::enemy::MAX_ARMYS_TYPE];
const sf::system::console::sprite::Info SetArmy::msSpriteInfos[sf::application::enemy::MAX_ARMYS_TYPE] =
{
	{"media\\ea01.png",0.0f,0.0f,64.0f,64.0f,0xff000000,sf::system::console::sprite::SPRITE2D}
};

// 僐儞僗僩儔僋僞 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
SetArmy::SetArmy()
{	mX = mY = mZ = 0.0f;
	mEnemyNo = 0;
	mDifficulty = sf::application::scene::Game::EASY;
};

// 僨僗僩儔僋僞 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
SetArmy::~SetArmy(){;};

// 嵟戝悢傪曉偡 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
const int SetArmy::max(void) const
{
	return sf::application::enemy::MAX_ARMYS_TYPE;
}

// 僐儅儞僪偺幚峴 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetArmy::exec(const float position)
{
	if(mDifficulty <= game()->difficulty()){
		sf::application::enemy::Armys::instance()->create(
			(sf::application::enemy::Armys::TYPE)mEnemyNo,
			mX,mY,mZ,game()
			);
	}
};

// 僐儅儞僪偺儘乕僪 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetArmy::load(std::istream &is){
	
	is >> mDifficulty;
	is >> mEnemyNo;
	is >> mX;
	is >> mY;
	is >> mZ;

	sf::application::enemy::Armys::instance()->load(mEnemyNo);

};// load()

// 僐儅儞僪偺僙乕僽 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetArmy::save(std::ostream &os){
	os << " " << mDifficulty;
	os << " " << mEnemyNo;
	os << " " << mX ;
	os << " " << mY;
	os << " " << mZ;
};// save();

// 儕僜乕僗偺儘乕僪 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetArmy::loadResource(void){
	using namespace sf::system::console::sprite;
	for(int i = 0;i < sf::application::enemy::MAX_TYPE;i++){
		if(!mspSprites[i].get()){
			PSprite ptemp(sf::system::instance()->console()->createSprite(&msSpriteInfos[i])); 
			mspSprites[i] = ptemp;
		}
	}
}// SetArmy::loadResource()

// 儕僜乕僗偺傾儞儘乕僪 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetArmy::unloadResource(void){
	using namespace sf::system::console::sprite;
	for(int i = 0;i < sf::application::enemy::MAX_TYPE;i++){
		if(mspSprites[i].get()){
			PSprite ptmp(NULL);
			mspSprites[i] = ptmp;
		}
	}
}// SetArmy::unloadResource()

// 攝抲儅僢僾忋偵昤夋 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetArmy::draw(sf::application::scene::DispositionEditor * const pEditor,const float position,const bool bMouse)
{
	if(bMouse){
		pEditor->x(pEditor->mouseX());
		pEditor->y(pEditor->mouseY());
	} else {
		pEditor->x(game()->background()->startOffsetX());
		pEditor->y(game()->background()->startOffsetY()
			+ (game()->scrollY() - position));
	}

	if(position == game()->scrollY() && !bMouse)
		pEditor->specular(0x00208020);
	else
		pEditor->specular(0);
	
	pEditor->drawMode(sf::system::console::DRAW_TRANS);
	pEditor->color(0xffffffff);

	mspSprites[mEnemyNo]->draw(pEditor);
}// SetArmy::draw()

// 僉乕墴壓帪偺張棟 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
void SetArmy::keyDown(const DWORD keyCode,const DWORD extKeyCode)
{
	switch((char)keyCode)
	{
	case '1':
		if(mEnemyNo > 0)
			mEnemyNo--;
		break;
	case '2':
		if(mEnemyNo < max() - 1)
			mEnemyNo++;
		break;
	}
}//keyDown();
