Ejemplo n.º 1
0
bool BaseBlock::init(BlockType type, cocos2d::Vec2 position)
{
    cocos2d::Size collisionSize;
    cocos2d::Vec2 speed;
    float score;
    float stamina;
    float time;
    std::string filename;
    
    bool result;

    cocos2d::Size visibleSize = Director::getInstance()->getVisibleSize();
    cocos2d::Vec2 origin = Director::getInstance()->getVisibleOrigin();
    
    std::string blockid = CommonUtil::itos((int)type + BLOCKIDBASE);
    
    //碰撞盒信息
    std::string collision = CommonUtil::getPropById(blockid, "collision");
    CCArray * colli = CommonUtil::split(collision.c_str(), ",");
    collisionSize.width = (dynamic_cast<CCString*>(colli->getObjectAtIndex(0)))->floatValue();
    collisionSize.height = (dynamic_cast<CCString*>(colli->getObjectAtIndex(1)))->floatValue();
    //速度信息
    std::string speedstr = CommonUtil::getPropById(blockid, "speed");
    speedstr.erase(0,1);
    speedstr.erase(speedstr.end()-1, speedstr.end());
    CCArray * speedli = CommonUtil::split(speedstr.c_str(), ",");
    speed.x = (dynamic_cast<CCString*>(speedli->getObjectAtIndex(0)))->floatValue();
    speed.y = (dynamic_cast<CCString*>(speedli->getObjectAtIndex(1)))->floatValue();
    //躲过得分数
    score = atof(CommonUtil::getPropById(blockid, "score").c_str());
    //碰撞消耗的体力值
    stamina = atof(CommonUtil::getPropById(blockid, "stamina").c_str());
    //碰撞效果影响时间
    time = atof(CommonUtil::getPropById(blockid, "time").c_str());
    //图片文件名
    filename = CommonUtil::getPropById(blockid, "filename");
    //effectlist
    std::string efflist = CommonUtil::getPropById(blockid, "effectlist");
    CCArray * efflistarr = CommonUtil::split(efflist.c_str(), ",");
    
    Ref * obj;
   
    CCARRAY_FOREACH(efflistarr, obj)
    {
        int temp = dynamic_cast<CCString*>(obj)->intValue();
        mBlockEffectList.push_back(temp);
    }
Ejemplo n.º 2
0
bool Item::init(ItemType type, cocos2d::Vec2 position)
{
    cocos2d::Size magnetSize;
    cocos2d::Vec2 speed;
  
    float value;
    float time;
    std::string filename;
    
    bool result;
    
    cocos2d::Size visibleSize = Director::getInstance()->getVisibleSize();
    cocos2d::Vec2 origin = Director::getInstance()->getVisibleOrigin();
    
    std::string itemid = CommonUtil::itos((int)type + ITEMIDBASE);
    
    // magnet
    std::string magstr = CommonUtil::getPropById(itemid, "magnetsize");
    CCArray * magli = CommonUtil::split(magstr.c_str(), ",");
    magnetSize.width = (dynamic_cast<CCString*>(magli->getObjectAtIndex(0)))->floatValue();
    magnetSize.height = (dynamic_cast<CCString*>(magli->getObjectAtIndex(1)))->floatValue();
    //速度信息
    std::string speedstr = CommonUtil::getPropById(itemid, "speed");
    speedstr.erase(0,1);
    speedstr.erase(speedstr.end()-1, speedstr.end());
    CCArray * speedli = CommonUtil::split(speedstr.c_str(), ",");
    speed.x = (dynamic_cast<CCString*>(speedli->getObjectAtIndex(0)))->floatValue();
    speed.y = (dynamic_cast<CCString*>(speedli->getObjectAtIndex(1)))->floatValue();
   
    //
    value = atof(CommonUtil::getPropById(itemid, "value").c_str());
    //碰撞效果影响时间
    time = atof(CommonUtil::getPropById(itemid, "time").c_str());
    //图片文件名
    filename = CommonUtil::getPropById(itemid, "filename");
    //effectlist
    std::string efflist = CommonUtil::getPropById(itemid, "effectlist");
    CCArray * efflistarr = CommonUtil::split(efflist.c_str(), ",");
    
    Ref * obj;
    
    CCARRAY_FOREACH(efflistarr, obj)
    {
        int temp = dynamic_cast<CCString*>(obj)->intValue();
        mItemEffectList.push_back(temp);
    }
Ejemplo n.º 3
0
void CAttackConfig::LoadText()
{
	std::string  data = cocos2d::FileUtils::getInstance()->getStringFromFile(StressText);
	String* ns = CCString::createWithFormat("%s", data.c_str());
	CCArray* array = CCGlobleConfig::split(ns->getCString(), "\n");
	for (int i = 1; i < array->count(); i++)
	{
		String * str = static_cast<String*>(array->getObjectAtIndex(i));
		CCArray * strarray = CCGlobleConfig::split(str->getCString(), "\t");
		CAttackData *data = new CAttackData();
		int index = 0;
		String * str0 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->ID = str0->intValue();
		str0->release();
		String * str1 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->Name = str1->getCString();
		str1->release();
		String * str2 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->TargetRank = str2->intValue();
		str2->release();
		String * str3 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->TargetType = str3->intValue();
		str3->release();
		String * str7 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->AttackPoint = str7->intValue();
		str7->release();

		String * str4 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->BulletType = str4->intValue();
		str4->release();
		String * str5 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		CCArray* carr = CCGlobleConfig::split(str5->getCString(), ",");
		for (int n = 0; n < carr->count(); n++)
		{
			data->BulletValue[n] = static_cast<String*>(carr->getObjectAtIndex(n))->floatValue();
		}
		str5->release();

		String * str9 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->EffectId = str9->intValue();
		str9->release();
		String* str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->EffectValue = str10->intValue();
		str10->release();

		str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->ResourceName1 = str10->getCString();
		str10->release();
		str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->ResourceFrameCount1 = str10->intValue();
		str10->release();
		str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->ResourceName2 = str10->getCString();
		str10->release();
		str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->ResourceFrameCount2 = str10->intValue();
		str10->release();
		str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->ResourceName3 = str10->getCString();
		str10->release();
		str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->ResourceFrameCount3 = str10->intValue();
		str10->release();

		str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->AttackVoice = str10->getCString();
		str10->release();
		str10 = static_cast<String*>(strarray->getObjectAtIndex(index++));
		data->HitVoice = str10->getCString();
		str10->release();
		data->updateResouce();
		DataList_.pushBack(data);

	}

}