Exemplo n.º 1
0
//------------------------------------------------------------------
//
// TMXIsoZorderNew
//
//------------------------------------------------------------------
TMXIsoZorderNew::TMXIsoZorderNew()
{
    auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/iso-test-zorder.tmx");
    addChild(map, 0, kTagTileMap);

    auto s = map->getContentSize();
    CCLOG("ContentSize: %f, %f", s.width,s.height);
    map->setPosition(Vec2(-s.width/2,0));
    
    _tamara = Sprite::create(s_pathSister1);
    map->addChild(_tamara, (int)map->getChildren().size() );
    _tamara->retain();
    int mapWidth = map->getMapSize().width * map->getTileSize().width;
    _tamara->setPosition(CC_POINT_PIXELS_TO_POINTS(Vec2( mapWidth/2,0)));
    _tamara->setAnchorPoint(Vec2(0.5f,0));

    
    auto move = MoveBy::create(10, Vec2(300,250));
    auto back = move->reverse();
    auto seq = Sequence::create(move, back,nullptr);
    _tamara->runAction( RepeatForever::create(seq) );
    
    schedule( CC_SCHEDULE_SELECTOR(TMXIsoZorderNew::repositionSprite) );
}
Exemplo n.º 2
0
//------------------------------------------------------------------
//
// TMXIsoZorder
//
//------------------------------------------------------------------
TMXIsoZorder::TMXIsoZorder()
{
    auto map = TMXTiledMap::create("TileMaps/iso-test-zorder.tmx");
    addChild(map, 0, kTagTileMap);

    auto s = map->getContentSize();
    CCLOG("ContentSize: %f, %f", s.width,s.height);
    map->setPosition(Point(-s.width/2,0));
    
    _tamara = Sprite::create(s_pathSister1);
    map->addChild(_tamara, map->getChildren().size() );
    _tamara->retain();
    int mapWidth = map->getMapSize().width * map->getTileSize().width;
    _tamara->setPosition(CC_POINT_PIXELS_TO_POINTS(Point( mapWidth/2,0)));
    _tamara->setAnchorPoint(Point(0.5f,0));

    
    auto move = MoveBy::create(10, Point(300,250));
    auto back = move->reverse();
    auto seq = Sequence::create(move, back,NULL);
    _tamara->runAction( RepeatForever::create(seq) );
    
    schedule( schedule_selector(TMXIsoZorder::repositionSprite) );
}
Exemplo n.º 3
0
void Player::onTouchMoved(Touch *touch, Event *event)
{
    Vec2 prev = event->getCurrentTarget()->getPosition();
    Vec2 delta =touch->getDelta();
    
    setTargetAngle(targetAngle+delta.x*rollSpeed*(rollReturnThreshold-fabsf(targetAngle)/maxRoll));
    
    Vec2 shiftPosition = delta+prev;
	
	auto camera = CameraExt::getInstance();
	setPosition(shiftPosition.getClampPoint(camera->GetCameraOriginToGL(), Vec2(camera->GetCameraOriginToGL().x + camera->getCameraSize().width, camera->getMapSize().height)));
}
Exemplo n.º 4
0
void Player::onAxisRepeat()
{
    Vec2 prev = this->getPosition();
    Vec2 delta =Vec2(15*axisX,-15*axisY);
    
    setTargetAngle(targetAngle+delta.x*rollSpeed*(rollReturnThreshold-fabsf(targetAngle)/maxRoll));
    
    Vec2 shiftPosition = delta+prev;
    
	auto camera = CameraExt::getInstance();
	setPosition(shiftPosition.getClampPoint(camera->GetCameraOriginToGL(), camera->GetCameraOriginToGL()+Vec2(camera->getCameraSize().width, camera->getMapSize().height)));
}
Exemplo n.º 5
0
bool AI::inBounds(int x, int y)
{
  int radius = getMapSize();
  return !(x<-radius || x>radius || y<-radius || y>radius);
}
Exemplo n.º 6
0
void MapLayer::update(float dt)
{

    // 根据路径移动
    if(_stepIndex >= 1) {

        if(_smallStepIndex == 0) {
            int ncol = ((AstarItem*)_path->getObjectAtIndex(_stepIndex))->getCol();
            int nrow = ((AstarItem*)_path->getObjectAtIndex(_stepIndex))->getRow();
            int pcol = ((AstarItem*)_path->getObjectAtIndex(_stepIndex - 1))->getCol();
            int prow = ((AstarItem*)_path->getObjectAtIndex(_stepIndex - 1))->getRow();

            if(pcol == ncol) {
                if(prow > nrow) {
                    _vmove = 2;

                } else if(prow <nrow) {
                    _vmove = 3;

                } else {
                    _vmove = -1;
                }
            } else if(prow == nrow) {
                if(pcol > ncol) {
                    _vmove = 1;

                } else if(pcol < ncol) {
                    _vmove = 0;

                } else {
                    _vmove = -1;
                }
            } else {
                _vmove = -1;
            }

        }

        Point herop = _tamara->getPosition();

        switch(_vmove) {
        case 0:
            herop.x += 1;
            herop.y -= 0.5;
            break;
        case 1:
            herop.x -= 1;
            herop.y += 0.5;
            break;
        case 2:
            herop.x += 1;
            herop.y += 0.5;
            break;
        case 3:
            herop.x -= 1;
            herop.y -= 0.5;
            break;
        case 4:
            herop.x += 1;
            break;
        case 5:
            herop.x -= 1;
            break;
        case 6:
            herop.y += 0.5;
            break;
        case 7:
            herop.y -= 0.5;
            break;
        default:
            break;
        }

        _smallStepIndex++;
        if(_smallStepIndex >= 32) {
            _smallStepIndex = 0;
            if(_stepIndex >= _path->count() - 1) {
                // 移动到终点
                _stepIndex = -1;
                _vmove = -1;

                _path->removeAllObjects();
                _path->release();
                _path = nullptr;

            } else {
                _stepIndex++;
                _vmove = -1;
            }
        }

        _tamara->setPosition(herop);

        // 地图随主角移动
        auto map = (TMXTiledMap*)this->getChildByTag(kTagTileMap);
        int mapWidth = map->getMapSize().width * map->getTileSize().width;
        int mapHeight = map->getMapSize().height * map->getTileSize().height;
        float deltaX = herop.x - mapWidth/2;
        float deltaY = herop.y - 112;
        auto winSize = Director::getInstance()->getWinSize();
        map->setPosition((winSize.width - map->getContentSize().width)/2 - deltaX, -deltaY);

    }
}
Exemplo n.º 7
0
int BaseAI::mapSize()
{
  return getMapSize();
}
Exemplo n.º 8
0
void CClient::loadGame(const std::string & fname, const bool server, const std::vector<int>& humanplayerindices, const int loadNumPlayers, int player_, const std::string & ipaddr, const std::string & port)
{
    PlayerColor player(player_); //intentional shadowing

    logNetwork->infoStream() <<"Loading procedure started!";

	CServerHandler sh;
    if(server)
         sh.startServer();
    else
         serv = sh.justConnectToServer(ipaddr,port=="" ? "3030" : port);

	CStopWatch tmh;
    unique_ptr<CLoadFile> loader;
	try
	{
		std::string clientSaveName = *CResourceHandler::get("local")->getResourceName(ResourceID(fname, EResType::CLIENT_SAVEGAME));
		std::string controlServerSaveName;

		if (CResourceHandler::get("local")->existsResource(ResourceID(fname, EResType::SERVER_SAVEGAME)))
		{
			controlServerSaveName = *CResourceHandler::get("local")->getResourceName(ResourceID(fname, EResType::SERVER_SAVEGAME));
		}
		else// create entry for server savegame. Triggered if save was made after launch and not yet present in res handler
		{
			controlServerSaveName = clientSaveName.substr(0, clientSaveName.find_last_of(".")) + ".vsgm1";
			CResourceHandler::get("local")->createResource(controlServerSaveName, true);
		}

		if(clientSaveName.empty())
			throw std::runtime_error("Cannot open client part of " + fname);
		if(controlServerSaveName.empty())
			throw std::runtime_error("Cannot open server part of " + fname);

		{
			CLoadIntegrityValidator checkingLoader(clientSaveName, controlServerSaveName, minSupportedVersion);
			loadCommonState(checkingLoader);
			loader = checkingLoader.decay();
		}
        logNetwork->infoStream() << "Loaded common part of save " << tmh.getDiff();
		const_cast<CGameInfo*>(CGI)->mh = new CMapHandler();
		const_cast<CGameInfo*>(CGI)->mh->map = gs->map;
		pathInfo = make_unique<CPathsInfo>(getMapSize());
		CGI->mh->init();
        logNetwork->infoStream() <<"Initing maphandler: "<<tmh.getDiff();
	}
	catch(std::exception &e)
	{
		logGlobal->errorStream() << "Cannot load game " << fname << ". Error: " << e.what();
		throw; //obviously we cannot continue here
	}

/*
    if(!server)
         player = PlayerColor(player_);
*/

    std::set<PlayerColor> clientPlayers;
    if(server)
         serv = sh.connectToServer();
    //*loader >> *this;

    if(server)
    {
         tmh.update();
         ui8 pom8;
         *serv << ui8(3) << ui8(loadNumPlayers); //load game; one client if single-player
         *serv << fname;
         *serv >> pom8;
         if(pom8) 
              throw std::runtime_error("Server cannot open the savegame!");
         else
              logNetwork->infoStream() << "Server opened savegame properly.";
    }

    if(server)
    {
         for(auto & elem : gs->scenarioOps->playerInfos)
              if(!std::count(humanplayerindices.begin(),humanplayerindices.end(),elem.first.getNum()) || elem.first==player)
              {
                  clientPlayers.insert(elem.first);
              }
         clientPlayers.insert(PlayerColor::NEUTRAL);
    }
    else
    {
        clientPlayers.insert(player);
    }

    std::cout << "CLIENTPLAYERS:\n";
    for(auto x : clientPlayers)
         std::cout << x << std::endl;
    std::cout << "ENDCLIENTPLAYERS\n";

    serialize(loader->serializer,0,clientPlayers);
    *serv << ui32(clientPlayers.size());
    for(auto & elem : clientPlayers)
        *serv << ui8(elem.getNum());
    serv->addStdVecItems(gs); /*why is this here?*/

    //*loader >> *this;
    logNetwork->infoStream() << "Loaded client part of save " << tmh.getDiff();

    logNetwork->infoStream() <<"Sent info to server: "<<tmh.getDiff();

    //*serv << clientPlayers;
	serv->enableStackSendingByID();
	serv->disableSmartPointerSerialization();

// 	logGlobal->traceStream() << "Objects:";
// 	for(int i = 0; i < gs->map->objects.size(); i++)
// 	{
// 		auto o = gs->map->objects[i];
// 		if(o)
// 			logGlobal->traceStream() << boost::format("\tindex=%5d, id=%5d; address=%5d, pos=%s, name=%s") % i % o->id % (int)o.get() % o->pos % o->getHoverText();
// 		else
// 			logGlobal->traceStream() << boost::format("\tindex=%5d --- nullptr") % i;
// 	}
}
Exemplo n.º 9
0
//Returns a deque of zombie steps to get you to the target.
//facing is the current facing
//Uses A* hopefully.
std::deque<int> AI::findZombiePath(int startX, int startY, int targetX,
                                 int targetY, int facing)
{
  std::cout << "s" << std::endl;
  const int ZOMBIE_ATTACK = 5 * 5;
  int wallIndex;
  bool solved = false;
  bool addChild;
  std::deque<int> solution;
  std::list<ZombieStep*> openList;
  std::map<int, ZombieStep*> allStates; //(ZombieStep.mapKey(), ZombieStep)
  std::map<int, ZombieStep*>::iterator iter;
  ZombieStep* start = new ZombieStep(startX, startY, facing, NULL);
  ZombieStep* nextChild;
  ZombieStep* parent;

  openList.push_front(start);
  allStates[start->mapKey()] = start;

  while (openList.size() > 0 && !solved)
  {
    solved = (openList.front()->x == targetX)
             && (openList.front()->y == targetY);
    
    if (!solved)
    {
      for (int i = 0; i < 3; i++)
      {
        nextChild = new ZombieStep(openList.front(), i);

        wallIndex = getWall(nextChild->x, nextChild->y);
        if (wallIndex > -1)
        {
          nextChild->depth += walls[wallIndex].hp() / ZOMBIE_ATTACK;
        }

        std::map<int, ZombieStep*>::iterator iter;
        int index = -1;
        iter = allStates.find(nextChild->mapKey());
        if (iter != allStates.end())
          addChild = false;
        else
          addChild = true;

        if (nextChild->x > getMapSize() || nextChild->x < -getMapSize())
          addChild = false;
        else if (nextChild->y > getMapSize() || nextChild->y < -getMapSize())
          addChild = false;
        
        if (addChild)
        {
          nextChild->remaining = zombieDistance(nextChild->x, nextChild->y,
                                    targetX, targetY, nextChild->facing);
          openList.push_back(nextChild);
          allStates[nextChild->mapKey()] = nextChild;
        }
        else
        {
          delete nextChild; //free if not added
        }
      }
      openList.pop_front();
    }
  }

  solution.clear();
  if (solved)
  {
    parent = openList.front();
    while(parent != NULL)
    {
      solution.push_front(parent->action);
      parent = parent->parent;
    }
  }
  

  for(iter = allStates.begin(); iter != allStates.end(); ++iter )
  {
    delete (iter->second);
  }
  return solution;
}
Exemplo n.º 10
0
void CClient::loadGame( const std::string & fname )
{
    logNetwork->infoStream() <<"Loading procedure started!";

	CServerHandler sh;
	sh.startServer();

	CStopWatch tmh;
	try
	{
		std::string clientSaveName = CResourceHandler::get()->getResourceName(ResourceID(fname, EResType::CLIENT_SAVEGAME));
		std::string controlServerSaveName;

		if (CResourceHandler::get()->existsResource(ResourceID(fname, EResType::SERVER_SAVEGAME)))
		{
			controlServerSaveName = CResourceHandler::get()->getResourceName(ResourceID(fname, EResType::SERVER_SAVEGAME));
		}
		else// create entry for server savegame. Triggered if save was made after launch and not yet present in res handler
		{
			controlServerSaveName = clientSaveName.substr(0, clientSaveName.find_last_of(".")) + ".vsgm1";
			CResourceHandler::get()->createResource(controlServerSaveName, true);
		}

		if(clientSaveName.empty())
			throw std::runtime_error("Cannot open client part of " + fname);
		if(controlServerSaveName.empty())
			throw std::runtime_error("Cannot open server part of " + fname);

		unique_ptr<CLoadFile> loader;
		{
			CLoadIntegrityValidator checkingLoader(clientSaveName, controlServerSaveName);
			loadCommonState(checkingLoader);
			loader = checkingLoader.decay();
		}
        logNetwork->infoStream() << "Loaded common part of save " << tmh.getDiff();
		const_cast<CGameInfo*>(CGI)->mh = new CMapHandler();
		const_cast<CGameInfo*>(CGI)->mh->map = gs->map;
		pathInfo = make_unique<CPathsInfo>(getMapSize());
		CGI->mh->init();
        logNetwork->infoStream() <<"Initing maphandler: "<<tmh.getDiff();

		*loader >> *this;
        logNetwork->infoStream() << "Loaded client part of save " << tmh.getDiff();
	}
	catch(std::exception &e)
	{
		logGlobal->errorStream() << "Cannot load game " << fname << ". Error: " << e.what();
		throw; //obviously we cannot continue here
	}

	serv = sh.connectToServer();
	serv->addStdVecItems(gs);

	tmh.update();
	ui8 pom8;
	*serv << ui8(3) << ui8(1); //load game; one client
	*serv << fname;
	*serv >> pom8;
	if(pom8) 
		throw std::runtime_error("Server cannot open the savegame!");
	else
        logNetwork->infoStream() << "Server opened savegame properly.";

	*serv << ui32(gs->scenarioOps->playerInfos.size()+1); //number of players + neutral
	for(auto it = gs->scenarioOps->playerInfos.begin(); 
		it != gs->scenarioOps->playerInfos.end(); ++it)
	{
		*serv << ui8(it->first.getNum()); //players
	}
	*serv << ui8(PlayerColor::NEUTRAL.getNum());
    logNetwork->infoStream() <<"Sent info to server: "<<tmh.getDiff();

	serv->enableStackSendingByID();
	serv->disableSmartPointerSerialization();

}
Exemplo n.º 11
0
void Tmx2MapData::readTmxFile(char * tmxurl,char * mapDataurl)
{
	auto map=CCTMXTiledMap::create(tmxurl);
	Size mapsz=map->getMapSize();
	xLen=(int16)mapsz.width;
	yLen=(int16)mapsz.height;
	Size titlesz=map->getTileSize();
	cellHeight=(int16)titlesz .height;
	cellWidth=(int16)titlesz.width;
	Size contentsz=map->getContentSize();
	width=(int16)contentsz.width;
	height=(int16)contentsz.height;
	fileArray =new std::vector<unsigned char>();
	std::vector<unsigned char> * aphaArray=new std::vector<unsigned char>();
	auto maplayer=map->getLayer("route");
	for (int i=0;i<mapsz.width;i++)
	{
		for (int j=0;j<mapsz.height;j++)
		{
			
			UINT gid=maplayer->tileGIDAt(Vec2(i,j));
			if (gid==0)
			{
				fileArray->push_back((unsigned char)0);
			}
			else
			{
				fileArray->push_back((unsigned char)1);
			}
		}
	}
	maplayer=map->getLayer("apha");
	for (int i=0;i<mapsz.width;i++)
	{
		for (int j=0;j<mapsz.height;j++)
		{

			UINT gid=maplayer->tileGIDAt(Vec2(i,j));
			if (gid==0)
			{
				aphaArray->push_back((unsigned char)0);
			}
			else
			{
				aphaArray->push_back((unsigned char)1);
			}
		}
	}
	ByteBuffer buffer;
	buffer<<width;
	buffer<<height;
	buffer<<xLen;
	buffer<<yLen;
	buffer<<cellWidth;
	buffer<<cellHeight;
	buffer<<(int16)0;
	buffer<<(int16)0;
	buffer<<*fileArray;
	buffer<<*aphaArray;
	CC_SAFE_DELETE(maskArray);
	FILE *a = fopen(mapDataurl,"wb");
	fwrite(buffer.contents(),buffer.size(),1,a);
	fclose(a);
}
Exemplo n.º 12
0
bool RogueScene::init()
{
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    // 乱数
    srand((unsigned int)time(NULL));
    
    // TouchEvent settings
    auto listener = EventListenerTouchOneByOne::create();
    listener->setSwallowTouches(true);
    
    listener->onTouchBegan = CC_CALLBACK_2(RogueScene::onTouchBegan, this);
    listener->onTouchMoved = CC_CALLBACK_2(RogueScene::onTouchMoved, this);
    listener->onTouchEnded = CC_CALLBACK_2(RogueScene::onTouchEnded, this);
//    this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);
    this->getEventDispatcher()->addEventListenerWithFixedPriority(listener, 1);
    
    auto winSize = Director::getInstance()->getWinSize();
    
    // ---------------------
    // タイルマップを生成
    // ---------------------
    auto pTiledMap = TMXTiledMap::create("tmx/desert.tmx");
    pTiledMap->setPosition(Point::ZERO);
    this->addChild(pTiledMap, RogueScene::zTiledMapIndex, RogueScene::kTiledMapTag);
    
    m_baseMapSize = pTiledMap->getMapSize();
    m_baseTileSize = pTiledMap->getTileSize();
    m_baseContentSize = pTiledMap->getContentSize();
    
    m_mapManager.init(0, (int)m_baseMapSize.height, 0, (int)m_baseMapSize.width);

    // 使ってなかった
//    // フロントレイヤー
//    auto pFrontLayer = Layer::create();
//    pTiledMap->addChild(pFrontLayer,
//                        RogueScene::TiledMapIndex::zTiledMapFrontIndex,
//                        RogueScene::TiledMapTag::kTiledMapFrontTag);
    
    // エネミーレイヤー
    auto pEnemyLayer = Layer::create();
    pTiledMap->addChild(pEnemyLayer,
                        RogueScene::TiledMapIndex::zTiledMapEnemyBaseIndex,
                        RogueScene::TiledMapTag::kTiledMapEnemyBaseTag);
    
    // ドロップアイテムレイヤー
    auto pDropItemLayer = Layer::create();
    pTiledMap->addChild(pDropItemLayer,
                        RogueScene::TiledMapIndex::zTiledMapDropItemBaseIndex,
                        RogueScene::TiledMapTag::kTiledMapDropItemBaseTag);
    
    // 障害物をmapManagerに適応する
    auto pColisionLayer = pTiledMap->getLayer("colision");
    for (int x = 0; x < m_baseMapSize.width; x++)
    {
        for (int y = 0; y < m_baseMapSize.height; y++)
        {
            if (pColisionLayer->getTileAt(Point(x, y)))
            {
                MapIndex mapIndex = {x, y, MoveDirectionType::MOVE_NONE};
                auto tileMapIndex = mapIndexToTileIndex(mapIndex);
                m_mapManager.addObstacle(&tileMapIndex);
            }
        }
    }
    
    // ---------------------
    // グリッド線を生成
    // ---------------------
    auto draw = DrawNode::create();
    draw->setPosition(Point::ZERO);
    
    // 線の太さと色
    float lineSize = 1 * 0.5;
    Color4F color = Color4F::MAGENTA;
    
    // 縦線を引く
    for (int x = 1; x < m_baseMapSize.width; x++)
    {
        float xPoint = x * m_baseTileSize.width;
        draw->drawSegment(Point(xPoint, 0), Point(xPoint, m_baseContentSize.height), lineSize, color);
    }
    // 横線を引く
    for (int y = 1; y < m_baseMapSize.height; y++)
    {
        float yPoint = y * m_baseTileSize.height;
        draw->drawSegment(Point(0, yPoint), Point(m_baseContentSize.width, yPoint), lineSize, color);
    }
    
    // マップに追加
    pTiledMap->addChild(draw, RogueScene::TiledMapIndex::zGridLineIndex, RogueScene::TiledMapTag::kGridLineTag);

    //-------------------------
    // ステータスバー?
    //-------------------------
    auto statusLayer = LayerColor::create(Color4B::BLACK);
    statusLayer->setContentSize(Size(winSize.width, m_baseTileSize.height * 0.8));
    statusLayer->setPosition(Point(0, winSize.height - statusLayer->getContentSize().height));
    
    // TODO: あとで更新する
    auto sampleText = LabelTTF::create(" --F Lv-- HP ---/--- 満腹度 ---/---          - G", GAME_FONT(16), 16);
    
    sampleText->setPosition(Point(sampleText->getContentSize().width / 2, statusLayer->getContentSize().height / 2));
    statusLayer->addChild(sampleText);
    
    this->addChild(statusLayer, RogueScene::zStatusBarIndex, RogueScene::kStatusBarTag);
    
    //    // 下のステータスバー2
    //    auto pStatusLayer2 = LayerColor::create(Color4B::BLACK);
    //    pStatusLayer2->setContentSize(Size(m_baseTileSize.width, m_baseTileSize.height));
    //    pStatusLayer2->setPosition(Point(0, 0));
    //
    //    // TODO: アイコン表示するかな(ステータスバー2?)
    //    auto pFaceSprite = Sprite::createWithSpriteFrame(SpriteFrame::create("actor_4_f.png", Rect(0, 0, 96, 96)));
    //    float scale = 1.0f / 3.0f;
    //    pFaceSprite->setScale(scale, scale);
    //    //    pFaceSprite->setContentSize(pFaceSprite->getContentSize() * scale);
    //    //    CCLOG("getContentSize (%f, %f) ", pFaceSprite->getContentSize().width, pFaceSprite->getContentSize().height);
    //    //    pFaceSprite->setPosition(Point(pFaceSprite->getContentSize().width / 2, pFaceSprite->getContentSize().height / 2));
    //    pFaceSprite->setPosition(Point(pFaceSprite->getContentSize().width * pFaceSprite->getScaleX() / 2, pFaceSprite->getContentSize().height * pFaceSprite->getScaleY() / 2));
    //    pStatusLayer2->addChild(pFaceSprite);
    //
    //    this->addChild(pStatusLayer2, RogueScene::zStatusBar2Index, RogueScene::kStatusBar2Tag);
    
    //-------------------------
    // ゲームログ表示
    //-------------------------
    //    float startWidth = pFaceSprite->getContentSize().width * pFaceSprite->getScaleX();
    auto pGameLogLayer = LayerColor::create(Color4B(0, 0, 0, 192));
    pGameLogLayer->setContentSize(Size(winSize.width * 0.8, m_baseTileSize.height * 1.5));
    pGameLogLayer->setPosition(winSize.width / 2 - pGameLogLayer->getContentSize().width / 2, 0);
    
    int baseFontSize = 10;
    auto pLogTextLabel = LabelTTF::create("", GAME_FONT(baseFontSize), baseFontSize, Size::ZERO, TextHAlignment::LEFT, TextVAlignment::TOP);
    pLogTextLabel->setPosition(Point(pLogTextLabel->getContentSize().width / 2 + pLogTextLabel->getFontSize() / 4, pGameLogLayer->getContentSize().height - pLogTextLabel->getContentSize().height / 2 - pLogTextLabel->getFontSize() / 4));
    pGameLogLayer->addChild(pLogTextLabel);
    this->addChild(pGameLogLayer, RogueScene::zGameLogIndex, RogueScene::kGameLogTag);
    
    // ------------------------
    // ミニマップ
    // ------------------------
    // 青で半透明
    auto miniMapLayer = LayerColor::create(Color4B(0, 0, 196, 128));
    // 1/8サイズ
    miniMapLayer->setContentSize(Size(m_baseMapSize.width * m_baseTileSize.width / 8,
                                      m_baseMapSize.height * m_baseTileSize.height / 8));
    // ステータスバーの下くらい
    miniMapLayer->setPosition(0, miniMapLayer->getPositionY() + winSize.height - miniMapLayer->getContentSize().height - statusLayer->getContentSize().height);
    this->addChild(miniMapLayer, RogueScene::zMiniMapIndex, RogueScene::kMiniMapTag);
    
    // ------------------------
    // イベントリ作成
    // ------------------------
    showItemList(1);
    hideItemList();
    
    // ---------------------
    // プレイヤー生成
    // ---------------------
    ActorSprite::ActorDto actorDto;
    actorDto.name = "ジニー";
    actorDto.faceImgId = 0;
    actorDto.imageResId = 1015;
    // 基本
    actorDto.attackRange = 1;
    actorDto.movePoint = 5;
    actorDto.playerId = 4;
    // 攻守
    actorDto.attackPoint = 5;
    actorDto.defencePoint = 1;
    // 経験値
    actorDto.exp = 0;
    actorDto.nextExp = 10;
    // HP
    actorDto.hitPoint = 15;
    actorDto.hitPointLimit = 15;
    actorDto.lv = 1;
    // 満腹度?精神力?
    actorDto.magicPoint = 100;
    actorDto.magicPointLimit = 100;

    ActorMapItem actorMapItem;
    actorMapItem.mapDataType = MapDataType::PLAYER;
    // 画面の中心(固定)
    actorMapItem.mapIndex = pointToIndex(Point(winSize.width/2, winSize.height/2));
    actorMapItem.seqNo = 1;
    actorMapItem.moveDist = actorDto.movePoint;
    actorMapItem.attackDist = actorDto.attackRange;
    actorMapItem.moveDone = false;
    actorMapItem.attackDone = false;
    
    auto actorSprite = ActorSprite::createWithActorDto(actorDto);
    actorSprite->setPosition(indexToPoint(actorMapItem.mapIndex)); // 画面の中心
    actorSprite->setActorMapItem(actorMapItem);
    actorSprite->runBottomAction();
    // プレイヤーは画面中心にくるのでmapLayerに追加しない
    this->addChild(actorSprite, RogueScene::zActorBaseIndex, (RogueScene::kActorBaseTag + actorMapItem.seqNo));
    
    // マップに追加
    m_mapManager.addActor(actorSprite->getActorMapItem());
    
    refreshStatus();
    
    // プレイヤーの位置表示用(同じく1/8サイズ)
    auto miniMapActorLayer = LayerColor::create(Color4B::YELLOW);
    // タイルの1/8サイズ
    miniMapActorLayer->setContentSize(m_baseTileSize / 8);
    // 現在位置からPositionを取得して1/8にする
    miniMapActorLayer->setPosition(indexToPointNotTileSize(actorSprite->getActorMapItem()->mapIndex) / 8);
    // 移動時に更新できるようにplayerIdをtag管理
    miniMapActorLayer->setTag(actorSprite->getTag());
    // add
    miniMapLayer->addChild(miniMapActorLayer);
    
    // ---------------------
    // 敵キャラ生成
    // ---------------------
    ActorSprite::ActorDto enemyDto;
    enemyDto.name = "スライム";
    enemyDto.faceImgId = 0;
    enemyDto.imageResId = 1011;
    // 基本
    enemyDto.attackRange = 1; // TODO: 未使用
    enemyDto.movePoint = 10; // 索敵範囲
    enemyDto.playerId = 901;
    // 攻守
    enemyDto.attackPoint = 2;
    enemyDto.defencePoint = 0;
    // 経験値
    enemyDto.exp = 0;
    enemyDto.nextExp = 10;
    // HP
    enemyDto.hitPoint = 10;
    enemyDto.hitPointLimit = 10;
    enemyDto.lv = 1;
    // 満腹度?精神力?
    enemyDto.magicPoint = 100;
    enemyDto.magicPointLimit = 100;
    
    MapIndex enemyMapIndex1 = {4, 4, MoveDirectionType::MOVE_DOWN};
    tileSetEnemyActorMapItem(enemyDto, enemyMapIndex1);
    
    ActorSprite::ActorDto enemyDto2 = enemyDto;
    MapIndex enemyMapIndex2 = {14,12, MoveDirectionType::MOVE_DOWN};
    tileSetEnemyActorMapItem(enemyDto2, enemyMapIndex2);
    
    ActorSprite::ActorDto enemyDto3 = enemyDto;
    MapIndex enemyMapIndex3 = {20,4, MoveDirectionType::MOVE_DOWN};
    tileSetEnemyActorMapItem(enemyDto3, enemyMapIndex3);
    
    //-------------------------
    // アイテム配置
    //-------------------------
    DropItemSprite::DropItemDto dropItemDto;
    dropItemDto.itemId = 1;
    dropItemDto.imageResId = 64; // imageId 10064
    dropItemDto.name = "ポーション";
    
    MapIndex mapIndex = {7, 5, MoveDirectionType::MOVE_NONE};
    tileSetDropMapItem(dropItemDto, mapIndex);

    DropItemSprite::DropItemDto dropItemDto2;
    dropItemDto2.itemId = 2;
    dropItemDto2.imageResId = 168; // imageId 10168
    dropItemDto2.name = "ぶどう";
    
    MapIndex mapIndex2 = {10, 9, MoveDirectionType::MOVE_NONE};
    tileSetDropMapItem(dropItemDto2, mapIndex2);
    
    // -------------------------------
    // メニュー
    // -------------------------------
    auto rect = Rect(0, 0, 300, 30);
    auto capRect = Rect(0, 0, 300, 30);
    auto pScale9Sprite1 = extension::Scale9Sprite::create("menu_button.png", rect, capRect);
    pScale9Sprite1->setContentSize(Size(40, 20));
    pScale9Sprite1->setOpacity(192);
    auto pScale9Sprite2 = extension::Scale9Sprite::create("menu_button.png", rect, capRect);
    pScale9Sprite2->setContentSize(Size(40, 20));
    pScale9Sprite2->setOpacity(128);
    
    auto pMenuItem1 = MenuItemSprite::create(pScale9Sprite1, pScale9Sprite2, [this](Object *pSender) {
        CCLOG("menuItem1が押された!");
            showItemList(1);
    });
    pMenuItem1->setColor(Color3B::GREEN);
    pMenuItem1->setPosition(Point(winSize.width - pMenuItem1->getContentSize().width / 2, pMenuItem1->getContentSize().height / 2));
    auto pMenu = Menu::create(pMenuItem1, NULL);
    pMenu->setPosition(Point::ZERO);
    this->addChild(pMenu, RogueScene::zMenuIndex, RogueScene::kMenuTag);

    // ---------------------------------
    // プレイヤーの先行
    changeGameStatus(GameStatus::PLAYER_TURN);
    
    return true;
}