public bool AddBuff(ISkill skill, int buffId) { SkillUtil.LogWarning(string.Format(" [BUFFMANAGER] [NAME]->{0} AddBuff-> {1}", mContext.GetSelfActor().GetTransform().name, buffId)); IBuff buff = null; bool canModify = true; float life = 0; if (buffMap.ContainsKey(buffId)) { buff = buffMap[buffId]; canModify = buff is IOverLayBuff; /*Buff * 1.已经拥有 2.有持续时间 3.不可叠加 * -》直接刷新Buff的持续时间(Life) */ if (!canModify) { RefreshTimerLife(buff); } } else { var data = SkillUtil.GetSkillBuffData(buffId); bool isOverLay = data.Attributes.Contains((int)EBuffAttributes.CanAdd); buff = isOverLay ? new OverlayBuff() : new Buff(); buff.Create(skill, mContext.GetSelfActor(), buffId); buffMap.Add(buffId, buff); } if (canModify) //只有新加的和可叠加的Buff才能触发Modify { BuffModify(buffId); //1.先判定这个Buff 是不是一个循环定时器 if (!TryAddLoopTimer(buffId)) { life = buff.GetDuringTime(); if (life > 0) { /* 可以执行到此处满足的条件: * 1.不是循环定时器 2.有效的Buff生命周期life 3.可以叠加效果的老BUFF或者刚刚添加的新BUFF * =》生成一个新的计时器 */ CreateNormalTimer(life, buffId); } } } OnBuffEventDispatch(EBuffActionType.AddBuff); return(true); }
void PlayAnimation() { if (!string.IsNullOrEmpty(data.SkillCastAnimation)) { context.GetSelfActor().PlayAnimation(data.SkillCastAnimation); } }
private Vector3 GetCenterTarget(ISkillContext context, SkillActionData data, CommonParam param) { var centerType = (SkillTargetCenter)data.Center; Vector3 pos = Vector3.zero; switch (centerType) { case SkillTargetCenter.Caster: pos = context.GetSelfActor().GetTransform().position; break; case SkillTargetCenter.Target: pos = param.ActorClicked?.GetTransform().position ?? pos; break; case SkillTargetCenter.Point: pos = param.Postion; break; case SkillTargetCenter.Attacker: //todo break; case SkillTargetCenter.Projectile: //todo break; case SkillTargetCenter.ProjectileHitPoint: //todo break; } return(pos); }
private void FilterTarget(ISkillContext context, SkillActionData data, CommonParam param) { removelist.Clear(); var targets = param.Targets; var needTeamType = (SkillTargetTeamType)data.Team; for (int i = 0; i < targets.Count; i++) { var target = targets[i]; if (needTeamType != SkillTargetTeamType.ALl) //阵营 { var targetTeamType = target.GetTargetTeamType(); if (target == context.GetSelfActor()) //todo 待数据层成型 删除 { targetTeamType = SkillTargetTeamType.Friend; } if (targetTeamType != needTeamType) { removelist.Add(target); } } if (!data.Type.Contains((int)SkillTargetType.All)) //类型 { for (int j = 0; j < data.Type.Count; j++) { var needType = (SkillTargetType)data.Type[j]; if (needType == target.GetTargetType()) { break; } if (j == data.Type.Count - 1) { removelist.Add(target); } } } } for (int i = 0; i < removelist.Count; i++) { targets.Remove(removelist[i]); } }
/// <summary> /// 弹射模式下的搜索 /// </summary> /// <param name="context"></param> /// <param name="data"></param> /// <param name="param"></param> private void BounceSearch(ISkillContext context, SkillActionData data, CommonParam param) { if (data.Id != param.BounceParam.SearchTargetActionId) { return; } param.ResetTarget(); var bounceData = SkillUtil.GetSkillActionData(param.BounceParam.BounceActionId); //弹射检查范围 SkillUtil.TryParseWithDebug(bounceData.Para4, out int range, "弹射范围"); bool isIgnoreRepeat = string.Equals("1", data.Para5); //todo fake data,need real check var targetArrary = GameObject.FindObjectsOfType <TestSkillActor>(); param.AddTargets(targetArrary); FilterTarget(context, data, param); var targets = param.Targets; //1.排除自己 //2.排除已经弹射过的 //3.找距离最近的 //4.已经死亡的排除 float minDistance = float.MaxValue; ISkillActor nearestActor = null; for (int i = 0; i < targets.Count; i++) { var target = targets[i]; if (target.IsDead()) { continue; } //todo TestSkillActor remove if ((TestSkillActor)target == (TestSkillActor)context.GetSelfActor()) { continue; } if (!isIgnoreRepeat && param.BounceParam.HasBounced(target)) { continue; } var distance = Vector3.Distance(target.GetTransform().position, param.BounceParam.LastBouncedActor.GetTransform().position); if (distance < minDistance && distance <= range) { minDistance = distance; nearestActor = target; } } param.ResetTarget(); if (nearestActor != null) { param.AddTarget(nearestActor); } }
private void NormalGetTargets(ISkillContext context, SkillActionData data, CommonParam param) { var rangeType = (SkillTargetRangeType)data.Radius.Key; var centerType = (SkillTargetCenter)data.Center; //线性投射会把Hit的目标动态AddTarget进来 //跟踪投射 策划会配置Center为2 if (centerType != SkillTargetCenter.ProjectileHitPoint) { param.ResetTarget(); } if (rangeType == SkillTargetRangeType.None) //不需要检测距离 { switch (centerType) { case SkillTargetCenter.Caster: //添加技能施放者 param.AddTarget(context.GetSelfActor()); break; case SkillTargetCenter.Target: //添加被施法目标 param.AddTarget(param.ActorClicked); break; default: //todo delete this later param.AddTarget(param.ActorClicked); break; } } else { Vector3 center = Vector3.zero; center = GetCenterTarget(context, data, param); var range = data.Radius.Value; switch (rangeType) { //todo case SkillTargetRangeType.Circle: case SkillTargetRangeType.Rect: case SkillTargetRangeType.Sector: //todo fake 暂时都按照 Radius处理 var targetArrary = GameObject.FindObjectsOfType <TestSkillActor>(); for (int i = 0; i < targetArrary.Length; i++) { var target = targetArrary[i]; if (target.IsDead()) { continue; } var distance = Vector3.Distance(target.GetTransform().position, center); if (distance <= range) { param.AddTarget(target); } } break; } } }