// Start void Start() { inst = GetComponent<SkillInstance>(); caster = inst.caster; speed = caster.baseMoveSpeed * moveSpeedMultiplier; //forwardVector = caster.charGraphics.forward * (caster.baseMoveSpeed * moveSpeedMultiplier); //caster.hasControlOverMovement = false; }
public SkillInstance GetSkillInstanceByName(string name) { SkillInstance ret = null; if (name.Equals ("Base_Kick")) { ret = new SkillInstance (); ret.Id_ = ++m_Id; ret.Name_ = name; ret.ColliderName_ = "NormalAttackCollider"; ret.Fx_ = null; ret.Sound_ = null; ret.TrackClass_ = "TrackMovementKickBase"; } return ret; }
public void SkillButtonClicked(SkillInstance skill) { skill.OnAcivate(PlayerObject); }
Vector2 AddSkill(SkillInstance skill, Vector2 offset) { return AddSkill(skill.BaseSkill, skill.Level, offset, skill); }
// SpawnSkillPrefab public void SpawnSkillPrefab( GameObject prefabSpawned, Vector3 position, Quaternion rotation, out GameObject clone, out SkillInstance inst ) { clone = (GameObject)Object.Instantiate(prefabSpawned, position, rotation); clone.transform.parent = Entity.skillInstancesRoot; clone.layer = gameObject.layer; inst = clone.GetComponent<SkillInstance>(); inst.caster = caster; inst.skill = skill; inst.skillStage = skillStage; }
public virtual bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime) { return false; }
// Use this for initialization void Awake() { base.Awake (); m_PlayerState = PlayerState.PlayerStateIdle; m_CharacterController = GetComponent<CharacterController> (); m_CurrentSkillInstance = null; m_SkillTriggerObjectList = new List<GameObject> (); m_Animator = GetComponent<AnimatorAlpha> (); if (m_CharacterController) {} }
private int TryGetTimeFromConfig(SkillInstance instance) { return(SkillParamUtility.RefixNonStringVariable <int>(m_Type, instance)); }
public override bool Cast(Entity target, string skillKey, bool autocast = false) { string tryAlias = Engine.GetSkillManager().GetKeyFromAlias(skillKey); if (tryAlias == null) { tryAlias = skillKey; } SkillInstance skill = Skills.ContainsKey(tryAlias) ? Skills[tryAlias] : null; if (skill == null) { Engine.Log().Log($"[{Name}] You don't have that skill({tryAlias})."); //log that you don't have that skill return(false); } if (skill.CooldownFinishTime != 0) { long seconds = (skill.CooldownFinishTime - Engine.GetTimer().GetNow()) / GameConstants.TickTime; Engine.Log().Log($"[{Name}] {skill.Skill.Name} is on cooldown for {seconds} s."); return(false); } if (!Free) { Engine.Log().Log($"[{Name}] You are busy."); return(false); } if (!ResourceMap.ContainsKey(skill.Values().Cost.Resource.Key)) { Engine.Log().Log($"[{Name}] You don't have \"{skill.Values().Cost.Resource.Name}\"."); return(false); } ResourceInstance res = ResourceMap[skill.Values().Cost.Resource.Key]; double amount = Sanitizer.ReplacePropeties(skill.Values().Cost.Amount, this).Resolve().Value.ToDouble(); if (!res.CanCast(amount)) { Engine.Log().Log($"[{Name}] Not enough {skill.Values().Cost.Resource.Name} for {skill.Skill.Name}."); return(false); } res.Cast(amount); Free = false; CurrentlyCasting = new SkillCastData(skill, target, this, Engine.GetTimer().GetNow()); long time = CurrentlyCasting.CastFinishTime - Engine.GetTimer().GetNow(); if (time >= GameConstants.TickTime * 3) { string type = skill.Skill.Type == SkillType.Cast ? "casting" : "channeling"; string castedFinish = Key.Equals(CurrentlyCasting.Target.Key) ? "" : $" on {CurrentlyCasting.Target.Name}"; Engine.Log() .Log( $"[{Name}] Started {type} {CurrentlyCasting.Skill.Skill.Name}{castedFinish}."); } return(true); }
override public void Update(IM.Number fDeltaTime) { base.Update(fDeltaTime); if (m_player.CanRebound(m_ball) && (timerRebound == null || timerRebound.stop)) { //Debug.Log("Rebound info of " + m_player.m_name); ReboundAttrConfig.ReboundAttr attr = GameSystem.Instance.ReboundAttrConfigData.GetReboundAttr(m_player.m_position); if (attr == null) { Debug.LogError("Rebound height config error."); } ShootSolution.SShootCurve curve = m_ball.CompleteLastCurve(); IM.Number ballHeight = m_ball.position.y; ballHeight *= (IM.Number.one - m_system.AI.devBallHeight); if (ballHeight >= attr.minHeight) { //Debug.Log("Rebound max height: " + attr.maxHeight +" Ball height: " + ballHeight + " Rebound height scale: " + attr.reboundHeightScale + " Ball height scale: " + attr.ballHeightScale); IM.Number npcReboundBallHeight = AIUtils.GetNPCReboundBallHeight(attr.maxHeight, ballHeight, attr.reboundHeightScale, attr.ballHeightScale); //Debug.Log("NPC rebound ball height: " + npcReboundBallHeight); IM.Number time1, time2; curve.GetTimeByHeight(npcReboundBallHeight, out time1, out time2); IM.Number ballFlyTime = time2; //Debug.Log("Ball fly time: " + ballFlyTime); if (ballFlyTime < -new IM.Number(0, 1)) { Debug.LogError("Ball fly time error."); } SkillInstance basicRebound = m_player.m_skillSystem.GetBasicSkillsByCommand(Command.Rebound)[0]; string basicActionId = basicRebound.skill.actions[0].action_id; IM.Number frameRate = m_player.animMgr.GetFrameRate(basicActionId); Dictionary <string, PlayerAnimAttribute.AnimAttr> rebounds = m_player.m_animAttributes.m_rebound; int reboundKey = rebounds[m_player.animMgr.GetOriginName(basicActionId)].GetKeyFrame("OnRebound").frame; IM.Number reboundActionTime = reboundKey / frameRate; IM.Number reboundDelayTime = ballFlyTime - m_ball.m_fTime - reboundActionTime; //Debug.Log("Rebound delay time: " + reboundDelayTime); if (reboundDelayTime < IM.Number.zero) { reboundDelayTime = IM.Number.zero; } timerRebound.SetTimer(reboundDelayTime); timerRebound.stop = false; return; } } if (m_ball.m_owner != null) { m_system.SetTransaction(AIState.Type.eIdle); } else { IM.Vector3 vMoveTarget = m_ball.position; if (m_ball.m_ballState == BallState.eUseBall_Shoot) { vMoveTarget = m_match.mCurScene.mBasket.m_vShootTarget; } vMoveTarget.y = IM.Number.zero; m_moveTarget = vMoveTarget; m_player.m_moveType = fogs.proto.msg.MoveType.eMT_Rush; if (m_ball.m_ballState == BallState.eLoseBall && (m_player.m_position == PositionType.PT_PG || m_player.m_position == PositionType.PT_SG)) { IM.Vector3 ballPos = m_ball.position; IM.Number distToBall = GameUtils.HorizonalDistance(ballPos, m_player.position); if (distToBall < PlayerState_BodyThrowCatch.GetMaxDistance(m_player) && ballPos.y <= IM.Number.one) { m_system.SetTransaction(AIState.Type.eBodyThrowCatch); } } } if (timerRebound != null) { timerRebound.Update(fDeltaTime); } }
private bool Prepare(GfxSkillSenderInfo senderObj, SkillInstance instance, GameObject obj, GameObject targetObj) { if (!m_TargetChecked) { m_TargetChecked = true; m_RealDuration = m_Duration; m_RealVelocity = m_Velocity; if (m_RealDuration <= 0) { m_RealDuration += instance.CurSectionDuration; } if (m_RealDuration <= 0) { LogSystem.Warn("charge duration is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId); return(false); } m_StartPos = obj.transform.position; Vector3 targetPos = Vector3.zero; if (null != targetObj) { targetPos = targetObj.transform.position; } if (!m_IsFreeMove && targetPos.sqrMagnitude > Geometry.c_FloatPrecision) { float degree = Geometry.GetYRadian(new ScriptRuntime.Vector2(m_StartPos.x, m_StartPos.z), new ScriptRuntime.Vector2(targetPos.x, targetPos.z)); ScriptRuntime.Vector2 newPos; if (m_RandRelativeToSelf) { int v = Helper.Random.Next(); if (v < 50) { newPos = new ScriptRuntime.Vector2(m_StartPos.x, m_StartPos.z) + Geometry.GetRotate(new ScriptRuntime.Vector2(m_Offset.x, m_Offset.z), degree); targetPos = new Vector3(newPos.X, m_StartPos.y + m_Offset.y, newPos.Y); } else { newPos = new ScriptRuntime.Vector2(m_StartPos.x, m_StartPos.z) + Geometry.GetRotate(new ScriptRuntime.Vector2(-m_Offset.x, m_Offset.z), degree); targetPos = new Vector3(newPos.X, m_StartPos.y + m_Offset.y, newPos.Y); } } else if (m_RelativeToSelf) { newPos = new ScriptRuntime.Vector2(m_StartPos.x, m_StartPos.z) + Geometry.GetRotate(new ScriptRuntime.Vector2(m_Offset.x, m_Offset.z), degree); targetPos = new Vector3(newPos.X, m_StartPos.y + m_Offset.y, newPos.Y); } else if (m_RandRelativeToTarget) { int v = Helper.Random.Next(); if (v < 50) { newPos = new ScriptRuntime.Vector2(targetPos.x, targetPos.z) + Geometry.GetRotate(new ScriptRuntime.Vector2(m_Offset.x, m_Offset.z), degree); targetPos = new Vector3(newPos.X, targetPos.y + m_Offset.y, newPos.Y); } else { newPos = new ScriptRuntime.Vector2(targetPos.x, targetPos.z) + Geometry.GetRotate(new ScriptRuntime.Vector2(-m_Offset.x, m_Offset.z), degree); targetPos = new Vector3(newPos.X, targetPos.y + m_Offset.y, newPos.Y); } } else { newPos = new ScriptRuntime.Vector2(targetPos.x, targetPos.z) + Geometry.GetRotate(new ScriptRuntime.Vector2(m_Offset.x, m_Offset.z), degree); targetPos = new Vector3(newPos.X, targetPos.y + m_Offset.y, newPos.Y); } m_Forward = targetPos - m_StartPos; m_Forward.y = 0; m_Forward.Normalize(); if (m_StopAtTarget == (int)StopAtTargetType.AdjustVelocity) { m_RealVelocity = (long)(1000.0f * (targetPos - m_StartPos).magnitude / m_RealDuration); m_TargetPos = targetPos; } else if (m_StopAtTarget == (int)StopAtTargetType.AdjustTime) { m_RealDuration = (long)(1000.0f * (targetPos - m_StartPos).magnitude / m_RealVelocity); m_TargetPos = targetPos; } else { m_TargetPos = m_StartPos + m_Forward * m_RealVelocity * m_RealDuration / 1000.0f; } } else { if (m_RandRelativeToSelf) { int v = Helper.Random.Next(); if (v < 50) { m_TargetPos = obj.transform.TransformPoint(m_Offset.x, 0, m_Offset.z); } else { m_TargetPos = obj.transform.TransformPoint(-m_Offset.x, 0, m_Offset.z); } } else if (m_RelativeToSelf) { m_TargetPos = obj.transform.TransformPoint(m_Offset.x, 0, m_Offset.z); } else { m_TargetPos = obj.transform.TransformPoint(0, 0, m_RealVelocity * m_RealDuration / 1000.0f); } m_Forward = obj.transform.forward; } } return(true); }
public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime) { GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo; if (null == senderObj) { return(false); } GameObject obj = senderObj.GfxObj; if (null == obj) { return(false); } GameObject targetObj = senderObj.TargetGfxObj; if (null != senderObj.TrackEffectObj) { obj = senderObj.TrackEffectObj; targetObj = senderObj.GfxObj; } if (curSectionTime < StartTime) { return(true); } else if (curSectionTime <= StartTime + m_RealDuration) { if (!Prepare(senderObj, instance, obj, targetObj)) { return(false); } if (null != m_Curve && m_Curve.keys.Length >= 2) { float time = Mathf.Clamp01((curSectionTime - StartTime) * 1.0f / m_RealDuration); float val = m_Curve.Evaluate(time); Vector3 targetPos = Vector3.SlerpUnclamped(new Vector3(m_StartPos.x, m_StartPos.y, m_StartPos.z), new Vector3(m_TargetPos.x, m_StartPos.y, m_StartPos.z), val); if (!m_IsFreeMove) { if (!TriggerUtil.RaycastNavmesh(obj.transform.position, targetPos)) { TriggerUtil.MoveObjTo(obj, targetPos); } else { targetPos = TriggerUtil.GetGroundPos(targetPos); TriggerUtil.MoveObjTo(obj, targetPos); } } else { TriggerUtil.MoveObjTo(obj, targetPos); } } else { float dist = TriggerUtil.ConvertToSecond(delta) * m_RealVelocity; Vector3 targetPos = obj.transform.position + m_Forward * dist; if (!m_IsFreeMove) { if (!TriggerUtil.RaycastNavmesh(obj.transform.position, targetPos)) { TriggerUtil.MoveObjTo(obj, targetPos); } else { targetPos = TriggerUtil.GetGroundPos(targetPos); TriggerUtil.MoveObjTo(obj, targetPos); } } else { TriggerUtil.MoveObjTo(obj, targetPos); } } return(true); } else { Vector3 diff = m_TargetPos - obj.transform.position; if (diff.sqrMagnitude > 0.01f) { Vector3 targetPos = m_TargetPos; if (!m_IsFreeMove) { if (!TriggerUtil.RaycastNavmesh(obj.transform.position, targetPos)) { TriggerUtil.MoveObjTo(obj, targetPos); } else { targetPos = TriggerUtil.GetGroundPos(targetPos); TriggerUtil.MoveObjTo(obj, targetPos); } } else { TriggerUtil.MoveObjTo(obj, targetPos); } } return(false); } }
public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime) { GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo; if (null == senderObj) { return(false); } GameObject obj = senderObj.GfxObj; if (null == obj) { return(false); } if (null != senderObj.TrackEffectObj) { obj = senderObj.TrackEffectObj; } if (curSectionTime < StartTime) { return(true); } if (!m_IsCurveMoving) { return(false); } if (!m_IsInited) { Init(senderObj, instance); } if (m_SectionListCopy.Count == 0) { m_IsCurveMoving = false; return(false); } m_Now += TriggerUtil.ConvertToSecond((long)(instance.OriginalDelta * instance.MoveScale)); MoveSectionInfo cur_section = m_SectionListCopy[0]; if (m_Now - cur_section.startTime > cur_section.moveTime) { float end_time = cur_section.startTime + cur_section.moveTime; float used_time = end_time - cur_section.lastUpdateTime; cur_section.curSpeedVect = Move(obj, cur_section.curSpeedVect, cur_section.accelVect, used_time); m_SectionListCopy.RemoveAt(0); if (m_SectionListCopy.Count > 0) { cur_section = m_SectionListCopy[0]; cur_section.startTime = end_time; cur_section.lastUpdateTime = end_time; cur_section.curSpeedVect = cur_section.speedVect; } else { m_IsCurveMoving = false; } } else { cur_section.curSpeedVect = Move(obj, cur_section.curSpeedVect, cur_section.accelVect, m_Now - cur_section.lastUpdateTime); cur_section.lastUpdateTime = m_Now; } return(true); }
public SkillInstance NewSkillINstance(int skillBaseId) { SkillInstance skillInstance = new SkillInstance(mDic_BaseSkillInstance[skillBaseId]); return(skillInstance); }
public void RemoveInstance(SkillInstance ins) { mSkillIns.Remove(ins); }
public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime) { GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo; if (null == senderObj) { return(false); } GameObject obj = senderObj.GfxObj; if (null == obj) { return(false); } if (curSectionTime < StartTime) { return(true); } if (0 == m_Type.CompareTo("anim")) { Animator animator = obj.GetComponentInChildren <Animator>(); if (null != animator) { float length = 0; int layerCount = animator.layerCount; for (int i = 0; i < layerCount; ++i) { AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(i); //LogSystem.Info("adjustsectionduration anim, skill id:{0} dsl skill id:{1}, length:{2} normalized time:{3} loop:{4} layer:{5} layer count:{6}", senderObj.SkillId, instance.DslSkillId, stateInfo.length, stateInfo.normalizedTime, stateInfo.loop, i, layerCount); if (length < stateInfo.length && !float.IsInfinity(stateInfo.length)) { length = stateInfo.length; } } if (length > Geometry.c_FloatPrecision) { long newDuration = (long)(length * 1000) + m_DeltaTime; if (instance.CurSectionDuration < newDuration) { instance.SetCurSectionDuration(newDuration); } } else { //LogSystem.Warn("adjustsectionduration anim length is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId); return(true); } } } else if (0 == m_Type.CompareTo("impact")) { int time = EntityController.Instance.GetImpactDuration(senderObj.ActorId, senderObj.SkillId, senderObj.Seq); if (time > 0) { long newDuration = (long)time + m_DeltaTime; if (instance.CurSectionDuration < newDuration) { instance.SetCurSectionDuration(newDuration); } } else { LogSystem.Warn("adjustsectionduration impact duration is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId); } } else { bool handled = false; Animator animator = obj.GetComponentInChildren <Animator>(); if (null != animator && null != animator.runtimeAnimatorController) { float length = 0; var clips = animator.runtimeAnimatorController.animationClips; for (int i = 0; i < clips.Length; ++i) { if (clips[i].name == m_Type) { length = clips[i].length; handled = true; break; } } if (length > Geometry.c_FloatPrecision) { long newDuration = (long)(length * 1000) + m_DeltaTime; if (instance.CurSectionDuration < newDuration) { instance.SetCurSectionDuration(newDuration); } } else { LogSystem.Warn("adjustsectionduration variable time is 0, skill id:{0} dsl skill id:{1} type:{2}", senderObj.SkillId, instance.DslSkillId, m_Type); } } if (!handled) { int time = TryGetTimeFromConfig(instance); if (time > 0) { long newDuration = (long)time + m_DeltaTime; if (instance.CurSectionDuration < newDuration) { instance.SetCurSectionDuration(newDuration); } } else { LogSystem.Warn("adjustsectionduration variable time is 0, skill id:{0} dsl skill id:{1} type:{2}", senderObj.SkillId, instance.DslSkillId, m_Type); } } } return(false); }
private void Load(ScriptableDataFile dataFile) { lock (m_Lock) { foreach (ScriptableDataInfo info in dataFile.ScriptableDatas) { if (info.GetId() == "skill") { FunctionData funcData = info.First; if (null != funcData) { CallData callData = funcData.Call; if (null != callData && callData.HaveParam()) { int id = int.Parse(callData.GetParamId(0)); if (!m_SkillInstances.ContainsKey(id)) { SkillInstance instance = new SkillInstance(); instance.Init(info); m_SkillInstances.Add(id, instance); Logger.Info("ParseSkill {0}", id); } else { //repeated skill config. } } } } } } }
public void AddSkill(SkillInstance skill) { m_Skills.Add(skill); skill.AttachToCharacter(this); }
public void ExcecuteSkillInstance(SkillInstance si) { GameObject go = ColliderManager.Instance.SpawnCollider (si.ColliderName_); TriggerEventObject teObj = go.AddComponent<TriggerEventObject> (); teObj.Owner = this; TrackMovement trackMovement = SkillManager.Instance.AddTrackComponent (go, si.TrackClass_); trackMovement.Target = gameObject; trackMovement.Switch = true; if (!m_SkillTriggerObjectList.Contains (go)) { m_SkillTriggerObjectList.Add (go); } }
public void LoadFuncData(Dsl.FunctionData funcData, SkillInstance instance) { }
public virtual void Analyze(object sender, SkillInstance instance) { }
public void LoadStatementData(Dsl.StatementData statementData, SkillInstance instance) { }
public bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime) { GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo; if (null == senderObj) { return(false); } if (senderObj.ConfigData.type == (int)SkillOrImpactType.Skill) { return(false);//track只能在impact或buff里使用 } GameObject obj = senderObj.GfxObj; if (null != obj) { if (curSectionTime >= m_TriggerProxy.StartTime) { if (!m_IsStarted) { m_IsStarted = true; Vector3 dest; string trackBone = m_TrackBone.Get(instance); m_BoneTransform = Utility.FindChildRecursive(obj.transform, trackBone); if (null != m_BoneTransform) { dest = m_BoneTransform.position; } else { dest = obj.transform.position; dest.y += 1.5f; LogSystem.Warn("[skill:{0} dsl skill id:{1}] trackbullet bone {2} can't find.", senderObj.SkillId, instance.DslSkillId, trackBone); } m_StartPos = EntityController.Instance.GetImpactSenderPosition(senderObj.ActorId, senderObj.SkillId, senderObj.Seq); object speedObj; if (instance.Variables.TryGetValue("emitSpeed", out speedObj)) { m_Speed = (float)speedObj; } else { return(false); } long duration = m_Duration.Get(instance); m_Lifetime = duration / 1000.0f; if (Geometry.DistanceSquare(m_StartPos.x, m_StartPos.z, dest.x, dest.z) > 0.01f) { m_TargetPos = Utility.FrontOfTarget(dest, m_StartPos, m_Speed * m_Lifetime); } else { m_TargetPos = obj.transform.TransformPoint(0, 0, m_Speed * m_Lifetime); } long newSectionDuration = m_TriggerProxy.StartTime + (long)(m_Lifetime * 1000); if (instance.CurSectionDuration < newSectionDuration) { instance.SetCurSectionDuration(newSectionDuration); } Quaternion dir; object dirObj; if (instance.Variables.TryGetValue("emitDir", out dirObj)) { dir = (Quaternion)dirObj; } else { dir = Quaternion.identity; } Vector3 scale; object scaleObj; if (instance.Variables.TryGetValue("emitScale", out scaleObj)) { scale = (Vector3)scaleObj; } else { scale = Vector3.one; } Vector3 lookDir = dest - m_StartPos; Quaternion q = Quaternion.LookRotation(lookDir); m_ControlPos = m_StartPos + Vector3.Scale(q * dir * Vector3.forward, scale * lookDir.magnitude * 0.5f); string effectPath = SkillParamUtility.RefixResourceVariable("emitEffect", instance, senderObj.ConfigData.resources); m_Effect = ResourceSystem.Instance.NewObject(effectPath, m_Lifetime) as GameObject; if (null != m_Effect) { senderObj.TrackEffectObj = m_Effect; TriggerUtil.SetObjVisible(m_Effect, true); m_Effect.SetActive(false); m_Effect.transform.position = m_StartPos; m_Effect.transform.localRotation = q; m_Effect.SetActive(true); EffectManager em = instance.CustomDatas.GetData <EffectManager>(); if (em == null) { em = new EffectManager(); instance.CustomDatas.AddData <EffectManager>(em); } em.AddEffect(m_Effect); em.SetParticleSpeed(instance.EffectScale); } else { if (string.IsNullOrEmpty(effectPath)) { LogSystem.Warn("[skill:{0} dsl skill id:{1}] trackbullet effect is empty.", senderObj.SkillId, instance.DslSkillId); } else { LogSystem.Warn("[skill:{0} dsl skill id:{1}] trackbullet effect {2} can't find.", senderObj.SkillId, instance.DslSkillId, effectPath); } } } else if (null != m_Effect) { Vector3 dest; if (null != m_BoneTransform) { dest = m_BoneTransform.position; } else { dest = obj.transform.position; dest.y += 1.5f; } dest = Utility.FrontOfTarget(m_StartPos, dest, 0.1f); //m_Effect.transform.position = Vector3.MoveTowards(m_Effect.transform.position, m_TargetPos, m_RealSpeed * Time.deltaTime); m_Effect.transform.position = Utility.GetBezierPoint(m_StartPos, m_ControlPos, m_TargetPos, (curSectionTime - m_TriggerProxy.StartTime) / 1000.0f / m_Lifetime); var pos = m_Effect.transform.position; if (!m_IsHit) { float distSqr = float.MaxValue; if (m_LastPos.sqrMagnitude > Geometry.c_FloatPrecision) { ScriptRuntime.Vector2 np; ScriptRuntime.Vector2 targetPos = new ScriptRuntime.Vector2(dest.x, dest.z); ScriptRuntime.Vector2 lastPos = new ScriptRuntime.Vector2(m_LastPos.x, m_LastPos.z); distSqr = Geometry.PointToLineSegmentDistanceSquare(targetPos, lastPos, new ScriptRuntime.Vector2(pos.x, pos.z), out np); } else { distSqr = (dest - pos).sqrMagnitude; } m_LastPos = pos; if (distSqr <= m_BulletRadiusSquare) { float curTime = Time.time; float interval = m_DamageInterval.Get(instance) / 1000.0f; if (m_LastTime + interval <= curTime) { m_LastTime = curTime; m_HitEffectRotation = Quaternion.LookRotation(m_StartPos - dest); int impactId = TriggerUtil.GetSkillImpactId(instance.Variables, senderObj.ConfigData); Dictionary <string, object> args; TriggerUtil.CalcImpactConfig(0, impactId, instance, senderObj.ConfigData, out args); if (args.ContainsKey("hitEffectRotation")) { args["hitEffectRotation"] = m_HitEffectRotation; } else { args.Add("hitEffectRotation", m_HitEffectRotation); } EntityController.Instance.TrackSendImpact(senderObj.ActorId, senderObj.SkillId, senderObj.Seq, impactId, args); //m_IsHit = true; } } } if (curSectionTime > m_TriggerProxy.StartTime + m_Lifetime * 1000) { m_Effect.SetActive(false); ResourceSystem.Instance.RecycleObject(m_Effect); m_Effect = null; instance.StopCurSection(); return(false); } } else { return(false); } return(true); } else { return(true); } } else { instance.StopCurSection(); return(false); } }
protected void _UpdatePassiveStateTransaction(SkillInstance newSkill) { if (newSkill == null) { return; } //Debug.Log(m_player.m_id + " Execute skill " + newSkill.skill.id + " " + newSkill.skill.name); Command cmd = (Command)newSkill.skill.action_type; if (!IsCommandValid(cmd)) { Debug.Log("Command " + cmd + " invalid. State: " + m_eState); return; } switch (cmd) { case Command.Shoot: ShootHelper.ShootByInput(m_player); break; case Command.Block: m_stateMachine.SetState(PlayerState.State.eBlock, true); break; case Command.CrossOver: m_stateMachine.SetState(PlayerState.State.eCrossOver, true); break; case Command.Dunk: m_stateMachine.SetState(PlayerState.State.eDunk, true); break; case Command.Layup: m_stateMachine.SetState(PlayerState.State.eLayup, true); break; case Command.MoveStep: m_stateMachine.SetState(PlayerState.State.eMoveStep, true); break; case Command.Boxout: m_stateMachine.SetState(PlayerState.State.eStand); break; case Command.Steal: m_stateMachine.SetState(PlayerState.State.eSteal, true); break; case Command.Pass: { if (m_player.m_passTarget == null) { m_player.m_passTarget = PassHelper.ChoosePassTarget(m_player); } if (m_player.m_passTarget != null) { m_stateMachine.SetState(PlayerState.State.ePass, true); } } break; case Command.Rebound: m_stateMachine.SetState(PlayerState.State.eRebound, true); break; case Command.RequireBall: m_stateMachine.SetState(PlayerState.State.eRequireBall); break; case Command.CutIn: m_stateMachine.SetState(PlayerState.State.eCutIn); break; case Command.BodyThrowCatch: m_stateMachine.SetState(PlayerState.State.eBodyThrowCatch); break; case Command.BackToBack: m_stateMachine.SetState(PlayerState.State.eBackToBack); break; case Command.PickAndRoll: m_stateMachine.SetState(PlayerState.State.ePickAndRoll); break; case Command.Defense: m_stateMachine.SetState(PlayerState.State.eDefense); break; case Command.Interception: m_stateMachine.SetState(PlayerState.State.eInterception); break; default: m_stateMachine.SetState(PlayerState.State.eStand); break; } }
protected bool InAttackRange(SkillInstance skill) { return DistToTarget() <= skill.BaseSkill.Range; }
public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime) { GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo; if (null == senderObj) { return(false); } Scene scene = senderObj.Scene; EntityInfo obj = senderObj.GfxObj; if (null == obj) { return(false); } if (curSectionTime < StartTime) { return(true); } if (m_IsExecuted && curSectionTime > (StartTime + m_RemainTime)) { return(false); } Vector3 pos = obj.GetMovementStateInfo().GetPosition3D(); EntityInfo target = senderObj.TargetGfxObj; if (!m_IsExecuted && (null == target || !string.IsNullOrEmpty(m_SelectTargetType))) { if (string.IsNullOrEmpty(m_SelectTargetType)) { int targetType = scene.EntityController.GetTargetType(senderObj.ActorId, senderObj.ConfigData, senderObj.Seq); if (targetType == (int)SkillTargetType.Friend || targetType == (int)SkillTargetType.RandFriend) { m_RealSelectTargetType = "randfriend"; } else { m_RealSelectTargetType = "randenemy"; } } TargetManager mgr = instance.CustomDatas.GetData <TargetManager>(); if (null == mgr) { mgr = new TargetManager(); instance.CustomDatas.AddData(mgr); } int targetId = scene.EntityController.SelectTargetForSkill(m_RealSelectTargetType, senderObj.ActorId, senderObj.ConfigData, senderObj.Seq, mgr.Targets); if (targetId > 0) { mgr.Add(targetId); target = scene.EntityController.GetGameObject(targetId); senderObj.TargetActorId = targetId; senderObj.TargetGfxObj = target; } } if (null != target) { m_IsExecuted = true; if (!m_IsHaveRotateSpeed || m_RotateSpeed.Y == 0) { TriggerUtil.Lookat(scene, obj, target.GetMovementStateInfo().GetPosition3D()); } else { float maxRotateDelta = m_RotateSpeed.Y * TriggerUtil.ConvertToSecond(delta); TriggerUtil.Lookat(scene, obj, target.GetMovementStateInfo().GetPosition3D(), maxRotateDelta); } } return(true); }