コード例 #1
0
void MainMenu::onEvent(Event e)
{
	if(strcmp(e.getID(), m_pStartSPButton.getName())== 0)
	{
		Event load_state("changestate", 2);
		load_state[0] = EventArg("game");
		load_state[1] = EventArg("customgame"); 

		postEvent(load_state);
	}
	else if(strcmp(e.getID(), m_pEditorButton.getName()) == 0)
	{		
		Event load_state("changestate", 2);
		load_state[0] = EventArg("editor");
		load_state[1] = EventArg("customgame"); 

		postEvent(load_state);
	}
	else if(strcmp(e.getID(), m_pQuitButton.getName()) == 0)
	{
		Event quit("quit", 0);

		postEvent(quit);
	}
}
コード例 #2
0
ファイル: BulletFactor.cpp プロジェクト: dzw/kylin001v
	KVOID BulletFactor::PostDamage( Entity* pCollidee )
	{
		if (!m_bExplode)
		{
			EventPtr spEV(
				KNEW Event(
				&ev_post_damage, 
				Event::ev_immediate, 
				0, 
				3, 
				EventArg(m_spHostAct->GetHostWorldID()),
				EventArg(m_spHostAct->GetMinDamage()),
				EventArg(m_spHostAct->GetMaxDamage())
				));

			KylinRoot::GetSingletonPtr()->PostMessage(pCollidee->GetID(),spEV);
		}
	}
コード例 #3
0
ファイル: ActSkill.cpp プロジェクト: dzw/kylin001v
KVOID Kylin::ActSkill::HitTarget( KUINT uID )
{
	Kylin::Entity* pTarget = KylinRoot::GetSingletonPtr()->GetEntity(uID);
	if (pTarget)
	{
		// 发送伤害消息
		EventPtr spEV(
			KNEW Event(
			&ev_post_damage, 
			Event::ev_immediate, 
			0, 
			3, 
			EventArg(GetHostWorldID()),
			EventArg(GetMinDamage()),
			EventArg(GetMaxDamage())
			));

		KylinRoot::GetSingletonPtr()->PostMessage(uID,spEV);
	}
}
コード例 #4
0
ファイル: Game.cpp プロジェクト: mlaveaux/DeferredDXRenderer
HRESULT Game::Initialize(HINSTANCE hInstance, int cmdShow)
{
	//**********************************************
	//Initialize the engine for the game
	if(FAILED(engineCore.initialize(hInstance, cmdShow)))
		return E_FAIL;

	//get the main state manager
	m_pStateManager = engineCore.getStateManager();
	
	//*******************************
	//activate the standard state (MenuState)
	Event state("changestate", 1);
	state[0] = EventArg("menu");

	postEvent(state);

	dwTimeOld = GetTickCount();

	return S_OK;
}
コード例 #5
0
void CVarManager::on_setcvar(Event& pArgs)
{
    std::string strIdentifier = pArgs[0].toChar();//pArgs.strVariable.c_str();
    std::string strValue = pArgs[1].toChar();//.strValue.c_str();

    ConVarData* _pData = search(strIdentifier.c_str());

    if (_pData == NULL) {
        EventManager::Instance().postMessage("cvar %s doesn't exist", strIdentifier.c_str());
        return;
    }

    CValue _value = _pData->m_Value;

    switch (_value.Type) {
    case T_INTEGER:
        _value.Integer = ::atoi(strValue.c_str());
        if (errno > 0) {
            EventManager::Instance().postMessage("can't set cvar %s (expected an integer, but got %s)", strIdentifier.c_str(), strValue.c_str());
            return;
        }
        break;

    case T_FLOAT:
        _value.Float = (float)::atof(strValue.c_str());
        if (errno > 0) {
            EventManager::Instance().postMessage("can't set cvar %s (expected a float, but got %s)", strIdentifier.c_str(), strValue.c_str());
            return;
        }
        break;

    case T_STRING:
        _value.strText = strValue;
        break;

    case T_BOOL:
        if (strValue.compare("true") == 0) {
            _value.Bool = true;
        }
        else if (strValue.compare("false") == 0) {
            _value.Bool = false;
        }
        else {
            EventManager::Instance().postMessage("can't set cvar %s (expected a bool, but got %s)", strIdentifier.c_str(), strValue.c_str());
            return;
        }
        break;

    case T_VECTOR:
        int index = (int)strValue.find_first_of(" ");
        assert(index == strValue.find_first_of(" ")); // Check if index was not truncated.

        std::string strFirst = strValue.substr(0, index);
        std::string strLast = strValue.substr(index + 1, strValue.length() - index);

        _value.Vector.x = ::atoi(strFirst.c_str());
        _value.Vector.y = ::atoi(strLast.c_str());
        if (errno > 0) {
            EventManager::Instance().postMessage("can't set cvar %s (expected a vector, but got %s)", strIdentifier.c_str(), strValue.c_str());
            return;
        }

        break;
    }

    _pData->m_Value = _value;
    if (strValue.length() == 0)
    {
        _pData->m_Value = pArgs[1].getValue();
    }

    Event cvarChange("cvarchange", 1);
    cvarChange[0] = EventArg(_value);
}