Skip to content

Instantly share code, notes, and snippets.

@daleth90
Created Oct 20, 2018
Embed
What would you like to do?
// 某個情境,將角色加入隊伍
// 依序尋找空的成員位置
for ( int i = 0; i < teamMembers.Length; i++ ) {
// 如果有空的位置,將新角色設定在該位置
// 因為成功的將角色加入隊伍了,因此直接結束這個迴圈
if ( teamMembers[ i ] == null) {
teamMembers[ i ] = character;
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment