SKILL_RESULT_CODE CastOnCasterSingle(KCharacter pDisplayCaster, KCharacter pLogicCaster) { SKILL_RESULT_CODE nResult = SKILL_RESULT_CODE.srcFailed; int nRetCode = 0; KSKILL_BULLET pBullet = new KSKILL_BULLET(); KTarget pTarget = new KTarget(); nRetCode = pTarget.SetTarget(pDisplayCaster); if (nRetCode == 0) { goto Exit0; } nRetCode = SetupBullet(pBullet, pLogicCaster, ref pTarget); if (nRetCode == 0) { goto Exit0; } if (pBullet.nEndFrame > FirstFightMgr.Instance().m_nGameLoop) { pLogicCaster.AddBullet(pBullet); } else { ApplyOnSingle(pBullet); } nResult = SKILL_RESULT_CODE.srcSuccess; Exit0: return(nResult); }
SKILL_RESULT_CODE CastOnCasterArea(KCharacter pDisplayCaster, KCharacter pLogicCaster) { SKILL_RESULT_CODE nResult = SKILL_RESULT_CODE.srcFailed; int nRetCode = 0; KTarget pTarget = new KTarget(); KSKILL_BULLET pBullet = new KSKILL_BULLET(); float fX = 0f; float fZ = 0f; nRetCode = pTarget.SetTarget(pDisplayCaster); if (nRetCode == 0) { goto Exit0; } nRetCode = SetupBullet(pBullet, pLogicCaster, ref pTarget); if (nRetCode == 0) { goto Exit0; } if (pBullet.nEndFrame > FirstFightMgr.Instance().m_nGameLoop) { pLogicCaster.AddBullet(pBullet); } else { pDisplayCaster.GetAbsoluteCoordinate(ref fX, ref fZ); nRetCode = (int)ApplyOnArea(pBullet, fX, fZ); } nResult = SKILL_RESULT_CODE.srcSuccess; Exit0: return(nResult); }
public KNpc NewNpc() { int nRetCode = 0; bool bNpcRegFlag = false; KNpc pResult = null; KNpc pNpc = new KNpc(); nRetCode = FirstFightMgr.Instance().m_NpcSet.Register(pNpc, 0); if (nRetCode == 0) { goto Exit0; } bNpcRegFlag = true; nRetCode = pNpc.Init(); if (nRetCode == 0) { goto Exit0; } pResult = pNpc; Exit0: if (pResult == null) { if (bNpcRegFlag) { FirstFightMgr.Instance().m_NpcSet.Unregister(pNpc); bNpcRegFlag = false; } } return(pResult); }
public void Active() { if (m_nPendingEvent != (int)KAI_EVENT.aevInvalid) { int nEvent = m_nPendingEvent; m_nPendingEvent = (int)KAI_EVENT.aevInvalid; FireEvent(nEvent, m_dwPendingEventSrc, m_nPendingEventParam); } if (m_nPrimaryTimerFrame != 0 && FirstFightMgr.Instance().m_nGameLoop > m_nPrimaryTimerFrame) { m_nPrimaryTimerFrame = 0; FireEvent((int)KAI_EVENT.aevOnPrimaryTimer, m_pOwner.m_dwID, FirstFightMgr.Instance().m_nGameLoop); } if (m_nSecondaryTimerFrame != 0 && FirstFightMgr.Instance().m_nGameLoop > m_nSecondaryTimerFrame) { m_nSecondaryTimerFrame = 0; FireEvent((int)KAI_EVENT.aevOnSecondaryTimer, m_pOwner.m_dwID, FirstFightMgr.Instance().m_nGameLoop); } if (m_nTertiaryTimerFrame != 0 && FirstFightMgr.Instance().m_nGameLoop > m_nTertiaryTimerFrame) { m_nTertiaryTimerFrame = 0; FireEvent((int)KAI_EVENT.aevOnTertiaryTimer, m_pOwner.m_dwID, FirstFightMgr.Instance().m_nGameLoop); } }
private bool CheckDie() { bool bResult = false; if (m_bToDie == false) { goto Exit0; } if (false) { } else { KNpc pNpc = (KNpc)this; pNpc.m_nCurrentLife = 0; pNpc.SetMoveState(CHARACTER_MOVE_STATE.cmsOnDeath); FirstFightMgr.Instance().DeleteNpc((KNpc)this); } bResult = true; Exit0: return(bResult); }
public void CheckBullet() { KSKILL_BULLET pBullet = null; if (m_pBulletListHead == null) { goto Exit0; } if (m_pBulletListHead.nEndFrame > FirstFightMgr.Instance().m_nGameLoop) { goto Exit0; } pBullet = m_pBulletListHead; m_pBulletListHead = m_pBulletListHead.pNext; ProcessBullet(pBullet); pBullet = null; Exit0: return; }
public int GetTarget(ref KCharacter ppCharacter) { int nResult = 0; switch (m_eTargetType) { case TARGET_TYPE.ttNpc: KNpc pNpc = FirstFightMgr.Instance().m_NpcSet.GetObj(m_dwID); if (pNpc == null) { goto Exit0; } ppCharacter = (KCharacter)pNpc; break; case TARGET_TYPE.ttPlayer: KPlayer pPlayer = FirstFightMgr.Instance().m_PlayerSet.GetObj(m_dwID); if (pPlayer == null) { goto Exit0; } ppCharacter = (KCharacter)pPlayer; break; default: goto Exit0; } nResult = 1; Exit0: return(nResult); }
/** * @brief 更新 * @param */ override public void Update(float dt) { KDownloadInstance.Instance().Update(); // 限帧 //float fCurTime = Time.realtimeSinceStartup; //if (fCurTime - m_fLastUpdateTime < 0.1f) //{ // return; //} //m_fLastUpdateTime = fCurTime; //Profiler.BeginSample("ClientGlobal.Update"); /// 逻辑层更新 ClientGlobal.Instance().Update(dt); //Profiler.EndSample(); FirstFightMgr.Instance().FrameMove(dt); //Profiler.BeginSample("DataManager.Update"); //管理器Process DataManager.Instance.Process(dt); //Profiler.EndSample(); //卸载资源 ProcessUnloadUnuseAsset(); base.Update(dt); // Profiler.EndSample(); }
public static FirstFightMgr Instance() { if (FirstFightMgr.s_Instance == null) { FirstFightMgr.s_Instance = new FirstFightMgr(); } return(FirstFightMgr.s_Instance); }
public void SetTertiaryTimer(uint nFrame) { if (nFrame <= 0) { return; } m_nTertiaryTimerFrame = FirstFightMgr.Instance().m_nGameLoop + nFrame; }
public SKILL_RESULT_CODE CastSkill(uint dwSkillID, ref KTarget pTarget) { int nRetCode = 0; SKILL_RESULT_CODE nResult = SKILL_RESULT_CODE.srcFailed; KCharacter pTargetCharacter = null; if (m_pEntity == null) { return(SKILL_RESULT_CODE.srcFailed); } ISkillPart skillPart = m_pEntity.GetPart(EntityPart.Skill) as ISkillPart; if (skillPart == null) { return(SKILL_RESULT_CODE.srcFailed); } if (pTarget == null) { return(SKILL_RESULT_CODE.srcFailed); } nRetCode = pTarget.GetTarget(ref pTargetCharacter); if (nRetCode == 0 || pTargetCharacter == null) { return(SKILL_RESULT_CODE.srcFailed); } IEntity targetEntity = pTargetCharacter.m_pEntity; if (targetEntity == null) { return(SKILL_RESULT_CODE.srcFailed); } skillPart.ReqNpcUseSkill(targetEntity, dwSkillID); // KSkill pSkill = FirstFightMgr.Instance().m_SkillManager.GetSkill(dwSkillID); pSkill.Cast(this, this, ref pTarget); //测试代码 // 伤害飘子 //FlyFontDataManager.Instance.ShowDamage(999, 1, pTargetCharacter.m_dwID, EntityType.EntityType_NPC, 1000000); //pTargetCharacter.Test_ConcludeResult(); nResult = SKILL_RESULT_CODE.srcSuccess; Exit0: return(nResult); }
public bool Setup(KCharacter pCharacter, int nAIType) { bool bResult = false; bool bRetCode = false; KAILogic pAILogic = null; int nInitState = 0; if (m_nCurrentEvent != 0) { goto Exit0; } m_pOwner = pCharacter; if (nAIType == 0) { // 清除原有AI类型 m_pAILogic = null; goto Exit1; } pAILogic = FirstFightMgr.Instance().m_AIManager.GetAILogic(nAIType); if (pAILogic == null) { //error goto Exit0; } m_nAIType = nAIType; m_pAILogic = pAILogic; nInitState = m_pAILogic.GetInitState(); bRetCode = SetState(nInitState); if (bRetCode == false) { //error goto Exit0; } m_nPrimaryTimerFrame = 0; m_nSecondaryTimerFrame = 0; m_nTertiaryTimerFrame = 0; m_nCurrentEvent = 0; FireEvent((int)KAI_EVENT.aevOnPrimaryTimer, m_pOwner.m_dwID, FirstFightMgr.Instance().m_nGameLoop); Exit1: bResult = true; Exit0: return(bResult); }
public int SetTarget(TARGET_TYPE eType, uint dwID) { int nResult = 0; switch (eType) { case TARGET_TYPE.ttNoTarget: break; case TARGET_TYPE.ttNpc: { KNpc pNpc = null; pNpc = FirstFightMgr.Instance().m_NpcSet.GetObj(dwID); if (pNpc == null) { goto Exit0; } break; } case TARGET_TYPE.ttPlayer: { KPlayer pPlayer = null; pPlayer = FirstFightMgr.Instance().m_PlayerSet.GetObj(dwID); if (pPlayer == null) { goto Exit0; } break; } break; default: //error break; } ; m_eTargetType = eType; m_dwID = dwID; nResult = 1; Exit0: if (nResult == 0) { m_eTargetType = TARGET_TYPE.ttNoTarget; } return(nResult); }
public static int CastSkill(KCharacter pCharacter, uint dwSkillID, uint dwSkillLevel, int nAISkillType) { int nResult = 0; int nRetCode = 0; KCharacter pTarget = null; KSkill pSkill = null; if (!(pCharacter.m_eMoveState < CHARACTER_MOVE_STATE.cmsOnDeath)) { return(2); } pCharacter.m_pSkillTarget = pCharacter.m_pSelectTarget; if (pCharacter.m_pSkillTarget.GetTargetType() == TARGET_TYPE.ttNpc || pCharacter.m_pSkillTarget.GetTargetType() == TARGET_TYPE.ttPlayer) { nRetCode = pCharacter.m_pSkillTarget.GetTarget(ref pTarget); if (nRetCode == 0 || pTarget == null) { goto Exit0; } } pSkill = FirstFightMgr.Instance().m_SkillManager.GetSkill(dwSkillID); if (pSkill == null) { goto Exit0; } nRetCode = (int)pSkill.CanCast(pCharacter, ref pCharacter.m_pSkillTarget); switch (nRetCode) { case (int)SKILL_RESULT_CODE.srcInvalidTarget: case (int)SKILL_RESULT_CODE.srcTooCloseTarget: case (int)SKILL_RESULT_CODE.srcTooFarTarget: break; } if (nRetCode != (int)SKILL_RESULT_CODE.srcSuccess) { return(2); } nRetCode = (int)pCharacter.CastSkill(dwSkillID, ref pCharacter.m_pSkillTarget); if (nRetCode != (int)SKILL_RESULT_CODE.srcSuccess) { return(2); } nResult = 1; Exit0: return(nResult); }
public KAIAction NewAction(int nActionID, int nActionKey) { if (nActionID <= KAIAction.KAI_ACTION_ID_NONE) { //error goto Exit0; } if (nActionKey <= (int)KAI_ACTION_KEY.eakInvalid) { //error goto Exit0; } if (nActionKey < KAIAction.KAI_USER_ACTION) { KAIManager.KAI_ACTION_FUNC pFucAction = null; pFucAction = FirstFightMgr.Instance().m_AIManager.GetActionFunction(nActionKey); if (pFucAction == null) { //error goto Exit0; } } else { //error goto Exit0; } if (m_ActionTable.ContainsKey(nActionID)) { //error goto Exit0; } KAIAction pAIAction = new KAIAction(); pAIAction.m_nKey = nActionKey; m_ActionTable.Add(nActionID, pAIAction); return(pAIAction); Exit0: return(null); }
public static int AINpcKeepSkillCastRange(KCharacter pCharacter, KAIAction pActionData) { int nResult = 0; int nRetCode = 0; int nBranchInRange = 1; int nBranchKeep = 2; float fMinRange = 0f; float fMaxRange = 0f; uint dwSkillID = 0; KNpc pNpc = null; KSkill pSkill = null; pNpc = (KNpc)pCharacter; dwSkillID = pNpc.m_pTemplate.dwSkillIDList[pNpc.m_nSkillSelectIndex]; if (dwSkillID == 10001) { int gg = 0; } pSkill = FirstFightMgr.Instance().m_SkillManager.GetSkill(dwSkillID); if (pSkill == null) { goto Exit0; } fMinRange = pSkill.m_fMinRadius; fMaxRange = pSkill.m_fMaxRadius; nRetCode = KeepRange(pCharacter, fMinRange, fMaxRange); if (!(nRetCode > 0)) { goto Exit0; } if (nRetCode == 1) { nResult = nBranchInRange; goto Exit0; } nResult = nBranchKeep; Exit0: return(nResult); }
//以目标为中心的圆形区域 SKILL_RESULT_CODE CastOnTargetArea(KCharacter pDisplayCaster, KCharacter pLogicCaster, ref KTarget rTarget) { SKILL_RESULT_CODE nResult = SKILL_RESULT_CODE.srcFailed; int nRetCode = 0; KSKILL_BULLET pBullet = new KSKILL_BULLET(); float fTargetX = 0f; float fTargetZ = 0f; nRetCode = SetupBullet(pBullet, pLogicCaster, ref rTarget); if (nRetCode == 0) { goto Exit0; } if (pBullet.nEndFrame > FirstFightMgr.Instance().m_nGameLoop) { pLogicCaster.AddBullet(pBullet); } else { nRetCode = rTarget.GetTarget(ref fTargetX, ref fTargetZ); if (nRetCode == 0) { goto Exit0; } nRetCode = (int)ApplyOnSingle(pBullet); if (nRetCode != (int)SKILL_RESULT_CODE.srcSuccess) { return((SKILL_RESULT_CODE)nRetCode); } nRetCode = (int)ApplyOnArea(pBullet, fTargetX, fTargetZ); if (nRetCode != (int)SKILL_RESULT_CODE.srcSuccess) { return((SKILL_RESULT_CODE)nRetCode); } } nResult = SKILL_RESULT_CODE.srcSuccess; Exit0: return(nResult); }
public static int AINpcCastSelectSkill(KCharacter pCharacter, KAIAction pActionData) { int nResult = 0; int nRetCode = 0; int nBranchSuccess = 1; int nBranchFailed = 2; int nSelectIndex = 0; KNpc pNpc = null; uint dwSkillID = 0; pNpc = (KNpc)pCharacter; nSelectIndex = pNpc.m_nSkillSelectIndex; dwSkillID = pNpc.m_pTemplate.dwSkillIDList[nSelectIndex]; if (FirstFightMgr.Instance().m_nGameLoop < pNpc.m_nSkillCommomCD) { return(nBranchFailed); } if (FirstFightMgr.Instance().m_nGameLoop < pNpc.m_nSkillCastFrame[nSelectIndex]) { return(nBranchFailed); } nRetCode = CastSkill(pCharacter, dwSkillID, 0, (int)AI_SKILL_TYPE.aistInvalid); if (nRetCode <= 0) { goto Exit0; } if (nRetCode == 1) { pNpc.m_nSkillCastFrame[nSelectIndex] = (int)FirstFightMgr.Instance().m_nGameLoop + pNpc.m_pTemplate.nSkillCastInterval[nSelectIndex]; pNpc.m_nSkillCommomCD = (int)FirstFightMgr.Instance().m_nGameLoop + 1; nResult = nBranchSuccess; goto Exit0; } nResult = nBranchFailed; Exit0: return(nResult); }
// 这里是否需要ref 参数 public int DeleteNpc(KNpc pNpc) { if (pNpc == null) { //error } if (pNpc.m_pScene != null) { RemoveNpc(pNpc); } pNpc.UnInit(); FirstFightMgr.Instance().m_NpcSet.Unregister(pNpc); pNpc = null; return(1); }
public int GetTarget(ref float pfX, ref float pfZ) { int nResult = 0; switch (m_eTargetType) { case TARGET_TYPE.ttNpc: { KNpc pNpc = FirstFightMgr.Instance().m_NpcSet.GetObj(m_dwID); if (pNpc == null) { goto Exit0; } pNpc.GetAbsoluteCoordinate(ref pfX, ref pfZ); break; } case TARGET_TYPE.ttPlayer: { KPlayer pPlayer = FirstFightMgr.Instance().m_PlayerSet.GetObj(m_dwID); if (pPlayer == null) { goto Exit0; } pPlayer.GetAbsoluteCoordinate(ref pfX, ref pfZ); } break; default: goto Exit0; } nResult = 1; Exit0: return(nResult); }
int SetupBullet(KSKILL_BULLET pBullet, KCharacter pCaster, ref KTarget rTarget) { int nResult = 0; int nRetCode = 0; float fCasterX = 0f; float fCasterZ = 0f; float fTargetX = 0f; float fTargetZ = 0f; KCharacter pTarget = null; float fTouchRange = 0f; float fDistance = 0f; float fHitDelay = 0f; if (pBullet == null) { goto Exit0; } if (pCaster == null) { goto Exit0; } if (rTarget == null) { goto Exit0; } pBullet.dwBulletID = FirstFightMgr.Instance().m_SkillManager.m_dwBulletIDIndex++; pBullet.pTarget = rTarget; pBullet.pSkillSrc = pCaster; pBullet.dwSkillSrcID = pCaster.m_dwID; pBullet.pSkillPointer = this; pBullet.pNext = null; switch (m_pBaseInfo.nCastMode) { case KSKILL_CAST_MODE.scmTargetSingle: break; default: break; } pCaster.GetAbsoluteCoordinate(ref fCasterX, ref fCasterZ); rTarget.GetTarget(ref fTargetX, ref fTargetZ); nRetCode = rTarget.GetTarget(ref pTarget); if (pTarget != null) { fTouchRange = pTarget.m_fTouchRange; } fDistance = KAI_SEARCH_CHARACTER.s_GetDistance2(fCasterX, fCasterZ, fTargetX, fTargetZ); if (fDistance > fTouchRange) { fDistance -= fTouchRange; } if (m_fBulletVelocity > 0f) { fHitDelay = (fDistance / m_fBulletVelocity); } int nHitDelay = ((int)(fHitDelay * 16)) + (int)FirstFightMgr.Instance().m_nGameLoop + m_pBaseInfo.nHitDelay; pBullet.nEndFrame = nHitDelay; nResult = 1; Exit0: return(nResult); }
public KAIActionHandle CallAction(KCharacter pCharacter, KAIActionHandle pActionKey) { KAIActionHandle pResult = new KAIActionHandle(); KAIActionHandle pNextAction = new KAIActionHandle(); KAIAction pAction = pActionKey.pAIAction; int nActionKey = 0; if (pAction == null) { pAction = GetAction(pActionKey.nAIActionID); } if (pAction == null) { //error goto Exit0; } nActionKey = pAction.m_nKey; if (nActionKey < KAIAction.KAI_USER_ACTION) { int nBranchIndex = 0; ulong ulPrevTickCount = 0; ulong ulPostTickCount = 0; KAIManager.KAI_ACTION_FUNC PAction = null; PAction = FirstFightMgr.Instance().m_AIManager.GetActionFunction(nActionKey); if (PAction == null) { //error goto Exit0; } nBranchIndex = PAction(pCharacter, pAction); if (nBranchIndex > 0 && nBranchIndex <= KAIAction.KAI_ACTION_BRANCH_NUM) { int nNextActionID = pAction.m_nBranch[nBranchIndex - 1]; KAIAction pNextActionTemp = pAction.m_pBranch[nBranchIndex - 1]; if (pNextActionTemp == null) { pNextActionTemp = GetAction(nNextActionID); pAction.m_pBranch[nBranchIndex - 1] = pNextActionTemp; } pNextAction.nAIActionID = nNextActionID; pNextAction.pAIAction = pNextActionTemp; } if (nBranchIndex == -1) { pNextAction.nAIActionID = KAIAction.KAI_ACTION_ID_NONE; pNextAction.pAIAction = null; } } else { // 没做 //error } pResult = pNextAction; Exit0: return(pResult); }