Created
August 4, 2014 09:25
-
-
Save zhixu/578afd81520d9d9384c4 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 setExpression(string name) | |
{ | |
if( ! expressions.ContainsKey( name ) )return; | |
if( LAppDefine.DEBUG_LOG ) Debug.Log( "Setting expression : " + name ) ; | |
AMotion motion=expressions[ name ] ; | |
expressionManager.startMotion( motion , false ) ; | |
} | |
public void setRandomExpression() | |
{ | |
int no=(int)(rand.NextDouble() * expressions.Count); | |
string[] keys = new string[expressions.Count]; | |
expressions.Keys.CopyTo(keys,0); | |
setExpression(keys[no]); | |
} |
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 ) ; | |
} | |
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
"expressions": | |
[ | |
{"name":"f01","file":"motions/expressions/f01.exp.json"}, | |
{"name":"f02","file":"motions/expressions/f02.exp.json"}, | |
{"name":"f03","file":"motions/expressions/f03.exp.json"}, | |
{"name":"f04","file":"motions/expressions/f04.exp.json"} | |
], | |
"motions": | |
{ | |
"idle": | |
[ | |
{"file":"motions/idle/idl_00.mtn" ,"fade_in":2000, "fade_out":2000}, | |
{"file":"motions/idle/idl_01.mtn" ,"fade_in":2000, "fade_out":2000}, | |
{"file":"motions/idle/idl_02.mtn" ,"fade_in":2000, "fade_out":2000} | |
], | |
"tap_body": | |
[ | |
{ "file":"motions/tap/tapBody01.mtn", "sound":"sounds/tap/tapBody01.mp3" }, | |
{ "file":"motions/tap/tapBody02.mtn", "sound":"sounds/tap/tapBody02.mp3" }, | |
{ "file":"motions/tap/tapBody03.mtn", "sound":"sounds/tap/tapBody03.mp3" } | |
], | |
"pinch_in": | |
[ | |
{ "file":"motions/pinch/pinchIn01.mtn", "sound":"sounds/pinch/pinchIn01.mp3" }, | |
{ "file":"motions/pinch/pinchIn02.mtn", "sound":"sounds/pinch/pinchIn02.mp3" }, | |
{ "file":"motions/pinch/pinchIn03.mtn", "sound":"sounds/pinch/pinchIn03.mp3" } | |
], | |
"pinch_out": | |
[ | |
{ "file":"motions/pinch/pinchOut01.mtn", "sound":"sounds/pinch/pinchOut01.mp3" }, | |
{ "file":"motions/pinch/pinchOut02.mtn", "sound":"sounds/pinch/pinchOut02.mp3" }, | |
{ "file":"motions/pinch/pinchOut03.mtn", "sound":"sounds/pinch/pinchOut03.mp3" } | |
], | |
"shake": | |
[ | |
{ "file":"motions/shake/shake01.mtn", "sound":"sounds/shake/shake01.mp3","fade_in":500 }, | |
{ "file":"motions/shake/shake02.mtn", "sound":"sounds/shake/shake02.mp3","fade_in":500 }, | |
{ "file":"motions/shake/shake03.mtn", "sound":"sounds/shake/shake03.mp3","fade_in":500 } | |
], | |
"flick_head": | |
[ | |
{ "file":"motions/flick/flickHead01.mtn", "sound":"sounds/flick/flickHead01.mp3" }, | |
{ "file":"motions/flick/flickHead02.mtn", "sound":"sounds/flick/flickHead02.mp3" }, | |
{ "file":"motions/flick/flickHead03.mtn", "sound":"sounds/flick/flickHead03.mp3" } | |
] |
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 motionCorrect() | |
{ | |
points++; // adds one point to the score | |
percentage = points/total; // recalculates percentage with new score | |
// character becomes happy that you answered the question correctly | |
appModel.setExpression("happy"); | |
// body movement changes depending on percentage | |
if (percentage >= 70) { | |
appModel.startRandomMotion ("extremely happy", LAppDefine.PRIORITY_NORMAL); | |
} else { | |
appModel.startRandomMotion("happy", LAppDefine.PRIORITY_NORMAL); | |
} | |
} | |
public void motionIncorrect() | |
{ | |
// set expressions based on percentage | |
if (percentage >= 90) { | |
appModel.setExpression("happy"); | |
} else if (percentage >=80) { | |
appModel.setExpression("judging"); | |
} else if (percentage >=70) { | |
appModel.setExpression("sad"); | |
} else { | |
appModel.setExpression("angry"); | |
} | |
// set motions based on percentage | |
if (percentage >= 90) { | |
appModel.startRandomMotion("judging", LAppDefine.PRIORITY_NORMAL); | |
} else if (percentage >= 25) { | |
appModel.startMotion("angry", LAppDefine.PRIORITY_NORMAL); | |
} else { | |
appModel.startMotion("very angry", LAppDefine.PRIORITY_NORMAL); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment