/// Creates a new Task object for the given coroutine. /// /// If autoStart is true (default) the task is automatically started /// upon construction. public SimpleTask(IEnumerator c, bool autoStart = true) { state = SimpleTaskServices.CreateTask(c); if (autoStart) { Start(); } }
public void SetAction(string actionName, float speed) { if (string.IsNullOrEmpty(actionName)) { Debug.LogWarning("action name is null !!!"); return; } SimpleTaskServices.CreateTask(setAction(actionName, speed)).Start(); }
public static TaskState CreateTask(IEnumerator coroutine) { if (singleton == null) { GameObject go = new GameObject("SimpleTaskServices"); DontDestroyOnLoad(go); singleton = go.AddComponent <SimpleTaskServices>(); } return(new TaskState(coroutine)); }
IEnumerator setAction(string actionName, float speed) { while (animator == null) { yield return(0); } if (animator.GetBool(actionName)) { yield break; } animator.Rebind(); if (actionName == ActionConst.CHANGE_CLOTH || actionName == ActionConst.CHANGE_SHOE || actionName == ActionConst.CHANGE_FACEHAIR || actionName == ActionConst.DRESS_IDLE) { SetCurrentAnimLayer(CharacterAnimLayer.fittingroomLayer); if (actionName == ActionConst.DRESS_IDLE) { animator.SetBool(ActionConst.CHANGE_CLOTH, false); animator.SetBool(ActionConst.CHANGE_FACEHAIR, false); animator.SetBool(ActionConst.CHANGE_SHOE, false); } else { animator.SetBool(actionName, true); SimpleTaskServices.CreateTask(SetAnim(actionName)).Start(); } } else { SetCurrentAnimLayer(CharacterAnimLayer.baseLayer); if (actionName == ActionConst.IDLE) { animator.SetBool(ActionConst.HELLO, false); animator.SetBool(ActionConst.TALK, false); animator.SetBool(ActionConst.WALK, false); } else { animator.SetBool(actionName, true); if (actionName != ActionConst.WALK) { SimpleTaskServices.CreateTask(SetAnim(actionName)).Start(); } } } }