Exemple #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());
}
Exemple #2
0
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);
}
Exemple #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);
        }

    }
    
}
Exemple #4
0
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);
}
Exemple #5
0
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;
}