IEnumerator useUnitSkillAI(string skillName, Unit aiUnit, Unit target) { yield return(StartCoroutine(turnToAI(aiUnit, target))); outline.RenderOutLine(aiUnit.transform); bool isSuccess = aiUnit.GetComponent <CharacterAction>().SetSkill(skillName); //Debug.Log("useUnitSkill=>" + skillName + "=>" + isSuccess); UnitSkill unitSkill = SkillManager.GetInstance().skillQueue.Peek().Key as UnitSkill; rtsCamera.FollowTarget(target.transform.position); yield return(new WaitForSeconds(0.5f)); unitSkill.Init(aiUnit.transform); unitSkill.Focus(target.transform.position); yield return(new WaitForSeconds(0.5f)); outline.CancelRender(); unitSkill.Confirm(); yield return(new WaitUntil(() => { return unitSkill.complete == true; })); rtsCamera.FollowTarget(aiUnit.transform.position); yield return(0); }
private IEnumerator Play() { var myUnits = UnitManager.GetInstance().units.FindAll(u => u.playerNumber == playerNumber); foreach (var u in myUnits) { if (u.GetComponent<Unit>().UnitEnd) break; rtsCamera.FollowTarget(u.transform.position); outline.RenderOutLine(u.transform); if (u.GetComponent<CharacterStatus>().roleEName == "Rock") { u.OnUnitEnd(); //真正的回合结束所应执行的逻辑。 DebugLogPanel.GetInstance().Log(u.GetComponent<CharacterStatus>().roleCName + "执行完毕"); yield return new WaitForSeconds(1f); } else { yield return StartCoroutine(UseSkill("EarthStyleDorodomuBarrier", u.transform)); u.OnUnitEnd(); //真正的回合结束所应执行的逻辑。 DebugLogPanel.GetInstance().Log(u.GetComponent<CharacterStatus>().roleCName + "执行完毕"); yield return new WaitForSeconds(1f); } } outline.CancelRender(); RoundManager.GetInstance().EndTurn(); }
public IEnumerator playFree(int playerNumber) { var nonMyUnits = UnitManager.GetInstance().units.FindAll(u => u.playerNumber == playerNumber); foreach (var u in nonMyUnits) { if (outline) { outline.RenderOutLine(u.transform); } rtsCamera.FollowTarget(u.transform.position); if (u.GetComponent <Unit>().UnitEnd) { } else { yield return(StartCoroutine(aiFreeBattle.ActiveAI(u))); u.OnUnitEnd(); //真正的回合结束所应执行的逻辑。 DebugLogPanel.GetInstance().Log(u.GetComponent <CharacterStatus>().roleCName + "执行完毕"); } yield return(new WaitForSeconds(1f)); } outline.CancelRender(); RoundManager.GetInstance().EndTurn(); }
private IEnumerator JiroubouDrama() { Unit u = UnitManager.GetInstance().units.Find(p => p.name == "jiroubou_1"); rtsCamera.FollowTarget(u.transform.position); outline.RenderOutLine(u.transform); yield return(StartCoroutine(UseSkill("EarthStyleDorodomuBarrier", u.transform))); u.OnUnitEnd(); //真正的回合结束所应执行的逻辑。 DebugLogPanel.GetInstance().Log(u.GetComponent <CharacterStatus>().roleCName + "执行完毕"); yield return(new WaitForSeconds(1f)); outline.CancelRender(); yield return(0); }
private IEnumerator Play() { var myUnits = UnitManager.GetInstance().units.FindAll(u => u.playerNumber == playerNumber); foreach (var u in myUnits) { if (u.GetComponent <Unit>().UnitEnd) { break; } rtsCamera.FollowTarget(u.transform.position); outline.RenderOutLine(u.transform); if (u.GetComponent <CharacterStatus>().roleEName == "Rock") { var currentHp = u.GetComponent <CharacterStatus>().attributes.Find(d => d.eName == "hp").value; var currentHPMax = u.GetComponent <CharacterStatus>().attributes.Find(d => d.eName == "hp").valueMax; var restValue = (int)(currentHPMax * 0.3f); restValue = currentHp + restValue > currentHPMax ? currentHPMax - currentHp : restValue; var hp = currentHp + restValue; UIManager.GetInstance().FlyNum(u.GetComponent <CharacterStatus>().arrowPosition / 2 + u.transform.position + Vector3.down * 0.2f, restValue.ToString(), UIManager.hpColor); ChangeData.ChangeValue(u.transform, "hp", hp); u.OnUnitEnd(); //真正的回合结束所应执行的逻辑。 DebugLogPanel.GetInstance().Log(u.GetComponent <CharacterStatus>().roleCName + "执行完毕"); yield return(new WaitForSeconds(1f)); } else { yield return(StartCoroutine(UseSkill("EarthStyleDorodomuBarrier", u.transform))); u.OnUnitEnd(); //真正的回合结束所应执行的逻辑。 DebugLogPanel.GetInstance().Log(u.GetComponent <CharacterStatus>().roleCName + "执行完毕"); yield return(new WaitForSeconds(1f)); } } outline.CancelRender(); RoundManager.GetInstance().EndTurn(); }
public bool ExcuteMove() { switch (moveState) { case MoveState.startPoint: if (animator.GetCurrentAnimatorStateInfo(0).shortNameHash == idleHash) { if (!animator.applyRootMotion) { animator.applyRootMotion = true; animator.SetBool(runningHash, true); //audio.Play(); FXManager.GetInstance().DustSpawn(character.position, character.rotation, null); GameController.GetInstance().Invoke(() => { character.Find("Render").gameObject.SetActive(false); GameController.GetInstance().Invoke(() => { character.Find("Render").gameObject.SetActive(true); }, 0.1f); }, 0.2f); } moveState = MoveState.line; } break; case MoveState.line: // | |__->___| |_______| | if (animator.GetCurrentAnimatorStateInfo(0).shortNameHash == runHash) { float distance = (Pos[i] - character.position).magnitude; //character.Translate(((Pos[i] - character.position).normalized) * Time.deltaTime * speed, Space.World); if (!animator.isMatchingTarget) { if (distance > 1) { MatchPoint(Pos[i]); } } var progress = animator.GetCurrentAnimatorStateInfo(0).normalizedTime - (int)animator.GetCurrentAnimatorStateInfo(0).normalizedTime; if (distance <= 0.35f) { animator.InterruptMatchTarget(false); character.Translate(Pos[i] - character.position, Space.World); animator.applyRootMotion = false; animator.SetBool(runningHash, false); moveState = MoveState.point; } } break; case MoveState.point: // | |_______|->|_______| | if (animator.GetCurrentAnimatorStateInfo(0).shortNameHash == idleHash) { if (i >= Pos.Count - 1) { moveState = MoveState.finalPoint; } else { i++; if (Pos[i] != character.position) { Quaternion wantedRot = Quaternion.LookRotation(Pos[i] - character.position); character.rotation = wantedRot; FXManager.GetInstance().DustSpawn(character.position, character.rotation, null); GameController.GetInstance().Invoke(() => { character.Find("Render").gameObject.SetActive(false); GameController.GetInstance().Invoke(() => { character.Find("Render").gameObject.SetActive(true); }, 0.1f); }, 0.2f); } if (!animator.applyRootMotion) { animator.applyRootMotion = true; animator.SetBool(runningHash, true); //audio.Play(); camera.FollowTarget(character.position); moveState = MoveState.line; } } } break; case MoveState.finalPoint: animator.applyRootMotion = false; camera.FollowTarget(character.position); Pos = null; return(true); } return(false); }