// 获得某以技能 所包含的 combo信息 Dictionary <int, string> GetComboList(int skillId) { Dictionary <int, string> list = new Dictionary <int, string>(); int startIndex = (skillId - 1) * 10 + 1; int endIndex = skillId * 10; for (int i = startIndex; i <= endIndex; i++) { SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(i); if (null == info) { continue; } foreach (var item in info.ExtraParamList) { if (item.ComboJudgeCount <= 0) { continue; } if (!list.ContainsKey(item.ComboJudgeCount)) { list.Add(item.ComboJudgeCount, item.ComboTips); } } } return(list); }
//根据服务器发回的数据进行结算 public override void ResultServerExec(IResultControl control) { SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(SkillResultID); if (null == info) { return; } Actor target = ActorManager.Singleton.Lookup(TargetID); Actor source = ActorManager.Singleton.Lookup(SourceID); if (null == target || source == null) { return; } //没有命中 if (!m_isHit) { return; } // 如果产生combo if (info.ComboNum > 0) { //m_damageModify = GetComboSkillDamageModify(SkillResultID); source.OnComboChanged(SkillResultID, TargetID, m_damageModify); } //目标强韧 { target.OnStaminaEvent(source, out m_isFly); } if (m_isBreak || m_isFly) { target.BeHited(source, m_isBack, m_isFly, info.AnimGauge); } else if (m_isFakeBreak) { target.FakeBeHited(source); } if (info.IsPlayEffect) { target.PlayEffect(info.EffectName, info.EffectDuration, info.EffectPos, info.IsAheadBone, Vector3.zero); } if (info.IsChangeShader) { AnimationShaderParamCallback callback = target.GetBodyParentObject().GetComponent <AnimationShaderParamCallback>(); callback.ChangeShader(info.ChangeShaderAnimName); } //战斗意志 source.OnAddWill(WillToFight.ENAddWillType.enSkillResult, new float[2] { info.SFightWillGet, info.NFightWillGet }); // 设置爆破点 target.SetBlastPos(source.RealPos, source.GetBodyObject().transform.forward); }
public void Load(byte[] bytes) { BinaryHelper helper = new BinaryHelper(bytes); int length = helper.ReadInt(); SkillResultList = new Dictionary <int, SkillResultInfo>(length); for (int index = 0; index < length; ++index) { SkillResultInfo info = new SkillResultInfo(); info.Load(helper); SkillResultList.Add(info.ID, info); } }
private float GetComboSkillDamageModify(int resultID) { float modify = 1.0f; SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(resultID); Actor source = ActorManager.Singleton.Lookup(SourceID); if (info != null && null != source) { if (source.Combo != null) { int count = source.Combo.TotalComboNumber; if (count <= MinComboNumber) { modify = 0; } else { switch ((ENSkillComboType)info.ComboType) { case ENSkillComboType.enMore: { modify = (float)((int)(((count - MinComboNumber) / MinComboStepModify) + 1) - 1) * MorePercent + 1; } break; case ENSkillComboType.enSome: { modify = (float)((int)(((count - MinComboNumber) / MinComboStepModify) + 1) - 1) * SomePercent + 1; } break; case ENSkillComboType.enLittle: { modify = (float)((int)(((count - MinComboNumber) / MinComboStepModify) + 1) - 1) * LittlePercent + 1; } break; default: break; } } } } return(modify); }
void AddCombo(int targetID, int resultID) { SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(resultID); if (null == info) { return; } TotalComboNumber = TotalComboNumber + info.ComboNum; //++TotalComboNumber; m_lastComboTime = Time.time; WeakenComboTime = 0; ComboModify(resultID, targetID); BattleArena.Singleton.SwordSoul.Add(TotalComboNumber, SwordSoulProps.ENAddComboType.enNormal); // 如果是长连接 if (ClientNet.Singleton.IsLongConnecting) { IMiniServer.Singleton.SendComboNum_C2BS((int)ENComboOperateType.enAdd, resultID); } }
public override void Exec(IResultControl control) { SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(SkillResultID); if (null == info) { return; } Actor target = ActorManager.Singleton.Lookup(TargetID); Actor source = ActorManager.Singleton.Lookup(SourceID); if (null != target && source != null) { float r = UnityEngine.Random.Range(0.0f, 1.0f); if (r >= source.Props.GetProperty_Float(ENProperty.hit) - target.Props.GetProperty_Float(ENProperty.avoid)) {//没有命中 return; } r = UnityEngine.Random.Range(0.0f, 1.0f); bool isFakeBreak = false, isBreak = false, isBack = false, isFly = false; if (r <= info.InterferePersent - target.Props.GetProperty_Float(ENProperty.AnitInterfere)) {//普通受击 isFakeBreak = true; r = UnityEngine.Random.Range(0.0f, 1.0f); if (r < info.BreakPersent - target.Props.GetProperty_Float(ENProperty.AnitInterrupt)) {//强受击 isBreak = true; //Debug.LogWarning("hit 打断 target id=" + target.ID.ToString()); r = UnityEngine.Random.Range(0.0f, 1.0f); if (r <= info.HitBackPersent - target.Props.GetProperty_Float(ENProperty.AnitRepel)) {//击退 //Debug.LogWarning("hit 击退 target id=" + target.ID.ToString()); isBack = true; r = UnityEngine.Random.Range(0.0f, 1.0f); if (r < info.HitFlyPersent - target.Props.GetProperty_Float(ENProperty.AnitLauncher)) {//击飞 //Debug.LogWarning("hit 击飞 target id=" + target.ID.ToString()); isFly = true; } } } } if (info.ComboNum > 0) { m_damageModify = GetComboSkillDamageModify(SkillResultID); source.OnComboChanged(SkillResultID, TargetID, m_damageModify); } {//目标强韧结算 float curStamina = target.Props.GetProperty_Float(ENProperty.stamina); if (curStamina <= 0.0f) { target.OnStaminaEvent(source, out isFly); isBack = isFly ? isFly : isBack; } } if (isBreak || isFly) { target.BeHited(source, isBack, isFly, info.AnimGauge); } else if (isFakeBreak) { target.FakeBeHited(source); } } else { return; } if (info.IsPlayEffect) { target.PlayEffect(info.EffectName, info.EffectDuration, info.EffectPos, info.IsAheadBone, Vector3.zero); } if (info.IsChangeShader) { AnimationShaderParamCallback callback = target.GetBodyParentObject().GetComponent <AnimationShaderParamCallback>(); callback.ChangeShader(info.ChangeShaderAnimName); } foreach (var item in info.ParamList) { if (item.ID == (int)ENResult.Skill) { BattleFactory.Singleton.CreateSkillResult(SourceID, (int)item.Param[0], target.ID, SkillID, item.Param); continue; } IResult r = BattleFactory.Singleton.CreateResult((ENResult)item.ID, SourceID, TargetID, SkillResultID, SkillID, item.Param); if (r != null) { if (item.ID == (int)ENResult.Damage) { ResultDamage damage = r as ResultDamage; damage.DamageModify = m_damageModify / 100 + 1; } r.ResultExpr(item.Param); BattleFactory.Singleton.DispatchResult(r); } } if (source.Combo != null) {//combo附加效果 int comboResultID = 0; foreach (var item in info.ExtraParamList) { if (item.ComboJudgeCount <= 0) { continue; } int comboValue = source.Combo.TotalComboNumber; if (comboValue >= item.ComboJudgeCount) { comboResultID = item.SkillResultID; } } if (comboResultID != 0) { BattleFactory.Singleton.CreateSkillResult(SourceID, comboResultID, target.ID, SkillID); } } //战斗意志 source.OnAddWill(WillToFight.ENAddWillType.enSkillResult, new float[2] { info.SFightWillGet, info.NFightWillGet }); }
public void OnTriggerEnter(GameObject selfObj, Collider other) { if (other.isTrigger) { //Debug.LogWarning("OnTriggerEnter other.isTrigger is true"); return; } Actor target = null; Transform targetObj = other.transform; while (null != targetObj && targetObj.name != "body") { targetObj = targetObj.parent; } if (null == targetObj) { //Debug.LogWarning("OnTriggerEnter target obj is null"); return; } ActorProp prop = targetObj.parent.GetComponent <ActorProp>(); target = prop.ActorLogicObj; if (null == target) { Debug.LogWarning("OnTriggerEnter target is null"); return; } if (target.IsDead) { Debug.LogWarning("OnTriggerEnter target is deaded"); return; } //Debug.LogWarning("OnTriggerEnter target id is " +target.ID.ToString()); SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(mSkillResultID); if (info == null) { return; } ActorProp selfProp = selfObj.transform.parent.GetComponent <ActorProp>(); Trap self = selfProp.ActorLogicObj as Trap; if (!self.CheckActorAttackResult(target)) { return; } if (ClientNet.Singleton.IsConnected) { IResult r = BattleFactory.Singleton.CreateResult(ENResult.Skill, self.ID, target.ID, mSkillResultID, 0); if (r != null) { target.SetBlastPos(self.RealPos, self.GetBodyObject().transform.forward); r.ResultExpr(null); BattleFactory.Singleton.GetBattleContext().CreateResultControl().DispatchResult(r); } } else { IResult r = BattleFactory.Singleton.CreateResult(ENResult.Skill, self.ID, target.ID, mSkillResultID, 0); if (r != null) { target.SetBlastPos(self.RealPos, self.GetBodyObject().transform.forward); r.ResultExpr(null); BattleFactory.Singleton.GetBattleContext().CreateResultControl().DispatchResult(r); } } // if (!string.IsNullOrEmpty(info.SoundList)) // {//播放击中声音 // string[] param = info.SoundList.Split(new char[1] { ',' }); // string sound = param[0]; // if (!string.IsNullOrEmpty(sound)) // { // m_audioPos = selfObj.transform.position; // GameResManager.Singleton.LoadResourceAsyncCallback(GameData.GetSoundPath(sound), Callback); // //AudioClip clip = PoolManager.Singleton.CreateSoundObj(sound) as AudioClip; // //AudioSource.PlayClipAtPoint(clip, selfObj.transform.position); // } // else // { // Debug.LogWarning("sound string is null"); // } // } }
// 加载特效 static void LoadEffect(int resultId) { if (resultId <= 0) { return; } SkillResultInfo skillResultInfo = m_skillResultTable.Lookup(resultId); if (null == skillResultInfo) { return; } // 特效物件1 // GameObject obj = GameData.LoadEffect<GameObject>(skillResultInfo.EffectName); if (skillResultInfo.EffectName != null && !m_hadResourceList.Contains(skillResultInfo.EffectName)) { m_resourceList.Add(skillResultInfo.EffectName, (int)Type.enEffect); m_hadResourceList.Add(skillResultInfo.EffectName); Debug.Log("m_resourceList 添加 LoadEffect " + skillResultInfo.EffectName + ",resultId:" + resultId); } // 特效物件2 for (int i = 0; i < skillResultInfo.ParamList.Length; i++) { ResultParam resultParam = skillResultInfo.ParamList[i]; if (resultParam.ID == 3) { int buffId = (int)resultParam.Param[0]; BuffInfo buffInfo = m_buffTable.Lookup(buffId); if (null == buffInfo) { continue; } BuffEffectInfo buffEffectInfo = m_buffEffectTable.Lookup(buffInfo.BuffEffectID); if (null == buffEffectInfo) { continue; } if (string.IsNullOrEmpty(buffEffectInfo.EffectName)) { continue; } if (!m_hadResourceList.Contains(buffEffectInfo.EffectName)) { m_resourceList.Add(buffEffectInfo.EffectName, (int)Type.enEffect); m_hadResourceList.Add(buffEffectInfo.EffectName); Debug.Log("m_resourceList 添加 " + buffEffectInfo.EffectName); } } } // 特效物件3 foreach (var item in skillResultInfo.ExtraParamList) { LoadEffect(item.SkillResultID); } }
public bool CreateSkillResult() { SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(SkillResultID); if (info == null) { Debug.LogError("SkillResultID is null, SkillResultID:" + SkillResultID + ",skillID:" + m_skillID + ",index:" + m_skillResultIDIndex); return(false); } CurrentActor.SelfAI.GetRangeTargetList(ENTargetType.enNone, info.InstantRange); List <int> resultActorIDList = new List <int>(); float minDistance = float.MaxValue; int tempActorID = 0; foreach (var targetID in CurrentActor.SelfAI.m_targetIDList) { Actor target = ActorManager.Singleton.Lookup(targetID); if (target == null || target.IsDead) { continue; } switch ((ENResultTargetType)info.ResultTargetType) { case ENResultTargetType.enEnemySingle: { //作用于单个enemy if (m_skillTarget != null && ActorTargetManager.IsEnemy(CurrentActor, m_skillTarget)) { //有技能目标,技能目标是enemy if (m_skillTarget == target) { tempActorID = m_skillTarget.ID; } } else { if (ActorTargetManager.IsEnemy(CurrentActor, target)) { Vector3 temp = target.RealPos - CurrentActor.MainPos; temp.y = 0; if (temp.magnitude < minDistance) { minDistance = temp.magnitude; tempActorID = target.ID; } } } } break; case ENResultTargetType.enEnemyAll: { //作用于所有enemy if (ActorTargetManager.IsEnemy(CurrentActor, target)) { resultActorIDList.Add(target.ID); } } break; case ENResultTargetType.enFriendlySingle: { //作用于单个friendly if (m_skillTarget != null && ActorTargetManager.IsFriendly(CurrentActor, m_skillTarget)) { //有技能目标,技能目标是friend if (m_skillTarget == target) { tempActorID = m_skillTarget.ID; } } else { if (ActorTargetManager.IsFriendly(CurrentActor, target)) { Vector3 temp = target.RealPos - CurrentActor.MainPos; temp.y = 0; if (temp.magnitude < minDistance) { minDistance = temp.magnitude; tempActorID = target.ID; } } } } break; case ENResultTargetType.enFriendlyAll: { //作用于所有friendly if (ActorTargetManager.IsFriendly(CurrentActor, target)) { resultActorIDList.Add(target.ID); } } break; case ENResultTargetType.enEveryone: { resultActorIDList.Add(target.ID); } break; case ENResultTargetType.enSelf: { if (CurrentActor == target) { tempActorID = target.ID; } } break; case ENResultTargetType.enFriendlyAllAndSelf: { if (ActorTargetManager.IsFriendly(CurrentActor, target) || CurrentActor == target) { resultActorIDList.Add(target.ID); } } break; case ENResultTargetType.enFriendlySingleAndSelf: { if (m_skillTarget != null && (ActorTargetManager.IsFriendly(CurrentActor, m_skillTarget) || m_skillTarget == CurrentActor)) { tempActorID = m_skillTarget.ID; } else { //自己 if (CurrentActor == target) { tempActorID = target.ID; } } } break; default: break; } } if (tempActorID != 0) { resultActorIDList.Add(tempActorID); } //if (ClientNet.Singleton.IsConnected) //{ //} //else { foreach (var targetID in resultActorIDList) { IResult r = BattleFactory.Singleton.CreateResult(ENResult.Skill, CurrentActor.ID, targetID, SkillResultID, m_skillInfo != null ? m_skillInfo.ID : 0); if (r != null) { Actor targetActor = ActorManager.Singleton.Lookup(targetID); targetActor.SetBlastPos(CurrentActor.RealPos, CurrentActor.GetBodyObject().transform.forward); r.ResultExpr(null); BattleFactory.Singleton.GetBattleContext().CreateResultControl().DispatchResult(r); } } } return(true); }
public void Update() { for (int i = 0; i < m_infoList.Count; ++i) { Info info = m_infoList[i]; //使用异步时,需要修改此代码 added by luozj if (info.m_itemInfo.IsWarningBeforeItem && info.m_isHaveWarningEffect) {//预警特效,并且没播放完毕 if (Time.time - info.m_startTime > info.m_itemInfo.WaringEffectDuration) { info.m_isHaveWarningEffect = false; if (null != info.m_objWarningEffect) { PoolManager.Singleton.ReleaseObj(info.m_objWarningEffect); info.m_objWarningEffect = null; } info.m_startTime = Time.time; info.m_itemObj.SetActive(true); //预警特效播放完毕之后,改变焦点 if (info.m_itemInfo.IsChangeCamera) { if (info.m_actorType == ActorType.enMain) { MainGame.Singleton.MainCamera.ChangeFollowTarget(info.m_itemObj, info.m_itemInfo.CC_ChangeTime, info.m_itemInfo.CC_BackTime, false); } } } else { continue; } } if (!info.m_itemObj.activeSelf) {//激活 info.m_itemObj.SetActive(true); } if (info.m_rigidbody != null) { info.m_rigidbody.WakeUp(); } if (info.m_startTime == 0) {//设置开始时间 info.m_startTime = Time.time; if (info.m_itemInfo.IsStretch) {//拉伸,直接对目标进行一次伤害 if (info.m_dstActor != null) { IResult r = BattleFactory.Singleton.CreateResult(ENResult.Skill, info.m_srcActor.ID, info.m_dstActor.ID, info.m_itemInfo.Item_ResultID, info.m_skillID); if (r != null) { info.m_dstActor.SetBlastPos(info.m_itemObj.transform.position, info.m_itemObj.transform.forward); r.ResultExpr(null); BattleFactory.Singleton.GetBattleContext().CreateResultControl().DispatchResult(r); } } } } if (info.m_duration != 0) {//时间 if (Time.time - info.m_startTime > info.m_duration) { info.m_isNeedRemove = true; continue; } } if (info.m_itemInfo.Item_MoveDistance != 0) {//距离 Vector3 moveDistance = info.m_itemObj.transform.position - info.m_startPos; if (moveDistance.magnitude > info.m_itemInfo.Item_MoveDistance) { info.m_isNeedRemove = true; continue; } } if (info.m_itemInfo.Item_IsDestroyAtTargetPos) {//飞行道具是否在目标位置上销毁 Vector3 moveDistance = info.m_targetPos - info.m_itemObj.transform.position; if (Mathf.Abs(moveDistance.magnitude) <= 0.4f) { info.m_itemObj.transform.position = info.m_targetPos; info.m_isNeedRemove = true; continue; } } if (info.m_isNeedRemove) { continue; } if (info.m_isLaunchSuspend) {//延缓发射 continue; } if (info.m_itemInfo.IsChangeCamera) {//改变camera if (!info.m_cameraIsBack) { //camera back if (Time.time - info.m_startTime > info.m_itemInfo.CC_Duration + info.m_itemInfo.CC_ChangeTime) { MainGame.Singleton.MainCamera.BackToActor(info.m_itemObj, info.m_itemInfo.CC_BackTime); info.m_cameraIsBack = true; } } } if (info.m_itemInfo.IsCurveMove) { //曲线移动 if (Time.time - info.m_startTime <= info.m_itemInfo.Item_AddtionalEffectTime) { //曲线移动时间内 if (info.m_itemInfo.Item_AddtionalSpeed != 0) { //移动 info.m_itemObj.transform.forward = info.m_curveForward; Vector3 forwardDistance = info.m_itemObj.transform.localPosition + info.m_curveForward * info.m_itemInfo.Item_AddtionalSpeed * Time.deltaTime; info.m_itemObj.transform.localPosition = forwardDistance; //计算朝向目标的方向 //Vector3 direction = info.m_targetPos - info.m_itemObj.transform.position; //direction.Normalize(); //info.m_forward = direction; } continue; } } if (info.m_itemInfo.IsTrack) { //追踪目标 if (!info.m_itemInfo.IsWarningBeforeItem && info.m_dstActor != null && !info.m_dstActor.IsDead) { //没有目标预警 info.m_targetPos = info.m_dstActor.RealPos; if (info.m_itemInfo.Item_IsLockY) { info.m_targetPos.y = info.m_itemObj.transform.position.y; } Vector3 direction = info.m_targetPos - info.m_itemObj.transform.position; direction.Normalize(); info.m_forward = direction; } } if (info.m_itemInfo.Item_MoveSpeed != 0) {//移动 info.m_itemObj.transform.forward = info.m_forward; Vector3 forwardDistance = info.m_itemObj.transform.localPosition + info.m_forward * info.m_itemInfo.Item_MoveSpeed * Time.deltaTime; info.m_itemObj.transform.localPosition = forwardDistance; } else { if (info.m_itemInfo.IsStretch) {//拉伸-z轴 float z = info.m_itemObj.transform.localScale.z; info.m_itemObj.transform.LocalScaleX(1); info.m_itemObj.transform.LocalScaleY(1); info.m_itemObj.transform.LocalScaleZ(z + info.m_itemInfo.Item_StretchSpeed * Time.deltaTime); } } } for (int j = 0; j < m_infoList.Count; ++j) { Info info = m_infoList[j]; if (info.m_isNeedRemove) { if (info.m_dstActor != null) { StartBouncy(info, info.m_dstActor.MainPos); } if (info.m_itemInfo.IsChangeCamera) { if (!info.m_cameraIsBack) {//camera back if (info.m_itemInfo.CC_DurationAfterDestroy > 0) { MainGame.Singleton.MainCamera.ChangeFollowTarget(info.m_itemObj.transform.position, 0, info.m_itemInfo.CC_BackTime, false, info.m_itemInfo.CC_DurationAfterDestroy); } else { MainGame.Singleton.MainCamera.BackToActor(info.m_itemObj, info.m_itemInfo.CC_BackTime); } info.m_cameraIsBack = true; } } if (info.m_itemInfo.IsResultForRemove) {//移除后是否有效果 SkillResultInfo srInfo = GameTable.SkillResultTableAsset.Lookup(info.m_itemInfo.ResultIDForRemove); GetTargetList(info.m_itemObj.transform.localPosition, info.m_actorType, info.m_actorCamp, ENTargetType.enEnemy, srInfo.InstantRange); for (int index = 0; index < m_targetIDList.Count; ++index) { //产生skillResult IResult r = BattleFactory.Singleton.CreateResult(ENResult.Skill, info.m_srcActor.ID, m_targetIDList[index], info.m_itemInfo.ResultIDForRemove, info.m_skillID); if (r != null) { Actor targetActor = ActorManager.Singleton.Lookup(m_targetIDList[index]); targetActor.SetBlastPos(info.m_itemObj.transform.position, info.m_itemObj.transform.forward); r.ResultExpr(null); BattleFactory.Singleton.GetBattleContext().CreateResultControl().DispatchResult(r); } } } if (info.m_itemInfo.IsEffectForRemove) {//是否在移除飞行特效后播放特效 PlayEffect(info.m_itemInfo.EffectNameForRemove, info.m_itemInfo.EffectTimeForRemove, info.m_itemObj.transform.localPosition); } PoolManager.Singleton.ReleaseObj(info.m_itemObj); } } m_infoList.RemoveAll(item => item.m_isNeedRemove); }
//播放攻击落空声音 protected void PlayMissingSound() { Collider c = null; foreach (var item in CurrentActor.ColliderArray) { if (item.gameObject.activeSelf) { c = item; break; } } if (c != null) { m_isStartTrigger = true; } else { if (m_isStartTrigger) { m_isStartTrigger = false; if (m_isMissing) {//播放落空声音 SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(SkillResultID); if (info == null) { Debug.LogWarning("skill result id is error,id:" + SkillResultID); return; } if (!string.IsNullOrEmpty(info.SoundList)) { string[] param = info.SoundList.Split(new char[1] { ',' }); if (param.Length < 2) { Debug.LogWarning("sound list is error, length is " + param.Length); return; } string sound = param[1]; if (!string.IsNullOrEmpty(sound)) { #if UNITY_IPHONE || UNITY_ANDRIOD #else AudioClip aClip = PoolManager.Singleton.LoadSound(sound); if (aClip != null) { AudioSource.PlayClipAtPoint(aClip, CurrentActor.MainPos); } #endif } else { Debug.LogWarning("sound string is null"); } } } m_isMissing = false; } } }
public override void ResultExpr(float[] param) { base.ResultExpr(param); if (param == null || param.Length < 5) { return; } Actor target = ActorManager.Singleton.Lookup(TargetID); if (null == target) { return; } Actor source = ActorManager.Singleton.Lookup(SourceID); if (null == source) { return; } //物理、魔法加成 float phyAdd = 0, magAdd = 0; //攻击力倍数的修正 float modifyValue = 0; //伤害修正 float damageModify = 1; SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(SkillResultID); if (null != info) { if (info.MinComboCount > 0) { if (source.Combo != null && source.Combo.TotalComboNumber >= info.MinComboCount) { phyAdd = info.PhyAttackAdd; magAdd = info.MagAttackAdd; } } if (source.Combo != null) { int comboNumber = source.Combo.TotalComboNumber; if (comboNumber > 44) { comboNumber = 44; } modifyValue = (int)(1.0f / 15.0f * comboNumber) * info.AttackModify; } if (info.ComboNum > 0) { damageModify = DamageModify; } if (info.IsWeakenComboTime) { target.OnWeakenComboTime(info.WeakenComboTime); } } {//结算 switch ((ENDamageType)param[0]) { #region enDamageFixed case ENDamageType.enDamageFixed: //固定伤害 { float damage = 0.0f; if (param[1] != 0) { //固定伤害 damage = param[1]; } if (param[2] != 0) { //百分比上下浮动 //目标的伤害系数 float woundParam = target.Props.GetProperty_Float(ENProperty.WoundParam); damage *= (woundParam != 0 ? woundParam : 1); damage *= UnityEngine.Random.Range(1 - param[2], 1 + param[2]); } DamageValue = damage; } break; #endregion #region enPhyDamageTimes case ENDamageType.enPhyDamageTimes: //物理攻击倍数伤害 { float srcAttackValue = source.Props.GetProperty_Float(ENProperty.phyattack); if (param[1] != 0) { //物理攻击力的倍数 srcAttackValue *= (param[1] + modifyValue); } srcAttackValue += phyAdd; float damage = srcAttackValue - target.Props.GetProperty_Float(ENProperty.phydefend); float min = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enPhyAttackMinValue).FloatTypeValue; if (damage < srcAttackValue * min) { //伤害最低为物理攻击*物理攻击力的最小值 damage = srcAttackValue * min; } else { if (param[2] != 0) { //百分比上下浮动 //目标的伤害系数 float woundParam = target.Props.GetProperty_Float(ENProperty.WoundParam); damage *= (woundParam != 0 ? woundParam : 1); damage *= UnityEngine.Random.Range(1 - param[2], 1 + param[2]); } } DamageValue = damage; m_attackValue = source.Props.GetProperty_Float(ENProperty.phyattack); } break; #endregion #region enMagDamageTimes case ENDamageType.enMagDamageTimes: //魔法攻击倍数伤害 { float srcAttackValue = source.Props.GetProperty_Float(ENProperty.magattack); if (param[1] != 0) { //魔法攻击力的倍数 srcAttackValue *= (param[1] + modifyValue); } srcAttackValue += magAdd; float damage = srcAttackValue - target.Props.GetProperty_Float(ENProperty.magdefend); float min = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enMagAttackMinValue).FloatTypeValue; if (damage < srcAttackValue * min) { //伤害最低为魔法攻击的10% damage = srcAttackValue * min; } else { if (param[2] != 0) { //百分比上下浮动 //目标的伤害系数 float woundParam = target.Props.GetProperty_Float(ENProperty.WoundParam); damage *= (woundParam != 0 ? woundParam : 1); damage *= UnityEngine.Random.Range(1 - param[2], 1 + param[2]); } } DamageValue = damage; m_attackValue = source.Props.GetProperty_Float(ENProperty.magattack); } break; #endregion #region enDamagePercent case ENDamageType.enDamagePercent: { float percent = param[1]; if (percent > 0 && percent < 1) { float damage = target.MaxHP * percent; float random = param[2]; if (random != 0) { //百分比上下浮动 //目标的伤害系数 float woundParam = target.Props.GetProperty_Float(ENProperty.WoundParam); damage *= (woundParam != 0 ? woundParam : 1); damage *= UnityEngine.Random.Range(1 - param[2], 1 + param[2]); } DamageValue = damage; } } break; #endregion #region enDamageSunder case ENDamageType.enDamageSunder: { float srcAttackValue = source.Props.GetProperty_Float(ENProperty.phyattack); srcAttackValue += phyAdd; float damage = srcAttackValue - target.Props.GetProperty_Float(ENProperty.phydefend) * param[1]; if (damage < srcAttackValue * 0.1f) { //伤害最低为物理攻击的10% damage = srcAttackValue * 0.1f; } else { if (param[2] != 0) { //百分比上下浮动 //目标的伤害系数 float woundParam = target.Props.GetProperty_Float(ENProperty.WoundParam); damage *= (woundParam != 0 ? woundParam : 1); damage *= UnityEngine.Random.Range(1 - param[2], 1 + param[2]); } } DamageValue = damage; m_attackValue = source.Props.GetProperty_Float(ENProperty.phyattack); } break; #endregion #region enDistancePhyDamageTimes case ENDamageType.enPhyDamageDistance: { SkillInfo skillInfo = GameTable.SkillTableAsset.Lookup(SkillID); if (skillInfo == null) { return; } float range = 0; float d = ActorTargetManager.GetTargetDistance(source.RealPos, target.RealPos); if (d < param[1]) { range = param[1]; } else if (d > param[2]) { range = param[2]; } else { range = d; } float attackValue = source.Props.GetProperty_Float(ENProperty.phyattack); float defend = target.Props.GetProperty_Float(ENProperty.phydefend); DamageValue = attackValue * (range / skillInfo.AttackDistance) * param[3] - defend; float min = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enPhyAttackMinValue).FloatTypeValue; if (DamageValue < attackValue * min) { DamageValue = attackValue * min; } } break; #endregion #region enDistanceMagDamageTimes case ENDamageType.enMagDamageDistance: { SkillInfo skillInfo = GameTable.SkillTableAsset.Lookup(SkillID); if (skillInfo == null) { return; } float range = 0; float d = ActorTargetManager.GetTargetDistance(source.RealPos, target.RealPos); if (d < param[1]) { range = param[1]; } else if (d > param[2]) { range = param[2]; } else { range = d; } float attackValue = source.Props.GetProperty_Float(ENProperty.magattack); float defend = target.Props.GetProperty_Float(ENProperty.magdefend); DamageValue = attackValue * (range / skillInfo.AttackDistance) * param[3] - defend; float min = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enMagAttackMinValue).FloatTypeValue; if (DamageValue < attackValue * min) { DamageValue = attackValue * min; } } break; #endregion default: break; } DamageResultType = (ENDamageResultType)param[4]; if (DamageValue != 0) { DamageValue *= damageModify; if (UnityEngine.Random.Range(0.0f, 1f) < source.Props.GetProperty_Float(ENProperty.crit)) {//暴击 m_isCrit = true; DamageValue *= (source.Props.GetProperty_Float(ENProperty.critParam)); } } else { Debug.LogWarning("damage result is error, damage is " + DamageValue.ToString() + ", source actor id is " + source.ID.ToString()); } } }
public void ComboChanged(int resultID, int targetID, float damageModify) { float now = Time.time; if (TotalComboNumber == 0) {//当前连击数为0 AddCombo(targetID, resultID); } else { if (now - m_lastComboTime <= m_nextComboTimeModify - WeakenComboTime + SwitchActorTime) {//连击成功 AddCombo(targetID, resultID); DamageModifyList[TotalComboNumber] = damageModify; SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(resultID); if (null != info) { for (int i = 0; i < info.ComboNum; i++) { BattleArena.Singleton.NotifyChanged((int)BattleArena.ENPropertyChanged.enComboCount, null); } } {//评价 int appraiseIndex = 0; if (IsAppraise((int)ENWorldParamIndex.enComboNice)) { appraiseIndex = (int)ENWorldParamIndex.enComboNice; } else if (IsAppraise((int)ENWorldParamIndex.enComboCool)) { appraiseIndex = (int)ENWorldParamIndex.enComboCool; } else if (IsAppraise((int)ENWorldParamIndex.enComboGreat)) { appraiseIndex = (int)ENWorldParamIndex.enComboGreat; } else if (IsAppraise((int)ENWorldParamIndex.enComboBravo)) { appraiseIndex = (int)ENWorldParamIndex.enComboBravo; } else if (IsAppraise((int)ENWorldParamIndex.enComboPerfect)) { appraiseIndex = (int)ENWorldParamIndex.enComboPerfect; } if (appraiseIndex != 0) { BattleArena.Singleton.NotifyChanged((int)BattleArena.ENPropertyChanged.enComboAppraise, appraiseIndex); } } } else {//连击失败 ComboClear(); } } SwitchActorTime = 0; }
private void ComboModify(int resultID, int targetID) { SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(resultID); if (info == null) { return; } float staminaModify = 0; switch ((ENSkillComboType)info.ComboType) { case ENSkillComboType.enMore: { //(取整(连击数/10)+1)*0.1 m_nextComboTimeModify = info.ComboTime + (float)((int)((TotalComboNumber / 10) + 1) - 1) * 0f; //(取整(连击数/10)+1)*0.1+1 staminaModify = (float)((int)((TotalComboNumber / 10) + 1) - 1) * 0f + 1; } break; case ENSkillComboType.enSome: { //(取整(连击数/10)+1)*0.12 m_nextComboTimeModify = info.ComboTime + (float)((int)((TotalComboNumber / 10) + 1) - 1) * 0f; //(取整(连击数/10)+1)*0.2+1 staminaModify = (float)((int)((TotalComboNumber / 10) + 1) - 1) * 0f + 1; } break; case ENSkillComboType.enLittle: { //(取整(连击数/10)+1)*0.15 m_nextComboTimeModify = info.ComboTime + (float)((int)((TotalComboNumber / 10) + 1) - 1) * 0f; //(取整(连击数/10)+1)*0.3+1 staminaModify = (float)((int)((TotalComboNumber / 10) + 1) - 1) * 0f + 1; } break; default: break; } //修改目标的强韧度 Actor target = ActorManager.Singleton.Lookup(targetID); if (target != null && !target.IsDead) { AttackAction action = target.ActionControl.LookupAction(ActorAction.ENType.enAttackAction) as AttackAction; if (action != null) { if (action.m_skillInfo.IsStaminaFixed) {//锁定强韧度 return; } } staminaModify *= info.StaminaDamage; float curStamina = target.Props.GetProperty_Float(ENProperty.stamina); curStamina -= staminaModify; if (curStamina < 0) { curStamina = 0; } target.Props.SetProperty_Float(ENProperty.stamina, curStamina); } }
//通过skillResultID产生技能result public bool CreateSkillResult(int sourceID, int skillResultID, int targetID = 0, int skillID = 0, float[] param = null) { m_self = ActorManager.Singleton.Lookup(sourceID); if (m_self == null) { Debug.LogWarning("self is null, id is " + sourceID); return(false); } Actor target = ActorManager.Singleton.Lookup(targetID); SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(skillResultID); if (info == null) { if (skillResultID != 0) { Debug.LogWarning("result id is error, id is " + skillResultID); } return(false); } float range = float.MinValue; if (info.InstantRange != 0) { range = info.InstantRange; } //优先判断当前目标和自己 switch ((ENResultTargetType)info.ResultTargetType) { case ENResultTargetType.enEnemySingle: { if (target != null && !target.IsDead) { if (ActorTargetManager.IsEnemy(m_self, target)) { float d = ActorTargetManager.GetTargetDistance(m_self.RealPos, target.RealPos); if (d <= range) { //给当前技能目标加skillresult CreateResult_Skill(info.ID, target, skillID, param); return(true); } } } } break; case ENResultTargetType.enFriendlySingle: { if (target != null && !target.IsDead) { if (ActorTargetManager.IsFriendly(m_self, target)) { float d = ActorTargetManager.GetTargetDistance(m_self.RealPos, target.RealPos); if (d <= range) { //给当前技能目标加skillresult CreateResult_Skill(info.ID, target, skillID, param); return(true); } } } } break; case ENResultTargetType.enSelf: case ENResultTargetType.enFriendlySingleAndSelf: { //给自己加skillresult CreateResult_Skill(info.ID, m_self, skillID, param); return(true); } //break; } ActorManager.Singleton.ForEach_result(CheckTarget, new float[4] { info.ID, range, info.ResultTargetType, skillID }); return(true); }
public override void Exec(IResultControl control) { base.Exec(control); if (m_paramList == null) { Debug.LogWarning("param is null"); return; } if (m_paramList.Length == 0) { Debug.LogWarning("param length is 0"); return; } m_self = ActorManager.Singleton.Lookup(SourceID); if (m_self == null) { Debug.LogWarning("actor is null, id is " + SourceID); return; } if (m_self.Type == ActorType.enNPC) { m_range = (m_self as NPC).CurrentTableInfo.AttackRange; } else { m_range = (m_self as Player).CurrentTableInfo.AttackRange; } SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(SkillResultID); if (info == null) { Debug.LogWarning("SkillResultInfo is null, id is " + SkillResultID); return; } switch ((ENChainDamageType)m_paramList[0]) { case ENChainDamageType.enMagicMulti: { float attackValue = m_self.Props.GetProperty_Float(ENProperty.magattack); float multi = m_paramList[1]; int count = (int)m_paramList[2]; float percent = m_paramList[3]; m_targetList = new List <Actor>(); Actor target = ActorManager.Singleton.Lookup(TargetID); if (target != null && !target.IsDead) { m_targetList.Add(target); } ActorManager.Singleton.ForEach(CheckTarget); for (int i = 0; i < count; ++i) { if (i >= m_targetList.Count) { return; } float defend = m_targetList[i].Props.GetProperty_Float(ENProperty.magdefend); float value = (attackValue * multi - defend) * (float)Math.Pow(percent, i); float min = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enMagAttackMinValue).FloatTypeValue; if (value < attackValue * min) { value = attackValue * min; } { //添加特效 m_targetList[i].PlayEffect(info.EffectName, info.EffectDuration, info.EffectPos, info.IsAheadBone, Vector3.zero); } { //添加combo float modifyValue = GetComboSkillDamageModify(SkillResultID); m_self.OnComboChanged(SkillResultID, m_targetList[i].ID, modifyValue); } IResult r = BattleFactory.Singleton.CreateResult(ENResult.Damage, SourceID, m_targetList[i].ID, 0, 0, new float[5] { (float)ResultDamage.ENDamageType.enDamageFixed, value, 0, 0, m_paramList[4] }); if (r != null) { r.ResultExpr(new float[5] { (float)ResultDamage.ENDamageType.enDamageFixed, value, 0, 0, m_paramList[4] }); BattleFactory.Singleton.DispatchResult(r); } } } break; case ENChainDamageType.enPercent: { int count = (int)m_paramList[2]; float percent = m_paramList[3]; m_targetList = new List <Actor>(); Actor target = ActorManager.Singleton.Lookup(TargetID); if (target != null && !target.IsDead) { m_targetList.Add(target); } ActorManager.Singleton.ForEach(CheckTarget); for (int i = 0; i < count; ++i) { if (i >= m_targetList.Count) { return; } float maxHP = m_targetList[i].MaxHP; float value = (maxHP * m_paramList[1]) * (float)Math.Pow(percent, i); { //添加特效 m_targetList[i].PlayEffect(info.EffectName, info.EffectDuration, info.EffectPos, info.IsAheadBone, Vector3.zero); } { //添加combo float modifyValue = GetComboSkillDamageModify(SkillResultID); m_self.OnComboChanged(SkillResultID, m_targetList[i].ID, modifyValue); } IResult r = BattleFactory.Singleton.CreateResult(ENResult.Damage, SourceID, m_targetList[i].ID, 0, 0, new float[5] { (float)ResultDamage.ENDamageType.enDamageFixed, value, 0, 0, m_paramList[4] }); if (r != null) { r.ResultExpr(new float[5] { (float)ResultDamage.ENDamageType.enDamageFixed, value, 0, 0, m_paramList[4] }); BattleFactory.Singleton.DispatchResult(r); } } } break; } }
public void OnTriggerEnter(GameObject selfObj, Collider other) { if (other.isTrigger) { //Debug.LogWarning("OnTriggerEnter other.isTrigger is true"); return; } Actor target = null; Transform targetObj = other.transform; while (null != targetObj && targetObj.name != "body") { targetObj = targetObj.parent; } if (null == targetObj) { //Debug.LogWarning("OnTriggerEnter target obj is null"); return; } ActorProp prop = targetObj.parent.GetComponent <ActorProp>(); target = prop.ActorLogicObj; if (null == target) { Debug.LogWarning("OnTriggerEnter target is null"); return; } if (target.IsDead) { //Debug.LogWarning("OnTriggerEnter target is deaded"); return; } //Debug.LogWarning("OnTriggerEnter target id is " +target.ID.ToString()); SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(SkillResultID); if (info == null) { Debug.LogError("SkillResultID is null, actor ID:" + CurrentActor.ID + "SkillResultID:," + SkillResultID + ",skillID:" + m_skillID + ",index:" + m_skillResultIDIndex); DebugLog.Singleton.OnShowLog("SkillResultID is null, actor ID:" + CurrentActor.ID + "SkillResultID:" + SkillResultID + ",skillID:" + m_skillID + ",index:" + m_skillResultIDIndex); return; } ActorProp selfProp = selfObj.transform.parent.GetComponent <ActorProp>(); Actor self = selfProp.ActorLogicObj; switch ((ENResultTargetType)info.ResultTargetType) { case ENResultTargetType.enEnemySingle: { //只作用于第一个enemy if (m_skillTarget != null) { if (m_skillTarget != target) { return; } } else { if (m_firstTarget != null) { return; } if (!ActorTargetManager.IsEnemy(self, target)) { return; } m_firstTarget = target; } } break; case ENResultTargetType.enEnemyAll: { //作用于所有enemy if (!ActorTargetManager.IsEnemy(self, target)) { return; } } break; case ENResultTargetType.enFriendlySingle: { //只作用于第一个friendly if (m_skillTarget != null) { if (m_skillTarget != target) { return; } } else { if (m_firstTarget != null) { return; } if (!ActorTargetManager.IsFriendly(self, target)) { return; } m_firstTarget = target; } } break; case ENResultTargetType.enFriendlyAll: { //作用于所有friendly if (!ActorTargetManager.IsFriendly(self, target)) { return; } } break; case ENResultTargetType.enEveryone: break; case ENResultTargetType.enSelf: { if (self != target) { return; } } break; case ENResultTargetType.enFriendlyAllAndSelf: { if (!ActorTargetManager.IsFriendly(self, target) && self != target) { return; } } break; case ENResultTargetType.enFriendlySingleAndSelf: { if (!ActorTargetManager.IsFriendly(self, target) && self != target) { return; } if (m_firstTarget != null) { return; } m_firstTarget = target; } break; default: return; } if (ClientNet.Singleton.IsConnected) { IResult r = BattleFactory.Singleton.CreateResult(ENResult.Skill, self.ID, target.ID, SkillResultID, m_skillInfo != null ? m_skillInfo.ID : 0); if (r != null) { target.SetBlastPos(self.RealPos, self.GetBodyObject().transform.forward); r.ResultExpr(null); BattleFactory.Singleton.GetBattleContext().CreateResultControl().DispatchResult(r); } } else { IResult r = BattleFactory.Singleton.CreateResult(ENResult.Skill, self.ID, target.ID, SkillResultID, m_skillInfo != null ? m_skillInfo.ID : 0); if (r != null) { target.SetBlastPos(self.RealPos, self.GetBodyObject().transform.forward); r.ResultExpr(null); BattleFactory.Singleton.GetBattleContext().CreateResultControl().DispatchResult(r); } } if (!string.IsNullOrEmpty(info.SoundList)) {//播放击中声音 string[] param = info.SoundList.Split(new char[1] { ',' }); string sound = param[0]; if (!string.IsNullOrEmpty(sound)) { #if UNITY_IPHONE || UNITY_ANDRIOD #else AudioClip aClip = PoolManager.Singleton.LoadSound(sound); if (aClip != null) { AudioSource.PlayClipAtPoint(aClip, selfObj.transform.position); } #endif } else { Debug.LogWarning("sound string is null"); } } m_isTriggerSucced = true; m_isMissing = false; }
void OnTriggerEnter(Collider other) { if (!ActorTargetManager.IsTrigger(other)) { return; } try { if (m_info.m_isNeedRemove) { return; } Transform targetObj = other.transform; while (null != targetObj && targetObj.name != "body") { targetObj = targetObj.parent; } if (null == targetObj) { return; } ActorProp actorProp = targetObj.parent.GetComponent <ActorProp>(); if (null == actorProp) { Debug.LogWarning("trigger return, actorProp get failed"); return; } Actor target = actorProp.ActorLogicObj; if (target == null || target.IsDead) { return; } if (m_info.m_itemInfo.IsOnlyForChosenTarget) { //只对选中目标生效 if (target != m_info.m_dstActor) { //不是选中目标 return; } } if (m_info.m_bouncyTargetIDList != null) { //反弹中 if (target != m_info.m_dstActor) { //不是选中目标 return; } } SkillResultInfo info = GameTable.SkillResultTableAsset.Lookup(m_info.m_itemInfo.Item_ResultID); if (info == null) { //Debug.LogWarning("trigger return, SkillResultInfo is null, result id is " + m_info.m_itemInfo.Item_ResultID); return; } switch ((ENResultTargetType)info.ResultTargetType) { case ENResultTargetType.enEnemySingle: case ENResultTargetType.enEnemyAll: { //作用于enemy if (!ActorTargetManager.IsEnemy(m_info.m_actorCamp, m_info.m_actorType, target)) { return; } } break; case ENResultTargetType.enFriendlySingle: case ENResultTargetType.enFriendlyAll: { //作用于friendly if (!ActorTargetManager.IsFriendly(m_info.m_actorCamp, m_info.m_actorType, target)) { return; } } break; case ENResultTargetType.enEveryone: break; case ENResultTargetType.enSelf: if (m_info.m_actorType != target.Type) { return; } break; case ENResultTargetType.enFriendlyAllAndSelf: case ENResultTargetType.enFriendlySingleAndSelf: { if (!ActorTargetManager.IsFriendly(m_info.m_actorCamp, m_info.m_actorType, target) && m_info.m_actorType != target.Type) { return; } } break; default: return; } if (m_targetIDList.Contains(target.ID)) { if (!m_info.m_itemInfo.IsMultiResult) {//不对目标多次生效 return; } } else { m_targetIDList.Add(target.ID); } GlobalEnvironment.Singleton.IsInCallbackOrTrigger = true; IResult r = BattleFactory.Singleton.CreateResult(ENResult.Skill, m_info.m_srcActor.ID, target.ID, m_info.m_itemInfo.Item_ResultID, m_info.m_skillID); if (r != null) { target.SetBlastPos(m_info.m_itemObj.transform.position, m_info.m_itemObj.transform.forward); r.ResultExpr(null); BattleFactory.Singleton.GetBattleContext().CreateResultControl().DispatchResult(r); } if (m_info.m_itemInfo.IsRemoveAfterResult) { m_info.m_isNeedRemove = true; } //播放击中声音 if (!string.IsNullOrEmpty(info.SoundList)) { string[] param = info.SoundList.Split(new char[1] { ',' }); string sound = param[0]; if (!string.IsNullOrEmpty(sound)) { #if UNITY_IPHONE || UNITY_ANDRIOD #else AudioClip aClip = PoolManager.Singleton.LoadSound(sound); if (aClip != null) { AudioSource.PlayClipAtPoint(aClip, gameObject.transform.position); } #endif } else { Debug.LogWarning("sound string is null"); } } RemoteAttackManager.Singleton.StartBouncy(m_info, target.MainPos); } catch (Exception e) { Debug.LogError("Error On OnTriggerEnter" + e.Message + ",,,,Stack:" + e.StackTrace.ToString()); } GlobalEnvironment.Singleton.IsInCallbackOrTrigger = false; }