public override void Animate(AnimCallBack onEnd) { Debug.Log("Animate"); if (!Check()) { onEnd.Invoke(); Debug.Log("invalid paramenters"); return; } // StartCoroutine(move(onEnd)); if (go1.GetComponent <EnvironmentObject>().unityChan) { go1.GetComponent <UChanVoice>().PlayYo(); agent = go1.GetComponent <NavMeshAgent>(); animator = go1.GetComponent <Animator>(); if (go2.transform.position.y > 0f) { points[0] = new Vector3(go2.transform.position.x, 0f, go2.transform.position.z); } Debug.Log(points[0]); NavMeshHit hit; if (NavMesh.SamplePosition(go2.transform.position, out hit, 2.0f, NavMesh.AllAreas)) { NavMeshPath path = new NavMeshPath(); if (NavMesh.CalculatePath(go1.transform.position, hit.position, NavMesh.AllAreas, path)) { agent.path = path; agent.isStopped = false; animator.SetBool("run", true); startAnimSpeed = animator.speed; startAgentSpeed = agent.speed; animator.speed = speed; agent.speed = speed * 4; StartCoroutine(CheckIfOnPlace(onEnd)); } else { onEnd.Invoke(); Debug.Log("Invalid Path. End Animate"); } // agent.destination = hit.position; } else { onEnd.Invoke(); Debug.Log("Invalid Path. End Animate"); } } else { onEnd.Invoke(); Debug.Log("Not a unity chan!"); } }
// IEnumerator move( AnimCallBack onEnd) // { // yield return null; // } IEnumerator CheckIfOnPlace(AnimCallBack onEnd) { Vector3 target = points[0]; while (Vector3.Distance(target, go1.transform.position) > 2f) { yield return(new WaitForSeconds(0.1f)); NavMeshHit hit; if (NavMesh.SamplePosition(points[0], out hit, 2.0f, NavMesh.AllAreas)) { NavMeshPath path = new NavMeshPath(); if (NavMesh.CalculatePath(go1.transform.position, hit.position, NavMesh.AllAreas, path)) { agent.path = path; } else { animator.speed = startAnimSpeed; agent.speed = startAgentSpeed; animator.speed = startAnimSpeed; agent.isStopped = true; animator.SetBool("run", false); onEnd.Invoke(); Debug.Log("Invalid Path. End Animate"); break; } // agent.destination = hit.position; } else { animator.speed = startAnimSpeed; agent.speed = startAgentSpeed; agent.isStopped = true; animator.SetBool("run", false); onEnd.Invoke(); Debug.Log("Invalid Path. End Animate"); break; } } go1.GetComponent <UChanVoice>().PlayLaught(); animator.speed = startAnimSpeed; agent.speed = startAgentSpeed; agent.isStopped = true; animator.SetBool("run", false); go1.GetComponent <UChanVoice>().PlayBreathing(); yield return(new WaitForSeconds(1)); onEnd.Invoke(); Debug.Log("End Animate"); yield return(null); }
private IEnumerator moveToDestination(AnimCallBack onEnd) { //go to next pos Vector3 tmp; Vector3 target = points[0]; float delta = Mathf.Abs(target.y - start_y); while (Vector3.Distance(target, go1.transform.position) > delta) { float step = speed * Time.deltaTime * 5; tmp = Vector3.MoveTowards(go1.transform.position, target, step); tmp.y = start_y; go1.transform.position = tmp; yield return(null); } //place second object on second point go2.transform.parent = null; go2.transform.position = points[1]; yield return(new WaitForSeconds(1)); onEnd.Invoke(); Debug.Log("End Animate"); }
public void StartSetupAnimation(Type animType) { currentSetupedAnim = (XVAnimation)gameObject.AddComponent(animType); currentSetupedAnim.go1 = setupAnimationsState.CurrentObjectToEdit.gameObject; onAnimationSelected?.Invoke(); animatedObjects.Add(setupAnimationsState.CurrentObjectToEdit); CheckSetupedAnim(); }
private void endAnim(AnimCallBack onEnd) { go1.GetComponent <UChanVoice>().PlayLaught(); animator.speed = startAnimSpeed; agent.speed = startAgentSpeed; agent.isStopped = true; animator.SetBool("walk", false); onEnd.Invoke(); Debug.Log("End Animate"); }
public override void Animate(AnimCallBack onEnd) { Debug.Log("Animate"); if (!Check()) { onEnd.Invoke(); Debug.Log("invalid paramenters"); return; } if (!go1.GetComponent <EnvironmentObject>().unityChan) { start_y = go1.transform.position.y; Debug.Log("Animate"); StartCoroutine(move(onEnd)); } else { onEnd.Invoke(); } }
public void CutListAndPlot(bool isAnim) { List <PlotableProcess> processes = toPlot.GetRange(0, rangePlot); if (processes.Count > 0) { processes[processes.Count - 1].attColor = processes[processes.Count - 1].RunColor; callBack?.Invoke(processes[processes.Count - 1]); UpdateData(processes, YLabel, title, isAnim); processes[processes.Count - 1].attColor = processes[processes.Count - 1].WaitingColor; } }
IEnumerator move(AnimCallBack onEnd) { Vector3 tmp; Vector3 target = points[0]; float delta = Mathf.Abs(target.y - start_y); while (Vector3.Distance(target, go1.transform.position) > delta) { float step = speed * Time.deltaTime * 5; // calculate distance to move tmp = Vector3.MoveTowards(go1.transform.position, target, step); tmp.y = start_y; go1.transform.position = tmp; yield return(null); } onEnd.Invoke(); Debug.Log("End Animate"); yield return(null); }
private void CheckSetupedAnim() { if (currentSetupedAnim.IsSecondObjectNeeded()) { needObject = true; //print msg DisplayToUser("Need second object"); } else { needObject = false; } if (currentSetupedAnim.points.Count < currentSetupedAnim.NumberOfPOintsNeeded() && !needObject) { needPoint = true; DisplayToUser("Need point"); } else { needPoint = false; } if (!needObject && !needPoint) { DisplayToUser("Animation setup successfully!!"); if (setupAnimationsState.CurrentObjectToEdit.unityChan) { setupAnimationsState.CurrentObjectToEdit.gameObject.GetComponent <UChanVoice>().PlayYata(); } AddToStack(currentSetupedAnim); currentSetupedAnim = null; onAnimationSetuped?.Invoke(); } }