Skip to content

Instantly share code, notes, and snippets.

@zhixu
Created August 4, 2014 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhixu/61a9b5d31c6f1e52aa2a to your computer and use it in GitHub Desktop.
Save zhixu/61a9b5d31c6f1e52aa2a to your computer and use it in GitHub Desktop.
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