Ejemplo n.º 1
0
    bool CCWorld::init(cocos2d::__String *id, CCGate *gate, cocos2d::__Dictionary *innerWorldsMap, cocos2d::__Dictionary *scores, cocos2d::__Array *missions) {
        bool result = CCSoomlaEntity::init(id);
        if (result) {
            setGate(gate);
            if (innerWorldsMap) {
                setInnerWorldsMap(innerWorldsMap);
            }
            else {
                setInnerWorldsMap(__Dictionary::create());
            }

            if (scores) {
                setScores(scores);
            }
            else {
                setScores(__Dictionary::create());
            }

            if (missions) {
                setMissions(missions);
            }
            else {
                setMissions(__Array::create());
            }

            return true;
        }
        return result;
    }
Ejemplo n.º 2
0
 bool CCWorld::init(cocos2d::__String *id) {
     bool result = CCSoomlaEntity::init(id);
     setInnerWorldsMap(__Dictionary::create());
     setScores(__Dictionary::create());
     setMissions(__Array::create());
     if (result) {
         return true;
     }
     return result;
 }
Ejemplo n.º 3
0
    bool CCWorld::initWithDictionary(cocos2d::__Dictionary *dict) {
        bool result = CCSoomlaEntity::initWithDictionary(dict);
        if (result) {

            Ref *ref;

            ref = dict->objectForKey(CCLevelUpConsts::JSON_LU_GATE);
            if (ref) {
                __Dictionary *gateDict = dynamic_cast<__Dictionary *>(ref);
                CC_ASSERT(gateDict);
                setGate((CCGate *) CCDomainFactory::getInstance()->createWithDictionary(gateDict));
            }

            ref = dict->objectForKey(CCLevelUpConsts::JSON_LU_WORLDS);
            if (ref) {
                __Array *worldDictArray = dynamic_cast<__Array *>(ref);
                CC_ASSERT(worldDictArray);
                __Array *worldArray = CCDomainHelper::getInstance()->getDomainsFromDictArray(worldDictArray);
                __Dictionary *worldsMap = __Dictionary::create();
                CCWorld *world;
                CCARRAY_FOREACH(worldArray, ref) {
                        world = dynamic_cast<CCWorld *>(ref);
                        CC_ASSERT(world);
                        worldsMap->setObject(world, world->getId()->getCString());
                        world->setParentWorld(this);
                    }
                setInnerWorldsMap(worldsMap);
            }

            ref = dict->objectForKey(CCLevelUpConsts::JSON_LU_SCORES);
            if (ref) {
                __Array *scoreDictArray = dynamic_cast<__Array *>(ref);
                CC_ASSERT(scoreDictArray);
                __Array *scoreArray = CCDomainHelper::getInstance()->getDomainsFromDictArray(scoreDictArray);
                __Dictionary *scoresMap = __Dictionary::create();
                CCScore *score;
                CCARRAY_FOREACH(scoreArray, ref) {
                        score = dynamic_cast<CCScore *>(ref);
                        CC_ASSERT(score);
                        scoresMap->setObject(score, score->getId()->getCString());
                    }
                setScores(scoresMap);
            }