Пример #1
0
/** 创建受击源到目标飞行特效
@param   
@param   
@return  
*/
bool EntityFactory::CreateBeHitFlyEffect(const SkillEffectContext& context)
{
	EntityView* pSourceEntityView = (EntityView*)getHandleData(context.src);
	if (pSourceEntityView == NULL)
	{
		ASSERT(false);
		return false;
	}

	//  调整光效方向;
	long magicAngle = pSourceEntityView->getAngle();
	//  创建飞行光效;
	handle magicOwner = context.src;

	int nFlyMagicID = getInt(context.id, SkillViewProperty_BeHitFlyMagicId);
	if (nFlyMagicID != 0)
	{
		EffectContext_Fly ec;
		ec.magicId = nFlyMagicID;
		ec.angle = magicAngle;
		ec.loops = -1;
		ec.moveSpeed = getFloat(context.id, SkillViewProperty_FlySpeed);
		ec.src = context.src;
		ec.target = context.target;
		ec.idExplode = getInt(context.id, SkillViewProperty_ExplodeMagicID);
		//  读取一下爆炸光效是否绑定在目标上;
		int nExplodeMagicAttachToTarget = getInt(context.id, SkillViewProperty_ExplodeMagicAttachToTarget);
		if (nExplodeMagicAttachToTarget == 1)
		{
			ec.hExplodeTarget = context.target;
		}
		else
		{
			ec.hExplodeTarget = 0;
		}
		ec.loopsExplode = 1;
		ec.ExplodeEffectContext = context;
		//return createEffect(EffectType_Fly, &ec, sizeof(EffectContext_Fly));

		EffectControl_Fly* ctrl = new EffectControl_Fly();
		if (!ctrl->create(ec))
		{
			delete ctrl;
			return false;
		}

		ctrl->setSrc(context.src);
		ctrl->setViewId(context.id);
		EffectControlManager::getInstance().add(ctrl);
		return true;
	}

	return true;
}
Пример #2
0
void HTTP_Requester::Handle_DNS_Error( const char * szDomain,DWORD dwErrorCode )
{
	REQUEST_LIST & request_list = m_DNSQueryingList[szDomain];

	REQUEST_LIST::iterator it = request_list.begin();
	for ( ;it!=request_list.end();++it )
	{
		HTTP_Response_Handler * handler = (HTTP_Response_Handler*)getHandleData(it->m_pHandler);
		if ( handler )
		     handler->OnError(dwErrorCode,it->m_szURL.c_str());
	}

	m_DNSQueryingList.erase(szDomain);
}
Пример #3
0
/** 创建受击特效
@param   
@param   
@return  
*/
bool EntityFactory::CreateBeHitEffect(const SkillEffectContext& context)
{
	EntityView* pSourceEntityView = (EntityView*)getHandleData(context.src);
	if (pSourceEntityView == NULL)
	{
		//ASSERT(false);
		return false;
	}

	//  调整光效方向;
	long magicAngle = pSourceEntityView->getAngle();
    
	//  目标受击音效;
	int nSoundID = getInt(context.id,SkillViewProperty_SoundIDBeHit);
	int nSoundLoop = getInt(context.id,SkillViewProperty_bSoundLoopeBeHit);
	if (nSoundID > 1000)
	{
		IFormManager* pFormManger = gGlobalClient->getFormManager();
		if (pFormManger)
		{
			pFormManger->PlaySound(nSoundID,nSoundLoop,0.8,SOUNDRES_TYPE_SOUND);
		}
	}

	// 目标受击光效
	int nAttackMagicID = getInt(context.id, SkillViewProperty_BeHitMagicId);
	if (nAttackMagicID != 0)
	{
		EffectContext_General ec;
		ec.magicId = nAttackMagicID;
		ec.loops = 1;
		ec.angle = magicAngle;
		ec.owner = context.target;
		ec.tile = context.ptCenter;
		EffectControl_General* ctrl = new EffectControl_General();
		if (!ctrl->create(ec))
		{
			delete ctrl;
			return false;
		}
		ctrl->setSrc(context.src);
		ctrl->setViewId(context.id);
		EffectControlManager::getInstance().add(ctrl);

		return true;
	}

	return true;
}
Пример #4
0
ITexture* MinimapTile::getTexture()
{
	if(!m_handle || !isValidHandle(m_handle))return 0;

	IResourceNode* node = (IResourceNode*)getHandleData(m_handle);
	if (node)
	{
		IResource* res = node->getResource();
		if (res)
		{
			return (ITexture*)res->getInnerData();
		}
	}

	return 0;
}
Пример #5
0
void ChangePartManager::update()
{
	if( isValidHandle(m_handle) && !m_bLoaded ) //句柄有效,且没有加载
	{
		IResourceNode* node = (IResourceNode*)getHandleData(m_handle);
		if( node)
		{
			IResource * res = node->getResource();
			if( res)
			{
				ModelNode * n = (ModelNode *)res->getInnerData();
				if( n )
				{
					onResLoad(n);
				}
			}
		}
	}
}
Пример #6
0
int EntityFactory::GetAnimationTime(const RequestAnimationContext& context)
{
	EntityView* pSourceEntityView = (EntityView*)getHandleData(context.src);
	if ((pSourceEntityView == NULL) || (context.id == 0))
	{
		ASSERT(false);
		return false;
	}

	// 取得配置的多个攻击动作中随机的一个
	int nActionId;
	const IntArray & AttackActId = getIntArray(context.id, SkillViewProperty_AttackActId);
	int nCount = AttackActId.count;

	if (nCount == 1)
	{
		nActionId = AttackActId.data[0];
	}
	else if (nCount > 1)
	{
		int nIndex = getRand(1, nCount);
		nActionId = AttackActId.data[nIndex - 1];
	}
	else
	{
		nActionId = 0;
	}

	//if (nActionId == )
	//{
	//}

	int nTicks = 0;
	pSourceEntityView->onCommand(EntityCommand_GetAnimationTime, (ulong)&nTicks, nActionId);

	return nTicks;
}
Пример #7
0
void FlowTextManager::renderSystemTips(IRenderSystem* pRenderSystem)
{
	EntityView* player = (EntityView*)getHandleData(gGlobalClient->getPlayer());
	xs::Point ptScreen;
	if (player)	
	{
		 //获取玩家位置
		gGlobalClient->getSceneManager()->world2Screen(player->getWorld(), ptScreen);

		// 头顶脚底的区域必须跟着玩家移动,尤其是在地图边界玩家位置不居中的时候
		mFlowArea[FlowArea_Top].render(ptScreen, pRenderSystem);
		mFlowArea[FlowArea_Bottom].render(ptScreen, pRenderSystem);
	}

	const xs::Rect& rc = gGlobalClient->getSceneManager()->getViewportRect();
	ptScreen.x = (rc.left + rc.right) / 2 - gGlobalClient->getSceneManager()->getViewTopLeftX();
	ptScreen.y = (rc.top + rc.bottom) / 2 - gGlobalClient->getSceneManager()->getViewTopLeftY();
	mFlowArea[FlowArea_Right].render(ptScreen, pRenderSystem);

	/*
	if (mFlowArea[FlowArea_Mouse].needRender())
	{
	// 获取鼠标位置
	xs::Point ptScreen;
	GetCursorPos(&ptScreen);
	ScreenToClient((HWND)gGlobalClient->getHWND(), &ptScreen);

	mFlowArea[FlowArea_Mouse].render(ptScreen, deltaTime);
	}*/

	for (FlowTextList::iterator it=mMouseTipsList.begin(); it!=mMouseTipsList.end();++it)
	{
		FlowText*& ft = *it;
		ft->render(pRenderSystem);
	}
}
/*
 * Common code for Java_org_catacombae_hfsexplorer_win32_WritableWin32File_openNative
 * and Java_org_catacombae_hfsexplorer_win32_WindowsLowLevelIO_openNative.
 */
jbyteArray openWin32File(JNIEnv *env,
			 jstring str,
			 DWORD dwDesiredAccess,
			 DWORD dwShareMode,
			 LPSECURITY_ATTRIBUTES lpSecurityAttributes,
			 DWORD dwCreationDisposition,
			 DWORD dwFlagsAndAttributes,
			 HANDLE hTemplateFile) {
  // Microsoft's old-school C compiler forces me to go C90 strict. Hopefully MinGW GCC will be 64-bit soon.
  jsize utf8FilenameLength;
  const jbyte *utf8Filename;
  int wcFilenameSize;
  WCHAR *wcFilename;
  HANDLE hnd;
  
  if(DEBUG) printf("openWin32File called\n");
  if(str == NULL) { // Must check input, or we can crash the jvm.
    throwByName(env, "java/lang/NullPointerException", "Filename is null.");
    return 0;
  }
  
  /* First, we convert the jstring to a jbyte array with the string encoded
     into UTF-8. */
  utf8FilenameLength = (*env)->GetStringUTFLength(env, str);
  utf8Filename = (*env)->GetStringUTFChars(env, str, NULL);
  if(DEBUG) printf("utf8FilenameLength: %d bytes\n", utf8FilenameLength);

  
  /* Then, we convert the UTF-8 string into windows WCHARs */
  wcFilenameSize = MultiByteToWideChar(CP_UTF8, 0, utf8Filename, utf8FilenameLength, NULL, 0);
  if(wcFilenameSize == 0) {
    handleMultiByteToWideCharError(env, GetLastError());
    (*env)->ReleaseStringUTFChars(env, str, utf8Filename);
    return 0;
  }
  ++wcFilenameSize; // the last WCHAR is the null terminator
  if(DEBUG) printf("wcFilenameSize: %d\n", wcFilenameSize);
  wcFilename = (WCHAR*)malloc(sizeof(WCHAR)*wcFilenameSize);
  if(MultiByteToWideChar(CP_UTF8, 0, utf8Filename, utf8FilenameLength, wcFilename, wcFilenameSize) == 0) {
    handleMultiByteToWideCharError(env, GetLastError());
    (*env)->ReleaseStringUTFChars(env, str, utf8Filename);
    free(wcFilename);
    return 0;
  }
  wcFilename[wcFilenameSize-1] = L'\0'; // Null termination.
  (*env)->ReleaseStringUTFChars(env, str, utf8Filename); // Release allocated resources.
  
  
  /* Perfect. */
  if(DEBUG) printf("Attempting to open \"");
  if(DEBUG) wprintf(L"%s", wcFilename);
  if(DEBUG) printf("\"\n");
  hnd = CreateFileW(wcFilename, dwDesiredAccess, dwShareMode, lpSecurityAttributes, 
		    dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
  free(wcFilename); // Done with that one now
  if(hnd == INVALID_HANDLE_VALUE) {
    throwByName(env, "java/lang/RuntimeException", "Could not open file.");
    return 0;
  }
  else {
    return getHandleData(env, hnd);
  }  
}
Пример #9
0
bool EntityFactory::CreateSkillBootEffect(const SkillEffectContext& context)
{
	EntityView* pSourceEntityView = (EntityView*)getHandleData(context.src);
	if (pSourceEntityView == NULL)
	{
		ASSERT(false);
		return false;
	}

	//  调整光效方向;
	long magicAngle = 0;
	if (getInt(context.id, SkillViewProperty_NotAdjustDir) == 0)
	{
		magicAngle = pSourceEntityView->getAngle();
	}

	//  发起攻击动作;
	AttackContext ac;
	ac.actionId = getInt(context.id, SkillViewProperty_AttackReadyActId);
	ac.loops = -1;
	ac.fAnimateSpeed = getFloat(context.id, SkillViewProperty_AttackReadyActSpeed);
	ac.isSpellAttack = context.isSpellSkill;
	bool bMounted = false;
	//pSourceEntityView->onCommand(EntityCommand_GetMount, (ulong)&bMounted);
	//if (bMounted)
	{
		pSourceEntityView->onCommand(EntityCommand_SetMount, 0);
	}
	pSourceEntityView->onCommand(EntityCommand_AttackReady, (ulong)&ac);

	//  生物攻击瞬间的光效;
	int nAttackMagicID = getInt(context.id, SkillViewProperty_AttackReadyMagicId);
	if (nAttackMagicID != 0)
	{
		EffectContext_LifeTime ec;
		ec.magicId = nAttackMagicID;
		ec.loops = -1;
		ec.angle = magicAngle;
		//  读取一下光效是否绑定在源上;
		int nAttackMagicAttachToSource = getInt(context.id, SkillViewProperty_AttackMagicAttachToSource);
		if (nAttackMagicAttachToSource == 1)
		{
			ec.owner = context.src;
		}
		else
		{
			ec.owner = 0;
		}
		ec.tile = pSourceEntityView->getTile();
		ec.life = context.nDuration;
		EffectControl_LifeTime* ctrl = new EffectControl_LifeTime();
		if (!ctrl->create(ec))
		{
			delete ctrl;
			return false;
		}
		ctrl->setSrc(context.src);
		ctrl->setViewId(context.id);
		EffectControlManager::getInstance().add(ctrl);
		return true;
	}

	return false;

	//  创建技能引导光效;
	ulong effectType = getInt(context.id, SkillViewProperty_EffectType);
	ulong magicId = getInt(context.id, SkillViewProperty_TrackMagicId);
	handle magicOwner = context.selectType == 2 ? INVALID_HANDLE : (context.selectType == 0 ? context.src : context.target);
	ulong ulInterval = getInt(context.id, SkillViewProperty_Delay);
	switch (effectType)
	{
	case EffectType_General:
		{
		}
		break;

	case EffectType_Fly:
		{
			//  填写飞行光效的参数;
			EffectContext_Fly ec;
			ec.magicId = magicId;
			ec.angle = magicAngle;
			ec.loops = -1;
			ec.moveSpeed = getFloat(context.id, SkillViewProperty_FlySpeed);
			ec.src = context.src;
			ec.target = context.target;
			ec.idExplode = getInt(context.id, SkillViewProperty_ExplodeMagicID);
			//  读取一下爆炸光效是否绑定在目标上;
			int nExplodeMagicAttachToTarget = getInt(context.id, SkillViewProperty_ExplodeMagicAttachToTarget);
			if (nExplodeMagicAttachToTarget == 1)
			{
				ec.hExplodeTarget = context.target;
			}
			else
			{
				ec.hExplodeTarget = 0;
			}
			ec.loopsExplode = 1;
			ec.ExplodeEffectContext = context;

#if 0
			EffectControl_Fly* ctrl = new EffectControl_Fly();
			if (!ctrl->create(ec))
			{
				delete ctrl;
				return false;
			}

			ctrl->setSrc(context.src);
			ctrl->setViewId(context.id);
			EffectControlManager::getInstance().add(ctrl);
#endif

			//  填写多次播放的光效的参数;
			EffectContext_MultiTimes< EffectContext_Fly > MultiTimesEffectContext;
			MultiTimesEffectContext.m_ulDuration = context.nDuration;
			MultiTimesEffectContext.m_ulInterval = ulInterval;
			MultiTimesEffectContext.m_EffectControlContext = ec;

			//  创建多次播放的光效;
			EffectControl_MultiTimes< EffectContext_Fly, EffectControl_Fly >* pMultiTimesEffect =
				new EffectControl_MultiTimes< EffectContext_Fly, EffectControl_Fly >();
			if (!pMultiTimesEffect->create(MultiTimesEffectContext))
			{
				delete pMultiTimesEffect;
				return false;
			}

			//  将创建的光效记录在光效控制管理器中,以便于后面的删除操作;
			pMultiTimesEffect->setSrc(context.src);
			pMultiTimesEffect->setViewId(context.id);
			EffectControlManager::getInstance().add(pMultiTimesEffect);

			return true;
		}
		break;

	case EffectType_LifeTime:
		{
		}
		break;

	case EffectType_MultiTimes:
		{
		}
		break;

	case EffectType_Area:
		{
		}
		break;

	case EffectType_MultiDir:
		{
		}
		break;

	case EffectType_RapidMove:
		{
		}
		break;

	case EffectType_DestRapidMove:
		{
		}
		break;

	case EffectType_SrcDestRapidMove:
		{
		}
		break;

		//	//跳跃类
	case EffectType_Jump:
		{
		}
		break;
	}

	return false;
}
Пример #10
0
bool EntityFactory::createSkillReadyEffect(const SkillEffectContext& context, bool bPlayAction, bool bHasInterval)
{
	EntityView* src = (EntityView*)getHandleData(context.src);
	if (src == NULL)
	{
		return false;
	}

	// 是否需调整光效方向
	long magicAngle = 0;
	if (getInt(context.id, SkillViewProperty_NotAdjustDir) == 0)
    {
		magicAngle = src->getAngle();
    }

	if (bPlayAction)
	{
		// 生物发起攻击动作
		AttackContext ac;
		ac.actionId = getInt(context.id, SkillViewProperty_AttackReadyActId);
		ac.loops = -1;
		ac.fAnimateSpeed = getFloat(context.id, SkillViewProperty_AttackReadyActSpeed);
		ac.isSpellAttack = context.isSpellSkill;
		//bool bMounted = false;
		//src->onCommand(EntityCommand_GetMount, (ulong)&bMounted);
		//if (bMounted)
		{
			src->onCommand(EntityCommand_SetMount, 0);
		}
		src->onCommand(EntityCommand_AttackReady, (ulong)&ac);

		//播放蓄气声效
		int nSoundID = getInt(context.id,SkillViewProperty_SoundIDPreAttack);
		int nSoundLoop = getInt(context.id,SkillViewProperty_bSoundLoopPreAttack);
		if (nSoundID>1000)
		{
			IFormManager* pFormManger = gGlobalClient->getFormManager();
			if (pFormManger)
			{
				pFormManger->PlaySound(nSoundID,nSoundLoop,0.8,SOUNDRES_TYPE_SOUND);
			}
		}
	}

    //  蓄气光效;
	ulong magicId = getInt(context.id, SkillViewProperty_AttackReadyMagicId);
	if (magicId != 0)
	{
		if (context.src)
		{
			MagicContext_General mc;
			mc.magicId = magicId;
			if (bHasInterval)
			{
				mc.loops = 1;
			}
			else
			{
				mc.loops = -1;
			}
            //  这里不使用context中记录的光效持续时间,而是由光效绑定者来决定什么时候结束光效;
            mc.nDuration = 0;
			mc.angle = magicAngle;
			mc.owner = context.src;
			mc.tile = src->getTile();
			MagicView* magic = (MagicView*)createMagic(MagicType_General, &mc, sizeof(mc));
			if (magic == NULL)
            {
                ASSERT(false);
				return false;
            }
		}
	}

	if (bPlayAction)
	{
		//  蓄气时在目标身上的光效;
		ulong magicIdOnTarget = getInt(context.id, SkillViewProperty_AttackReadyMagicIdOnTarget);
		if (magicIdOnTarget != 0)
		{
			if (context.src)
			{
				//  填写光效参数;
				MagicContext_General mc;
				mc.magicId = magicIdOnTarget;
				mc.loops = -1;
				//  这里不使用context中记录的光效持续时间,而是由光效绑定者来决定什么时候结束光效;
				mc.nDuration = 0;
				mc.angle = magicAngle;
				//  读取一下光效是否绑定在目标上;
				int nAttackReadyMagicOnTargetAttachToTarget = getInt(context.id, SkillViewProperty_AttackReadyMagicOnTargetAttachToTarget);
				if (nAttackReadyMagicOnTargetAttachToTarget == 1)
				{
					mc.owner = context.target;
				}
				else
				{
					mc.owner = 0;
				}
				mc.tile = context.ptTarget;
				//  创建光效;
				MagicView* pTargetMagic = (MagicView*)createMagic(MagicType_General, &mc, sizeof(mc));
				if (pTargetMagic == NULL)
				{
					ASSERT(false);
					return false;
				}

				//  如果光效没有绑定在目标上,则将其添加到与源相关的光效中;
				if (nAttackReadyMagicOnTargetAttachToTarget != 1)
				{
					src->onCommand(EntityCommand_AddMagic, (ulong)pTargetMagic);
				}
			}
		}
	}

	return true;
}
Пример #11
0
bool EntityFactory::createSkillTrackEffect(const SkillEffectContext& context)
{
	EntityView* pSourceEntityView = (EntityView*)getHandleData(context.src);
	if ((pSourceEntityView == NULL) || (context.id == 0))
	{
		ASSERT(false);
		return false;
	}

	// 是否需调整光效方向
	long magicAngle = 0;
	//if (getInt(context.id, SkillViewProperty_NotAdjustDir) == 0)
	//{
		magicAngle = pSourceEntityView->getAngle();
	//}

	//// 生物发起攻击动作
	AttackContext ac;

	// 取得配置的多个攻击动作中随机的一个
	int nActionId;
	const IntArray & AttackActId = getIntArray(context.id, SkillViewProperty_AttackActId);
	int nCount = AttackActId.count;

	if (nCount == 1)
	{
		nActionId = AttackActId.data[0];
	}
	else if (nCount > 1)
	{
		int nIndex = getRand(1, nCount);
		nActionId = AttackActId.data[nIndex - 1];
	}
	else
	{
		nActionId = 0;
	}

	ac.actionId = nActionId;

	ac.loops = context.loops;
	ac.fAnimateSpeed = getFloat(context.id, SkillViewProperty_AttackActSpeed);
	ac.isSpellAttack = context.isSpellSkill;
	//  冲锋技能是在瞬移效果完成后再做攻击动作;
	ulong effectType = getInt(context.id, SkillViewProperty_EffectType);
	//if (effectType != EffectType_RapidMove && effectType != EffectType_Jump)
	//{
	//	pSourceEntityView->onCommand(EntityCommand_Attack, (ulong)&ac);
	//}
	//  捆仙索技能在瞬移效果完成后也不需要做攻击动作;
	if (effectType == EffectType_DestRapidMove || effectType == EffectType_SrcDestRapidMove)
	{
		ac.actionId = 0;
	}

	ulong magicId = getInt(context.id, SkillViewProperty_TrackMagicId);
	if (magicId == 0 && (effectType != EffectType_RapidMove && effectType != EffectType_DestRapidMove && effectType != EffectType_SrcDestRapidMove && effectType != EffectType_Jump))
	{
		return true;//(context.id == 1001) ? true : false;
	}

	//  创建技能光效;
	handle magicOwner = context.selectType == 2 ? INVALID_HANDLE : (context.selectType == 0 ? context.src : context.target);
	switch (effectType)
	{
	case EffectType_General:
		{
			EffectContext_General ec;
			ec.magicId = magicId;
			ec.loops = 1;
			ec.angle = magicAngle;

			//  读取一下光效是否绑定在目标上;
			//  对于通过光效,也使用了SkillViewProperty_ExplodeMagicAttachToTarget来指定光效是否绑定在目标上;
			int nExplodeMagicAttachToTarget = getInt(context.id, SkillViewProperty_ExplodeMagicAttachToTarget);
			if (nExplodeMagicAttachToTarget == 1)
			{
				ec.owner = magicOwner;
			}
			else
			{
				ec.owner = 0;
			}
			ec.tile = context.ptCenter;
			//return createEffect(EffectType_General, &ec, sizeof(ec));

			EffectControl_General* ctrl = new EffectControl_General();
			if (!ctrl->create(ec))
			{
				delete ctrl;
				return false;
			}

			ctrl->setSrc(context.src);
			ctrl->setViewId(context.id);
			EffectControlManager::getInstance().add(ctrl);
			return true;
		}
		break;

	case EffectType_Fly:
		{
			EffectContext_Fly ec;
			ec.magicId = magicId;
			ec.angle = magicAngle;
			ec.loops = -1;
			ec.moveSpeed = getFloat(context.id, SkillViewProperty_FlySpeed);
			ec.src = context.src;
			ec.target = context.target;
			ec.idExplode = getInt(context.id, SkillViewProperty_ExplodeMagicID);
			//  读取一下爆炸光效是否绑定在目标上;
			int nExplodeMagicAttachToTarget = getInt(context.id, SkillViewProperty_ExplodeMagicAttachToTarget);
			if (nExplodeMagicAttachToTarget == 1)
			{
				ec.hExplodeTarget = context.target;
			}
			else
			{
				ec.hExplodeTarget = 0;
			}
			ec.loopsExplode = 1;
			ec.ExplodeEffectContext = context;
			//return createEffect(EffectType_Fly, &ec, sizeof(EffectContext_Fly));

			EffectControl_Fly* ctrl = new EffectControl_Fly();
			if (!ctrl->create(ec))
			{
				delete ctrl;
				return false;
			}

			ctrl->setSrc(context.src);
			ctrl->setViewId(context.id);
			EffectControlManager::getInstance().add(ctrl);
			return true;
		}
		break;

	case EffectType_LifeTime:
		{
			EffectContext_LifeTime ec;
			ec.magicId = magicId;
			ec.loops = -1;
			ec.angle = magicAngle;
			ec.owner = magicOwner;//context.target;
			ec.tile = context.ptCenter;
			ec.life = getInt(context.id, SkillViewProperty_LifeTime);
			//return createEffect(EffectType_LifeTime, &ec, sizeof(ec));

			EffectControl_LifeTime* ctrl = new EffectControl_LifeTime();
			if (!ctrl->create(ec))
			{
				delete ctrl;
				return false;
			}

			ctrl->setSrc(context.src);
			ctrl->setViewId(context.id);
			EffectControlManager::getInstance().add(ctrl);
			return true;
		}
		break;

	case EffectType_MultiTimes:
		{
#if 0
			EffectContext_MultiTimes ec;
			ec.magicId = magicId;
			ec.loops = 1;
			ec.angle = magicAngle;
			ec.tile = context.ptCenter;
			ec.interval = getInt(context.id, SkillViewProperty_Delay);
			ec.times = getInt(context.id, SkillViewProperty_Times);
			ec.owner = magicOwner;//context.target;
			//return createEffect(EffectType_MultiTimes, &ec, sizeof(EffectContext_MultiTimes));

			EffectControl_MultiTimes* ctrl = new EffectControl_MultiTimes();
			if (!ctrl->create(ec))
			{
				delete ctrl;
				return false;
			}

			ctrl->setSrc(context.src);
			ctrl->setViewId(context.id);
			EffectControlManager::getInstance().add(ctrl);
			return true;
#endif
		}
		break;

	case EffectType_Area:
		{
			EffectContext_Area ec;
			ec.magicId = magicId;
			ec.loops = 1;
			ec.angle = magicAngle;
			ec.owner = magicOwner;//0;
			ec.tile = context.ptCenter;
			ec.interval = getInt(context.id, SkillViewProperty_Delay);
			ec.life = getInt(context.id, SkillViewProperty_LifeTime);
            
            IntArray& intArray = getIntArray(context.id, SkillViewProperty_AttackRange);
			ec.arr = &intArray;
			//return createEffect(EffectType_Area, &ec, sizeof(EffectContext_Area));

			EffectControl_Area* ctrl = new EffectControl_Area();
			if (!ctrl->create(ec))
			{
				delete ctrl;
				return false;
			}

			ctrl->setSrc(context.src);
			ctrl->setViewId(context.id);
			EffectControlManager::getInstance().add(ctrl);
			return true;
		}
		break;

	case EffectType_MultiDir:
		{
			const IntArray& arr = getIntArray(context.id, SkillViewProperty_AttackRange);
			if (arr.count != 3)
				return false;

			EffectContext_MultiDir ec;
			ec.magicId = magicId;
			ec.loops = -1;
			ec.angle = magicAngle;
			ec.owner = context.src;
			ec.tile = context.ptCenter;
			ec.moveSpeed = getFloat(context.id, SkillViewProperty_FlySpeed);
			ec.dirs = arr.data[2];
			ec.blockType = 0;
			ec.width = arr.data[0];
			ec.maxDist = arr.data[1];
			ec.pt = pSourceEntityView->getTile();
			//return createEffect(EffectType_MultiDir, &ec, sizeof(EffectContext_MultiDir));

			EffectControl_MultiDir* ctrl = new EffectControl_MultiDir();
			if (!ctrl->create(ec))
			{
				delete ctrl;
				return false;
			}

			ctrl->setSrc(context.src);
			ctrl->setViewId(context.id);
			EffectControlManager::getInstance().add(ctrl);
			return true;
		}
		break;

	case EffectType_RapidMove:
		{
			//  创建爆炸光效;
			int nExplodeMagicID = getInt(context.id, SkillViewProperty_ExplodeMagicID);
			if (nExplodeMagicID != 0)
			{
				EffectContext_General ec;
				ec.magicId = nExplodeMagicID;
				ec.loops = 1;
				ec.angle = magicAngle;
				//  读取一下爆炸光效是否绑定在目标上;
				int nExplodeMagicAttachToTarget = getInt(context.id, SkillViewProperty_ExplodeMagicAttachToTarget);
				if (nExplodeMagicAttachToTarget == 1)
				{
					ec.owner = context.target;
				}
				else
				{
					ec.owner = 0;
				}
				ec.tile = context.ptTarget;
				EffectControl_General* ctrl = new EffectControl_General();
				if (!ctrl->create(ec))
				{
					delete ctrl;
					return false;
				}
				ctrl->setSrc(context.src);
				ctrl->setViewId(context.id);
				EffectControlManager::getInstance().add(ctrl);
			}

			//  创建瞬移特效;
			EffectContext_RapidMove ec;
			ec.magicId = magicId;
			ec.loops = -1;
			ec.angle = magicAngle;
			ec.owner = context.src;
			ec.tile = context.ptCenter;
			ec.ac = ac;

			EffectControl_RapidMove* ctrl = new EffectControl_RapidMove();
			if (!ctrl->create(ec))
			{
				delete ctrl;
				return false;
			}

			ctrl->setSrc(context.src);
			ctrl->setViewId(context.id);
			EffectControlManager::getInstance().add(ctrl);

			return true;
		}
		break;

	case EffectType_DestRapidMove:
		{
			EffectContext_RapidMove ec;
			ec.magicId = magicId;
			ec.loops = -1;
			ec.angle = magicAngle;
			ec.owner = context.target;
			ec.tile = context.ptCenter;
			ec.ac = ac;

			EffectControl_RapidMove* ctrl = new EffectControl_RapidMove();
			if (!ctrl->create(ec))
			{
				delete ctrl;
				return false;
			}

			ctrl->setSrc(context.src);
			ctrl->setViewId(context.id);
			EffectControlManager::getInstance().add(ctrl);
			return true;
		}
		break;

	case EffectType_SrcDestRapidMove:
		{
			EffectContext_RapidMove ecSrc;
			ecSrc.magicId = magicId;
			ecSrc.loops = -1;
			ecSrc.angle = magicAngle;
			ecSrc.owner = context.src;
			ecSrc.tile = context.ptTarget;
			ecSrc.ac = ac;

			EffectControl_RapidMove* ctrlSrc = new EffectControl_RapidMove();
			if (!ctrlSrc->create(ecSrc))
			{
				delete ctrlSrc;
				return false;
			}

			ctrlSrc->setSrc(context.src);
			ctrlSrc->setViewId(context.id);
			EffectControlManager::getInstance().add(ctrlSrc);
			//return true;
			//  创建爆炸光效;
			int nExplodeMagicID = getInt(context.id, SkillViewProperty_ExplodeMagicID);
			if (nExplodeMagicID != 0)
			{
				EffectContext_General ec;
				ec.magicId = nExplodeMagicID;
				ec.loops = 1;
				ec.angle = magicAngle;
				//  读取一下爆炸光效是否绑定在目标上;
				int nExplodeMagicAttachToTarget = getInt(context.id, SkillViewProperty_ExplodeMagicAttachToTarget);
				if (nExplodeMagicAttachToTarget == 1)
				{
					ec.owner = context.target;
				}
				else
				{
					ec.owner = 0;
				}
				ec.tile = context.ptTarget;
				EffectControl_General* ctrl = new EffectControl_General();
				if (!ctrl->create(ec))
				{
					delete ctrl;
					return false;
				}
				ctrl->setSrc(context.src);
				ctrl->setViewId(context.id);
				EffectControlManager::getInstance().add(ctrl);
			}

			EffectContext_RapidMove ecDest;
			ecDest.magicId = magicId;
			ecDest.loops = -1;
			ecDest.angle = magicAngle;
			ecDest.owner = context.target;
			ecDest.tile = context.ptCenter;
			ecDest.ac = ac;

			EffectControl_RapidMove* ctrlDest = new EffectControl_RapidMove();
			if (!ctrlDest->create(ecDest))
			{
				delete ctrlDest;
				return false;
			}

			ctrlDest->setSrc(context.src);
			ctrlDest->setViewId(context.id);
			EffectControlManager::getInstance().add(ctrlDest);
			return true;
		}
		break;

		//跳跃类
	case EffectType_Jump:
		{
			EffectContext_RapidMove ec;
			ec.magicId = magicId;
			ec.loops = -1;
			ec.angle = magicAngle;
			ec.owner = context.src;
			ec.tile = context.ptCenter;
			ec.ac = ac;

			EffectControl_Jump* ctrl = new EffectControl_Jump();
			if (!ctrl->create(ec))
			{
				delete ctrl;
				return false;
			}

			ctrl->setSrc(context.src);
			ctrl->setViewId(context.id);
			EffectControlManager::getInstance().add(ctrl);
			return true;
		}
		break;
	}

	return true;
}
Пример #12
0
bool EntityFactory::createSkillAttackEffect(const SkillEffectContext& context)
{
	EntityView* pSourceEntityView = (EntityView*)getHandleData(context.src);
	if ((pSourceEntityView == NULL) || (context.id == 0))
	{
		ASSERT(false);
		return false;
	}

	// 是否需调整光效方向
	long magicAngle = 0;
	if (getInt(context.id, SkillViewProperty_NotAdjustDir) == 1)
    {
       magicAngle = pSourceEntityView->getAngle();
    }

	// 生物发起攻击动作
	AttackContext ac;

	// 取得配置的多个攻击动作中随机的一个
	int nActionId;
	const IntArray & AttackActId = getIntArray(context.id, SkillViewProperty_AttackActId);
	int nCount = AttackActId.count;

	if (nCount == 1)
	{
		nActionId = AttackActId.data[0];
	}
	else if (nCount > 1)
	{
		int nIndex = getRand(1, nCount);
		nActionId = AttackActId.data[nIndex - 1];
	}
	else
	{
		nActionId = 0;
	}

	ac.actionId = nActionId;

	ac.loops = context.loops;
	ac.fAnimateSpeed = getFloat(context.id, SkillViewProperty_AttackActSpeed);
	ac.isSpellAttack = context.isSpellSkill;
    //  冲锋技能是在瞬移效果完成后再做攻击动作;
	ulong effectType = getInt(context.id, SkillViewProperty_EffectType);
	if ( effectType != EffectType_Jump
		/*&& effectType != EffectType_RapidMove*/) // modify by zjp;冲锋的过程中做动作
	{
		if (ac.actionId!=0)		
		{
			//bool bMounted = false;
			//pSourceEntityView->onCommand(EntityCommand_GetMount, (ulong)&bMounted);
			//if (bMounted)
			{
				pSourceEntityView->onCommand(EntityCommand_SetMount, 0);
			}
			pSourceEntityView->onCommand(EntityCommand_Attack, (ulong)&ac);
		}
	}
    //  捆仙索在完成后也不需要做动作  
	if (effectType == EffectType_DestRapidMove || effectType == EffectType_SrcDestRapidMove)
    {
        ac.actionId = 0;
    }

    //  施法光效;
    int nAttackMagicID = getInt(context.id, SkillViewProperty_AttackMagicId);
    if (nAttackMagicID != 0)
    {
        EffectContext_General ec;
        ec.magicId = nAttackMagicID;
        ec.loops = 1;
        ec.angle = magicAngle;
		//  读取一下光效是否绑定在源上;
		int nAttackMagicAttachToSource = getInt(context.id, SkillViewProperty_AttackMagicAttachToSource);
		if (nAttackMagicAttachToSource == 1)
		{
			ec.owner = context.src;
		}
		else
		{
			ec.owner = 0;
		}
		// modify by zjp.修改特效释放的位置
		//ec.tile = pSourceEntityView->getTile();
		ec.tile = context.ptCenter;

        EffectControl_General* ctrl = new EffectControl_General();
        if (!ctrl->create(ec))
        {
            delete ctrl;
            return false;
        }
        ctrl->setSrc(context.src);
        ctrl->setViewId(context.id);
        EffectControlManager::getInstance().add(ctrl);
    }

	//播放攻击声效
	const IntArray & nSoundIDArray = getIntArray(context.id,SkillViewProperty_SoundIDAttack);
	int nSoundCount = nSoundIDArray.count;
	int nSoundID = 0;
	if (nSoundCount == 1)
	{
		nSoundID = nSoundIDArray.data[0];
	}
	else if (nSoundCount > 1)
	{
		IEntity* pEntity = (IEntity*)pSourceEntityView->getUserData();
		if (pEntity && pEntity->GetEntityClass()->IsPerson())
		{
			int PersonSex = pEntity->GetNumProp(CREATURE_PROP_SEX);
			if (PersonSex == PERSON_SEX_MALE)
			{
				nSoundID = nSoundIDArray.data[0];
			}
			else if(PersonSex == PERSON_SEX_FEMALE)
			{
				nSoundID = nSoundIDArray.data[1];
			}
		}
	}
	int nSoundLoop = getInt(context.id,SkillViewProperty_bSoundLoopeAttack);
	if (nSoundID>1000)
	{
		IFormManager* pFormManger = gGlobalClient->getFormManager();
		if (pFormManger)
		{
			pFormManger->PlaySound(nSoundID,nSoundLoop,0.8,SOUNDRES_TYPE_SOUND);
		}
	}

	return true;
}