VOID CGamePro_ChangeScene::Tick(VOID)
{
	CGameProcedure::Tick();
	switch(GetStatus())
	{

	case CHANGESCENE_DISCONNECT:
		{

			// 连接到 game server(socket) 
			ConnectToGameServer();
			break;
		}
	case CHANGESCENE_CONNECT_SUCCESS:
		{
			//SetStatus(ENTERSCENE_REQUESTING);

			// 发送CGConnect 消息
			SendCGConnectMsg();
			break;
		}
	case CHANGESCENE_SENDING_CGCONNECT:
		{
			break;
		}
	case CHANGESCENE_RECEIVE_CGCONNECT_SUCCESS:
		{
			ChangeToEnterGameProdure();
			break;
		}
	case CHANGESCENE_RECEIVE_CGCONNECT_FAIL:
		{
			break;
		}
	default:
		{
			break;
		}
	}
	
}
Пример #2
0
/***********************************************************
called to check for game events and handle them
***********************************************************/
void LbaNetEngine::HandleGameEvents()
{
    std::vector<GameEvent *> events;
    InternalWorkpile::getInstance()->GetPendingEvents(events);
    std::vector<GameEvent *>::iterator it = events.begin();
    std::vector<GameEvent *>::iterator end = events.end();
    for(; it != end; ++it)
    {
        switch((*it)->GetType())
        {
        case 1: // login event
            if(m_currentstate == ELogin)
            {
                //SaveCharToFile();
                LoginEvent * ev = static_cast<LoginEvent *> (*it);
                TryLogin(ev->_Name, ev->_Password);
                m_gui_handler.SetPlayerName(ev->_Name);
            }
            break;

        case 2: // gui exit event
            ExitGui();
            break;

        case 3: // change world event
        {
            ChangeWorldEvent * evcw = static_cast<ChangeWorldEvent *> (*it);
            ChangeWorld(evcw->_NewWorld);
        }
        break;

        case 4: // display gui event
        {
            DisplayGUIEvent * evdg = static_cast<DisplayGUIEvent *> (*it);
            DisplayGUI(evdg->_GuiNumber);
        }
        break;

        case 5: // GameServerAddressEvent
        {
            GameServerAddressEvent * evdg = static_cast<GameServerAddressEvent *> (*it);
            ConnectToGameServer(evdg->_ServerName, evdg->_ServerAddress);
        }
        break;

        case 6: // GameServerUnreachableEvent
        {
            GameErrorMessageEvent * evdg = static_cast<GameErrorMessageEvent *> (*it);
            GameErrorMessage(evdg->_Message);
        }
        break;

        case 7: // NewMapEvent
        {
            NewMapEvent * evdg = static_cast<NewMapEvent *> (*it);
            m_lbaNetModel.NewMapEvent(evdg->_MapName, evdg->_MapType);
            m_gui_handler.SetCurrentMap(evdg->_MapName);
        }
        break;



        case 8: // new font size event
        {
            m_gui_handler.ReloadFontSize();
        }
        break;

        //case 9: // teleport event
        //	{
        //		TeleportEvent * evcbe = static_cast<TeleportEvent *> (*it);
        //		m_lbaNetModel.ChangeMap(evcbe->_NewMap, evcbe->_Spawning);
        //	}
        //break;

        //case 10: // teleport event
        //	{
        //		ChangeMainBodyColorEvent * evcbe = static_cast<ChangeMainBodyColorEvent *> (*it);
        //		if(evcbe->_plus)
        //			m_lbaNetModel.IncreasePlayerBodyColor();
        //		else
        //			m_lbaNetModel.DecreasePlayerBodyColor();
        //	}
        //break;

        case 11: // display text event
        {
            if(m_currentstate == EGaming)
            {
                DisplayGameTextEvent * evcbe = static_cast<DisplayGameTextEvent *> (*it);
                m_gui_handler.DisplayGameText(evcbe->_textid);
            }
        }
        break;

        //case 12: // player scripted event
        //	{
        //		if(m_currentstate == EGaming)
        //		{
        //			MainPlayerScriptedEvent * evcbe = static_cast<MainPlayerScriptedEvent *> (*it);
        //			m_lbaNetModel.DoPlayerScriptedEvent(evcbe->_script);
        //		}
        //	}
        //break;

        //case 13: // game signal event
        //	{
        //		if(m_currentstate == EGaming)
        //		{
        //			GameSignalvent * evcbe = static_cast<GameSignalvent *> (*it);
        //			m_lbaNetModel.SignalEvent(evcbe->_signal, evcbe->_targets);
        //		}
        //	}
        //break;

        //case 14: // teleport anywere event
        //	{
        //		if(m_currentstate == EGaming)
        //		{
        //			TeleportAnyEvent * evcbe = static_cast<TeleportAnyEvent *> (*it);
        //			m_lbaNetModel.ChangeMap(evcbe->_NewMap, evcbe->_X, evcbe->_Y, evcbe->_Z, 0);
        //		}
        //	}
        //break;

        //case 15: // change perspective event
        //	{
        //		ChangePerspectiveEvent * evcs = static_cast<ChangePerspectiveEvent *> (*it);
        //		m_lbaNetModel.ChangePespective(evcs->_perspective);
        //	}
        //break;

        //case 16: // display exits event
        //	{
        //		DisplayExitsEvent * evcs = static_cast<DisplayExitsEvent *> (*it);
        //		m_lbaNetModel.DisplayExits(evcs->_display);
        //	}
        //break;

        //case 17: // playerhurt
        //	{
        //		PlayerHurtEvent * evcs = static_cast<PlayerHurtEvent *> (*it);
        //		m_lbaNetModel.PlayerHurt(evcs->_fromactorid);
        //	}
        //break;

        //case 18: // do full check
        //	{
        //		m_lbaNetModel.DoFullCheckEvent();
        //	}
        //break;

        //case 19: // player life changed
        //	{
        //		PlayerLifeChangedEvent * evcs = static_cast<PlayerLifeChangedEvent *> (*it);
        //		m_lbaNetModel.PlayerLifeChanged(evcs->_CurLife, evcs->_MaxLife,
        //											evcs->_CurMana, evcs->_MaxMana);

        //		_MaxLife = evcs->_MaxLife;
        //		_MaxMana = evcs->_MaxMana;
        //		_CurrentLife = evcs->_CurLife;
        //		if(_CurrentLife < 0)
        //			_CurrentLife = 0;
        //		_CurrentMana = evcs->_CurMana;
        //		if(_CurrentMana < 0)
        //			_CurrentMana = 0;
        //	}
        //break;

        //case 20: // player name color changed
        //	{
        //		PlayerNameColorChangedEvent * evcs =
        //			static_cast<PlayerNameColorChangedEvent *> (*it);
        //		m_lbaNetModel.SetPlayerNameColor(evcs->_R, evcs->_G, evcs->_B);
        //	}
        //break;

        //case 21: // change stance event
        //	{
        //		ChangeStanceEvent * evcs =
        //			static_cast<ChangeStanceEvent *> (*it);
        //		PlayerChangeStance(evcs->_stance);
        //	}
        //break;

        //case 22: // inventory used event
        //	{
        //		InventoryObjectUsedEvent * evcs =
        //			static_cast<InventoryObjectUsedEvent *> (*it);
        //		m_lbaNetModel.InventoryUsed(evcs->_ObjectId, _CurrentLife==_MaxLife, _CurrentMana==_MaxMana);
        //	}
        //break;

        case 23: // focus chatbox event
            FocusChatbox(true);
            break;

            //case 24: // display NPC dialog
            //	{
            //		DisplayDialogEvent * evcs =
            //			static_cast<DisplayDialogEvent *> (*it);
            //		m_guiHandler.ShowDialog(evcs->_ActorId, evcs->_ActorName, evcs->_Dialog,
            //									evcs->_Show, evcs->_inventory);
            //	}
            //break;


            //case 25: // object update event
            //	{
            //		ObjectUpdateEvent * evcs =
            //			static_cast<ObjectUpdateEvent *> (*it);

            //		if(!evcs->_Received)
            //		{
            //			std::stringstream strs;
            //			strs<<"You used "<<evcs->_Number<<" [colour='FFFFFFFF'][image='set:"<<ImageSetHandler::GetInstance()->GetInventoryMiniImage(evcs->_ObjectId)<<"   image:full_image']";
            //			ThreadSafeWorkpile::ChatTextData cdata;
            //			cdata.Channel = "All";
            //			cdata.Sender = "info";
            //			cdata.Text = strs.str();
            //			ThreadSafeWorkpile::getInstance()->AddChatData(cdata);
            //		}
            //		else
            //		{
            //			std::stringstream strs;
            //			strs<<"You received "<<evcs->_Number<<" [colour='FFFFFFFF'][image='set:"<<ImageSetHandler::GetInstance()->GetInventoryMiniImage(evcs->_ObjectId)<<"   image:full_image']";
            //			ThreadSafeWorkpile::ChatTextData cdata;
            //			cdata.Channel = "All";
            //			cdata.Sender = "info";
            //			cdata.Text = strs.str();
            //			ThreadSafeWorkpile::getInstance()->AddChatData(cdata);
            //		}
            //	}
            //break;
        }

        delete *it;
    }
}