// Async method for move camera to character private IEnumerator MoveCameraToCharacterAsync(CharacterScript character, MoveCameraToCallback callback) { var lookToEvent = new GameEvent("look to", new Dictionary <string, object>() { { "gameobject", character.transform.gameObject }, { "instant", false }, { "synchronous", true } }); Game.main.enqueueEvent(lookToEvent); yield return(new WaitForEventFinished(lookToEvent)); callback(true); }
// Async method for trigger animation private IEnumerator triggerAnimationAsync(CharacterScript character, string animationName, string then, MoveCameraToCallback callback) { Entity entity = character.transform.GetComponent(typeof(Entity)) as Entity; GameEvent animationEvent = null; if (then == "") { animationEvent = new GameEvent("animate entity", new Dictionary <string, object>() { { "decorationanimator", entity.decorationAnimator }, { "animation", animationName }, { "synchronous", true } }); } else { animationEvent = new GameEvent("animate entity", new Dictionary <string, object>() { { "decorationanimator", entity.decorationAnimator }, { "animation", animationName }, { "then", then }, { "synchronous", true } }); } Game.main.enqueueEvent(animationEvent); yield return(new WaitForEventFinished(animationEvent)); callback(true); }
// Trigger animation public void TriggerAnimation(CharacterScript character, string animationName, string then, MoveCameraToCallback callback) { StartCoroutine(triggerAnimationAsync(character, animationName, then, callback)); }
// Camera look to Character public void MoveCameraToCharacter(CharacterScript character, MoveCameraToCallback callback) { StartCoroutine(MoveCameraToCharacterAsync(character, callback)); }