protected override ErrorCode doStart(ActionInitParam param) { ErrorCode err = base.doStart(param); if (err != ErrorCode.Succeeded) { return(err); } ActionDisplacementInitParam displacementInit = param as ActionDisplacementInitParam; mDisplacementResource = displacementInit.displacementResource; if (mDisplacementResource.leagueSelectionOnExecute != LeagueSelection.None && mDisplacementResource.skillEffect2OthersOnExecute != uint.MaxValue) { mTargetSelectionOnExecute = new TargetSelectionTableItem() { resID = -1, desc = "displacement hit", leagueSel = mDisplacementResource.leagueSelectionOnExecute, maxTargetCount = uint.MaxValue, shape = ShapeType.ShapeType_Rect, RectLength = mDisplacementResource.radiusOnCollide * 2 } } ; return(ErrorCode.Succeeded); }
/// <summary> /// 判断某一skilleffect是否是有害的. /// </summary> /// <param name="type">skilleffect的类型</param> /// <param name="resID">skilleffect的资源ID</param> /// <returns></returns> public static bool IsHarmfulEffect(SkillEffectType type, uint resID) { switch (type) { case SkillEffectType.Buff: SkillBuffTableItem resBuff = DataManager.BuffTable[resID] as SkillBuffTableItem; return(resBuff == null || resBuff.harmful); case SkillEffectType.Impact: SkillImpactTableItem resImpact = DataManager.ImpactTable[resID] as SkillImpactTableItem; return(resImpact == null || resImpact.harmful); case SkillEffectType.Displacement: SkillDisplacementTableItem resDisplacement = DataManager.DisplacementTable[resID] as SkillDisplacementTableItem; return(resDisplacement == null || resDisplacement.harmful); case SkillEffectType.Spasticity: return(true); default: ErrorHandler.Parse(ErrorCode.LogicError, "invalid skill effect type: " + type); break; } return(true); }
/// <summary> /// 开始位移. /// </summary> /// <param name="actionCenter">动作控制器</param> /// <param name="attackerAttr">发起这次位移的单位的属性(如果是突进, 那么是角色本身; 如果是击退, 为发起击退技能的单位)</param> /// <param name="displacementRes"></param> /// <returns></returns> public static ErrorCode StartDisplace(BattleUnitActionCenter actionCenter, AttackerAttr attackerAttr, uint displacementResID) { SkillDisplacementTableItem displacementRes = DataManager.DisplacementTable[displacementResID] as SkillDisplacementTableItem; if (displacementRes == null) { SkillUtilities.ResourceNotFound("displacement", displacementResID); return(ErrorCode.ConfigError); } // 免疫控制(有害的位移, 都视为控制). if (!actionCenter.Owner.CanBeStuned() && displacementRes.harmful) { return(ErrorCode.AddEffectFailedSkillEffectImmunity); } if ((actionCenter.GetActionByType(ActionTypeDef.ActionTypeDisplacement) as ActionDisplacement) != null) { return(ErrorCode.MaxStackCount); } Vector3 ownerPosition = actionCenter.Owner.GetPosition(); Vector3 targetPosition = ownerPosition; float distance = displacementRes.distance; if (distance < 0) { return(ErrorCode.ConfigError); } Vector3 displaceDirection = Vector3.zero; // 确定方向. switch (displacementRes.displacementType) { case SkillDisplacementType.Rush: displaceDirection = Utility.RadianToVector3(actionCenter.Owner.GetDirection()); break; case SkillDisplacementType.Beatback: displaceDirection = Utility.RadianToVector3(attackerAttr.EffectStartDirection); break; default: return(ErrorCode.ConfigError); } displaceDirection.y = 0; // 速度为负, 取反方向. if (displacementRes.speed < 0f) { displaceDirection = Vector3.zero - displaceDirection; } // beatback时, 特殊处理距离与朝向. if (displacementRes.displacementType == SkillDisplacementType.Beatback) { // 击退, 且速度为负时, 表示牵引向目标点. if (displacementRes.speed < 0f) { float magnitude = displaceDirection.magnitude; // 牵引的位置不会超过目标点的位置, 且与目标点的位置至少为0.5f. if (magnitude < distance) { distance = Mathf.Max(0f, magnitude - 0.5f); } } else // 击退时, 面朝起始点方向(后仰). { actionCenter.Owner.SetDirection(Utility.Vector3ToRadian(displaceDirection) + Mathf.PI); } } displaceDirection.Normalize(); displaceDirection *= distance; targetPosition += displaceDirection; BaseScene scn = SceneManager.Instance.GetCurScene(); if (scn == null) { return(ErrorCode.LogicError); } targetPosition = scn.FarthestWalkable(ownerPosition, targetPosition); ActionDisplacementInitParam param = new ActionDisplacementInitParam(); param.targetPosition = targetPosition; param.displacementResource = displacementRes; param.mAttackerAttr = attackerAttr; return(actionCenter.StartAction(param)); }
private bool checkDisplacement() { DataType myName = DataType.DATA_SKILL_DISPLACEMENT; IDictionaryEnumerator itr = DataManager.DisplacementTable.GetEnumerator(); while (itr.MoveNext()) { SkillDisplacementTableItem item = itr.Value as SkillDisplacementTableItem; if (!checkParam(item.displacementType < SkillDisplacementType.Count, myName, item.resID, "type")) { return(false); } if (!checkParam(!Utility.isZero(item.speed), myName, item.resID, "speed")) { return(false); } if (item._3DEffectIdOnExecute != uint.MaxValue && !checkLink(myName, item.resID, DataType.DATA_EFFECT, item._3DEffectIdOnExecute)) { return(false); } if (!checkParam(item.leagueSelectionOnExecute < LeagueSelection.Count, myName, item.resID, "阵营识别")) { return(false); } if (!checkParam(item.radiusOnCollide >= 0, myName, item.resID, "碰撞半径")) { return(false); } if (!checkParam(!item.interruptSkillUsing || item.displacementType == SkillDisplacementType.Beatback, myName, item.resID, "打断技能", "只有类型为" + (uint)SkillDisplacementType.Beatback + "的displacement才可以打断技能")) { return(false); } if (item.skillEffect2OthersOnExecute != uint.MaxValue && !checkLink(myName, item.resID, DataType.DATA_SKILL_EFFECT, item.skillEffect2OthersOnExecute)) { return(false); } if (item.skillEffect2SelfOnArrive != uint.MaxValue && !checkLink(myName, item.resID, DataType.DATA_SKILL_EFFECT, item.skillEffect2SelfOnArrive)) { return(false); } if (item.targetSelectionOnArrive != uint.MaxValue && !checkLink(myName, item.resID, DataType.DATA_SKILL_TARGET_SELECTION, item.targetSelectionOnArrive)) { return(false); } if (item.skillEffect2OthersOnArrive != uint.MaxValue && !checkLink(myName, item.resID, DataType.DATA_SKILL_EFFECT, item.skillEffect2OthersOnArrive)) { return(false); } } // foreach (int key in DataManager.DisplacementTable.Keys) // { // // } return(true); }