예제 #1
0
void World::spawnWave(const cocos2d::ValueVector &waveData) {
    for (unsigned int i = 0; i < waveData.size(); i++) {
        const auto &model = getModel((unsigned int) waveData.at(i).asInt());
        _gameplayLayer->addEnemyShip(model, i, _mapLayer->_path, _spawnManager->getCurrentWave());
    }

    _hudLayer->updateWaveIndicators(_spawnManager->getCurrentWave(), _spawnManager->getMaxWave());
}
예제 #2
0
파일: SQLite.cpp 프로젝트: hustg4/CocosLua
bool SQLite::createTable(const std::string &tableName, const cocos2d::ValueVector &columnVector)
{
    std::string sql = "CREATE TABLE IF NOT EXISTS ";
    sql.append(tableName);
    sql.append("(");
    
    int count = columnVector.size();
    for (int i = 0;i<count;i++) {
        std::string columnName = columnVector[i].asString();
        sql.append(columnName);
        sql.append(" TEXT");
        if (i != count-1) {
            sql.append(",");
        }
    }
    
    sql.append(")");
    
    return this->executeUpdate(sql);
}
예제 #3
0
void Json_Parser::write_a_array(cocos2d::ValueVector &temp,rapidjson::Value &val2,rapidjson::Document::AllocatorType&allocator){
     rapidjson::Value array2(rapidjson::kArrayType);
    for (int i=0; i<temp.size(); i++) {
        rapidjson::Value v;
        if(temp.at(i).getType()==Value::Type::DOUBLE){
            v.SetDouble(temp.at(i).asDouble());
            val2.PushBack(v,allocator);
        }
        else if(temp.at(i).getType()==Value::Type::STRING){
            v.SetString(temp.at(i).asString().c_str(),allocator);
            val2.PushBack(v,allocator);
        }
        else if(temp.at(i).getType()==Value::Type::BOOLEAN){
            v.SetBool(temp.at(i).asBool());
            val2.PushBack(v,allocator);
        }
        else if(temp.at(i).getType()==Value::Type::INTEGER){
            v.SetInt(temp.at(i).asInt());
           val2.PushBack(v,allocator);
        }
        else if(temp.at(i).getType()==Value::Type::NONE){
            v.SetNull();
           val2.PushBack(v,allocator);
        }
        else if(temp.at(i).getType()==Value::Type::MAP){
            ValueMap chmap=temp.at(i).asValueMap();
            v.SetObject();
                write_a_map(chmap,v,allocator);
             val2.PushBack(v,allocator);
        }
        else if(temp.at(i).getType()==Value::Type::VECTOR){
            
            ValueVector chvec=temp.at(i).asValueVector();
            v.SetArray();
                write_a_array(chvec, v, allocator);
            val2.PushBack(v, allocator);
        }

    }
    
}
예제 #4
0
파일: SQLite.cpp 프로젝트: hustg4/CocosLua
bool SQLite::insertIntoTable(const std::string &tableName, const cocos2d::ValueVector& valueArray)
{
    std::string sql = "INSERT INTO ";
    sql.append(tableName);
    sql.append(" VALUES(");
    
    int count = valueArray.size();
    for (int i = 0;i < count;i++) {
        std::string value = valueArray[i].asString();
        sql.append("'");
        sql.append(value);
        sql.append("'");
        if (i != count-1) {
            sql.append(",");
        }
        i++;
    }
    sql.append(")");
    
    return this->executeUpdate(sql);
}
예제 #5
0
파일: SQLite.cpp 프로젝트: hustg4/CocosLua
std::string SQLite::getExecuteSql(const std::string &tableName, const std::string &columnName, const cocos2d::ValueVector &columnValues)
{
    std::string sql = "SELECT * FROM ";
    sql.append(tableName);
    sql.append(" WHERE ");
    sql.append(columnName);
    sql.append(" IN (");
    
    int count = columnValues.size();
    for (int i = 0; i < count; i++) {
        std::string value = columnValues[i].asString();
        sql.append("'");
        sql.append(value);
        sql.append("'");
        if (i != count-1) {
            sql.append(",");
        }
    }
    sql.append(")");
    
    return sql;
}