Created
August 4, 2014 09:47
-
-
Save zhixu/61a9b5d31c6f1e52aa2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void startRandomMotion(string name ,int priority) | |
{ | |
int max = modelSetting.getMotionNum( name ); | |
int no = (int)(rand.NextDouble() * max ) ; // picking a random number from your motion group | |
startMotion( name, no, priority ) ; | |
} | |
public void startMotion(string name, int no,int priority) | |
{ | |
string motionName = modelSetting.getMotionFile( name, no ) ; | |
if( motionName==null || motionName.Equals( "" ) ) | |
{ | |
if(LAppDefine.DEBUG_LOG) Debug.Log("Motion name is invalid"); | |
return; | |
} | |
if( ! mainMotionManager.reserveMotion( priority ) ) | |
{ | |
if(LAppDefine.DEBUG_LOG){ Debug.Log("Do not play because book already playing, or playing a motion already");} | |
return ; | |
} | |
AMotion motion = FileManager.loadAssetsMotion( motionName ) ; | |
if( motion == null ) | |
{ | |
Debug.Log( "Failed to read the motion." ) ; | |
mainMotionManager.setReservePriority( 0 ) ; | |
return; | |
} | |
motion.setFadeIn(modelSetting.getMotionFadeIn(name, no)); | |
motion.setFadeOut(modelSetting.getMotionFadeOut(name, no)); | |
if( ( modelSetting.getMotionSound(name, no)) == null) | |
{ | |
if(LAppDefine.DEBUG_LOG) Debug.Log("Start motion : "+motionName); | |
mainMotionManager.startMotionPrio(motion,priority); | |
} | |
else | |
{ | |
string soundPath=modelSetting.getMotionSound( name, no ) ; | |
soundPath = Regex.Replace(soundPath,".mp3$",""); | |
AudioClip acVoice=FileManager.loadAssetsSound( soundPath ) ; | |
if(LAppDefine.DEBUG_LOG) Debug.Log("Start motion : "+motionName+" voice : "+soundPath); | |
startVoiceMotion( motion,acVoice,priority); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment