Example #1
0
bool NFCHelloWorld2::AfterInit()
{
	NFDataList xData;
	xData.AddInt(111);




// #ifdef NF_USE_ACTOR
//     if(pPluginManager->GetActorID() == NFIActorManager::EACTOR_MAIN)
// #endif
    {
        std::cout << "Hello, world2, AfterInit" << std::endl;

		//created a object for this test
        NFIObject* pObject = new NFCObject(NFGUID(0, 1), pPluginManager);

		//add a property name is "Hello" of this object
        pObject->GetPropertyManager()->AddProperty(pObject->Self(), "Hello", TDATA_STRING);
		//add a property name is "World" of this object
        pObject->GetPropertyManager()->AddProperty(pObject->Self(), "World", TDATA_INT);

		//set the "world" property value as 1111
        pObject->SetPropertyInt("World", 1111);
		int n1 = pObject->GetPropertyInt("World");
		//get the "world" property value and printf it
        const int nProperty1 = pObject->GetPropertyInt("World");
        std::cout << "Property World:" << nProperty1 << std::endl;

        //add a call back functin for "world" property
        pObject->AddPropertyCallBack("World", this, &NFCHelloWorld2::OnPropertyCallBackEvent);

		////set the "world" property value as 2222[than the function "HelloWorld2::OnPropertyCallBackEvent" will be called]
        pObject->SetPropertyInt("World", 2222);
		int n2 = pObject->GetPropertyInt("World");

		//get the "world" property value and printf it
        const int nProperty2 = pObject->GetPropertyInt("World");
        std::cout << "Property World:" << nProperty2 << std::endl;

    }

    return true;
}
int NFCBriefSkillConsumeProcessModule::ConsumeProcess( const NFIDENTID& self, const std::string& strSkillName, const NFIValueList& other, NFIValueList& damageListValue, NFIValueList& damageResultList )
{
    NFIPropertyManager* pPropertyManager = m_pElementInfoModule->GetPropertyManager( strSkillName );
    if ( pPropertyManager == NULL )
    {
        return 1;
    }

//     NFIProperty* pSkillDamageProperty = pPropertyManager->GetElement( "DamageProperty" );
//     NFIProperty* pSkillDamageValue = pPropertyManager->GetElement( "DamageValue" );
//     NFIProperty* pSkillDamageType = pPropertyManager->GetElement( "DamageType" );
//     NFIProperty* pSkillDamageSubType = pPropertyManager->GetElement( "DamageSubType" );
//     if ( pSkillDamageProperty == NULL || pSkillDamageValue == NULL || pSkillDamageType == NULL || pSkillDamageSubType == NULL )
//     {
//         return 1;
//     }
// 
//     int nDamageType = pSkillDamageType->QueryInt();
//     int nDamageSubType = pSkillDamageSubType->QueryInt();
//     NFCValueList valueEffectProperty( pSkillDamageProperty->QueryString().c_str(), "," );
//     NFCValueList valueEffectValue( pSkillDamageValue->QueryString().c_str(), "," );
// 
//     if ( valueEffectProperty.GetCount() != valueEffectValue.GetCount() )
//     {
//         return 1;
//     }

    //for ( int i = 0; i < valueEffectProperty.GetCount(); i++ )
    {
        //先测定目标是否有此属性(其实是担心配错了)
        for ( int j = 0; j < other.GetCount(); j++ )
        {
            NFIDENTID identOther = other.ObjectVal( j );
            if ( identOther.IsNull() )
            {
                continue;
            }

            NFIObject* pObject = m_pKernelModule->GetObject( identOther );
            if ( pObject == NULL )
            {
                continue;
            }

            //短刀伤害,只能是HP,MP之类的有最大上限值的属性
//             std::string strCurProperty = valueEffectProperty.StringVal( i );
//             std::string strMaxProperty = "MAX" + strCurProperty;
//             NFIProperty* pOtherCurProperty = pObject->GetPropertyManager()->GetElement( strCurProperty );
//             NFIProperty* pOtherMaxProperty = pObject->GetPropertyManager()->GetElement( strMaxProperty );
//             if ( pOtherCurProperty == NULL || pOtherMaxProperty == NULL )
//             {
//                 continue;
//             }

            NFIProperty* pLastProperty = pObject->GetPropertyManager()->GetElement( "LastAttacker" );
            if ( pLastProperty )
            {
                pLastProperty->SetObject( self );
            }
        }
    }
    //m_pKernelModule->LogErrorItem(strSkillName.c_str(), "");

    return 0;
}