Ejemplo n.º 1
0
void CSharpTollgate::heroCall(CCNode* pNode)
{
	CTableViewCell *node = (CTableViewCell*)pNode;
	CButton *btn = (CButton*)node->getChildByTag(1);
	//人物会动
	CCScaleTo *tobig = CCScaleTo::create(0.55f,1.0*btn->getScaleX(),1.0*btn->getScaleY());
	CCScaleTo *toSmall = CCScaleTo::create(0.55f,0.96*btn->getScaleX(), 0.96*btn->getScaleY());
	btn->runAction(CCRepeatForever::create(CCSequence::create(toSmall,tobig,nullptr)));
}
Ejemplo n.º 2
0
void CMainCityUI::checkShowActivity( CCObject* pObj )
{
	if(DataCenter::sharedData()->getUser()->getUserData()->getFirstLogin())
	{
		CButton *btn = (CButton*)m_ui->getChildByTag(Activity_Btn);
		btn->runAction(CCCallFuncN::create(this, callfuncN_selector(CMainCityUI::onTimeWaitCityAction)));
		DataCenter::sharedData()->getUser()->getUserData()->setFirstLogin(false);
	}
}
Ejemplo n.º 3
0
void LoginLayerUC::initLogin()
{
	CCLOG("LoginLayerUC::initLogin");

	if(m_ui!=nullptr)
	{
		return;
	}

	//播放背景音乐
	PlayBackgroundMusic(BGM_Login,true);

	m_ui = LoadComponent("EnterGameUC.xaml");
	m_ui->setTag(1);
	m_ui->setPosition(VCENTER);
	m_LayoutRoot->addChild(m_ui, 2);

	//自己的登陆框隐藏
	m_pLoginLay = (CLayout *)m_ui->getChildByTag(10);
	m_pLoginLay->setVisible(false);

	//选择好的服务器列表
	m_pCurrentServerUI = (CLayout *)m_ui->findWidgetById("current_server");
	m_pCurrentServerUI->setVisible(true);


	//默认服务器
	updateSelectServer();

	//服务器选区
	CLayout* pLayout = (CLayout*)m_ui->findWidgetById("serverCell");
	pLayout->retain();
	m_ui->removeChild(pLayout);
	m_pCell = pLayout;

	//获取空的滑动列表Scroll
	m_pTableView = (CTableView*)m_ui->findWidgetById("serverScroll");
	m_pTableView->setDirection(eScrollViewDirectionVertical);
	m_pTableView->setSizeOfCell(m_pCell->getContentSize());
	m_pTableView->setCountOfCell(m_serverInfo.server_list().size());
	m_pTableView->setBounceable(true);
	m_pTableView->setDataSourceAdapter(this, ccw_datasource_adapter_selector(LoginLayerUC::tableviewDataSource));
	m_pTableView->reloadData();


	//按钮打开服务器列表
	CImageView* pBtnServer = (CImageView*)m_ui->findWidgetById("serverBtn");


	//快速登录按钮
	CButton * pQuickLogin = (CButton *)m_ui->getChildByTag(1);
	pQuickLogin->setOnClickListener(this,ccw_click_selector(LoginLayerUC::onQuickLogin));
	CCActionInterval *scaleSmall = CCScaleTo::create(0.9f,0.98f);
	CCFadeTo *out = CCFadeTo::create(0.9f,60);
	CCSpawn *spawn = CCSpawn::createWithTwoActions(scaleSmall,out);
	CCActionInterval *scaleBig = CCScaleTo::create(1.2f,1.0f);
	CCFadeTo *in = CCFadeTo::create(1.2f,255);
	CCSpawn *spawn1 = CCSpawn::createWithTwoActions(scaleBig,in);
	CCSequence *seque = CCSequence::createWithTwoActions(spawn,spawn1);
	CCRepeatForever *action = CCRepeatForever::create(seque);
	pQuickLogin->runAction(action);
	pQuickLogin->setVisible(true);

	//清除用户信息
	DataCenter::sharedData()->getUser()->clear();

	//版本做相对位置处理
	CLabel* pLabel = (CLabel *)m_ui->findWidgetById("version");
	pLabel->setAnchorPoint(ccp(1.0f, 0.0f));
	pLabel->setPosition(ccp(VRIGHT-20, VBOTTOM+20));
	CC_SAFE_RETAIN(pLabel);
	pLabel->removeFromParentAndCleanup(true);
	this->addChild(pLabel);
	CC_SAFE_RELEASE(pLabel);
	pLabel->setString(CCString::createWithFormat("Version:%s", m_serverInfo.game_version().c_str())->getCString());


	//隐藏服务器列表
	showServerList();
	hideServerList();


	//TODO
	//初始化UC_SDK?-放在最前面
	//还是点击登录再初始化?
	//点击登录再初始化吧
	//初始化完直接请求登录


	//先连接连接服务器
	const Server& gameServer = m_serverInfo.server_list().Get(m_iSelectServerIndex);

	//检查服务器是否可用
	if(!checkServerStatus(gameServer))	
	{
		return;
	}

	LinkedGameServer(gameServer);
}
Ejemplo n.º 4
0
void CMainCityUI::onEnter()
{
	BaseLayer::onEnter();

	UserData *user = DataCenter::sharedData()->getUser()->getUserData();
	
	//角色信息相对位置处理
	CLayout* headPart = (CLayout*)m_ui->findWidgetById("head_part");
	headPart->setPosition(m_ui->convertToNodeSpace(ccp(VLEFT+headPart->getContentSize().width/2, VTOP-headPart->getContentSize().height/2)));

	//显示角色名,等级,体力,金币
	CLabel *nameLabel = (CLabel*)headPart->getChildByTag(10);
	nameLabel->setString(user->getRoleName().c_str());
	nameLabel->setColor(RGB_ROLE_COLOR);	
	
	CLabel *level = (CLabel*)(headPart->findWidgetById("level"));
	level->setString(CCString::createWithFormat("Lv%d",user->getLevel())->getCString());
	
	CProgressBar *progressBar = (CProgressBar*)(headPart->getChildByTag(11));
	progressBar->setMaxValue(user->getNextExp());
	progressBar->startProgress(user->getExp(),0.3f);

	CLabelAtlas *vip_level = (CLabelAtlas*)(headPart->findWidgetById("level_vip"));
	vip_level->setString(ToString(user->getVip()));
	if (user->getVip()==0)
	{
		vip_level->setVisible(false);
		CLabelAtlas *vip_font = (CLabelAtlas*)(headPart->findWidgetById("vip_font"));
		vip_font->setVisible(false);
	}

	CImageView *headbg = (CImageView *)(headPart->findWidgetById("headbg"));
	headbg->setTouchEnabled(true);
	headbg->setOnClickListener(this, ccw_click_selector(CMainCityUI::onHeadImgBtn));

	CButton *button = nullptr;
	int i = 1;
	for (; i<=9; ++i)
	{
		CCNode *lay = dynamic_cast<CCNode*>( m_ui->getChildByTag(i));
		button = dynamic_cast<CButton*>(lay->getChildByTag(i));
// 			button->setEnabled(false);
		button->setOnClickListener(this, ccw_click_selector(CMainCityUI::onClickBtn));
		button->setSelectedTexture(((CCSprite*)(button->getNormalImage()))->getTexture());
		button->getSelectedImage()->setScale(1.1f);
		m_btnPos[i] = button->getPosition();
	}

	CCSprite* head = (CCSprite*)headPart->getChildByTag(15);

	if (user->getThumb()>0)
	{
		CCTexture2D *texture = CCTextureCache::sharedTextureCache()
		->addImage(CCString::createWithFormat("headIcon/%d.png", user->getThumb())->getCString());
		if (texture)
		{
			head->setTexture(texture);
		}
	}
	else
	{
		string fbName = user->getFbId()+".jpg";
		string fullName = CCFileUtils::sharedFileUtils()->fullPathForFilename(fbName.c_str());
		bool isFileExist = CCFileUtils::sharedFileUtils()->isFileExist(fullName);
		if(isFileExist)
		{
			CCSprite *headBg = (CCSprite *)(headPart->findWidgetById("headbg"));
			CCSprite *sp = CCSprite::create(fbName.c_str());
			CCSprite* spr = MakeFaceBookHeadToCircle(sp);
			spr->setPosition(headBg->getPosition());
			headPart->removeChild(head);
		    spr->setTag(15);
			headPart->addChild(spr);
		}
		else
		{
			HttpLoadImage::getInstance()->bindUiTarget(this);
			CCString *imgUrl = CCString::createWithFormat(FACEBOOKIMG_106,user->getFbId().c_str());
			HttpLoadImage::getInstance()->requestUrlImage(imgUrl->getCString(),user->getFbId().c_str());
		}
	}

	CImageView* vip = (CImageView*)headPart->findWidgetById("vip");
	vip->setTouchEnabled(true);
	vip->setOnClickListener(this,ccw_click_selector(CMainCityUI::onVip));

	//添加签到,充值等其他入口
	CAccessLayer* pAccess = CAccessLayer::create();
	this->addChild(pAccess, 99);

	CSceneManager::sharedSceneManager()->addMsgObserver(UPDATE_HERO,this,GameMsghandler_selector(CMainCityUI::updateRoleProperty));
	CSceneManager::sharedSceneManager()->addMsgObserver(TASK_NOTICE,this,GameMsghandler_selector(CMainCityUI::updateTaskNotice));
	CSceneManager::sharedSceneManager()->addMsgObserver(MAIL_NOTICE,this,GameMsghandler_selector(CMainCityUI::updateMailNotice));
	CSceneManager::sharedSceneManager()->addMsgObserver(UPDATE_FUNCTIONOPEN,this,GameMsghandler_selector(CMainCityUI::updateFuctionOpen));
	CSceneManager::sharedSceneManager()->addMsgObserver(UPDATE_GAMETIP,this,GameMsghandler_selector(CMainCityUI::updateGameTip));
	CSceneManager::sharedSceneManager()->addMsgObserver(SHOW_HEAD,this,GameMsghandler_selector(CMainCityUI::showHead));

	CCSprite *red = (CCSprite*)(m_ui->findWidgetById("redPoint"));

	CCSprite *mailPoint = (CCSprite*)(m_ui->findWidgetById("mailPoint"));

	if (user->getRoleAction()<user->getActionLimit())
	{
		this->schedule(schedule_selector(CMainCityUI::updateActionTime),user->getInterval()*60);
	}
    GetTcpNet->registerMsgHandler(FriendReqNumMsg,this,CMsgHandler_selector(CMainCityUI::processNetMsg));
	GetTcpNet->registerMsgHandler(CBExchangeMsg,this,CMsgHandler_selector(CMainCityUI::exchangeMsg));

	//正在引导,不自动弹窗
	if(user->getNewStep()==2||user->getNewStep()==17/*CGuideManager::getInstance()->getIsRunGuide()*/)
	{
		DataCenter::sharedData()->setCityActionType(CA_None);
	}
	else if(user->getNewStep()<=0 || user->getNewStep()>=100)
	{
		//自动弹签到
		runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.7f), CCCallFunc::create(this, callfunc_selector(CMainCityUI::autoShowSign))));
	}

	switch (DataCenter::sharedData()->getCityActionType())
	{
	case CA_Levelup:
		{
			CButton *btn = (CButton*)m_ui->getChildByTag(HeroInfo_Btn);
			btn->runAction(CCSequence::create(CCDelayTime::create(0.6f),
				CCCallFuncN::create(this, callfuncN_selector(CMainCityUI::onTimeWaitCityAction)),
				NULL));
			DataCenter::sharedData()->setCityActionType(CA_None);
		}
		break;
	case CA_GoToChapater:
		{
			CButton *btn = (CButton*)m_ui->getChildByTag(Battle_Btn);
			btn->runAction(CCSequence::create(CCDelayTime::create(0.2f),
				CCCallFuncN::create(this, callfuncN_selector(CMainCityUI::onTimeWaitCityAction)),
				NULL));
			m_bShowChapterFlag = true;
			DataCenter::sharedData()->setCityActionType(CA_None);
		}
		break;
	case CA_GoToStage:
		{
			this->runAction(CCSequence::create(CCDelayTime::create(0.8f),
				CCCallFunc::create(this, callfunc_selector(CMainCityUI::runTollgatepreviewCallBack)),
				NULL));
			DataCenter::sharedData()->setCityActionType(CA_None);
		}break;
	default:
		break;
	}

	//绑定场景隐藏和显示的消息
	NOTIFICATION->addObserver(this, callfuncO_selector(CMainCityUI::show), SHOW_MAIN_SCENE, nullptr);
	NOTIFICATION->addObserver(this, callfuncO_selector(CMainCityUI::hide), HIDE_MAIN_SCENE, nullptr);
	NOTIFICATION->addObserver(this, callfuncO_selector(CMainCityUI::checkShowActivity), "CheckShowActivity", nullptr);


	CCNode *lay = dynamic_cast<CCNode*>( m_ui->getChildByTag(6));
	button = dynamic_cast<CButton*>(lay->getChildByTag(6));
	CCAnimation *batAnim = AnimationManager::sharedAction()->getAnimation("9015");
	batAnim->setDelayPerUnit(0.1f);
	CCSprite *batLight = createAnimationSprite("skill/9015.png",button->getPosition(),batAnim,true);
	batLight->setScale(1.4f);
	m_ui->addChild(batLight);

	showNoticeTip(CTaskControl::getInstance()->getGameTips());
// 	CCSprite *spr = CCSprite::create("headImg/506.png");
// 	spr->setScale(1.2f);
// 	CCSprite *sp = maskedSprite(spr);
// 	CCSprite *headBg = (CCSprite *)(headPart->findWidgetById("headbg"));
// 	sp->setPosition(headBg->getPosition());
// 	headPart->addChild(sp);

	//在线礼包
	int iNexTime = user->getOnlinePrizeTime();
	if (iNexTime!=-1)
	{
		if (m_pTimeGift==nullptr)
		{
			m_pTimeGift = CTimeGift::create();
			m_pTimeGift->setTouchPriority(-3);
			this->addChild(m_pTimeGift, 2);
		}
		m_pTimeGift->setTime(iNexTime);
	}

}