// 状态处理 public void Process(EntityParent theOwner, params Object[] args) { theOwner.Transform.GetComponent <UnityEngine.Animation>().CrossFade("locking"); MogoMotor theMotor = theOwner.motor; theMotor.enabled = false; }
// 状态处理 public void Process(EntityParent theOwner, params Object[] args) { theOwner.Transform.animation.CrossFade("picking"); MogoMotor theMotor = theOwner.motor; theMotor.isMovable = false; }
private void DelayExtraMove(int hitActionID) { SkillAction action = SkillAction.dataMap[hitActionID]; MogoMotor theMotor = theOwner.motor; float extraSpeed = action.extraSpeed; theMotor.SetExrtaSpeed(extraSpeed); theMotor.SetMoveDirection(theOwner.Transform.forward); TimerHeap.AddTimer <MogoMotor>((uint)action.extraSl, 0, (m) => { m.SetExrtaSpeed(0); }, theMotor); }
virtual public void ClearSkill(bool remove = false, bool naturalEnd = false) { TimerHeap.DelTimer(hitTimerID); TimerHeap.DelTimer(delayAttackTimerID); if (currSpellID != -1) { if (SkillAction.dataMap.ContainsKey(currHitAction) && remove) { RemoveSfx(currHitAction); } SkillData s; if (SkillData.dataMap.TryGetValue(currSpellID, out s) && remove) { foreach (var i in s.skillAction) { RemoveSfx(i); } } currHitAction = -1; } //for (int i = 0; i < hitTimer.Count; i++) //{ // TimerHeap.DelTimer(hitTimer[i]); //} hitTimer.Clear(); //if (Actor) //{ //Actor.AnimatorStateChanged = null; //} MogoMotor theMotor = motor; if (Transform) { theMotor.enableStick = true; theMotor.enableRotation = true; theMotor.SetExrtaSpeed(0); theMotor.SetMoveDirection(Vector3.zero); } ChangeMotionState(MotionState.IDLE); currSpellID = -1; //if (this is EntityMyself && naturalEnd) //{ // (battleManger as PlayerBattleManager).NextCmd(); //} }
private void AttackingMove(SkillAction action) { MogoMotor theMotor = theOwner.motor; if (theMotor == null) { return; } float extraSpeed = action.extraSpeed; if (extraSpeed != 0) { if (action.extraSt <= 0) { theMotor.SetExrtaSpeed(extraSpeed); theMotor.SetMoveDirection(theOwner.Transform.forward); TimerHeap.AddTimer <MogoMotor>((uint)action.extraSl, 0, (m) => { m.SetExrtaSpeed(0); }, theMotor); } else { TimerHeap.AddTimer <int>((uint)action.extraSt, 0, DelayExtraMove, action.id); } } else { theMotor.SetExrtaSpeed(0); } // 是否允许,在技能过程中使用 摇杆改变方向 //if (theOwner is EntityMyself) //{ // theMotor.enableStick = action.enableStick > 0; //} if (action.teleportDistance > 0 && extraSpeed <= 0) { Vector3 dst = Vector3.zero; dst = theOwner.Transform.position + theOwner.Transform.forward * action.teleportDistance; theMotor.TeleportTo(dst); } }
private void FirePerson(GameObject go) { if (MainUILogicManager.Instance != null) { MainUILogicManager.Instance.IsAttackable = false; } MogoWorld.thePlayer.CleanCharging(); MogoWorld.thePlayer.ClearSkill(); MogoWorld.thePlayer.ChangeMotionState(MotionState.ROLL); MogoMainCamera.Instance.Shake(5, 0.1f); ShowGameObject(go); go.transform.LookAt(new Vector3(target.transform.position.x, go.transform.position.y, target.transform.position.z)); // TimerHeap.AddTimer(200, 0, ShowGameObject, go); go.transform.position = transform.position; float h = go.transform.position.y - targetPosition.y; float s = Vector3.Distance(new Vector3(targetPosition.x, go.transform.position.y, targetPosition.z), go.transform.position); float vy = Mathf.Sqrt(gravity * Mathf.Pow(s, 2) / (4 * s + 8 * h)); float vx = 2 * vy; Vector3 directionX = (new Vector3(targetPosition.x, go.transform.position.y, targetPosition.z) - go.transform.position).normalized; Vector3 directionY = Vector3.up; // 玩家MoveTo MogoMotor motor = go.GetComponent <MogoMotor>(); //motor.enableStick = false; motor.SetIfFlying(true); motor.SetExrtaSpeed(vx); motor.verticalSpeed = vy; motor.SetMoveDirection(directionX); EventDispatcher.TriggerEvent(Events.GearEvent.TrapBegin, gearType); }
// 状态处理 public void Process(EntityParent theOwner, params System.Object[] args) { MogoMotor theMotor = theOwner.motor; if (theOwner is EntityMonster || (theOwner is EntityPlayer && !(theOwner is EntityMyself))) { theOwner.ApplyRootMotion(false); theOwner.SetSpeed(1); theMotor.SetSpeed(0.4f); //服务器没有同步其他玩家的速度,这里暂时硬编码处理, //待确定其他玩家与怪物移动位移的控制方案再修改(程序控制还是动作位移) if (theOwner.speed == 0) { //theMotor.SetExrtaSpeed(6); } else { theMotor.SetExrtaSpeed(theOwner.speed); } return; } else if (theOwner is EntityDummy || theOwner is EntityMercenary) { theOwner.ApplyRootMotion(false); //theOwner.SetSpeed(1); theMotor.SetSpeed(0.4f * theOwner.aiRate); theMotor.SetExrtaSpeed(theOwner.GetIntAttr("speed") * 0.01f * theOwner.blackBoard.speedFactor * theOwner.aiRate); } else { theOwner.ApplyRootMotion(true); // theOwner.SetSpeed(1); theMotor.SetExrtaSpeed(5); theMotor.SetSpeed(0.4f); } theMotor.isMovable = true; }
// 状态处理 public void Process(EntityParent theOwner, params Object[] args) { // 播放 idle 动画 if (theOwner == null) { return; } if (theOwner.CanMove() && theOwner.motor != null) { theOwner.motor.enableStick = true; } MogoMotor theMotor = theOwner.motor; if (theOwner is EntityMonster) { theOwner.ApplyRootMotion(false); } // 设置 速度 if (theMotor != null) { theMotor.SetSpeed(0.0f); theMotor.SetExrtaSpeed(0); } //theMotor.SetExrtaSpeed(0f); if (theOwner.charging) { return; } if (theOwner is EntityPlayer && MogoWorld.inCity) { theOwner.SetAction(-1); } else { theOwner.SetAction(0); } theOwner.SetActionByStateFlagInIdleState(); }
private void HideGameObject(GameObject go) { MogoFXManager.Instance.AlphaFadeOut(go, 0.01f); MogoWorld.connoning = true; //检测指引消失/出现 EventDispatcher.TriggerEvent(Events.DirecterEvent.DirActive); //让主角飞行过程中不会托管 EventDispatcher.TriggerEvent(Events.StoryEvent.CGBegin); //bipMasterGo = go.transform.FindChild("Bip_master").gameObject; //bipMasterGo.SetActive(false); //renderers = go.GetComponentsInChildren<SkinnedMeshRenderer>(); //foreach (var ren in renderers) //{ // ren.gameObject.SetActive(false); //} ControlStick.instance.Reset(); MogoMotor motor = go.GetComponent <MogoMotor>(); motor.enableStick = false; MogoFXManager.Instance.RemoveShadow(MogoWorld.thePlayer.ID); }
// 状态处理 public void Processold(EntityParent theOwner, params Object[] args) { if (theOwner is EntityDummy) { theOwner.animator.applyRootMotion = true; } if (args.Length != 1) { Debug.LogError("error spell id"); return; } int actionID = (int)(args[0]); SkillAction action = SkillAction.dataMap[actionID]; SkillData s = SkillData.dataMap[theOwner.currSpellID]; // 回调,基于计时器。 在duration 后切换回 idle 状态 int duration = action.duration; if (duration <= 0 && action.action > 0 && s.skillAction.Count == 1) { //theOwner.AddCallbackInFrames<int, EntityParent>( // (_actionID, _theOwner) => // { // _theOwner.TriggerUniqEvent<int>(Events.FSMMotionEvent.OnAttackingEnd, _actionID); // }, // actionID, // theOwner); } else if (duration <= 0 && s.skillAction.Count > 1 && theOwner.hitActionIdx >= (s.skillAction.Count - 1)) { if (SkillAction.dataMap[s.skillAction[0]].duration <= 0) { theOwner.AddCallbackInFrames <int, EntityParent>( (_actionID, _theOwner) => { _theOwner.TriggerUniqEvent <int>(Events.FSMMotionEvent.OnAttackingEnd, _actionID); }, actionID, theOwner); } } else if (duration > 0 && action.action > 0) { //theOwner.stateFlag = Mogo.Util.Utils.BitSet(theOwner.stateFlag, 13);//专为旋风斩 //theOwner.immuneShift = true; TimerHeap.AddTimer <int, EntityParent>( (uint)duration, 0, (_actionID, _theOwner) => { _theOwner.TriggerUniqEvent <int>(Events.FSMMotionEvent.OnAttackingEnd, _actionID); MogoMotor theMotor = _theOwner.motor; if (_theOwner.Transform) { theMotor.enableStick = true; theMotor.SetExrtaSpeed(0); theMotor.SetMoveDirection(UnityEngine.Vector3.zero); } //_theOwner.stateFlag = Mogo.Util.Utils.BitReset(_theOwner.stateFlag, 13);//专为旋风斩 //_theOwner.immuneShift = false; _theOwner.ChangeMotionState(MotionState.IDLE); }, actionID, theOwner); } // 回调,基于计时器。 在removeSfxTime 后关闭持久的sfx if (action.duration > 0) { TimerHeap.AddTimer <int, EntityParent>( (uint)action.duration, 0, (_actionID, _theOwner) => { _theOwner.RemoveSfx(_actionID); }, actionID, theOwner); } theOwner.OnAttacking(actionID, theOwner.Transform.localToWorldMatrix, theOwner.Transform.rotation, theOwner.Transform.forward, theOwner.Transform.position); }
private void ProcessHit(EntityParent theOwner, int spellID, List <object> args) { int actionID = (int)args[0]; UnityEngine.Matrix4x4 ltwm = (UnityEngine.Matrix4x4)args[1]; UnityEngine.Quaternion rotation = (UnityEngine.Quaternion)args[2]; UnityEngine.Vector3 forward = (UnityEngine.Vector3)args[3]; UnityEngine.Vector3 position = (UnityEngine.Vector3)args[4]; if (theOwner is EntityDummy && theOwner.animator != null) { theOwner.animator.applyRootMotion = true; } SkillAction action = SkillAction.dataMap[actionID]; SkillData s = SkillData.dataMap[spellID]; // 回调,基于计时器。 在duration 后切换回 idle 状态 int duration = action.duration; if (duration <= 0 && s.skillAction.Count > 1)// && theOwner.hitActionIdx >= (s.skillAction.Count - 1)) { if (SkillAction.dataMap[s.skillAction[0]].duration <= 0) { theOwner.AddCallbackInFrames <int, EntityParent>( (_actionID, _theOwner) => { _theOwner.TriggerUniqEvent <int>(Events.FSMMotionEvent.OnAttackingEnd, _actionID); }, actionID, theOwner); } } else if (duration > 0 && action.action > 0) { TimerHeap.AddTimer <int, EntityParent>( (uint)duration, 0, (_actionID, _theOwner) => { _theOwner.TriggerUniqEvent <int>(Events.FSMMotionEvent.OnAttackingEnd, _actionID); MogoMotor theMotor = _theOwner.motor; if (_theOwner.Transform) { theMotor.enableStick = true; theMotor.SetExrtaSpeed(0); theMotor.SetMoveDirection(UnityEngine.Vector3.zero); } //_theOwner.stateFlag = Mogo.Util.Utils.BitReset(_theOwner.stateFlag, 13);//专为旋风斩 //_theOwner.immuneShift = false; _theOwner.ChangeMotionState(MotionState.IDLE); }, actionID, theOwner); } // 回调,基于计时器。 在removeSfxTime 后关闭持久的sfx if (action.duration > 0) { TimerHeap.AddTimer <int, EntityParent>( (uint)action.duration, 0, (_actionID, _theOwner) => { _theOwner.RemoveSfx(_actionID); }, actionID, theOwner); } theOwner.OnAttacking(actionID, ltwm, rotation, forward, position); }
public override void HandleData() { var info = Arguments[0] as CellAttachedInfo; if (!MogoWorld.Entities.ContainsKey(info.id)) { return; } var entity = MogoWorld.Entities[info.id]; //entity.TurnTo(0, info.face * 2, 0); if (!(entity is EntityMercenary)) { // >0移动到XY的服务器预计时间 ==0移动到XY ==1当前服务器XY校验 if (info.checkFlag == 0) { entity.MoveTo(info.position.x, info.position.z, 0, 0 /*info.face * 2.0f*/, 0); } else if (info.checkFlag > 1) { uint diaotaT = (uint)(UnityEngine.Time.realtimeSinceStartup * 1000) - MogoWorld.thePlayer.syncInfo[3]; uint curServerTime = MogoWorld.thePlayer.syncInfo[5] + diaotaT; uint toTarXYUseTimeUsec = 0; if (info.checkFlag > curServerTime) { toTarXYUseTimeUsec = info.checkFlag - curServerTime; } else { toTarXYUseTimeUsec = info.checkFlag - curServerTime; } MogoMotor theMotor = entity.motor; if (theMotor == null) { return; } UnityEngine.Vector3 dstP = theMotor.targetToMoveTo; float dis_entityP2dstP = UnityEngine.Vector2.Distance(new UnityEngine.Vector2(info.position.x, info.position.z), new UnityEngine.Vector2(entity.Transform.position.x, entity.Transform.position.z));//前端实体到目标距离 float adapterSpeed = dis_entityP2dstP / (toTarXYUseTimeUsec * 0.001f); entity.speed = adapterSpeed; theMotor.SetExrtaSpeed(entity.speed); entity.MoveTo(info.position.x, info.position.z, 0, 0 /*info.face * 2.0f*/, 0); } else { /* * if (entity != null && entity.Transform != null) * { * MogoMotor theMotor = entity.motor; * UnityEngine.Vector3 dstP = theMotor.targetToMoveTo; * float dis_entityP2dstP = UnityEngine.Vector2.Distance(new UnityEngine.Vector2(dstP.x, dstP.z), * new UnityEngine.Vector2(entity.Transform.position.x, entity.Transform.position.z));//前端实体到目标距离 * float dis_checkP2dstP = UnityEngine.Vector2.Distance(new UnityEngine.Vector2(dstP.x, dstP.z), * new UnityEngine.Vector2(info.position.x, info.position.z));//后端实体到目标距离(忽略网络延迟) * float dis = UnityEngine.Vector2.Distance(new UnityEngine.Vector2(entity.Transform.position.x, entity.Transform.position.z), * new UnityEngine.Vector2(info.position.x, info.position.z));//后端实体到目标距离(忽略网络延迟) * //float dis = Math.Abs(dis_checkP2dstP - dis_entityP2dstP); * * if ((dis_checkP2dstP < dis_entityP2dstP) && (dis > 0.4f)) * { * * entity.speed = entity.m_orgSpeed * 1.5f; * theMotor.SetExrtaSpeed(entity.speed); * //Mogo.Util.LoggerHelper.Error("need speed Up: " + entity.speed + dstP); * } * else if ((dis_checkP2dstP > dis_entityP2dstP) && (dis > 0.4f)) * { * entity.speed = entity.m_orgSpeed * 0.7f; * theMotor.SetExrtaSpeed(entity.speed); * //Mogo.Util.LoggerHelper.Error("need speed Down: " + entity.speed + dstP); * } * else * { * entity.speed = entity.m_orgSpeed; * theMotor.SetExrtaSpeed(entity.speed); * //Mogo.Util.LoggerHelper.Error("need speed normal: " + entity.speed + dstP); * } * * } */ } } }