void BuildingSprite::showUI()
{
    this->setTexture(IMG_BUILDING_Floor);
    _size = this->getContentSize();
    
    string nomal_IMG = GM()->getBuildingIMG(_type);
    string broken_IMG = GM()->getBuildingBrokenIMG(_type);
    _normal = Sprite::create(nomal_IMG);
    _broken = Sprite::create(broken_IMG);
    _tip = Sprite::create(IMG_BUILDING_ArrowTip);
    _broken->setOpacity(0);
    _tip->setOpacity(0);

    this->setPosition(GM()->getMapPos(_pos));
    _normal->setAnchorPoint(Vec2::ZERO);
    _normal->setPosition(Vec2(-15, -10));
    _tip->setAnchorPoint(Vec2::ZERO);
    _tip->setPosition(Vec2(-20, -20));

    this->addChild(_normal, 1);
    this->addChild(_broken, 1);
    this->addChild(_tip);
    
    // 遮罩
    this->setLocalZOrder(_pos.y + _pos.x);
    this->setOpacity(0);

}
Beispiel #2
0
void DBManager::createBuildingListInfo()
{
    ValueVector data;
    loadCsvData(CSV_BUILDINGLISTINFO, data);
    
    string timeStamp = GM()->getIntToStr(GM()->getTimeStamp());
    string sql = "create table BuildingListInfo(ID integer primary key autoincrement, BuildingID, PositionX, PositionY, BuildState, LastBuildTime, LastGoldHarvest, LastWoodHarvest)";
    executeUpdate(sql);
    
    for (int i = 1; i < data.size(); i++) {
        ValueMap& map = data.at(i).asValueMap();
        sql = "insert into BuildingListInfo values("
        + map["ID"].asString() + ", '"
        + map["BuildingID"].asString() + "', '"
        + map["PositionX"].asString() + "', '"
        + map["PositionY"].asString() + "', '"
        + map["BuildState"].asString() + "', '"
        + timeStamp + "', '"
        + timeStamp + "', '"
        + timeStamp + "')";
        
//        CCLOG("sql: %s", sql.c_str());
        executeUpdate(sql);
    }
}
Beispiel #3
0
void HomeHudLayer::setWoodCapacity(int capacity)
{
    _woodCapacity = capacity;
    DM()->updateWoodCapacity(_woodCapacity);
    
    auto ui = (Widget*)this->getChildByName("UI");
    auto woodCount = (Text*)Helper::seekWidgetByName(ui, "WoodCount");
    auto woodCapacity = (Text*)Helper::seekWidgetByName(ui, "WoodCapacity");
    auto woodBar = (LoadingBar*)Helper::seekWidgetByName(ui, "WoodBar");
    
    woodCount->setString(GM()->getIntToStr(_woodCount));
    woodCapacity->setString(GM()->getIntToStr(_woodCapacity));
    woodBar->setPercent(100.0 * _woodCount / _woodCapacity);
}
void WorldHudLayer::addWood(int add)
{
    auto ui = (Widget*)this->getChildByName("UI");
    auto woodCount = (Text*)Helper::seekWidgetByName(ui, "WoodCount");
    auto woodCapacity = (Text*)Helper::seekWidgetByName(ui, "WoodCapacity");
    auto woodBar = (LoadingBar*)Helper::seekWidgetByName(ui, "WoodBar");
    
    _woodCount = GM()->getMin(_woodCount + add, _woodCapacity);
    DM()->updateWood(_woodCount);
    
    woodCount->setString(GM()->getIntToStr(_woodCount));
    woodCapacity->setString(GM()->getIntToStr(_woodCapacity));
    woodBar->setPercent(100.0 * _woodCount / _woodCapacity);
}
void BattleHudLayer::showInfo()
{
    auto ui = (Widget*)this->getChildByName("UI");
    
    // 城池属性
    auto level = (Text*)Helper::seekWidgetByName(ui, "Level");
    auto name = (Text*)Helper::seekWidgetByName(ui, "Name");
    auto goldreward = (Text*)Helper::seekWidgetByName(ui, "GoldReward");
    auto woodreward = (Text*)Helper::seekWidgetByName(ui, "WoodReward");
    auto ringreward = (Text*)Helper::seekWidgetByName(ui, "RingReward");
    
    level->setString(GM()->getIntToStr(_level));
    name->setString(_name);
    goldreward->setString(GM()->getIntToStr(_goldReward));
    woodreward->setString(GM()->getIntToStr(_woodReward));
    ringreward->setString(GM()->getIntToStr(_ringReward));
    
    // 士兵数量
    auto fighterCount = (Text*)Helper::seekWidgetByName(ui, "FighterCount");
    auto bowmanCount = (Text*)Helper::seekWidgetByName(ui, "BowmanCount");
    auto gunnerCount = (Text*)Helper::seekWidgetByName(ui, "GunnerCount");
    auto meatCount = (Text*)Helper::seekWidgetByName(ui, "MeatCount");
    fighterCount->setString("x" + GM()->getIntToStr(_count[1]));
    bowmanCount->setString("x" + GM()->getIntToStr(_count[2]));
    gunnerCount->setString("x" + GM()->getIntToStr(_count[3]));
    meatCount->setString("x" + GM()->getIntToStr(_count[4]));
}
Beispiel #6
0
void HomeHudLayer::addGold(int add)
{
    _goldCount = GM()->getMin(_goldCount + add, _goldCapacity);
    DM()->updateGold(_goldCount);
    
    auto ui = (Widget*)this->getChildByName("UI");
    auto goldCount = (Text*)Helper::seekWidgetByName(ui, "GoldCount");
    auto goldCapacity = (Text*)Helper::seekWidgetByName(ui, "GoldCapacity");
    auto goldBar = (LoadingBar*)Helper::seekWidgetByName(ui, "GoldBar");
    
    goldCount->setString(GM()->getIntToStr(_goldCount));
    goldCapacity->setString(GM()->getIntToStr(_goldCapacity));
    goldBar->setPercent(100.0 * _goldCount / _goldCapacity);
}
void SoilderInfoDialog::update(float dt)
{

    int type = cocos2d::random(0, 1);
    int id = cocos2d::random(0, 7);

    // run
    if (type == 0) {
        arm->getAnimation()->play("run" + GM()->getIntToStr(id));
    }
    // atk
    else {
        arm->getAnimation()->play("atk" + GM()->getIntToStr(id));
    }
}
// 更新
void BuildingSprite::update(float dt)
{
    // 是否仍在升级中
    
    // 是否为金矿厂、木材厂
    if (_type != BUILDING_TYPE_MineFactory && _type != BUILDING_TYPE_WoodFactory) return;
    if (bubble != nullptr) return;
    
    int stamp = GM()->getTimeStamp();
    
    if (_type == BUILDING_TYPE_MineFactory) {
        if (_lastGoldHarvest == 0) return;
        if (stamp - _lastGoldHarvest > 60) {
            bubble = HarvestBubble::create(HARVEST_TYPE_GOLD);
            bubble->setPosition(Vec2(_size.width/2, _normal->getContentSize().height ));
            this->addChild(bubble, 100);
            bubble->_callback = CC_CALLBACK_0(BuildingSprite::harvest, this);
        }
    }
    else {
        if (_lastWoodHarvest == 0) return;
        if (stamp - _lastWoodHarvest > 60) {
            bubble = HarvestBubble::create(HARVEST_TYPE_WOOD);
            bubble->setPosition(Vec2(_size.width/2, _normal->getContentSize().height ));
            this->addChild(bubble, 100);
            bubble->_callback = CC_CALLBACK_0(BuildingSprite::harvest, this);
        }
    }
}
Beispiel #9
0
void my_fx(double *fx, double *x, double *u, double time) //evaluate of df/dx
{

	   
	 setmt0(fx, nx, nx);


	 // set the dfx/dv part which is an identity matrix
	 int i, k, l;
	 for(i=0; i<N+1; i++)
	 {
		 for(k=i*d; k<i*d+d; k++)
		 {
			 fx[map(k, k + (N+1)*d, nx)] = 1;
						
		 }
	 }

	 GS(fx, x, N, d, nx);

	 GM(fx, x, N, d, nx);
	 
	 GL(fx, x, N, d, nx);

	 Gl1(fx, x, N, d, nx);

	return;
}     
HRESULT DSVL_VideoSource::GetCurrentMediaFormat(LONG* frame_width,
                                                LONG *frame_height,
                                                double* frames_per_second,
                                                PIXELFORMAT* pixel_format)
{
	return((GM(p_graphManager))->GetCurrentMediaFormat(frame_width, frame_height, frames_per_second, pixel_format));
}
Beispiel #11
0
void Soilder::showUI()
{
    switch (_type) {
        case SOILDER_TYPE_FIGHTER: {
            arm = Armature::create(ANIM_NAME_FIGHTER);
        }
            break;
        case SOILDER_TYPE_BOWMAN: {
            arm = Armature::create(ANIM_NAME_BOWMAN);
        }
            break;
        case SOILDER_TYPE_GUNNER: {
            arm = Armature::create(ANIM_NAME_GUNNER);
        }
            break;
        case SOILDER_TYPE_MEAT: {
            arm = Armature::create(ANIM_NAME_MEATSHIELD);
        }
            break;
        default:
            break;
    }
    
    this->addChild(arm);
    
    this->setPosition(GM()->getMapPos(_pos));
    this->setLocalZOrder((int)_pos.x + (int)_pos.y);
    
    this->setScale(0.6);
}
// 收获资源
void BuildingSprite::harvest()
{
    int stamp = GM()->getTimeStamp();
    
    if (_type == BUILDING_TYPE_MineFactory) {
        int diff = stamp - _lastGoldHarvest;
        int gold = (diff * _goldProduct) / 3600;
        
        HomeMapLayer* parent = (HomeMapLayer*)this->getParent();
        HomeHudLayer* hud = (HomeHudLayer*)parent->_hudLayer;
        hud->addGold(gold);
        
        _lastGoldHarvest = stamp;
        DM()->updateLastGoldHarvest(_id, _lastGoldHarvest);
    }
    else {
        int diff = stamp - _lastWoodHarvest;
        int wood = (diff * _woodProduct) / 3600;
        
        HomeMapLayer* parent = (HomeMapLayer*)this->getParent();
        HomeHudLayer* hud = (HomeHudLayer*)parent->_hudLayer;
        hud->addWood(wood);
        
        _lastWoodHarvest = stamp;
        DM()->updateLastWoodHarvest(_id, _lastWoodHarvest);
    }

    bubble = nullptr;
}
HRESULT DSVL_VideoSource::CheckoutMemoryBuffer(MemoryBufferHandle* pHandle, 
                                               BYTE** Buffer,
                                               unsigned int *Width,
                                               unsigned int *Height,
                                               PIXELFORMAT* PixelFormat,
                                               REFERENCE_TIME* Timestamp)
{
	return((GM(p_graphManager))->CheckoutMemoryBuffer(pHandle,Buffer,Width,Height,PixelFormat,Timestamp));
}
void BuildingSprite::onTouchMoved(Touch* pTouch, Event* pEvent)
{
    Vec2 pos = this->getParent()->convertToNodeSpace(pTouch->getLocation());
    Vec2 delta = pos - this->getPosition();
    _deltaPos += GM()->getDistance(Vec2(0, 0), pTouch->getDelta());
    
    if (_isSelected == true) {
        moveBuilding(delta);
    }
}
Beispiel #15
0
void DBManager::createMiwuStateInfo()
{
    ValueVector data;
    loadCsvData(CSV_MIWUSTATEINFO, data);
    
    string timeStamp = GM()->getIntToStr(GM()->getTimeStamp());
    string sql = "create table MiwuStateInfo(MiwuID integer primary key autoincrement, Type)";
    executeUpdate(sql);
    
    for (int i = 1; i < data.size(); i++) {
        ValueMap& map = data.at(i).asValueMap();
        sql = "insert into MiwuStateInfo values("
        + map["MiwuID"].asString() + ", '"
        + map["Type"].asString() + "')";
        
//        CCLOG("sql: %s", sql.c_str());
        executeUpdate(sql);
    }
}
// 移动建筑
void BuildingSprite::moveBuilding(Vec2 delta)
{
    if (fabs(delta.x) >= TILED_WIDTH/2.0 || fabs(delta.y) >= TILED_HEIGHT/2.0) {
        int sgnX = 1, sgnY = 1;
        if (delta.x < 0) sgnX = -1;
        if (delta.y < 0) sgnY = -1;
        
        this->setPosition(this->getPosition() + Vec2(sgnX*TILED_WIDTH/2, sgnY*TILED_HEIGHT/2));
        
        Vec2 tiledPos = GM()->getTiledPos(this->getPosition());

        // 是否越界,或被其他设施占领
        if (GM()->isOutMap(this->getPosition()) || GM()->isCovered(tiledPos)) {
            this->setColor(Color3B::RED);
        }else {
            this->setColor(Color3B::GREEN);
        }
    }
}
Beispiel #17
0
void DBManager::createSoilderListInfo()
{
    ValueVector data;
    loadCsvData(CSV_SOILDER_LISTINFO, data);
    
    string timeStamp = GM()->getIntToStr(GM()->getTimeStamp());
    string sql = "create table SoilderListInfo(ID integer primary key autoincrement, SoilderID, Count)";
    executeUpdate(sql);
    
    for (int i = 1; i < data.size(); i++) {
        ValueMap& map = data.at(i).asValueMap();
        sql = "insert into SoilderListInfo values("
        + map["ID"].asString() + ", '"
        + map["SoilderID"].asString() + "', '"
        + map["Count"].asString() + "')";
        
//        CCLOG("sql: %s", sql.c_str());
        executeUpdate(sql);
    }
}
Beispiel #18
0
void Soilder::atk()
{
    if (_isbroken == true || _healthPoint <= 0) {
        return;
    }
    if (_type == SOILDER_TYPE_BOWMAN) {
        Vec2 src = GM()->getMapPos(_pos);
        Vec2 des = GM()->getMapPos(_target->_pos);
        auto bullet = BulletSprite::create(src, des, _damage, _target, IMG_BULLET_ARROW);
        this->getParent()->addChild(bullet, 99);
    }
    else if(_type == SOILDER_TYPE_GUNNER) {
        Vec2 src = GM()->getMapPos(_pos);
        Vec2 des = GM()->getMapPos(_target->_pos);
        auto bullet = BulletSprite::create(src, des, _damage, _target, IMG_BULLET_SHELL);
        this->getParent()->addChild(bullet, 99);
    }
    else {
        _target->hurt(_damage);
    }
}
bool BuildingSprite::onTouchBegan(Touch* pTouch, Event* pEvent)
{
    if (_canTouched == false) return false;
    if (GM()->_newBuild == true) return false;

    Vec2 pos = this->getParent()->convertToNodeSpace(pTouch->getLocation());
    _deltaPos = 0.0;
    
    if(GM()->isPointInDiamond(this->getPosition(), TILED_SIZE*2, pos)) {
        _isTouched = true;
        if (_isSelected == true) {
            listener->setSwallowTouches(true);
        }
    }
    else {
        _isTouched = false;
        _isSelected = false;
        listener->setSwallowTouches(false);
    }
    return true;
}
Beispiel #20
0
void HomeHudLayer::addPlayerExp(int add)
{
    DM()->updatePlayerExp(add);
    loadData();

    // player
    auto ui = (Widget*)this->getChildByName("UI");
    auto playerLevel = (Text*)Helper::seekWidgetByName(ui, "PlayerLevel");
    auto playerBar = (LoadingBar*)Helper::seekWidgetByName(ui, "PlayerBar");
    playerLevel->setString(GM()->getIntToStr(_level));
    playerBar->setPercent(100.0 * _exp / _expRequire);
}
Beispiel #21
0
 bool  
   updateGM(unsigned int index, double weight, const arma::vec & mu, const arma::mat & sigma) {
     if (arma::det(sigma) <= 0) {
       //mixture_.erase(mixture_.begin() + index);
       weights_(index) = 0.;
       normalizeWeights();
       return false;
     }
     weights_[index] = weight;
     mixture_[index] = GM(mu, sigma);
     return true;
   }
Beispiel #22
0
void DBManager::createHeroListInfo()
{
    ValueVector data;
    loadCsvData(CSV_HERO_LISTINFO, data);
    
    string timeStamp = GM()->getIntToStr(GM()->getTimeStamp());
    string sql = "create table HeroListInfo(ID integer primary key autoincrement, HeroID, Exp, State)";
    executeUpdate(sql);
    
    for (int i = 1; i < data.size(); i++) {
        ValueMap& map = data.at(i).asValueMap();
        sql = "insert into HeroListInfo values("
        + map["ID"].asString() + ", '"
        + map["HeroID"].asString() + "', '"
        + map["Exp"].asString() + "', '"
        + map["State"].asString() + "')";
        
//        CCLOG("sql: %s", sql.c_str());
        executeUpdate(sql);
    }
}
Beispiel #23
0
void Soilder::update(float dt)
{
    if (_isbroken == true) {
        this->unscheduleAllCallbacks();
        return;
    }
    
    if (_target == nullptr || _target->isDeath()) {
        this->stopAllActions();
        _target = _ai->getTargetEnemy(_pos);
    }
    if (_target == nullptr) {
        arm->getAnimation()->play("run0");
        arm->getAnimation()->stop();
        return;
    }
    
    // 攻击
    if (_ai->isWithinShootRange(_pos, _target->_pos, _shootRange)) {
        _dir = GM()->getDir(_pos, _target->_pos);
        
        arm->getAnimation()->play("atk" + GM()->getIntToStr(_dir));
        
        auto delay = DelayTime::create(0.7f);
        auto func = CallFunc::create(CC_CALLBACK_0(Soilder::atk, this));
        this->runAction(Sequence::create(delay, func, nullptr));
    }
    
    // 走路
    else {
        Vec2 pos = _ai->getNextPos(_pos, _target->_pos, false);
        _dir = GM()->getDir(pos);
        
        this->runAction(MoveBy::create(1.0f, GM()->getMapDelta(_dir)));
        arm->getAnimation()->play("run" + GM()->getIntToStr( _dir <= 7 ? _dir : 1));
        
        _pos += pos;
        this->setLocalZOrder((int)_pos.x + (int)_pos.y);
    }
}
Beispiel #24
0
void WorldHudLayer::showUI()
{
    auto ui = GUIReader::getInstance()->widgetFromJsonFile(UI_LAYER_WORLDHUD);
    this->addChild(ui, 0, "UI");
    
    // HomeButton
    auto btnEnter = (Button*)Helper::seekWidgetByName(ui, "HomeButton");
    btnEnter->addTouchEventListener(CC_CALLBACK_2(WorldHudLayer::btnCallback, this));

    // player
    auto playerName = (Text*)Helper::seekWidgetByName(ui, "PlayerName");
    auto playerLevel = (Text*)Helper::seekWidgetByName(ui, "PlayerLevel");
    auto playerBar = (LoadingBar*)Helper::seekWidgetByName(ui, "PlayerBar");
    playerName->setString(_name);
    playerLevel->setString(GM()->getIntToStr(_level));
    playerBar->setPercent(100.0 * _exp / _expRequire);
    // gold
    auto goldCount = (Text*)Helper::seekWidgetByName(ui, "GoldCount");
    auto goldCapacity = (Text*)Helper::seekWidgetByName(ui, "GoldCapacity");
    auto goldBar = (LoadingBar*)Helper::seekWidgetByName(ui, "GoldBar");
    goldCount->setString(GM()->getIntToStr(_goldCount));
    goldCapacity->setString(GM()->getIntToStr(_goldCapacity));
    goldBar->setPercent(100.0 * _goldCount / _goldCapacity);
    // wood
    auto woodCount = (Text*)Helper::seekWidgetByName(ui, "WoodCount");
    auto woodCapacity = (Text*)Helper::seekWidgetByName(ui, "WoodCapacity");
    auto woodBar = (LoadingBar*)Helper::seekWidgetByName(ui, "WoodBar");
    woodCount->setString(GM()->getIntToStr(_woodCount));
    woodCapacity->setString(GM()->getIntToStr(_woodCapacity));
    woodBar->setPercent(100.0 * _woodCount / _woodCapacity);
    // ring
    auto ringCount = (Text*)Helper::seekWidgetByName(ui, "RingCount");
    ringCount->setString(GM()->getIntToStr(_ringCount));
}
Beispiel #25
0
bool TownSprite::onTouchBegan(Touch* pTouch, Event* pEvent)
{
    Vec2 pos = this->getParent()->convertToNodeSpace(pTouch->getLocation());
    
    Vec2 center = this->getPosition();
    CCSize size = this->getContentSize();
    if(GM()->isPointInRect(center - Vec2(0, size.height/6.0), Size(size.width, size.height*2.0/3.0), pos)) {
        this->setScale(0.9f);
        _delta = 0.0;
        return true;
    }
    return false;
}
Beispiel #26
0
// 更新
void TownSprite::update(float dt)
{
    if (_type != TOWN_TYPE_LIBERATE) return;
    if (_lastHarvest == 0) return;
    if (bubble != nullptr) return;
    
    int stamp = GM()->getTimeStamp();
    if (stamp - _lastHarvest > 60) {
        bubble = HarvestBubble::create(HARVEST_TYPE_BOTH);
        bubble->setPosition(this->getPosition() + Vec2(0, this->getContentSize().height/2 + 20));
        this->getParent()->addChild(bubble, 2);
        bubble->_callback = CC_CALLBACK_0(TownSprite::harvest, this);
    }
}
Beispiel #27
0
void HomeHudLayer::btnCallback(Ref* sender, Widget::TouchEventType type)
{
    if (type == Widget::TouchEventType::ENDED) {
        Button* btn = (Button*)sender;
        string name = btn->getName();
        if (name == "WorldButton") {
            GM()->enterWorldScene();
        }
        else if(name == "BuildButton") {
            // CCLOG("BuildButton");
            auto buildDialog = NewBuildDialog::create();
            this->getParent()->addChild(buildDialog, 99);
        }
    }
}
void BuildingSprite::onTouchEnded(Touch* pTouch, Event* pEvent)
{
    // 标记为被选中
    if(_isTouched == true) {
        if (_deltaPos <= LIMIT_DELTA) {
            
            // 第一次点击
            if (_isSelected == false) {
                // 先去除占地
                GM()->setCoverd(_pos, -1);
            }
            
            _isSelected = true;
            this->setOpacity(255);
            this->setColor(Color3B::GREEN);
            this->setLocalZOrder(TILED_TOTAL_X + TILED_TOTAL_Y + 1);
            _tip->setOpacity(255);
            selectedAction();
        }
    }
    else {
        if (_isShowOpt == true) {
            _isSelected = false;
            this->setOpacity(0);
            this->setColor(Color3B::WHITE);
            this->setTiledPos();
            _tip->setOpacity(0);
            unselectedAction();
        }
    }
    
    // 显示/隐藏操作opt
    if (_isTouched == true) {
        if (_deltaPos <= LIMIT_DELTA) {
            auto maplayer = (HomeMapLayer*)this->getParent();
            auto optlayer = ((HomeScene*)maplayer->getParent())->_optLayer;
            optlayer->show(this);
            _isShowOpt = true;
        }
    }
    else if(_isShowOpt == true) {
        auto maplayer = (HomeMapLayer*)this->getParent();
        auto optlayer = ((HomeScene*)maplayer->getParent())->_optLayer;
        optlayer->hide(this);
        _isShowOpt = false;
    }
}
void BuildingSprite::loadData(int index)
{
    ValueMap data = DM()->_building.at(index).asValueMap();
    
    _id                 = data["ID"].asInt();
    _BuildingID         = data["BuildingID"].asInt();
    _pos                = Vec2(data["PositionX"].asInt(), data["PositionY"].asInt());
    _buildState         = data["BuildState"].asInt();
    _lastBuildTime      = data["LastBuildTime"].asInt();
    _lastGoldHarvest    = data["LastGoldHarvest"].asInt();
    _lastWoodHarvest    = data["LastWoodHarvest"].asInt();

    _type               = data["Type"].asInt();
    _level              = data["Level"].asInt();
    _name               = data["Name"].asString();
    _healthPoint        = data["HealthPoint"].asInt();
    _description        = data["Description"].asString();

    _goldRequire        = data["GoldRequire"].asInt();
    _woodRequire        = data["WoodRequire"].asInt();
    _timeRequire        = data["TimeRequire"].asInt();
    _baseLevelRequire   = data["BaseLevelRequire"].asInt();
    _playerLevelRequire = data["PlayerLevelRequire"].asInt();
    _expReward          = data["ExpReward"].asInt();

    // 生产属性
    _goldProduct        = data["GoldProduct"].asInt();
    _woodProduct        = data["WoodProduct"].asInt();
    // 资源属性
    _goldCapacity       = data["GoldCapacity"].asInt();
    _woodCapacity       = data["WoodCapacity"].asInt();
    // 攻击属性
    _isBroken           = false;
    _canAttack          = data["CanAttack"].asInt();
    _damage             = data["Damage"].asInt();
    _attackSpeed        = data["AttackSpeed"].asInt();
    _shootRange         = data["ShootRange"].asInt();
    _damageRange        = data["DamageRange"].asInt();
    

    // 覆盖地面
    GM()->setCoverd(_pos, 1);
    
//    CCLOG("%d: %d, %s (%d,%d)", _id, _BuildingID, _name.c_str(), _buildState, _lastBuildTime);
}
Beispiel #30
0
// 收获资源
void TownSprite::harvest()
{
//    CCLOG("harvest");

    int stamp = GM()->getTimeStamp();
    int diff = stamp - _lastHarvest;
    int gold = (diff * _goldProduct) / 3600;
    int wood = (diff * _woodProduct) / 3600;
    
    WorldMapLayer* parent = (WorldMapLayer*)this->getParent();
    WorldHudLayer* hud = (WorldHudLayer*)parent->_hudLayer;
    hud->addGold(gold);
    hud->addWood(wood);
    
    _lastHarvest = stamp;
    DM()->updateTownHarvest(_id, _lastHarvest);
    bubble = nullptr;
}