当前位置: 首页>>代码示例>>C++>>正文


C++ PlayerPtr类代码示例

本文整理汇总了C++中PlayerPtr的典型用法代码示例。如果您正苦于以下问题:C++ PlayerPtr类的具体用法?C++ PlayerPtr怎么用?C++ PlayerPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PlayerPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SchedulePtr

SchedulePtr ScheduleBroadcastCmd::GetSchedule() const
{
    if ( m_spContext == NULL )
    {
        return SchedulePtr();
    }

    // Get schedule day
    const CFoundation::Date& today = m_spContext->GetGame()->GetDate();
    ScheduleDay eScheduleDay = SCHEDULE_DAY_END;
    if ( m_Date == today )
    {
        eScheduleDay = SCHEDULE_DAY_TODAY;
    }
    else if ( m_Date == today + 1 )
    {
        eScheduleDay = SCHEDULE_DAY_TOMORROW;
    }

    PlayerPtr spPlayer = m_spContext->GetPlayer();
    if ( spPlayer == NULL )
    {
        return SchedulePtr();
    }
    
    // Get schedule
    SchedulingPtr spScheduling = spPlayer->GetScheduling();
    return spScheduling->GetSchedule( eScheduleDay );
}
开发者ID:coeing,项目名称:cframework,代码行数:29,代码来源:ScheduleBroadcastCmd.cpp

示例2: switch

bool GameService::ProcessMsg(InsideMessage* msg)
{
    if (!msg)
        return false;

    CallBackType cbType = _calltype[msg->_msgid];
    switch (cbType)
    {
    case cbInsideDelegate:
        _inside_delegate.Call(msg->_msgid, *msg);
        break;

    case cbSessionInsideDelegate:
    {
        PlayerSessionPtr session = _session_manager->GetSession(msg->_sessionid);
        std::pair<PlayerSession*, InsideMessage*> arg = std::make_pair(session.get(), msg);
        _session_inside_delegate.Call(msg->_msgid, arg);
    }
        break;

    case cbPlayerInsideDelegate:
    {
        PlayerPtr player = GetPlayer(msg->_sessionid);
        std::pair<Player*, InsideMessage*> arg = std::make_pair(player.get(), msg);
        _player_inside_delegate.Call(msg->_msgid, arg);
    }
        break;

    default:
        break;
    }
    return true;
}
开发者ID:wudaijun,项目名称:NGServer,代码行数:33,代码来源:GameService.cpp

示例3: Execute

void ScheduleNewsCmd::Execute() const
{
    if ( m_spContext == NULL )
    {
        return;
    }

    PlayerPtr spPlayer = m_spContext->GetPlayer();
    if ( spPlayer == NULL )
    {
        return;
    }

    // Get news component
    PlayerCompNewsPtr spCompNews = spPlayer->GetCompNews();

    if ( m_spNews != NULL )
    {
        // Pay the news
        Budget& budget = spPlayer->GetBudget();
        budget.Book( CMadTV::ACCOUNT_CASH, CMadTV::ACCOUNT_NEWS_COSTS, m_spNews->GetCurrentPrice(), m_spContext->GetGame()->GetDateTime(), "Bought news" );
    }

    // Schedule
    spCompNews->SetPlannedNews( m_u32Slot, m_spNews );
}
开发者ID:coeing,项目名称:cframework,代码行数:26,代码来源:ScheduleNewsCmd.cpp

示例4: comparePos

void App::comparePos(PlayerPtr player)
{
	if (player->getY() > getPos() + 2.5) {
		speed = 0.15;
	}
	else {
		speed = base_speed;
	}
}
开发者ID:RedMajkel,项目名称:TheTower,代码行数:9,代码来源:App.cpp

示例5: Attack

	int Player::Attack(PlayerPtr target, int baseDamage)
	{
		int attackDamage = baseDamage; //todo: let level have an effect on this
		int rd = attackDamage/2 + rand() % (attackDamage + 1 / 2);
		int causedDamage = rd - rand() % target->GetDP();
		target->OnDamage(causedDamage, std::dynamic_pointer_cast<GameObject>(Ptr()));
		return causedDamage;
	}
开发者ID:mkalte666,项目名称:Dragon2D_FlushPrototype,代码行数:8,代码来源:Player.cpp

示例6: CreatePlayer

GS2D_API PlayerPtr CreatePlayer(VideoPtr pVideo, const std::wstring& fileName)
{
	PlayerPtr player = PlayerPtr(new DShowPlayer);
	
	if (!player->LoadVideo(pVideo, fileName))
	{
		return PlayerPtr();
	}
	return player;
}
开发者ID:angeltown,项目名称:ethanon,代码行数:10,代码来源:DShowPlayer.cpp

示例7: printf

void Gamefield::onStart(ClientPtr client, PacketPtr packet) {
	auto p = std::dynamic_pointer_cast<StartPacket >(packet);
	String color = mOptions.player.color[rand()%mOptions.player.color.size()];
	printf("Player %s joind the game\n", p->Name.c_str());
	PlayerPtr ply = std::make_shared<Player>(shared_from_this(), client, color, p->Name);
	mPlayer[client->getId()] = ply;
	ply->addBall(createBall(ply));
	ply->updateClient();
	client->emit(std::make_shared<EmptyPacket<PID_Start> >());
}
开发者ID:iseiseje,项目名称:agar.io-clone,代码行数:10,代码来源:Gamefield.cpp

示例8: makeControll

void PlayerBehavior::update( ) {
	//何もしなかったら待機
	_player_state = PLAYER_STATE_WAIT;
	
	CONTROLL controll = makeControll( );

	walk( controll );
	attack( controll );
	AppPtr app = App::getTask( );

	if ( _parent->getStatus( ).hp <= 0 ) {
		_player_state = PLAYER_STATE_DEAD;
		SoundPtr sound = Sound::getTask( );
		sound->playSE( Sound::SE_GAME_OVER );
		ClientPtr client = Client::getTask( );
		SERVERDATA data;
		data.command = COMMAND_STATUS_POS;
		data.value[ 0 ] = _player_id;
		data.value[ 1 ] = 0;
		data.value[ 2 ] = 0;
		client->send( data );

		if ( _controll ) {
			app->setState( App::STATE_DEAD );
		}
	} else {
		PlayerPtr player = std::dynamic_pointer_cast< Player >( _parent );
		player->addSP( 1 );
	}
	_before_state = _player_state;
	PlayerPtr player = std::dynamic_pointer_cast< Player >( _parent );
	int sp = player->getSP( );
	//AdventurePtr adventure = app->getAdventure( );
	if ( ( !_is_tutorial_sence ) && ( sp == Player::FULL_SP_NUM ) && _controll ) {
		//adventure->set( Adventure::TYPE_COMMON_TUTORIAL_3 );
		_is_tutorial_sence = true;
	}
	for ( int i = PLAYER_ETUDE_RED; i <= PLAYER_ETUDE_BLUE; i++ ) {
		Vector pos = _parent->getPos( ) - app->getPlayer( i )->getPos( );
		if ( !_is_conntact_minotaur && 
			( _player_id < PLAYER_ETUDE_RED ) && 
			( pos.getLength( ) < CONNTACT_MINOTAUR_LENGTH ) &&
			_controll ) {
			//adventure->set( Adventure::TYPE_COMMON_CYCLOPS_CONTACT );
			//adventure->set( Adventure::TYPE_COMMON_AFTER_MINOTAUR_ENTRY );
			_is_conntact_minotaur = true;
		}
	}
	_keep_pos = _parent->getPos( );
}
开发者ID:tcagame,项目名称:Attraction2016,代码行数:50,代码来源:PlayerBehavior.cpp

示例9: Start

void Transport::Start(utfstring url){
#ifdef _DEBUG
	std::cerr << "Transport::Start called" << std::endl;
#endif
    // Check if this is already Prepared
    PlayerPtr player    = this->nextPlayer;
    this->nextPlayer.reset();
#ifdef _DEBUG
	std::cerr << "Transport: nextPlayer reset" << std::endl;
#endif

    // If the nextPlayer wasn't the same as the one started, lets create a new one
    if(!player || player->url!=url){
        // Or create a new player
    	Player::OutputPtr output;
#ifdef _DEBUG
	std::cerr << "Transport: new output created for player" << std::endl;
#endif
        player  = Player::Create(url, &output);
        player->SetVolume(this->volume);
#ifdef _DEBUG
	std::cerr << "Transport: new player created" << std::endl;
#endif
    }

    // Add to the players
    this->players.push_front(player);
    this->currentPlayer = player;
#ifdef _DEBUG
	std::cerr << "Transport: player added to player list" << std::endl;
#endif

    // Lets connect to the signals of the currentPlayer
    this->currentPlayer->PlaybackStarted.connect(this,&Transport::OnPlaybackStarted);
    this->currentPlayer->PlaybackAlmostEnded.connect(this,&Transport::OnPlaybackAlmostEnded);
    this->currentPlayer->PlaybackEnded.connect(this,&Transport::OnPlaybackEnded);
    this->currentPlayer->PlaybackError.connect(this, &Transport::OnPlaybackError);
#ifdef _DEBUG
	std::cerr << "Transport: player-Play() about to be called" << std::endl;
#endif
    // Start playing
    player->Play();
}
开发者ID:LeonJavaAndroid,项目名称:musikcube,代码行数:43,代码来源:Transport.cpp

示例10: initPlayer

void Scene::initPlayer( PlayerPtr player, const std::string& image_filename )
{
    int ID = player->ID_NUM;
    
    // Init Sprite and Info
    playerSprites[ID] = ci::gl::Texture( loadImage( loadAsset(image_filename) ) );
    spriteInfo[ID].sheetWidth = playerSprites[ID].getWidth();
    spriteInfo[ID].width = player->getWidth();
    playerPtrs[ID] = player;
}
开发者ID:jacinthn,项目名称:TennisDudes,代码行数:10,代码来源:Scene.cpp

示例11: Execute

void ClearRecentlySubscribedChannelsCmd::Execute() const
{
    if ( m_spContext == NULL )
    {
        return;
    }

    PlayerPtr spPlayer = m_spContext->GetPlayer();
    if ( spPlayer == NULL )
    {
        return;
    }

    // Get news component
    PlayerCompNewsPtr spCompNews = spPlayer->GetCompNews();

    // Clear recently subscribed channels
    spCompNews->RemoveRecentlySubscribedChannels();
}
开发者ID:coeing,项目名称:cframework,代码行数:19,代码来源:ClearRecentlySubscribedChannelsCmd.cpp

示例12: onPlayerAction

void GameEngine::onPlayerAction(GameActionPtr action, PlayerPtr player) {
	cout << "GameEngine::onPlayerAction(...)" << endl;
	if (logic.checkPlayerAction(player, action) == true) {
		std::cout << "Action ist gueltig.\n";
		doAction(player, action);
		std::cout << "Action ausgeführt.\n";
	} else {
		std::cout << "Action von Spieler #" << player->getPlayerIdStr()
				<< " ist ungueltig.\n";
	}
}
开发者ID:msiemens,项目名称:UH-INF-StrategicGame,代码行数:11,代码来源:GameEngine.cpp

示例13: SetAliveFlag

Bomb::Bomb(PlayerPtr owner, Position position, int explosion_range)
  : m_anim_frame_num(0),
    m_position(position),
    m_time_from_last_frame_switch(.0),
    m_aabb(position+Position(.1,.1), position+Position(.9,.9)),
    m_owner(owner),
    m_owner_id(owner->GetId()),
    m_explision_range(explosion_range),
    m_living_time(0) {
  SetAliveFlag(true);
}
开发者ID:mmilewski,项目名称:bynadlaster,代码行数:11,代码来源:Bomb.cpp

示例14: main

int
main(int argc, char** argv)
{
    Options opts;
    opts.addOpt("t", "timeout", Options::NeedArg, "5");
    opts.addOpt("b", "broadcast");
    try
    {
        opts.parse(argc, (const char**)argv);
    }
    catch(const IceUtilInternal::BadOptException& e)
    {
        cerr << argv[0] << ": " << e.reason << endl;
        return EXIT_FAILURE;
    }

    Game game;
    game.hits = 0;
    game.state = StateStart;
    game.broadcast = opts.isSet("b");
    game.noise = false;

    PlayerPtr playerA = new Player(&game, StatePlayerA);
    playerA->start();
    PlayerPtr playerB = new Player(&game, StatePlayerB);
    playerB->start();

    cout << "running spurious wake test (" << ((game.broadcast) ? "broadcast" : "signal") << ")... " << flush;

    ThreadControl::sleep(Time::seconds(atoi(opts.optArg("t").c_str())));

    if(game.broadcast)
    {
        {
            Mutex::Lock sync(game.mutex);
            game.noise = true;
        }
        for(int i =0 ; i < 100000; ++i)
        {
            game.cond.broadcast();
        }
        {
            Mutex::Lock sync(game.mutex);
            game.noise = false;
        }
    }

    {
        Mutex::Lock sync(game.mutex);
        game.state = StateGameOver;
        game.cond.broadcast();
    }

    playerA->getThreadControl().join();
    playerB->getThreadControl().join();

    cout << game.hits << " ok" << endl;

    return 0;
}
开发者ID:Crysty-Yui,项目名称:ice,代码行数:60,代码来源:Match.cpp

示例15: Verify

Unsigned32 ScheduleNewsCmd::Verify() const
{
    if ( m_spContext == NULL )
    {
        return ERROR_NONE;
    }

    PlayerPtr spPlayer = m_spContext->GetPlayer();
    if ( spPlayer == NULL )
    {
        return ERROR_NONE;
    }

    // Get news component
    PlayerCompNewsPtr spCompNews = spPlayer->GetCompNews();

    // Check if slot is valid
    if ( m_u32Slot >= PlayerCompNews::NUM_PLANNED_NEWS )
    {
        return ERROR_INVALID_SLOT;
    }

    // Check if player has news
    if ( m_spNews != NULL &&
        !spCompNews->HasNews( m_spNews ) )
    {
        return ERROR_NEWS_NOT_AVAILABLE;
    }

    // Check if enough money available
    Budget& budget = spPlayer->GetBudget();
    if ( m_spNews != NULL &&
         budget.GetCash() < m_spNews->GetCurrentPrice() )
    {
        return ERROR_INSUFFICIENT_MONEY;
    }

    return ERROR_NONE;
}
开发者ID:coeing,项目名称:cframework,代码行数:39,代码来源:ScheduleNewsCmd.cpp


注:本文中的PlayerPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。