//向当前所面朝方向进行攻击 public override IEnumerator RunLogic() { Log.AI("Check Animation " + GetAttr().GetComponent <Animation>().IsPlaying(activeSkill.skillData.AnimationName)); float passTime = 0; var realAttackTime = activeSkill.skillData.AttackAniTime / GetAttr().GetSpeedCoff(); //var animation = GetAttr().animation; //var attackAniName = activeSkill.skillData.AnimationName; //var rate = GetAttr().animation[attackAniName].length/realAttackTime; Log.AI("AttackAniSpeed " + " realAttackTime " + realAttackTime); //PlayAni(activeSkill.skillData.AnimationName, rate, WrapMode.Once); var isEvt = false; while (!quit) { if (CheckEvent()) { isEvt = true; break; } if (passTime >= realAttackTime * 0.8f) { break; } passTime += Time.deltaTime; yield return(null); } Log.AI("Stop SkillState "); skillStateMachine.Stop(); if (!isEvt) { aiCharacter.ChangeState(AIStateEnum.IDLE); } }
public override IEnumerator RunLogic() { Log.AI("Check Animation " + GetAttr().GetComponent <Animation>().IsPlaying(activeSkill.skillData.AnimationName)); float passTime = 0; var animation = GetAttr().GetComponent <Animation>(); var attackAniName = activeSkill.skillData.AnimationName; while (!quit) { if (CheckEvent()) { yield break; } if (skillStateMachine.skillDataConfig.animationLoop) { if (passTime >= skillStateMachine.skillDataConfig.attackDuration) { break; } } else { if (passTime >= animation [attackAniName].length * 0.8f / animation [attackAniName].speed) { break; } } passTime += Time.deltaTime; yield return(null); } Log.AI("Stop SkillState "); skillStateMachine.Stop(); aiCharacter.ChangeState(AIStateEnum.IDLE); }
public override IEnumerator RunLogic() { Log.AI("Check Animation sentry " + GetAttr().GetComponent <Animation>().IsPlaying(activeSkill.skillData.AnimationName)); float passTime = 0; //var animation = GetAttr().animation; //var attackAniName = activeSkill.skillData.AnimationName; /* * while (!quit) * { * * if (CheckEvent()) * { * yield break; * } * if (skillStateMachine.skillDataConfig.animationLoop ) * { * if(passTime >= skillStateMachine.skillDataConfig.attackDuration) { * break; * } * } else * { * if (passTime >= animation [attackAniName].length * 0.8f / animation [attackAniName].speed) * { * break; * } * } * passTime += Time.deltaTime; * yield return null; * } */ while (!quit && passTime < 2) { if (CheckEvent()) { yield break; } passTime += Time.deltaTime; yield return(null); } Log.AI("Stop SkillState sentry " + passTime); skillStateMachine.Stop(); aiCharacter.ChangeState(AIStateEnum.IDLE); }
//向当前所面朝方向进行攻击 public override IEnumerator RunLogic() { Log.AI("Check Animation " + GetAttr().GetComponent <Animation>().IsPlaying(activeSkill.skillData.AnimationName)); float passTime = 0; //var realAttackTime = GetAttr ().ObjUnitData.AttackAniSpeed; var realAttackTime = activeSkill.skillData.AttackAniTime / GetAttr().GetSpeedCoff(); var animation = GetAttr().GetComponent <Animation>(); var attackAniName = activeSkill.skillData.AnimationName; var rate = GetAttr().GetComponent <Animation>()[attackAniName].length / realAttackTime; Log.AI("AttackAniSpeed " + rate + " realAttackTime " + realAttackTime); PlayAni(activeSkill.skillData.AnimationName, rate, WrapMode.Once); var playerMove = GetAttr().GetComponent <MoveController> (); var physics = playerMove.GetComponent <PhysicComponent>(); var targetPlayer = GetAttr().GetComponent <CommonAI>().targetPlayer; while (!quit) { if (CheckEvent()) { break; } Vector3 dir = targetPlayer.transform.position - GetAttr().transform.position; dir.y = 0; var newDir = Vector3.Slerp(GetAttr().transform.forward, dir, Time.deltaTime * FastRotateSpeed); physics.TurnTo(newDir); if (passTime >= animation[attackAniName].length * 0.8f / animation[attackAniName].speed) { break; } passTime += Time.deltaTime; yield return(null); } MyEventSystem.myEventSystem.PushLocalEvent(GetAttr().GetLocalId(), MyEvent.EventType.AnimationOver); Log.AI("Stop SkillState "); skillStateMachine.Stop(); aiCharacter.ChangeState(AIStateEnum.IDLE); }
//向当前所面朝方向进行攻击 public override IEnumerator RunLogic() { Log.AI("Check Animation " + GetAttr().GetComponent <Animation>().IsPlaying(activeSkill.skillData.AnimationName)); float passTime = 0; //var realAttackTime = GetAttr ().ObjUnitData.AttackAniSpeed; var realAttackTime = activeSkill.skillData.AttackAniTime / GetAttr().GetSpeedCoff(); var animation = GetAttr().GetComponent <Animation>(); var attackAniName = activeSkill.skillData.AnimationName; var rate = GetAttr().GetComponent <Animation>() [attackAniName].length / realAttackTime; Log.AI("AttackAniSpeed " + rate + " realAttackTime " + realAttackTime); PlayAni(activeSkill.skillData.AnimationName, rate, WrapMode.Once); var playerMove = GetAttr().GetComponent <MoveController>(); var camRight = playerMove.camRight; var camForward = playerMove.camForward; var vcontroller = playerMove.vcontroller; var physics = playerMove.GetComponent <PhysicComponent>(); var isEvt = false; while (!quit) { if (CheckEvent()) { isEvt = true; break; } float v = 0; float h = 0; if (vcontroller != null) { h = vcontroller.inputVector.x; //CameraRight v = vcontroller.inputVector.y; //CameraForward } Vector3 moveDirection = playerMove.transform.forward; Vector3 targetDirection = h * camRight + v * camForward; if (targetDirection != Vector3.zero) { moveDirection = Vector3.RotateTowards(moveDirection, targetDirection, rotateSpeed * Time.deltaTime, 0); moveDirection = moveDirection.normalized; //playerMove.transform.rotation = Quaternion.LookRotation (moveDirection); physics.TurnTo(moveDirection); var movement = moveDirection * walkSpeed; physics.MoveSpeed(movement); } if (passTime >= animation [attackAniName].length * 0.8f / animation [attackAniName].speed) { break; } passTime += Time.deltaTime; yield return(null); } MyEventSystem.myEventSystem.PushLocalEvent(GetAttr().GetLocalId(), MyEvent.EventType.AnimationOver); Log.AI("Stop SkillState "); skillStateMachine.Stop(); if (!isEvt) { aiCharacter.ChangeState(AIStateEnum.IDLE); } }
/* * 伤害计算过程 * 1:伤害对象判定 客户端做 * 2:伤害数值确定 服务端 或者客户端 * 3:伤害效果施展 例如击退 服务端 或者 客户端 */ //TODO:增加摇杆控制攻击方向功能 这样人物会根据摇杆方向来确定攻击目标 IEnumerator WaitForAttackAnimation(Animation animation) { var playerMove = GetAttr().GetComponent <MoveController>(); var camRight = playerMove.camRight; var camForward = playerMove.camForward; var vcontroller = playerMove.vcontroller; var physics = playerMove.GetComponent <PhysicComponent>(); var rd = Random.Range(1, 3); BackgroundSound.Instance.PlayEffect("onehandswinglarge" + rd); skillStateMachine = SkillLogic.CreateSkillStateMachine(GetAttr().gameObject, activeSkill.skillData, GetAttr().transform.position); Log.AI("Wait For Combat Animation"); //GameObject enemy = NearestEnemy (); float passTime = 0; //var transform = GetAttr ().transform; bool hitYet = false; do { if (!hitYet && GetEvent().onHit) { hitYet = true; } if (CheckEvent()) { break; } float v = 0; float h = 0; if (vcontroller != null) { h = vcontroller.inputVector.x; //CameraRight v = vcontroller.inputVector.y; //CameraForward } if (Mathf.Abs(h) > 0.1f || Mathf.Abs(v) > 0.1f) { Vector3 moveDirection = playerMove.transform.forward; Vector3 targetDirection = h * camRight + v * camForward; if (targetDirection != Vector3.zero) { moveDirection = Vector3.RotateTowards(moveDirection, targetDirection, rotateSpeed * Time.deltaTime, 0); } moveDirection = moveDirection.normalized; //playerMove.transform.rotation = Quaternion.LookRotation (moveDirection); physics.TurnTo(moveDirection); var movement = moveDirection * walkSpeed; physics.MoveSpeed(movement); } if (passTime >= animation [attackAniName].length * 0.8f / animation [attackAniName].speed) { break; } passTime += Time.deltaTime; var vhValue = Mathf.Abs(v) + Mathf.Abs(h); if (hitYet && vhValue > 0.2f) { //stopAttack = true; break; } yield return(null); } while(!quit); Log.Ani("Animation is Playing stop " + attackAniName); skillStateMachine.Stop(); }