void InstanceScript::LoadDoorData(const DoorData* data)
{
    while (data->entry)
    {
        if (data->bossId < bosses.size())
            doors.insert(std::make_pair(data->entry, DoorInfo(&bosses[data->bossId], data->type, BoundaryType(data->boundary))));

        ++data;
    }
    sLog->outDebug(LOG_FILTER_TSCR, "InstanceScript::LoadDoorData: " UI64FMTD " doors loaded.", uint64(doors.size()));
}
Beispiel #2
0
void InstanceData::LoadDoorData(const DoorData *data)
{
    while (data->entry)
    {
        if (data->bossId < bosses.size())
            doors.insert(std::make_pair(data->entry, DoorInfo(&bosses[data->bossId], data->type, BoundaryType(data->boundary))));

        ++data;
    }
    sLog.outDebug("InstanceData::LoadDoorData: %u doors loaded.", doors.size());
}
Beispiel #3
0
void InstanceScript::LoadDoorData(const DoorData* data)
{
    while (data->entry)
    {
        if (data->bossId < bosses.size())
            doors.insert(std::make_pair(data->entry, DoorInfo(&bosses[data->bossId], data->type, BoundaryType(data->boundary))));

        ++data;
    }
    TC_LOG_DEBUG("scripts", "InstanceScript::LoadDoorData: " UI64FMTD " doors loaded.", uint64(doors.size()));
}
Beispiel #4
0
void MapLayer::readData(){
    // get now stage info
    int stageKind = UserDefault::getInstance()->getIntegerForKey("stageKind");
    int stageIdentity = UserDefault::getInstance()->getIntegerForKey("stageIdentity");
    
    std::string path = FileUtils::getInstance()->getWritablePath() + StringUtils::format("projectWhipping/data/stage/mapData_%02d_%02d.bin", stageKind, stageIdentity);
    CCLOG("readpath : %s(MapLayer.cpp)", path.c_str());
    FILE *f = fopen(path.c_str(), "rb");
    
    // if file doesn't exit make default map file
    if(f == NULL){
        CCLOG("make file(MapLayer.cpp)");
        f = fopen(path.c_str(), "wb");
        fclose(f);
        
        width = 64;
        height = 32;
        anchorX = 352;
        anchorY = 160;
        doorCount = 2;
        
        DoorInfo di1 = DoorInfo(63, 23, 2, 9, 0);
        doorList.push_back(di1);
        DoorInfo di2 = DoorInfo(0, 26, 2, 1, 0);
        doorList.push_back(di2);
        
        UserDefault::getInstance()->setIntegerForKey("jejeStartX", 63);
        UserDefault::getInstance()->setIntegerForKey("jejeStartY", 23);
        
        mapData = new unsigned char*[height];
        for(int i=0; i<height; i++){
            mapData[i] = new unsigned char[width];
            memset(mapData[i], 1, width);
        }
        
        for(int i = height-1; i >= 0; i--)
        {
            for(int j=0; j<width; j++){
                Add(mapData[i][j], j, i, 0, true);
            }
        }
        
        WriteData();
        
        return;
    }
    
    // read map width, height
    fread(&width, sizeof(int), 1, f);
    fread(&height, sizeof(int), 1, f);
    fread(&anchorX, sizeof(int), 1, f);
    fread(&anchorY, sizeof(int), 1, f);
    
    // make mapData array
    mapData = new unsigned char*[height];
    for(int i=0; i<height; i++){
        mapData[i] = new unsigned char[width];
        memset(mapData[i], 0, width);
    }
    
    // read doorCound, doorInfo
    {
        fread(&doorCount, sizeof(int), 1, f);
        
        // get before stage info
        int fromKind = UserDefault::getInstance()->getIntegerForKey("fromStageKind");
        int fromIdentity = UserDefault::getInstance()->getIntegerForKey("fromStageIdentity");
        int doorNumber = UserDefault::getInstance()->getIntegerForKey("doorNumber");
        
        for(int i=0; i<doorCount; i++){
            DoorInfo info(0,0,0,0,0);
            fread(&info, sizeof(DoorInfo), 1, f);
            doorList.push_back(info);
            if(fromKind == info.toKind && fromIdentity == info.toIdentity && info.number == doorNumber){
                // set jeje's start position
                UserDefault::getInstance()->setIntegerForKey("jejeStartX", info.x);
                UserDefault::getInstance()->setIntegerForKey("jejeStartY", info.y);
            }
        }
    }
    
    // make madData first
    for(int i = height-1; i >= 0; i--)
    {
        fread(mapData[i], sizeof(unsigned char), width, f);
        for(int j=0; j<width; j++){
            if(mapData[i][j] > 2)
                mapData[i][j] = 0;
            Add(mapData[i][j], j, i, 0, true);
        }
    }
    
    // read obstacleCount, info
    {
        fread(&obstacleCount, sizeof(int), 1, f);
        
        for(int i=0; i<obstacleCount; i++){
            MapObjectInfo info;
            fread(&info, sizeof(MapObjectInfo), 1, f);
            Add(info.number, info.x, info.y, info.option, true);
        }
    }
    
    // read objectCount, info
    {
        fread(&objectCount, sizeof(int), 1, f);
        
        for(int i=0; i<objectCount; i++){
            MapObjectInfo info;
            fread(&info, sizeof(MapObjectInfo), 1, f);
            Add(info.number, info.x, info.y, info.option, true);
        }
    }

    fclose(f);
}