Exemplo n.º 1
0
int NFGamePVPModule::OnNPCHPEvent(const NFGUID & self, const std::string & strPropertyName, const NFData & oldVar, const NFData & newVar)
{
	if (newVar.GetInt() <= 0)
	{
		const NFGUID& identAttacker = m_pKernelModule->GetPropertyObject(self, NFrame::NPC::LastAttacker());
		const std::string& strCnfID = m_pKernelModule->GetPropertyString(self, NFrame::NPC::ConfigID());
		int nExp = m_pKernelModule->GetPropertyInt(self, NFrame::NPC::EXP());

		if (!identAttacker.IsNull())
		{
			if (m_pKernelModule->GetPropertyString(identAttacker, NFrame::IObject::ClassName()) == NFrame::Player::ThisName())
			{
				//is hero?
				int nSceneID = m_pKernelModule->GetPropertyInt32(identAttacker, NFrame::Player::SceneID());
				int nFightingStar = m_pKernelModule->GetPropertyInt32(identAttacker, NFrame::Player::FightingStar());
				int nCup = m_pKernelModule->GetPropertyInt(identAttacker, NFrame::Player::Cup());
				int nOpponentCup = m_pKernelModule->GetPropertyInt(identAttacker, NFrame::Player::OpponentCup());

				NFGUID xViewOpponent = m_pKernelModule->GetPropertyObject(identAttacker, NFrame::Player::OpponentID());
				NFGUID xOpponentFighting = m_pKernelModule->GetPropertyObject(identAttacker, NFrame::Player::OpponentFighting());
				E_SCENE_TYPE sceneType = (E_SCENE_TYPE)m_pElementModule->GetPropertyInt(std::to_string(nSceneID), NFrame::Scene::Type());

				if (sceneType == E_SCENE_TYPE::SCENE_TYPE_SINGLE_CLONE_SCENE
					|| sceneType == E_SCENE_TYPE::SCENE_TYPE_MULTI_CLONE_SCENE)
				{
					NFMsg::ENPCType eNPCType = (NFMsg::ENPCType)(m_pElementModule->GetPropertyInt(strCnfID, NFrame::NPC::NPCType()));
					if (eNPCType == NFMsg::ENPCType::ENPCTYPE_HERO)
					{
						nFightingStar++;
						m_pKernelModule->SetPropertyInt(identAttacker, NFrame::Player::FightingStar(), nFightingStar);

						if (nFightingStar >= 2)
						{
							if (nCup > nOpponentCup)
							{
								m_pKernelModule->SetPropertyInt(identAttacker, NFrame::Player::WonCup(), 5 * nFightingStar);
							}
							else
							{
								m_pKernelModule->SetPropertyInt(identAttacker, NFrame::Player::WonCup(), 3 * nFightingStar);
							}
						}
					}

					//add exp for hero
				}
			}
		}
	}

	return 0;
}
Exemplo n.º 2
0
int NFCGamePVPModule::OnPlayerHPEvent(const NFGUID & self, const std::string & strPropertyName, const NFData & oldVar, const NFData & newVar)
{
	//is pvp
	int pvpType = m_pKernelModule->GetPropertyInt(self, NFrame::Player::PVPType());
	if (pvpType == NFMsg::EPVPType::PVP_INDIVIDUAL)
	{
		if (newVar.GetInt() <= 0)
		{
			m_pScheduleModule->AddSchedule(self, "NFCGamePVPModule::OnDeadSwapHeroHeart", this, &NFCGamePVPModule::OnDeadSwapHeroHeart, 5.0f, 1);
		}
	}

	return 0;
}
Exemplo n.º 3
0
int NFCRecord::FindRowByColValue(const int nCol, const NFData& var, NFDataList& varResult)
{
    if (!ValidCol(nCol))
    {
        return -1;
    }

    NFDATA_TYPE eType = var.GetType();
    if (eType != mVarRecordType->Type(nCol))
    {
        return -1;
    }

    switch (eType)
    {
        case TDATA_INT:
            return FindInt(nCol, var.GetInt(), varResult);
            break;

        case TDATA_FLOAT:
            return FindFloat(nCol, var.GetFloat(), varResult);
            break;

        case TDATA_STRING:
            return FindString(nCol, var.GetString(), varResult);
            break;

        case TDATA_OBJECT:
            return FindObject(nCol, var.GetObject(), varResult);
            break;

		case TDATA_VECTOR2:
			return FindVector2(nCol, var.GetVector2(), varResult);
			break;

        case TDATA_VECTOR3:
			return FindVector3(nCol, var.GetVector3(), varResult);
			break;

        default:
            break;
    }

    return -1;
}
Exemplo n.º 4
0
int NFCHelloWorld2::OnPropertyCallBackEvent( const NFGUID& self, const std::string& strProperty, const NFData& oldVar, const NFData& newVar)
{
    
    std::cout << "OnPropertyCallBackEvent Property: " << strProperty << " OldValue: " << oldVar.GetInt() << " NewValue: " << newVar.GetInt() << std::endl;

    return 0;
}