// 快速转向并释放技能aa public void QuickSkill(Vector2 v, int iSkillID) { if (mMainCamera == null) { return; } Ray ray = mMainCamera.ScreenPointToRay(v); sdActorInterface monster = PickupMonster(ray); if (monster == null) { Vector3 terrainPosition = new Vector3(); if (FingerGesturesInitializer.NavMesh_RayCast(ray, ref terrainPosition, 100000.0f)) { Vector3 charPosition = GetPosition(); Vector3 nextDirection = terrainPosition - charPosition; MoveDir(nextDirection); fStopTime = 0.3f; } } else { Vector3 monsterPosition = monster.transform.position; Vector3 charPosition = GetPosition(); Vector3 nextDirection = monsterPosition - charPosition; MoveDir(nextDirection); fStopTime = 0.3f; } CastSkill(iSkillID); }
static sdActorInterface GetNearestMonster(List <sdActorInterface> lstMonserHit, Vector3 vPos, List <sdActorInterface> lstMonster) { Vector3 vTempPos = vPos; sdActorInterface ret = null; float fDis = 10000.0f; lstMonster.ForEach(delegate(sdActorInterface monster) { bool bIsInList = false; foreach (sdGameMonster obj in lstMonserHit) { if (monster == obj && !bIsInList) { bIsInList = true; vTempPos = obj.transform.position; } } //lstMonserHit if (!bIsInList) { Vector3 v = monster.transform.position - vTempPos; float f = v.magnitude; if (f < fDis) { fDis = f; ret = monster; } } }); return(ret); }
// 队友受到伤害回调函数aa public virtual void OnFriendHurt(sdActorInterface kAttacker) { if (mEnable) { kAutoState.OnFriendHurt(kAttacker, this); } }
// @describe 统一的攻击判定(包括主角对怪物\宠物对怪物\怪物对主角\怪物对宠物)aa // @param[in] kAttacker 攻击者aa // @param[in] kSkillInfo 攻击技能属性表aa // @param[in] kStrikeCenter 攻击中心aa // @param[in] iHitPointIndex // @param[in,out] kCallback 攻击回调aa public virtual int DoSDAttack(sdActorInterface kAttacker, Hashtable kSkillAction, Vector3 kStrikeCenter, int iHitPointIndex, sdAttackCB kCallback) { int iStrikeType = (int)kSkillAction["byAoeAreaType"]; int iStrikeAngle = (int)kSkillAction["nAoeAreaData"]; float fStrikeDistance = (float)kSkillAction["nAoeArea"] * 0.001f; //int iStrikeCenterType = (int)kSkillAction["byAoeCenterType"]; int iStrikeCenterOffset = 0; // if (kSkillAction.ContainsKey("nAoeCenterData")) { iStrikeCenterOffset = (int)kSkillAction["nAoeCenterData"]; } Vector3 vFixedCenter = kStrikeCenter + kAttacker.GetDirection() * (float)iStrikeCenterOffset * 0.001f; return(DoSDAttack(kAttacker, kSkillAction, iStrikeType, vFixedCenter, fStrikeDistance, iStrikeAngle, iHitPointIndex, kCallback)); }
public bool AddBuffLayer(int id, Hashtable buffinfo, sdActorInterface casterActor) { int iMaxLayerCount = (int)buffinfo["byAugment"]; if (iMaxLayerCount > 1) { int isShare = (int)buffinfo["IsShare"]; sdBuff layeredBuff = null; if (isShare != 0) { layeredBuff = FindBuffByCastActor(id, casterActor); } else { layeredBuff = FindBuff(id); } if (layeredBuff != null) { layeredBuff.AddLayer(); if (!layeredBuff.IsHide()) { BuffChange(buffs); } return(true); } } return(false); }
// 切换目标aa public void OnChangeTarget(sdActorInterface kActor, sdActorInterface kPreviousTarget, sdActorInterface kTarget) { mPreviousTarget = kPreviousTarget; mTarget = kTarget; mBehaviourStateEventType = EBehaviourStateEventType.enBSET_Target; //< 当次事件类型aa }
// 宠物被杀死回调aa protected void OnPetKilled(sdActorInterface kMonster) { int iLastActivePetIndex = sdNewPetMgr.Instance.ActivePetIndex; sdNewPetMgr.Instance.DeactivePet(); ActiveNextPet(iLastActivePetIndex); }
// 战斗系统切换攻击目标事件(注册到战斗系统的事件回调)aa protected void NotifyBattleSystemChangeTarget(sdActorInterface kActor, sdActorInterface kPreviousTarget, sdActorInterface kTarget) { if (NotifyChangeTarget != null) { NotifyChangeTarget(kActor, kPreviousTarget, kTarget); } if (GetActorType() == ActorType.AT_Player) { if (!mLoadTargetEffect) { LoadTargetEffect(); } mTargetEffectTarget = kTarget; if (kTarget == null) { if (mTargetEffect != null) { mTargetEffect.SetActive(false); } } } }
// 节点中的怪物掉血事件回调aa protected void NotifyHurt(sdActorInterface kActor, sdActorInterface kAttacker, int iHP) { if (NotifyMemberHurt != null) { NotifyMemberHurt(kActor, kAttacker, iHP); } }
sdBuff FindBuffByCastActor(int id, sdActorInterface castActor) { sdBuff buff = null; for (int i = 0; i < buffs.Count; i++) { buff = buffs[i]; if (buff.GetTemplateID() == id) { if (castActor == buff.m_CasterActor || castActor == null) { return(buff); } } } for (int i = 0; i < HideBuffs.Count; i++) { buff = HideBuffs[i]; if (buff.GetTemplateID() == id) { if (castActor == buff.m_CasterActor || castActor == null) { return(buff); } } } return(null); }
// 节点中的怪物掉血事件回调aa protected void NotifyChangeTarget(sdActorInterface kActor, sdActorInterface kPreciousTarget, sdActorInterface kTarget) { if (NotifyMemberChangeTarget != null) { NotifyMemberChangeTarget(kActor, kPreciousTarget, kTarget); } }
// // 角色移动(继承自sdGameActor)aa // public override void moveInternal(Vector3 delta) // { // if (mMotionController == null) // return; // // CollisionFlags flags = mMotionController.Move(delta*Time.deltaTime); // if (sdGameLevel.instance != null && sdGameLevel.instance.AutoMode) // { // if((int)(flags&CollisionFlags.Sides) != 0) // { // if (mBlocked) // { // mBlockedTime += Time.deltaTime; // if (mBlockedTime > 3.0f) // { // mBlocked = false; // mBlockedTime = 0.0f; // sdGameLevel.instance.ClearMainCharacterMove(); //< 如果被阻挡超过3s则清空移动数据aa // } // } // else // { // mBlocked = true; // mBlockedTime = 0.0f; // } // } // else // { // mBlocked = false; // mBlockedTime = 0.0f; // } // } // } // 阻挡回调aa protected void NotifyFindBlocked(sdActorInterface kActor) { if (sdGameLevel.instance != null && sdGameLevel.instance.AutoMode) { sdGameLevel.instance.ClearMainCharacterMove(); //< 如果被阻挡超过3s则清空移动数据aa } }
// 切换攻击目标(战斗系统内部调用)aa public void OnChangeTarget(sdActorInterface kPreviousTarget, sdActorInterface kTarget) { if (NotifyChangeTarget != null) { NotifyChangeTarget(mActor, kPreviousTarget, kTarget); } }
//查找dis范围内与dir夹角最小的actor public sdActorInterface FindNearestAngle(sdActorInterface actor, HeaderProto.ESkillObjType objType, Vector3 dir, float dis, float angle) { sdActorInterface ret = null; List <sdActorInterface> lst = new List <sdActorInterface>(); lst = GetTargetActor(actor, objType, true); float fcos = Mathf.Cos(angle / 180.0f * Mathf.PI); for (int index = 0; index < lst.Count; ++index) { sdActorInterface target = lst[index]; Vector3 targetDir = target.transform.position - actor.transform.position; if (targetDir.magnitude > dis) { continue; } targetDir.y = 0; targetDir.Normalize(); Vector3 faceDir = dir; faceDir.y = 0; faceDir.Normalize(); float value = Vector3.Dot(targetDir, faceDir); if (value > fcos) { fcos = value; ret = lst[index]; } } return(ret); }
// 区域中的怪物被杀死回调aa protected void NotifyMonsterKilled(sdActorInterface kActor) { mMonsterList.Remove(kActor.gameObject); mMonsterKilledList.Add(kActor.gameObject); if (mMonsterList.Count == 0 && mSubNodeList.Count == 0) { if (!bDelayLeaveTrigger) { WhenLeaveTrigger(gameObject, new int[4] { 0, 0, 0, 0 }); } else { sdUICharacter.Instance.ShowMsgLine(sdConfDataMgr.Instance().GetShowStr("pttip1"), Color.yellow); bCanLeave = true; fDelayTime = 3.0f; } if (sdGameLevel.instance.levelType == sdGameLevel.LevelType.PET_TRAIN) { sdPTManager.Instance.AddAttack(); if (gameObject.name == "Area2")//挑战结束 { PT_End(); } } } }
// 鎬?墿缇ゆ垚鍛樺彈浼ゅ?鎴栬呭彂鐜扮?涓涓?洰鏍囧洖璋僡a public void OnAreaGroupAlert(sdActorInterface kAttacker) { if (GetActorType() == ActorType.AT_Monster) { MonsterAutoFight kMonsterAutoFight = mAutoFight as MonsterAutoFight; kMonsterAutoFight.OnFriendHurt(kAttacker); //< 鏀诲嚮缇ゆ垚鍛樿?浣滄敾鍑昏嚜宸半缇ゆ垚鍛樺彂鐜扮洰鏍囪?浣滆嚜宸卞彂鐜癮a } }
// 摇杆模式下施放技能时辅助调整方向aa protected void JoyStickCastSkill(sdSkill s) { // 翻滚技能不使用辅助施放aaa if (s.id == 1002) { return; } // 自动选取朝向上的怪物aaaa HeaderProto.ESkillObjType objType = 0; if (statePointer.bPassive) { sdBaseState state = s.GetFirstValidAction(); objType = (HeaderProto.ESkillObjType)state.stateData["byTargetType"]; } else { objType = (HeaderProto.ESkillObjType)statePointer.stateData["byTargetType"]; } float xbias = 0.0f; float ybias = 0.0f; sdGameLevel.instance.mainCharMoveControl(out xbias, out ybias); sdActorInterface actor = null; bool bTurnDir = false; // 释放技能前,检查下方向键方向范围内是否有目标,如果有就转向释放技能,没有就不转向aaa if (Mathf.Abs(xbias) > 0.1f || Mathf.Abs(ybias) > 0.1f) { Vector3 worldDir = Vector3.right * xbias + Vector3.forward * ybias; worldDir.y = 0.0f; worldDir.Normalize(); actor = sdGameLevel.instance.actorMgr.FindNearestAngle(_gameActor, objType, worldDir, 5.0f, 80.0f); if (actor != null) { //_gameActor._moveVector = worldDir; _gameActor.TargetFaceDirection = worldDir; bTurnDir = true; } } // 在角色当前方向上寻找最小夹角的目标aaa if (!bTurnDir) { actor = sdGameLevel.instance.actorMgr.FindNearestAngle(_gameActor, objType, _gameActor.GetDirection(), 5.0f, 180.0f); if (actor != null) { Vector3 dir = actor.transform.position - _gameActor.transform.position; dir.y = 0; dir.Normalize(); _gameActor.TargetFaceDirection = dir; } } }
// 获取状态aa protected void NotifyAddDebuffState(sdActorInterface kActor, HeaderProto.ECreatureActionState eState) { if (mBehaviourEventTree == null) { return; } mBehaviourStateBlock.OnAddDebuffState(kActor, eState); SyncUpdateBehaviourTree(); }
// 被召唤回调aa public void OnSummoned(sdActorInterface kActor) { mSummonedCount += 1; mMaxHP = kActor.GetMaxHP(); mPreviousHP = mMaxHP; mAccumHurtHP = 0; mBehaviourStateEventType = EBehaviourStateEventType.enBSET_Summoned; //< 当次事件类型aa }
// 血量改变回调aa protected void NotifyAddHP(sdActorInterface kActor, int iHP) { if (mBehaviourEventTree == null) { return; } mBehaviourStateBlock.OnAddHP(kActor, iHP); SyncUpdateBehaviourTree(); }
// 死亡回调aa protected void NotifyKilled(sdActorInterface kActor) { if (mBehaviourEventTree == null) { return; } mBehaviourStateBlock.OnKilled(kActor); SyncUpdateBehaviourTree(); }
// // 鐩熷弸鍒囨崲鏀诲嚮鐩?爣浜嬩欢(娉ㄥ唽鍒伴昏緫鑺傜偣鐨勪簨浠跺洖璋傝aa // protected void NotifyBehaviourChangeTarget(sdActorInterface kActor, sdActorInterface kPreviousTarget, sdActorInterface kTarget) // { // if (kActor != this) // { // if (kPreviousTarget == null && kTarget != null) // { // if (mAutoFight != null) // { // mAutoFight.OnFriendHurt(kTarget); //< 鐩熷弸鍙戠幇鐩?爣瑙嗕綔鑷?繁鍙戠幇aa // } // } // } // } // 鐩熷弸鍙椾激瀹充簨浠电娉ㄥ唽鍒伴昏緫鑺傜偣鐨勪簨浠跺洖璋傝aa protected void NotifyBehaviourNodeHurt(sdActorInterface kActor, sdActorInterface kAttacker, int iHP) { if (kActor != this) { if (mAutoFight != null) { mAutoFight.OnFriendHurt(kAttacker); //< 鏀诲嚮鐩熷弸瑙嗕綔鏀诲嚮鑷?繁aa } } }
public void ResearchTarget() { mPlayerAutoState.ClearMainCharacterMove(this); sdActorInterface actor = mPlayerAutoState.GetAttackTarget(); if (actor != null) { mPlayerAutoState.SetTarget(actor, this); } }
// 禁止双方移动和使用技能aa protected void PKStop() { if (m_pvpRival != null) { m_pvpRival.NotifyKilled -= sdPVPManager.Instance.KillPVPRival; sdActorInterface kActivePet = m_pvpRival.Retainer; HeaderProto.ECreatureActionState[] state = new HeaderProto.ECreatureActionState[2]; state[0] = HeaderProto.ECreatureActionState.CREATURE_ACTION_STATE_STAY; state[1] = HeaderProto.ECreatureActionState.CREATURE_ACTION_STATE_LIMIT_SKILL; for (int i = 0; i < state.Length; i++) { if (kActivePet != null) { kActivePet.AddDebuffState(state[i]); } m_pvpRival.AddDebuffState(state[i]); } m_pvpRival = null; mActivePet = null; foreach (DictionaryEntry kEntry in mPetList) { Hashtable kProperty = kEntry.Value as Hashtable; if (kProperty == null) { continue; } kProperty["Enable"] = false; } } if (sdGameLevel.instance.mainChar != null) { sdGameLevel.instance.mainChar.NotifyKilled -= KillMe; sdActorInterface kActivePet = sdGameLevel.instance.mainChar.Retainer; HeaderProto.ECreatureActionState[] state = new HeaderProto.ECreatureActionState[2]; state[0] = HeaderProto.ECreatureActionState.CREATURE_ACTION_STATE_STAY; state[1] = HeaderProto.ECreatureActionState.CREATURE_ACTION_STATE_LIMIT_SKILL; for (int i = 0; i < state.Length; i++) { if (kActivePet != null) { kActivePet.AddDebuffState(state[i]); } sdGameLevel.instance.mainChar.AddDebuffState(state[i]); } } }
// @describe 统一的攻击判定(包括主角对怪物\宠物对怪物\怪物对主角\怪物对宠物)aa // @param[in] kAttacker 攻击者aa // @param[in] kSkillInfo 攻击技能属性表aa // @param[in] iStrikeType 攻击类型aa // @param[in] kStrikeCenter 攻击中心aa // @param[in] fStrikeDisance 攻击范围aa // @param[in] iStrikeAngle 攻击角度(用于扇形区域)aa // @param[in] iHitPointIndex // @param[in,out] kCallback 攻击回调aa public virtual int DoSDAttack(sdActorInterface kAttacker, Hashtable kSkillAction, int iStrikeType, Vector3 kStrikeCenter, float fStrikeDistance, int iStrikeAngle, int iHitPointIndex, sdAttackCB kCallback) { return(0); }
// 区域中的怪物被攻击事件回调aa protected void NotifyMonsterHurt(sdActorInterface kActor, sdActorInterface kAttacker, int iHurt) { foreach (GameObject kChild in mMonsterList) { sdGameMonster kMonster = kChild.GetComponent <sdGameMonster>(); if (kMonster != null && kMonster != kActor) { kMonster.OnAreaGroupAlert(kAttacker); } } }
// 血量改变回调aa public void OnAddHP(sdActorInterface kActor, int iHP) { mPreviousHP = kActor.GetCurrentHP(); mChangeHP = iHP; if (iHP < 0) { mAccumHurtHP += iHP; //< 只计算伤害量aa } mBehaviourStateEventType = EBehaviourStateEventType.enBSET_HP; //< 当次事件类型aa }
void CalculateBubbleType(Hashtable table, sdActorInterface actor, sdActorInterface targetActor, bool isSuper, bool bDodge, ref DamageResult dr) { if (actor.GetActorType() == ActorType.AT_Pet) { dr.bubbleType = Bubble.BubbleType.eBT_PetHurt; } else if (targetActor.GetInstanceID() == sdGameLevel.instance.mainChar.GetInstanceID() && dr.damage != 0) { dr.bubbleType = Bubble.BubbleType.eBT_SelfHurt; } else { if (bDodge) { if (targetActor.GetInstanceID() == sdGameLevel.instance.mainChar.GetInstanceID()) { dr.bubbleType = Bubble.BubbleType.eBT_Dodge; } else { dr.bubbleType = Bubble.BubbleType.eBT_Miss; } } //else if (dr.damage == 0) //{ // dr.bubbleType = Bubble.BubbleType.eBT_Miss; //} else if (isSuper) { int skillID = ((int)table["ParentID"]) / 100; if (skillID == 1001) { dr.bubbleType = Bubble.BubbleType.eBT_CriticalBaseHurt; } else { dr.bubbleType = Bubble.BubbleType.eBT_CriticalSkillHurt; } } else { int skillID = ((int)table["ParentID"]) / 100; if (skillID == 1001) { dr.bubbleType = Bubble.BubbleType.eBT_BaseHurt; } else { dr.bubbleType = Bubble.BubbleType.eBT_SkillHurt; } } } }
// 切换目标回调(包括第一次发现目标和丢失目标)aa protected void NotifyChangeTarget(sdActorInterface kActor, sdActorInterface kPreviousTarget, sdActorInterface kTarget) { if (mBehaviourEventTree == null) { return; } if (kPreviousTarget != kTarget) { mBehaviourStateBlock.OnChangeTarget(kActor, kPreviousTarget, kTarget); SyncUpdateBehaviourTree(); } }
public static bool IsActorEnemy(sdActorInterface actorA, sdActorInterface actorB) { int iGroupA = (int)actorA.groupid; int iGroupB = (int)actorB.groupid; GroupType[,] gtArray = sdConfDataMgr.Instance().m_Group; GroupType type = gtArray[iGroupA, iGroupB]; if (type == GroupType.GT_Enemy) { return(true); } return(false); }