//防御,换武器,爆气3连处理. public bool ProcessNormalAction(MeteorUnit Owner) { MeteorInput Input = Owner.controller.Input; if (Input.HasInput((int)EKeyList.KL_Defence, (int)EInputType.EIT_Pressing, Time.deltaTime)) { Owner.Defence(); return(true); } else if (Input.HasInput((int)EKeyList.KL_ChangeWeapon, (int)EInputType.EIT_Click, Time.deltaTime)) { Owner.ChangeWeapon(); return(true); } else if (Input.HasInput((int)EKeyList.KL_BreakOut, (int)EInputType.EIT_Click, Time.deltaTime)) { Owner.DoBreakOut(); return(true); } return(false); }
void ProcessGunAction(MeteorUnit target) { PoseStatus posMng = target.posMng; MeteorInput Input = target.controller.Input; MeteorUnit Owner = target; //响应 if (Input.HasInput((int)EKeyList.KL_BreakOut, (int)EInputType.EIT_Click)) { Owner.SetGunReady(false); Owner.DoBreakOut(); } else //除了跳/受击/爆气 清了枪蹲下的状态,其他全部不能清理这个状态 if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_ShortRelease) && Owner.IsOnGround()) { Owner.SetGunReady(false); Owner.SetGround(false); Jump(Owner, Input.mInputVector, Input.KeyStates[(int)EKeyList.KL_Jump].PressedTime / MeteorInput.ShortPressTime); } else if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_FullPress) && Owner.IsOnGround()) { Owner.SetGunReady(false); Owner.SetGround(false); Jump(Owner, Input.mInputVector); } else if (Input.HasInput((int)EKeyList.KL_KeyW, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.CrouchRush(); } else if (Input.HasInput((int)EKeyList.KL_KeyS, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.CrouchRush(1); } else if (Input.HasInput((int)EKeyList.KL_KeyA, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.CrouchRush(2); } else if (Input.HasInput((int)EKeyList.KL_KeyD, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.CrouchRush(3); } else if (Input.mInputVector != Vector2.zero) { MoveOnCrouch(Owner, Input.mInputVector); } else if (Input.mInputVector == Vector2.zero && !posMng.Rotateing) { if (posMng.mActiveAction.Idx != CommonAction.GunIdle) { posMng.ChangeAction(CommonAction.GunIdle); } } }
public void ProcessBehaviour(MeteorUnit target) { PoseStatus posMng = target.posMng; MeteorInput Input = target.controller.Input; MeteorUnit Owner = target; //后面改为状态机 遵循 当前动作-遍历每一个中断动作-扫描切换所需状态.符合则切换(关键是这个状态表不好生成) //除了idle以外还有其他预备动作,都可以随意切换 if (posMng.mActiveAction.Idx == CommonAction.Idle || PoseStatus.IsReadyAction(posMng.mActiveAction.Idx) || posMng.mActiveAction.Idx == CommonAction.Dead)//动作是假死,角色没有挂 { if (ProcessNormalAction(Owner)) { return; } else if (Input.HasInput((int)EKeyList.KL_Help, (int)EInputType.EIT_Click)) { //复活队友 Owner.posMng.ChangeAction(CommonAction.Reborn); } else if (Input.HasInput((int)EKeyList.KL_Defence, (int)EInputType.EIT_Pressing)) { Owner.Defence(); return; } else if (Input.HasInput((int)EKeyList.KL_Crouch, (int)EInputType.EIT_Pressing)) { Owner.OnCrouch(); return; } else if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_ShortRelease) && Owner.IsOnGround()) { Jump(Owner, Input.mInputVector, Input.KeyStates[(int)EKeyList.KL_Jump].PressedTime / MeteorInput.ShortPressTime); } else if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_FullPress) && Owner.IsOnGround()) { Jump(Owner, Input.mInputVector); } else if (Input.HasInput((int)EKeyList.KL_KeyW, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.IdleRush(); } else if (Input.HasInput((int)EKeyList.KL_KeyS, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.IdleRush(1); } else if (Input.HasInput((int)EKeyList.KL_KeyA, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.IdleRush(2); } else if (Input.HasInput((int)EKeyList.KL_KeyD, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.IdleRush(3); } else if (Input.mInputVector != Vector2.zero) { Move(Owner, Input.mInputVector); } } else if (posMng.mActiveAction.Idx == CommonAction.Crouch || (posMng.mActiveAction.Idx >= CommonAction.CrouchForw && posMng.mActiveAction.Idx <= CommonAction.CrouchBack)) { if (Owner.GetWeaponType() == (int)EquipWeaponType.Gun && Owner.GunReady) { ProcessGunAction(Owner); return; } //除了不能防御 if (ProcessNormalAction(Owner)) { return; } else if (Input.HasInput((int)EKeyList.KL_Crouch, (int)EInputType.EIT_Releasing)) { posMng.ChangeAction(CommonAction.Idle, 0.1f); } else if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_ShortRelease) && Owner.IsOnGround()) { Jump(Owner, Input.mInputVector, Input.KeyStates[(int)EKeyList.KL_Jump].PressedTime / MeteorInput.ShortPressTime); } else if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_FullPress) && Owner.IsOnGround()) { Jump(Owner, Input.mInputVector); } else if (Input.HasInput((int)EKeyList.KL_KeyW, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.CrouchRush(); } else if (Input.HasInput((int)EKeyList.KL_KeyS, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.CrouchRush(1); } else if (Input.HasInput((int)EKeyList.KL_KeyA, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.CrouchRush(2); } else if (Input.HasInput((int)EKeyList.KL_KeyD, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.CrouchRush(3); } else if (Input.mInputVector != Vector2.zero) { MoveOnCrouch(Owner, Input.mInputVector); } else if (Input.mInputVector == Vector2.zero && !posMng.Rotateing) { if (posMng.mActiveAction.Idx != CommonAction.Crouch) { posMng.ChangeAction(CommonAction.Crouch, 0.1f); } } } else if (posMng.mActiveAction.Idx == CommonAction.Run || posMng.mActiveAction.Idx == CommonAction.RunOnDrug) { if (Input.HasInput((int)EKeyList.KL_Help, (int)EInputType.EIT_Click)) { //复活队友 Owner.posMng.ChangeAction(CommonAction.Reborn); } else if (Input.HasInput((int)EKeyList.KL_Crouch, (int)EInputType.EIT_Pressing)) { Owner.OnCrouch(); } else if (Input.HasInput((int)EKeyList.KL_KeyW, (int)EInputType.EIT_DoubleClick)) { Owner.IdleRush(); } else if (Input.HasInput((int)EKeyList.KL_KeyS, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.IdleRush(1); } else if (Input.HasInput((int)EKeyList.KL_KeyA, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.IdleRush(2); } else if (Input.HasInput((int)EKeyList.KL_KeyD, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.IdleRush(3); } else if (Input.mInputVector == Vector2.zero) { posMng.ChangeAction(0, 0.1f); } else if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_ShortRelease) && Owner.IsOnGround()) { Jump(Owner, Input.mInputVector, Input.KeyStates[(int)EKeyList.KL_Jump].PressedTime / MeteorInput.ShortPressTime); } else if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_FullPress) && Owner.IsOnGround()) { Jump(Owner, Input.mInputVector); } else if (ProcessNormalAction(Owner)) { return; } else if (Input.mInputVector != Vector2.zero) { Move(Owner, Input.mInputVector); } } else if (posMng.mActiveAction.Idx == CommonAction.WalkLeft) { if (Input.HasInput((int)EKeyList.KL_Crouch, (int)EInputType.EIT_Pressing)) { Owner.OnCrouch(); } else if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_ShortRelease) && Owner.IsOnGround()) { Jump(Owner, Input.mInputVector, Input.KeyStates[(int)EKeyList.KL_Jump].PressedTime / MeteorInput.ShortPressTime); } else if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_FullPress) && Owner.IsOnGround()) { Jump(Owner, Input.mInputVector); } else if (Input.HasInput((int)EKeyList.KL_KeyW, (int)EInputType.EIT_DoubleClick)) { Owner.IdleRush(); } else if (Input.HasInput((int)EKeyList.KL_KeyS, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.IdleRush(1); } else if (Input.HasInput((int)EKeyList.KL_KeyA, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.IdleRush(2); } else if (Input.HasInput((int)EKeyList.KL_KeyD, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.IdleRush(3); } else if (!posMng.Rotateing && Input.mInputVector == Vector2.zero) { posMng.ChangeAction(CommonAction.Idle, 0.1f); } else if (ProcessNormalAction(Owner)) { return; } else if (Input.mInputVector != Vector2.zero) { Move(Owner, Input.mInputVector); } } else if (posMng.mActiveAction.Idx == CommonAction.WalkRight) { if (Input.HasInput((int)EKeyList.KL_Crouch, (int)EInputType.EIT_Pressing)) { Owner.OnCrouch(); } else if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_ShortRelease) && Owner.IsOnGround()) { Jump(Owner, Input.mInputVector, Input.KeyStates[(int)EKeyList.KL_Jump].PressedTime / MeteorInput.ShortPressTime); } else if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_FullPress) && Owner.IsOnGround()) { Jump(Owner, Input.mInputVector); } else if (Input.HasInput((int)EKeyList.KL_KeyW, (int)EInputType.EIT_DoubleClick)) { Owner.IdleRush(); } else if (Input.HasInput((int)EKeyList.KL_KeyS, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.IdleRush(1); } else if (Input.HasInput((int)EKeyList.KL_KeyA, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.IdleRush(2); } else if (Input.HasInput((int)EKeyList.KL_KeyD, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.IdleRush(3); } else if (!posMng.Rotateing && Input.mInputVector == Vector2.zero) { posMng.ChangeAction(CommonAction.Idle, 0.1f); } else if (ProcessNormalAction(Owner)) { return; } else if (Input.mInputVector != Vector2.zero) { Move(Owner, Input.mInputVector); } } else if (posMng.mActiveAction.Idx == CommonAction.WalkBackward) { if (Input.HasInput((int)EKeyList.KL_Crouch, (int)EInputType.EIT_Pressing)) { Owner.OnCrouch(); } else if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_ShortRelease) && Owner.IsOnGround()) { Jump(Owner, Input.mInputVector, Input.KeyStates[(int)EKeyList.KL_Jump].PressedTime / MeteorInput.ShortPressTime); //Debug.LogError("jumpback"); } else if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_FullPress) && Owner.IsOnGround()) { Jump(Owner, Input.mInputVector); } else if (Input.HasInput((int)EKeyList.KL_KeyW, (int)EInputType.EIT_DoubleClick)) { Owner.IdleRush(); } else if (Input.HasInput((int)EKeyList.KL_KeyS, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.IdleRush(1); } else if (Input.HasInput((int)EKeyList.KL_KeyA, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.IdleRush(2); } else if (Input.HasInput((int)EKeyList.KL_KeyD, (int)EInputType.EIT_DoubleClick)) { //这里要判断武器 Owner.IdleRush(3); } else if (!posMng.Rotateing && Input.mInputVector == Vector2.zero) { posMng.ChangeAction(CommonAction.Idle, 0.1f); } else if (ProcessNormalAction(Owner)) { return; } else if (Input.mInputVector != Vector2.zero) { Move(Owner, Input.mInputVector); } } else if ((posMng.mActiveAction.Idx >= CommonAction.BrahchthrustDefence && posMng.mActiveAction.Idx <= CommonAction.HammerDefence) || (posMng.mActiveAction.Idx >= CommonAction.ZhihuDefence && posMng.mActiveAction.Idx <= CommonAction.RendaoDefence)) { //还有乾坤刀的其他2种姿势没处理 if (Input.HasInput((int)EKeyList.KL_Defence, (int)EInputType.EIT_Releasing)) { Owner.ReleaseDefence(); } } else if (posMng.mActiveAction.Idx == CommonAction.Struggle || posMng.mActiveAction.Idx == CommonAction.Struggle0) //地面挣扎.僵直中无法输入. { if (Owner.IsOnGround()) { if (Input.HasInput((int)EKeyList.KL_KeyW, (int)EInputType.EIT_Release)) { posMng.ChangeAction(CommonAction.DCForw, 0.1f); } else if (Input.HasInput((int)EKeyList.KL_KeyS, (int)EInputType.EIT_Release)) { posMng.ChangeAction(CommonAction.DCBack, 0.1f); } else if (Input.HasInput((int)EKeyList.KL_KeyA, (int)EInputType.EIT_Release)) { posMng.ChangeAction(CommonAction.DCLeft, 0.1f); } else if (Input.HasInput((int)EKeyList.KL_KeyD, (int)EInputType.EIT_Release)) { posMng.ChangeAction(CommonAction.DCRight, 0.1f); } else if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_ShortRelease)) { Jump(Owner, Input.mInputVector, Input.KeyStates[(int)EKeyList.KL_Jump].PressedTime / MeteorInput.ShortPressTime); } else if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_FullPress)) { Jump(Owner, Input.mInputVector); } else if (Input.HasInput((int)EKeyList.KL_Defence, (int)EInputType.EIT_Click)) { if (posMng.mActiveAction.Idx == CommonAction.Struggle) { Owner.posMng.ChangeAction(CommonAction.IdleBack, 0.1f); } else if (posMng.mActiveAction.Idx == CommonAction.Struggle0) { Owner.posMng.ChangeAction(CommonAction.IdleFront, 0.1f); } } } } else if (Owner.Climbing) { if (Input.HasInput((int)EKeyList.KL_KeyW, (int)EInputType.EIT_Release)) { //Owner.ProcessFall(); Owner.posMng.ChangeAction(CommonAction.JumpFall); } else if (Owner.ImpluseVec.y > 0 && Owner.OnTouchWall) { if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_Click)) { //Debug.LogError("ProcessTouchWallJump"); Owner.ProcessTouchWallJump(true); } } else if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_Click)) { //Debug.LogError("ProcessJump2"); Owner.ProcessJump2(); } } else if (posMng.mActiveAction.Idx >= CommonAction.Jump && posMng.mActiveAction.Idx <= CommonAction.WallLeftJump) { if (Input.HasInput((int)EKeyList.KL_ChangeWeapon, (int)EInputType.EIT_Click)) { Owner.ChangeWeapon(); } else if (Owner.ImpluseVec.y > 0) { if (Input.HasInput((int)EKeyList.KL_Jump, (int)EInputType.EIT_Click)) { Owner.ProcessJump2(); } } } else if (posMng.mActiveAction.Idx == CommonAction.GunIdle) { ProcessGunAction(Owner); } else if (posMng.IsHurtPose() && Input.HasInput((int)EKeyList.KL_BreakOut, (int)EInputType.EIT_Click)) { Owner.DoBreakOut(); } }
void OnIdle() { tick += Time.deltaTime; waitCrouch -= Time.deltaTime; waitDefence -= Time.deltaTime; if (tick > updateDelta) { MeteorUnit u = owner.GetLockedTarget(); if (u == null) { targetPath.Clear(); pathIdx = -1; targetPos = Vector3.zero; } else { //targetPath = GameBattleEx.Instance.FindPath(owner.transform.position, u); //pathIdx = 0; //targetPos = u.transform.position; } tick = 0.0f; } //if (targetPos != Vector3.zero && Vector3.Distance(targetPos, owner.transform.position) < 80) //{ //owner.Defence(); //Status = EAIStatus.Defence; //} //else //{ //大于50M,尝试走过去。 //if (targetPos != Vector3.zero) //{ // Status = EAIStatus.GotoTarget;//先朝目标转向,然后跑过去.不寻路先. //} //} //模拟AI计算下一步该做什么。 //AI分为发现目标,和未发现目标2种情况下的行为概率. //if (targetPath != null)//targetPos != Vector3.zero) //{ //有目标 //Quaternion cur = Quaternion.LookRotation(targetPos - transform.position, Vector3.up); //if (Quaternion.Angle(transform.rotation, Quaternion.Inverse(targetQuat)) <= 10.0f) //{ //使用什么武器? //走到什么位置?距离多远,是否存在需要跳跃才能过去的沟渠。 //发什么招式?武器招式->对方是否跳跃 /技能 ->蓝是否充足 //是否气血小于健康范围 //是否没有足够蓝 //距离应该是最重要的. // float d = Vector3.Distance(transform.position, targetPos); // if (AIData != null) // { // for (int i = 0; i < AIData.Count; i++) // { // if (d > AIData[i]) // } // } // Status = EAIStatus.Run; // //owner.posMng.ChangeAction(CommonAction.Run); //} //else //{ // Status = EAIStatus.Rotate; //} //} //else //{ //} int random = Global.Rand.Next(0, 101); switch (SubStatus) { case EAISubStatus.Think: //采取一个什么行动,朝目标丢招式,转向目标 break; } //Log.LogFrame("随机0-7:得到" + random); if (PlayWeaponPoseCorout != null) { } else if (owner.posMng.mActiveAction.Idx == CommonAction.Crouch && waitCrouch <= 0.0f) { switch (random) { case 0: case 1: case 2: case 3: case 4: owner.controller.Input.OnKeyUp(EKeyList.KL_Crouch); break; } } else if (owner.posMng.mActiveAction.Idx <= 10) { //owner.posMng.ChangeAction(CommonAction.Taunt); switch (random) { case 0: case 1: owner.controller.Input.OnKeyDown(EKeyList.KL_Defence, true); //防御 waitDefence = 1.0f; break; case 2: case 3: owner.controller.Input.OnKeyUp(EKeyList.KL_Attack); //攻击收起 break; case 4: case 5: owner.controller.Input.OnKeyDown(EKeyList.KL_Attack, true); //攻击 break; case 6: if (owner.AngryValue >= Global.ANGRYMAX) { owner.PlaySkill(); //开大 } break; case 7: TryPlayWeaponPose(); //使用武器招式. break; case 8: owner.controller.Input.OnKeyDown(EKeyList.KL_Crouch, true); //蹲下 waitCrouch = 3.0f; break; //case 9://双击某个方向键2次 // TryAvoid(); // break; } } else if (((owner.posMng.mActiveAction.Idx >= CommonAction.BrahchthrustDefence) && (owner.posMng.mActiveAction.Idx <= CommonAction.HammerDefence)) || ((owner.posMng.mActiveAction.Idx >= CommonAction.ZhihuDefence) && (owner.posMng.mActiveAction.Idx <= CommonAction.RendaoDefence))) { if (random < 2 && waitDefence <= 0.0f) { owner.ReleaseDefence(); } else if (random >= 3 && random <= 4 && waitDefence <= 0.0f && owner.AngryValue >= Global.ANGRYMAX) { owner.DoBreakOut(); } else if (waitDefence <= 0.0f && owner.AngryValue >= Global.ANGRYMAX && random == 5) { owner.PlaySkill(); } //else if (waitDefence <= 0.0f && random == 6) // owner.posMng.ChangeAction(CommonAction.DCForw); } else if (owner.posMng.mActiveAction.Idx == CommonAction.Struggle || owner.posMng.mActiveAction.Idx == CommonAction.Struggle0) { if (struggleCoroutine == null) { struggleCoroutine = owner.StartCoroutine(ProcessStruggle()); } } else if (owner.posMng.IsAttackPose() && owner.controller.Input.AcceptInput()) { //尝试输出下一个连招 TryPlayNextWeaponPose(); } }