scieee AI-readable full text Open interactive document viewer

Code activity 1 for interaction of user with tablet and NAO robot in a Unity program. DIVINTECH

Caro-Via, Selene; Cortés Escañuela, Pol; Fonseca, David; Canaleta, Xavi; HERRERO-MARTÍN, JAVIER

Abstract

Code activity 1 for interaction of user with tablet and NAO robot in a Unity program. DIVINTECH

Full text

Uses of robotics to improve the instrumental skills of students with Autism Spectrum Disorder through the development of new inclusive contexts (DivInTech) Code of Activity 1: The Numbers 1 Activity 1: The numbers File 1: Configuration.cs 1 u s i n g System . C o l l e c t i o n s ; 2 u s i n g System . C o l l e c t i o n s . Gene ri c ; 3 u s i n g U ni t yEng ine ; 4 u s i n g U ni t yEng ine . SceneManagement ; 5 u s i n g U ni t yEng ine . UI ; 6 u s i n g TMPro ; 7 u s i n g DG. Tweening ; 8 9 10 p u b l i c c l a s s C o n f i g u r a t i o n : MonoBehaviour 11 { 12 / / C o n s t a n t e s para e n v i a r i n f o r m a c i o n 13 p r i v a t e s t r i n g LowValue = " LowValue " ; 14 p r i v a t e s t r i n g HighValue = " HighValue " ; 15 p r i v a t e s t r i n g NumValues = " NumValues " ; 16 p r i v a t e s t r i n g NumPlayers = " NumPlayers " ; 17 p r i v a t e s t r i n g PosValues = " PosValues " ; 18 p r i v a t e s t r i n g OrdValues = " OrdValues " ; 19 p r i v a t e s t r i n g Cat1 = " Cat1 " ; 20 p r i v a t e s t r i n g Cat2 = " Cat2 " ; 21 p r i v a t e s t r i n g Cat3 = " Cat3 " ; 22 p r i v a t e s t r i n g RobotIP = " RobotIP " ; 23 p r i v a t e s t r i n g Genero = " Genero " ; 24 25 This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 26 / / V a r i a b l e s i n t e r f i c i e 27 p u b l i c TMP_InputField InputField_NumbersMin ; 28 p u b l i c TMP_InputField InputField_NumbersMax ; 29 p u b l i c TMP_Dropdown Dropdown_NumbersNum ; 30 p u b l i c GameObject Tog gle Butto n ; 31 p u b l i c TextMeshProUGUI Tog gleText ; 32 33 / / V a r i a b l e s i n t e r n a s 34 private int tiempo_espera_mika ; 35 private int cifra_menor ; 36 private int cifra_mayor ; 37 private int cantidad_cifras ; 38 private int num_jugadores ; 39 p r i v a t e s t r i n g p o s _ c i f r a s ; 40 p r i v a t e s t r i n g o r d e n _ c i f r a s ; 41 p r i v a t e s t r i n g c a t e g o r i a 1 ; 42 p r i v a t e s t r i n g c a t e g o r i a 2 ; 43 p r i v a t e s t r i n g c a t e g o r i a 3 ; 44 p r i v a t e s t r i n g r o b o t _ i p ; 45 46 / / 1 = M, 0 = N, −1 = F 47 private int t o g g l e S t a t u s = 0 ; 48 private int togglePreviousStatus = 1; 49 50 / / S t a r t i s c a l l e d b e f o r e t h e f i r s t frame u pda te 51 void S t a r t ( ) 52 { 53 this . tiempo_espera_mika = 0; 54 t h i s . c i f r a _ m e n o r = 2 ; 55 t h i s . c i f r a _ m a y o r = 6 ; 56 / / Valor por d e f e c t o 57 t h i s . c a n t i d a d _ c i f r a s = 5; 58 t h i s . num_jugadores = 1; 59 t h i s . o r d e n _ c i f r a s = " o r de n a da s " ; 60 t h i s . p o s _ c i f r a s = " s e g u i d a s " ; 61 t h i s . c a t e g o r i a 1 = " a n i m a l es " ; 62 t h i s . c a t e g o r i a 2 = " c o l o r e s " ; 63 t h i s . c a t e g o r i a 3 = " f r u t a s " ; 64 t h i s . r o b o t _ i p = " 1 9 2 . 1 6 8 . 3 1 . 9 1 " ; 65 } 66 67 / / Update i s c a l l e d once per frame 68 void Update ( ) 69 { 70 71 } 72 73 p r i v a t e bool CheckCifraMenor ( ) { 74 i f ( t h i s . c i f r a _ m e n o r <= 1) { This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 75 t h i s . InputField_NumbersMin . image . c o l o r = Col or . r e d ; 76 return f a l s e ; 77 } 78 t h i s . InputField_NumbersMin . image . c o l o r = Col or . w hi t e ; 79 return true ; 80 } 81 82 p r i v a t e bool CheckCifraMayor ( ) { 83 / / Comprovamos que l a c i f r a mayor sea s u p e r i o r a l a c i f r a menor 84 i f ( t h i s . c i f r a _ m a y o r <= t h i s . c i f r a _ m e n o r | t h i s . c i f r a _ m a y o r <= 0) { 85 t h i s . InputField_NumbersMax . image . c o l o r = Color . r ed ; 86 return f a l s e ; 87 } 88 t h i s . InputField_NumbersMax . image . c o l o r = Color . w hi te ; 89 return true ; 90 } 91 92 p r i v a t e bo ol C h e c k C a n t i d a d C i f r a s ( ) { 93 / / Comprovamos que s e haya m o d i f i c a d o e l v a l o r y que l a d i f e r e n c i a e n t r e l a s c i f r a s sea mayor a l a c a n t i d a d de c i f r a s a mo st ra r 94 i f ( t h i s . c a n t i d a d _ c i f r a s > ( t h i s . ci f ra _ ma y or − t h i s . c i f r a _ m e n o r +1) ) { 95 t h i s . Dropdown_NumbersNum . image . c o l o r = Colo r . r e d ; 96 t h i s . InputField_NumbersMax . image . c o l o r = Color . r ed ; 97 return f a l s e ; 98 } 99 t h i s . Dropdown_NumbersNum . image . c o l o r = Colo r . w hi te ; 100 t h i s . InputField_NumbersMax . image . c o l o r = Color . w hi te ; 101 return true ; 102 } 103 104 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 105 / / BUTTONS FUNCTIONS 106 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 107 p u b l i c void Continuar () { 108 i f ( t h i s . CheckCifraMenor ( ) & t h i s . CheckCifraMayor ( ) & t h i s . C h e c k C a n t i d a d C i f r a s ( ) ) { 109 P l a y e r P r e f s . S e t I n t ( LowValue , t h i s . c i f r a _ m e n o r ) ; 110 P l a y e r P r e f s . S e t I n t ( HighValue , t h i s . c i f r a _ m a y o r ) ; 111 P l a y e r P r e f s . S e t I n t ( NumValues , t h i s . c a n t i d a d _ c i f r a s ) ; 112 P l a y e r P r e f s . S e t I n t ( NumPlayers , t h i s . num_jugadores ) ; 113 P l a y e r P r e f s . S e t S t r i n g ( PosValues , t h i s . p o s _ c i f r a s ) ; 114 P l a y e r P r e f s . S e t S t r i n g ( OrdValues , t h i s . o r d e n _ c i f r a s ) ; 115 P l a y e r P r e f s . S e t S t r i n g ( Genero , t h i s . T oggleText . t e x t ) ; 116 i f ( t h i s . c a t e g o r i a 1 != " " ) { 117 P l a y e r P r e f s . S e t S t r i n g ( Cat1 , t h i s . c a t e g o r i a 1 ) ; This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 118 } 119 else { 120 P l a y e r P r e f s . S e t S t r i n g ( Cat1 , " an im a l e s " ) ; 121 } 122 i f ( t h i s . c a t e g o r i a 2 != " " ) { 123 P l a y e r P r e f s . S e t S t r i n g ( Cat2 , t h i s . c a t e g o r i a 2 ) ; 124 } 125 else { 126 P l a y e r P r e f s . S e t S t r i n g ( Cat2 , " c o l o r e s " ) ; 127 } 128 i f ( t h i s . c a t e g o r i a 3 != " " ) { 129 P l a y e r P r e f s . S e t S t r i n g ( Cat3 , t h i s . c a t e g o r i a 3 ) ; 130 } 131 else { 132 P l a y e r P r e f s . S e t S t r i n g ( Cat3 , " f r u t a s " ) ; 133 } 134 P l a y e r P r e f s . S e t S t r i n g ( RobotIP , t h i s . r o b o t _ i p ) ; 135 SceneManager . LoadScene ( " F i n a l C o n f i g u r a t i o n " ) ; 136 } 137 } 138 139 p u b l i c void A t r a s ( ) { 140 SceneManager . LoadScene ( "Menu" ) ; 141 } 142 143 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 144 / / INPUTFIELD FUNCTIONS 145 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 146 147 148 p u b l i c void Ca ll b ac k C if r aM e no r ( s t r i n g s ) { 149 Debug . Log ( s ) ; 150 i n t . Try Par se ( s , ou t i n t r e s u l t ) ; 151 t h i s . c i f r a _ m e n o r = r e s u l t ; 152 Debug . Log ( t h i s . c i f r a _ m e n o r ) ; 153 } 154 155 p u b l i c void Ca ll b ac k C if r aM a yo r ( s t r i n g s ) { 156 Debug . Log ( s ) ; 157 i n t . Try Par se ( s , ou t i n t r e s u l t ) ; 158 t h i s . c i f r a _ m a y o r = r e s u l t ; 159 Debug . Log ( t h i s . c i f r a _ m a y o r ) ; 160 } 161 162 p u b l i c void C a l l b a c k C a t e g o r i a 1 ( s t r i n g s ) { 163 Debug . Log ( s ) ; 164 t h i s . c a t e g o r i a 1 = s ; 165 Debug . Log ( t h i s . c a t e g o r i a 1 ) ; 166 } This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 167 168 p u b l i c void C a l l b a c k C a t e g o r i a 2 ( s t r i n g s ) { 169 Debug . Log ( s ) ; 170 t h i s . c a t e g o r i a 2 = s ; 171 Debug . Log ( t h i s . c a t e g o r i a 2 ) ; 172 } 173 174 p u b l i c void C a l l b a c k C a t e g o r i a 3 ( s t r i n g s ) { 175 Debug . Log ( s ) ; 176 t h i s . c a t e g o r i a 3 = s ; 177 Debug . Log ( t h i s . c a t e g o r i a 3 ) ; 178 } 179 180 p u b l i c void CallbackRobotIP( string s) { 181 t h i s . r o b o t _ i p = s ; 182 } 183 184 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 185 / /DROPDOWN FUNCTIONS 186 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 187 p u b l i c void CallbackCantidadCifras( i n t i nd ex ) { 188 swi tch ( i nd ex ) { 189 cas e 0 : 190 t h i s . c a n t i d a d _ c i f r a s = 5; 191 break ; 192 cas e 1 : 193 t h i s . c a n t i d a d _ c i f r a s = 6; 194 break ; 195 cas e 2 : 196 t h i s . c a n t i d a d _ c i f r a s = 7; 197 break ; 198 cas e 3 : 199 t h i s . c a n t i d a d _ c i f r a s = 8; 200 break ; 201 cas e 4 : 202 t h i s . c a n t i d a d _ c i f r a s = 9; 203 break ; 204 cas e 5 : 205 t h i s . c a n t i d a d _ c i f r a s = 1 0; 206 break ; 207 } 208 } 209 210 p u b l i c void CallbackCifras( int in de x ) { 211 swi tch ( i nd ex ) { 212 cas e 0 : 213 t h i s . o r d e n _ c i f r a s = " o r de n a da s " ; 214 break ; 215 cas e 1 : This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 216 t h i s . o r d e n _ c i f r a s = " d e s o r d en a d a s " ; 217 break ; 218 } 219 } 220 221 p u b l i c void CallbackPosicionCifras( i n t i nd ex ) { 222 swi tch ( i nd ex ) { 223 cas e 0 : 224 t h i s . p o s _ c i f r a s = " s e g u i d a s " ; 225 break ; 226 cas e 1 : 227 t h i s . p o s _ c i f r a s = " a l e a t o r i a s " ; 228 break ; 229 } 230 } 231 232 p u b l i c void CallbackNumJugadores ( int in de x ) { 233 234 swi tch ( i nd ex ) { 235 cas e 0 : 236 t h i s . num_jugadores = 1; 237 break ; 238 cas e 1 : 239 t h i s . num_jugadores = 2; 240 break ; 241 cas e 2 : 242 t h i s . num_jugadores = 3; 243 break ; 244 } 245 Debug . Log ( t h i s . num_jugadores ) ; 246 } 247 248 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 249 / / TOGGLE BUTTON FUNCTIONS 250 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 251 p u b l i c void ClickOnToggleButton () { 252 i f ( t o g g l e S t a t u s == −1 | | t o g g l e S t a t u s == 1) { 253 Tog gleB utto n . t r a n s f o r m . DOLocalMoveX ( 0 , 0 . 2 5 f ) ; 254 / / T o g g l e B u t t o n . t r a n s f o r m . l o c a l P o s i t i o n = new V e c to r 3 ( 0 , 0 , 0 ) ; 255 t o g g l e S t a t u s = 0 ; 256 Tog gl eT ex t . S e t T e x t ( "N" ) ; 257 } 258 else { 259 i f (togglePreviousStatus == 1) { 260 Tog gleB utto n . t r a n s f o r m . DOLocalMoveX ( 2 5 , 0 . 2 5 f ) ; 261 / / T o g g l e B u t t o n . t r a n s f o r m . l o c a l P o s i t i o n = new Ve cto r3 ( 2 5 , 0 , 0 ) ; 262 t o g g l e P r e v i o u s S t a t u s = −1; This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 263 t o g g l e S t a t u s = −1; 264 Tog gl eT ex t . S e t T e x t ( " F" ) ; 265 } 266 else { 267 Tog gleB utto n . t r a n s f o r m . DOLocalMoveX ( −25 , 0.25 f ) ; 268 / / T o g g l e B u t t o n . t r a n s f o r m . l o c a l P o s i t i o n = new V e ct or 3 ( −25 ,0 ,0) ; 269 t o g g l e P r e v i o u s S t a t u s = 1 ; 270 t o g g l e S t a t u s = 1; 271 Tog gl eT ex t . S e t T e x t ( "M" ) ; 272 } 273 } 274 Debug . Log ( t o g g l e S t a t u s ) ; 275 276 } 277 278 279 } This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). File 2: Configuration_Final.cs 1 u s i n g System . C o l l e c t i o n s ; 2 u s i n g System . C o l l e c t i o n s . Ge ne ri c ; 3 u s i n g U ni t yEng ine ; 4 u s i n g U ni t yEng ine . SceneManagement ; 5 u s i n g U ni t yEng ine . UI ; 6 u s i n g TMPro ; 7 u s i n g System . IO ; 8 u s i n g System ; 9 u s i n g static DebugUtils ; 10 u s i n g System . Linq ; 11 12 13 p u b l i c c l a s s C o n f i g u r a t i o n _ F i n a l : MonoBehaviour 14 { 15 16 [ System . S e r i a l i z a b l e ] 17 p u b l i c c l a s s So ngL ist 18 { 19 p u b l i c s t r i n g [ ] songs ; 20 } 21 22 [ System . S e r i a l i z a b l e ] 23 p u b l i c c l a s s Da nc eL is t 24 { 25 p u b l i c s t r i n g [ ] da nce s ; 26 } 27 28 p u b l i c TMP_Dropdown Dropdown_FinalSongs ; 29 p u b l i c TMP_Dropdown Dropdown_FinalDance ; 30 31 / / C o n s t a n t e s para e n v i a r i n f o r m a c i o n 32 p r i v a t e s t r i n g M us i ca F i na l = " Mu s ic a Fi n a l " ; 33 p r i v a t e s t r i n g B a i l e F i n a l = " B a i l e F i n a l " ; 34 35 p r i v a t e s t r i n g folderSongsName = " Di vInT echS esion 1 / Songs " ; 36 p r i v a t e s t r i n g folderDancesName = " D ivInT echS esio n1 / Dances " ; 37 38 p r i v a t e s t r i n g fileSongsName = " s ongs . j s o n " ; 39 p r i v a t e s t r i n g fileDancesName = " d anc es . j s o n " ; 40 41 / / V a r i a b l e s i n t e r n a s 42 p r i v a t e s t r i n g m u s i c F i n a l ; 43 p r i v a t e s t r i n g d a nc e F i n a l ; 44 45 So ng Lis t s o n g L i s t ; 46 Dan ceL ist d a n c e L i s t ; 47 This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 48 p u b l i c static s t r i n g G et F o ld e r ( ) 49 { 50 i f ( A p p l i c a t i o n . p l a t f o r m == Runt ime Pla tfor m . Android ) 51 { 52 return A p p l i c a t i o n . p e r s i s t e n t D a t a P a t h ; 53 } 54 else 55 { 56 return En vi ronment . G e t F o l d e r P a t h ( Envir on me nt . S p e c i a l F o l d e r . U s e r P r o f i l e ) ; 57 } 58 } 59 60 p u b l i c static D i r e c t o r y I n f o S a f e C r e a t e D i r e c t o r y ( s t r i n g pa th ) 61 { 62 / / Gene r ate i f you don ’ t ch eck i f t h e d i r e c t o r y e x i s t s 63 i f ( D i r e c t o r y . E x i s t s ( p at h ) ) 64 { 65 return n u l l ; 66 } 67 return D i r e c t o r y . C r e a t e D i r e c t o r y ( pa th ) ; 68 } 69 70 71 / / S t a r t i s c a l l e d b e f o r e t h e f i r s t frame u pda te 72 void S t a r t ( ) 73 { 74 / / CARGAR LA MUSICA 75 / / −−−−−−−−−−−−−−−− 76 s t r i n g r u t a S o n g s = Pat h . Combine ( G e t F o ld e r ( ) , folderSongsName ) ; 77 SafeCreateDirectory(rutaSongs) ; 78 r u t a S o n g s = Path . Combine ( r ut aSo ng s , fileSon gsN am e ) ; 79 80 i f ( F i l e . E x i s t s ( r u t a S o n g s ) ) 81 { 82 s t r i n g j s o n C o n t e n t = F i l e . R eadAllText ( r u t a S o n g s ) ; 83 s o n g L i s t = J s o n U t i l i t y . FromJson < SongList >( j s o n C o n t e n t ) ; 84 85 i f ( s o n g L i s t != n u l l && s o n g L i s t . songs . Length > 0 ) 86 { 87 f o r e a c h ( s t r i n g song in s o n g L i s t . so ngs ) 88 { 89 TMP_Dropdown . OptionDat a o pci on = new TMP_Dropdown . OptionDat a ( song ) ; 90 Dropdown_FinalSongs . o p t i o n s . Add ( o pci on ) ; 91 Deb ug Uti ls . Log ( song ) ; / / Muestra l o s nombres de l a s c a n c i o n e s en l a c o n s o la This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 97 / / I n d i c a r qu é vamos a hacer y que t i e n e que p r e s i o n a r e l boton 98 G_ExplainActivity , 99 100 / / E sperar a que p u l s e 101 G_WaitButtonPressed , 102 103 / / Hacer c l a v e de a n t i c i p a c i o n 104 G_Anticipa tionKey2 , 105 106 / / E spera r a que e l u s u a r i o mi re a l r o b o t 107 G_WaitAnticipatoryKey2 , 108 109 / / Apar e cer v a l o r e s en l a p a n t a l l a 110 / / I n d i c a r v a l o r a e n co n t r ar en l a i n t e r f í c i e 111 G_IndicateNumber2Find , 112 113 / / Comprovar b o t o n e s p r e si o n ad o s , en cas o c o r r e c t o , seguir 114 G_WaitNumber2Find , 115 116 / / I n c i c a r c a t e g o r i a a d e c i r X e le me n t o s 117 G_IndicateCategory2Say , 118 119 / / E sperar r e s p u e s t a de l a i n s t r u c t o r a 120 / / y c o n t e s t a r acorde 121 / / y poner p a n t a l l a en bl anc o 122 G_WaitCategory2Say , 123 124 / / INICIO DEL FINAL 125 / / −−−−−−−−−−−−−−−− 126 127 / / Mostrar por p a n t a l l a g r a c ia s 128 / / Env iar g r a c i a s a nao 129 EndG_SayThanks , 130 131 / / Env iar mensaje para que b a i l e 132 EndG_Dance , 133 134 / / E sperar f i n d el b a i l e 135 EndG_WaitDance , 136 137 / / Env iar mensaje s i l e ha g us ta do a c t i v i d a d 138 EndG_ActivityLiked , 139 140 / / E sperar r e s p u e s t a 141 / / Dar r e s p u e s t a v e r b a l en f u n ci o n r e s p u e s t a 142 EndG_WaitActivityLiked 143 This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 144 145 } 146 147 / / Fr ases para dar l a b i e n v e n i d a 148 p r i v a t e s t r i n g [ ] WelcomePhrases = { 149 " Hola , ¿ cómo e s t á s ? " , 150 "Me a l e g r a v e r t e . ¿Cómo e s t á s hoy ? " , 151 " Hola , ¿ cómo va e l d í a ? " , 152 "Qué t a l e s t á s hoy , {0}? " , 153 " Hola {0} , ¿ cómo e s t á s ? " , 154 " Hola { 0 } . ¿Qué h i c i s t e a y er ? " , 155 "Qué bi e n v e r t e ! ¿Qué has hecho e s t a mañ ana ? " , 156 " Hola { 0 } . ¿Qué es l o que má s t e ha g u s t a d o de l o que has hecho e s t a mañ ana ? " , 157 " Hola , que b i e n que volvamos a h a c e r una a c t i v i d a d . ¿ Es t á s f e l i z ? " , 158 " Hola . A mí me g u st a h a c e r a c t i v i d a d e s c o n t i go . ¿A t i tambi én? " , 159 " Hola , ¿ c ómo e s t á s ? Me a l e g r a v e r t e . " , 160 " Hola , ¿ cómo e s t á s ? Te he echado de menos . " , 161 " ¡ Hola ! Me a l e g r a v e rt e , ¿dó nde e s t a b a s ? " , 162 " ¡ Hola ! Me e n c a n t a v e r t e , ¿ qu é e s t a b a s ha ci e nd o a n t e s de v e n i r conmigo ? " , 163 " Hola , ¿ c ómo e s t á s ? Me a l e g r a t e n e r t e aqu í . " , 164 " ¡ Hola ! Me a l e g r a que e s t é s aqu í , y t u ¿ e s t á s f e l i z ? " , 165 " Hola , ¿ c ómo e s t á s ? Me e n c a n t a v e r t e de nuevo . " , 166 " Hola , ¿ c ómo e s t á s ? Me a l e g r a que hayas veni do . " , 167 " Hola . Me a l e g r a que h ay as v en ido a h a c e r una nueva a c t i v i d a d . ¿Cómo e s t á s ? " , 168 " Hola { 0} . ¿Qué ha r á s a l s a l i r d el c o l e g i o ? " , 169 "Me a l e g r o de v e r t e {0} . ¿Cómo t e e n c u e n t r a s ? " , 170 " Que f e l i z e s t o y de v e r t e { 0 } . ¿Cómo va t u d í a ? " , 171 " Hola { 0} . Est oy f e l i z de v e r t e . ¿Qué t a l t e va l a e s c u e l a ? " , 172 " E st oy f e l i z de v e r t e { 0 } . ¿Qué ti emp o h ace hoy ? " 173 } ; 174 175 176 / / Fra ses para l e v a n t a r s e 177 p r i v a t e s t r i n g [ ] Stan dUpPh rases = { 178 " {0} , me voy a l e v a n t a r p ar a h a b l a r c o n t i g o " , 179 "Me l e v a n t o p ar a s e n t ir m e má s a g u s to " , 180 "Me pongo de p i e p a ra h a b l a r c o n t i g o " , 181 "Me voy a l e v a n t a r p a r a v e r t e b i e n " , 182 " E spe ra que me l e v a n t o pa ra h a b l a r c o n t i g o " , 183 " {0} , me l e v a n t o , que l l e v o mucho r a t o s i n moverme " , 184 "Me voy a poner de pie , p ar a h ac e r l a a c t i v i d a d c o n t i g o " , 185 "Me voy a p oner de pi e , a s í e s t a r é má s a g u s t o " , This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 186 " {0} , me pongo de p i e p a ra h a b l a r c o n t i g o " , 187 "Me pongo de pie , a s í t e ve r é má s c l a r a m e n t e " , 188 "Me pondr é de p ie p a r a ve r b i e n cómo ha ce s l a a c t i v i d a d " , 189 " Espera , me l e v a n t a r é p ar a h a b l a r c o n t i g o " , 190 "Voy a l e v an t a rm e p a ra h a b l a r c o n t i g o má s f á c i l m e n t e " , 191 "Me l e v a n t o pa ra s e n t i r m e má s a g u st o m i e n t r a s hablamos " , 192 "Voy a ponerme de p i e p a r a h a c e r l a a c t i v i d a d má s f á c i l m e n t e " , 193 "Me pondr é de p ie p ar a mantener una p o s t u r a má s c o n f o r t a b l e " , 194 "Me pongo de p i e p a r a v e r b i e n l a c l a s e " , 195 "Me pondr é de p i e p ar a s e n t i r m e mejor d u r a n t e l a a c t i v i d a d " , 196 "Voy a l e v a n t a r m e p a r a e s t a r má s c e r c a de t i " , 197 " Pa ra e s c u c h a r t e bien , me pongo de p ie " , 198 "Voy a ponerme de p i e p a r a p a r t i c i p a r de l l e n o en l a a c t i v i d a d " , 199 "Me pondr é de p ie p a r a coloc arme en una buena p o s i c i ón p ar a l a a c t i v i d a d " , 200 "Voy a l e v a n t a r m e p a r a que l a a c t i v i d a d s ea má s f á c i l de s e g u i r " , 201 "Me l e v a n t a r é p ar a que podamos h a b l a r c a r a a c a r a " , 202 "Me pongo de p i e p a ra s e n t i r m e mejor d u r a n t e l a a c t i v i d a d " , 203 "Voy a ponerme de p ie p ar a pode r moverme má s l i b r e m e n t e " , 204 "Me l e v a n t a r é p ar a p ode r h a b l a r c o n t i g o de forma má s c ó moda" 205 } ; 206 207 / / F ras es para p r e g u n t a r s i s e q u i e r e d i v e r t i r 208 p r i v a t e s t r i n g [ ] E n j o yP h r a se s = { 209 "Vamos a d i v e r t i r n o s , ¿ t e a p e t e c e ? " , 210 "Vamos a p a s a r l o bien , ¿ l o hacemos ? " , 211 "Vamos a ha c e r una a c t i v i d a d c hula , ¿ qu é t e p ar e c e ? " , 212 " ¿ Q u i e r e s h a c e r una a c t i v i d a d muy c h u l a conmigo ? " , 213 " Te a p e t e c e ha c e r una a c t i v i d a d s ú p e r d i v e r t i d a conmigo ? " , 214 "Me g u s t a r í a h a c e r una a c t i v i d a d c o nt i go , ¿y a t i conmigo ? " , 215 "Hoy vamos a h a c e r una a c t i v i d a d que t e va a e n c a n t a r , ¿ t e g u s t a r í a ? " , 216 " Quiero ha c er una a c t i v i d a d c o n t i g o . ¿Qué t e p a re c e ? " , 217 " Nos pre paramos p a ra h a c e r una a c t i v i d a d . ¿La hacemos ? " , 218 " La a c t i v i d a d de hoy me g u st a mucho , ¿ q u i e r e s h a c e r l a ? " , 219 " ¿ Te a p e t e c e d i v e r t i r t e conmigo ? " , 220 " ¿ Q u i e r e s acompa ñarme p a ra d i v e r t i r n o s ? " , 221 " ¿Te a p e t e c e u n i r t e a l a d i v e r s i ón conmigo ? " , This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 222 " ¿ Te animas a d i v e r t i r t e conmigo ? " , 223 " ¿ Q u ie re s c o m p a r t i r una a c t i v i d a d d i v e r t i d a conmigo ? " , 224 " ¿Te g u s t a r í a p a s ar un buen r a t o conmigo ? " , 225 " ¿Te a p e te c e d i s f r u t a r de un momento d i v e r t i d o conmigo ? " , 226 " ¿ Te a p e t e c e c o m p a r t i r una t a r e a d i v e r t i d a ? " , 227 " ¿ Qu i e r e s ayudarme a p a s a r un momento d i v e r t i d o ? " , 228 " ¿Te animas a p a s a r un buen r a t o conmigo ? " , 229 " ¿ Q u ie re s d i s f r u t a r de un momento a g r a d a b l e conmigo ? " , 230 " ¿ Q ui e r e s acompañarme en e s t a a c t i v i d a d d i v e r t i d a ? " , 231 " ¿ Q u i e r e s d i s f r u t a r de un buen r a t o conmigo ? " , 232 " ¿ Te animas a d i s f r u t a r de un momento de d i v e r s i ón conmigo ? " , 233 " Ahora me t oc a h a ce r una a c t i v i d a d . ¿Te a p e t e c e ? " 234 } ; 235 236 / / F ras es para p r e g u n t a r s i q u i e r e empezar 237 p r i v a t e s t r i n g [ ] S t a r t P h r a s e s = { 238 " ¿ Q u i e r e s empezar ? " , 239 " ¿ Q ui e r e s i n i c i a r l a a c t i v i d a d conmigo ? " , 240 " Quiero empezar l a a c t i v i d a d . ¿Tú tambi én ? " , 241 " ¿ E st á todo l i s t o ? " , 242 " ¿Comenzamos? " , 243 " An tes de que hagamos l a a c t i v i d a d , ¿ Q u i e r e s p r e gu n ta rm e al g u na co sa ? " , 244 "Ya ver á s qué a c t i v i d a d t a n d i v e r t i d a , ¿ l a hacemos ? " , 245 "Me a p e t e c e comenzar , ¿y a t i ? " , 246 " Es e l momento de empezar . ¿Lo hacemos ? " , 247 " ¿ Q ui e r e s que empecemos l a a c t i v i d a d en equ ipo ? " , 248 " ¿ Q ui e r e s que empecemos l a a c t i v i d a d como equi po ? " , / / 249 " ¿Te animas a empezar l a a c t i v i d a d conmigo ? " , 250 " ¿ Q ui e r e s que empecemos l a a c t i v i d a d aho ra ? " , 251 " ¿Te g u s t a r í a comenzar l a a c t i v i d a d conmigo ? " , / / 252 " ¿ Qu i e r e s que empecemos l a a c t i v i d a d des de e l p r i n c i p i o ? " , / / 253 " ¿Te a p e t e c e empezar l a a c t i v i d a d como eq uip o ? " , / / 254 " ¿Hemos comprobado que t odo e s t á l i s t o p a r a comenzar ? " , 255 " ¿Hemos v i s t o que to do e s t á en orden a n t e s de i n i c i a r ? " , 256 " ¿ Estamos a p un t o p a r a comenzar ? " , 257 " ¿Qué t e pa r e c e s i empezamos con l a a c t i v i d a d ah or a ? " , / / 258 "Av í same cuando e s t é to do l i s t o p a r a empezar " 259 } ; 260 261 / / Hacer una i n t r o d u c c i ón a l j ue go y p e d i r que p u l s e b ot ón 262 / / TODO: New Only s e s s i o n 1 263 private string [] PreExplanationOfTheGamePhrases = { 264 " Ahora vamos a h a c e r una a c t i v i d a d con nú meros . P u l s a e l b o t ón p a r a empezar . " , 265 " ¡ Vamos a empezar una a c t i v i d a d con nú meros ! Haz c l i c en e l b o t ón p a r a comenzar . " , This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 266 " ¡ Comenzamos con una a c t i v i d a d con l o s nú meros ! Haz c l i c en e l b ot ón p a r a empezar . " , 267 " ¡ Empezamos l a a c t i v i d a d con nú meros ! Haz c l i c en e l b ot ón p a r a comenzar . " , 268 " ¡ Es hor a de empezar l a a c t i v i d a d con nú meros ! Haz c l i c en e l b o t ón p a r a empezar l a a c t i v i d a d . " , 269 " ¡ Comenzamos l a a c t i v i d a d de l o s nú meros ! P u l s a e l bo t ón p a r a empezar . " , 270 " ¡ Empezamos con una a c t i v i d a d de números ! Haz c l i c en e l b o t ón p a r a empezar . " , 271 " ¡ Hora de comenzar l a a c t i v i d a d de l o s nú meros ! Haz c l i c en e l b ot ón p a r a empezar . " , 272 " ¡ Vamos a h a c e r una a c t i v i d a d con l o s nú meros ! Haz c l i c en e l b o t ón p a r a comenzar l a a c t i v i d a d . " , 273 " ¡ Comenzamos l a a c t i v i d a d con nú meros ! Haz c l i c en e l b ot ó n p a r a empezar . " , 274 " ¡ Empezamos con una a c t i v i d a d s o b r e l o s nú meros ! Haz c l i c en e l b ot ón p a r a empezar . " , 275 " ¡ Hora de comenzar l a a c t i v i d a d con l o s nú meros ! P u l s a e l b o t ón p a r a empezar . " , 276 " ¡ Vamos a empezar l a a c t i v i d a d de l o s nú meros ! Haz c l i c en e l b o t ón p a r a comenzar . " , 277 " ¡ Es l a hora de comenzar una a c t i v i d a d con nú meros ! Haz c l i c en e l b ot ón p a r a empezar . " , 278 " ¡ Comenzamos con una a c t i v i d a d donde a p a r e c e r á n nú meros ! P u l s a e l b ot ón p a r a empezar . " , 279 " Ahora vamos a h a c e r una a c t i v i d a d de l o s nú meros . P u l s a e l b o t ón p a r a empezar . " , 280 " Ahora me va s a ens e ñ a r l o s nú meros . P u l s a e l b o t ón p a r a empezar . " 281 } ; 282 283 / / Pr eg un ta r s i l e ha g us ta do l a a c t i v i d a d 284 p r i v a t e s t r i n g [ ] A c t i v i t y L i k e d P h r a s e s = { 285 " ¿ Te ha g u s t a d o l o que hemos hecho ? " , 286 " ¿Has d i s f r u t a d o de l a a c t i v i d a d que hemos hecho ? " , 287 " ¿ Te ha g u s t a d o ? " , 288 " ¿Te ha p a r e c i d o d i v e r t i d o l o que hemos hecho ? " , 289 " ¿ Has a p r e n d i d o a l g o nuevo de l o que hemos hecho ? " , 290 " ¿ Te ha p a r e c i d o i n t e r e s a n t e l a a c t i v i d a d que hemos hecho ? " , 291 " ¿ Has d i s f r u t a d o t r a b a j a n d o en e s t o ? " , 292 " ¿ Te ha g u s t a d o l a a c t i v i d a d que hemos hecho ? " , 293 " ¿Qué t e ha p a r e c i d o lo que hemos hecho ? " , 294 " ¿Has d i s f r u t a d o t a n t o como yo con l a a c t i v i d a d que hemos hecho ? " , 295 " ¿ Te ha g u s t a d o t a n t o como a mí l a a c t i v i d a d que hemos hecho ? " , 296 " ¿Te ha p a r e c i d o d i v e r t i d o e l tiempo que hemos de d ic a do a This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). e s t o ? " , 297 " ¿Te ha g us ta do c ómo hemos t r a b a j a d o ? " , 298 " ¿Qué e s l o que má s t e ha g u s t a d o de l o que hemos hecho ? " , 299 " ¿Has d i s f r u t a d o de l a a c t i v i d a d conmigo ? " , 300 " ¿ Te ha g u s t a d o h a c e r l a a c t i v i d a d conmigo ? " 301 } ; 302 303 / / De c ir adi ó s 304 p r i v a t e s t r i n g [ ] GoodByePhrases = { 305 " ¡ Otro d í a volvemos a b a i l a r ! Adió s . " , 306 "Me ha g u s t a d o e ns e ñ a r t e c ómo b a i l o . ¡ H ast a l u e go ! " , 307 " Espero que hayas d i s f r u t a d o t a n t o como yo . ¡ Adió s ! " , 308 "Qué d i v e r t i d o b a i l a r c o n t i g o . ¡ Hasta o t r o d í a ! " , 309 " Espero que hayas d i s f r u t a d o t a n t o como yo b a i l a nd o . ¡ Hast a p r o n t o ! " , 310 "Me g u s t ó ense ñ a r t e l o que hago . ¡ Adió s ! " , 311 " Espero que t e haya g u s t a d o . ¡ Nos vemos o t r o d í a ! " , 312 "Ha s id o g e n i a l ens e ñ a r t e l o que s é h a c e r . ¡ Hasta l a pr ó xima ! " , 313 " Espero que hayas d i s f r u t a d o de mi b a i l e . ¡ Adió s ! " , 314 "Ha s i d o p l a c e r c o m p a r t i r c o n t i g o l o que s é h a ce r . ¡ Nos vemos o t r o d í a ! " , 315 " Espero que t e haya g u s t a d o b a i l a r t a n t o como a mí . ¡ H as t a lu eg o ! " , 316 "Ha s i d o d i v e r t i d o ense ñ a r t e l o que s é h a c e r . ¡ Adió s ! " , 317 "Ha s i d o un p l a c e r ens e ñ a r t e c ómo b a i l o . ¡ Hasta o t r o d í a ! " , 318 "Me ha g us ta d o b a i l a r c o n t i g o . ¡ Ha sta lu ego ! " , 319 "Ha s i d o d i v e r t i d o ense ñ a r t e l o que s é h a c e r . ¡ Hasta o t r o d í a ! " 320 } ; 321 322 / / D eci r que l o ha hecho b i e n 323 p r i v a t e s t r i n g [ ] WellDonePhrases = { 324 " Ge n ia l " , 325 "Muy b i e n " , 326 " Bien " , 327 " Bien hecho " , 328 "Sú per " , 329 " Guay " , 330 " G e n ia l {0} " , 331 "Muy b i e n {0} " , 332 " Bien {0} " , 333 " Bien hecho {0} " , 334 "Sú per {0} " , 335 " Guay {0} " 336 } ; 337 338 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 339 / / VARIABLES 340 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 341 // Interface 342 p u b l i c GameObject canv as ; 343 p u b l i c GameObject b u t t o n ; 344 GameObject [ ] b u t t o n s ; 345 p u b l i c LayerMask UIMask ; 346 GameObject b u t t o n 2 ; 347 p u b l i c TextMeshProUGUI t i t l e _ t x t ; 348 p u b l i c TextMeshProUGUI name_txt ; 349 i n t [ ] v a l u e s ; 350 bool b u t t o n _ c l i c k e d ; 351 S t r i n g b u t t o n _ v a l u e ; 352 353 / / SOCKET t o r o b o t c o n t r o l l e r 354 T c p C l i e n t mySoc ke t_ robot ; 355 p u b l i c NetworkStream t h e S t r e a m _ r o b o t ; 356 S tr ea m Wr it e r t h e W r i t e r _ r o b o t ; 357 StreamReader t h e R e a d e r _ r o b o t ; 358 359 / / SOCKET t o t e a c h e r c o n t r o l l e r 360 p r i v a t e Thread t e a c h e r _ t h r e a d ; 361 p r i v a t e T c p L i st en er t c p L i s t e n e r _ t e a c h e r ; 362 private TcpClient connectedTcpClient_teacher ; 363 p r i v a t e S t r e am W r i te r t h e W r i t e r _ t e a c h e r ; 364 p r i v a t e boo l t e a c h e r _ k e e p R e a d i n g ; 365 p r i v a t e s t r i n g t e a c h e r _ i n t e r f a c e _ m e s s a g e ; 366 p r i v a t e s t r i n g i n t e r f a c e _ t e a c h e r _ m e s s a g e ; 367 368 / / I n f o r m a c i o n d e l j ue g o e s c r i t a por l a c o n f i g u r a c i o n 369 i n t num_values ; 370 / / i n t w a i t _ t i m e ; 371 string concat_string_names ; 372 i n t low_ value ; 373 i n t h i g h _ v a l u e ; 374 s t r i n g p o s _ v a l u e s ; 375 s t r i n g o r d _ v a l u e s ; 376 s t r i n g c a t e g o r i a 1 ; 377 s t r i n g c a t e g o r i a 2 ; 378 s t r i n g c a t e g o r i a 3 ; 379 380 / / C o n f i g u r a c i o n d e l j u eg o t r a b a j a d a 381 s t r i n g [ ] names ; / / User 1 −−> c h i l d / / User 2 −−> e d u c a t o r / / User 3 −−> o t h e r c h i l d 382 383 / / V a r i a b l e s d e l j ueg o 384 S t a t e s s t a t e ; 385 386 s t r i n g game_message ; This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 387 388 i n t loop_times ; 389 390 s t r i n g v a l u e _ s e l e c t e d ; 391 392 s t r i n g c a t e g o r y ; 393 394 i n t randomIndex ; 395 396 / / F in a l de b a i l a r 397 s t r i n g m u s i c a F i n a l = " " ; 398 s t r i n g b a i l e F i n a l = " " ; 399 400 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 401 / / START FUNCTIONS 402 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 403 404 / / S t a r t i s c a l l e d b e f o r e t h e f i r s t frame u pda te 405 void S t a r t ( ) 406 { 407 / / Obtener l a i n fo r m ac i o n de l a c o n f i g u r a c i o n 408 // .......................................... 409 t h i s . num_values = P l a y e r P r e f s . G e t I n t ( NumValues ) ; 410 / / t h i s . w a it _ t i m e = P l a y e r P r e f s . G e t I n t ( WaitTime ) ; 411 t h i s . c o n c a t _ s t r i n g _ n a m e s = P l a y e r P r e f s . G e t S t r i n g ( NamePlayers) ; 412 t h i s . low_ valu e = P l a y e r P r e f s . G e t I n t ( LowValue ) ; 413 t h i s . h i g h_ v al u e = P l a y e r P r e f s . G e t I n t ( HighValue ) ; 414 t h i s . p o s _v a lu e s = P l a y e r P r e f s . G e t S t r i n g ( PosValues ) ; 415 t h i s . o r d _ va l u e s = P l a y e r P r e f s . G e t S t r i n g ( OrdValues ) ; 416 t h i s . c a t e g o r i a 1 = P l a y e r P r e f s . G e t S t r i n g ( Cat1 ) ; 417 t h i s . c a t e g o r i a 2 = P l a y e r P r e f s . G e t S t r i n g ( Cat2 ) ; 418 t h i s . c a t e g o r i a 3 = P l a y e r P r e f s . G e t S t r i n g ( Cat3 ) ; 419 420 / / F in a l de b a i l a r 421 t h i s . m u si ca Fi na l = P l a y e r P r e f s . G e t S t r i n g ( M us i c aF i na l ) ; 422 t h i s . b a i l e F i n a l = P l a y e r P r e f s . G e t S t r i ng ( B a i l e F i n a l ) ; 423 424 / / T ra baj ar l a i nf o rm a c io n de l a c o n f i g u r a c i o n 425 // .......................................... 426 t h i s . names = c o n c a t _ s t r i n g _ n a m e s . S p l i t ( char . P a r s e ( " _ " ) ) ; 427 428 / / Guardar en e l lo g 429 // .......................................... 430 t h i s . GuardarConfigLog ( ) ; 431 432 / / C o n f i g u r a r s o c k e t t e a c h e r 433 // .......................................... 434 t h i s . t h e W r i t e r _ t e a c h e r = n u l l ; This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 435 t e a c h e r _ k e e p R e a d i n g = t r u e ; 436 t e a c h e r _ i n t e r f a c e _ m e s s a g e = " " ; 437 i n t e r f a c e _ t e a c h e r _ m e s s a g e = " " ; 438 this . ConfigTeacherSocket () ; 439 440 / / C o n f i g u r a r s o c k e t r o b o t 441 // .......................................... 442 t h i s . Con fig Rob otS ock et ( ) ; 443 444 / / P re pa ra ci on i n t e r f i c i e 445 // .......................................... 446 447 t h i s . b u t to n 2 = new GameObject ( " b u t t o n " , t y p e o f ( CanvasRenderer ) , t y p e o f ( Image ) , t y p e o f ( B utton ) ) ; 448 / / Creamos un ar ra y donde guardar l o s v a l o r e s 449 t h i s . v a l u e s = new int [ num_values ]; 450 / / Y lo i n i c i a l i z a m o s a 0 todo 451 for (i n t i = 0 ; i < num_values ; i ++) { 452 t h i s . v a l u e s [ i ] = 0 ; 453 } 454 455 / / Creamos l o s v a l o r s a m ostr ar 456 t h i s . b u t t o n s = new GameObject [ num_values ] ; 457 C r e a t e V a l u e s ( t h i s . v a l u e s ) ; 458 C r e a t e B u t t o n s ( t h i s . v a l u e s ) ; 459 H id eB utt on s ( ) ; 460 461 462 / / I n i c i a r v a r i a b l e s 463 // .......................................... 464 465 t h i s . b u t t o n _ c l i c k e d = f a l s e ; 466 t h i s . b u t t o n _ v a l u e = " " ; 467 468 / / t h i s . f l a g _ v a l u e _ s e l e c t e d = f a l s e ; 469 t h i s . v a l u e _ s e l e c t e d = " " ; 470 471 t h i s . l o o p _ t i m e s = 0 ; 472 473 t h i s . s t a t e = S t a t e s . I n i t ; 474 475 t h i s . game_message = " " ; 476 477 t h i s . c a t e g o r y = " " ; 478 479 t h i s . randomIndex = 0 ; 480 481 Uni tyEn gine . Random . I n i t S t a t e ( ( i n t ) System . D at eTi me Off se t . Now . ToUnixTimeSeconds ( ) ) ; This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 482 483 } 484 485 / / Guardar en e l lo g l a c o n f i g u r a c i o n 486 void GuardarConfigLog () { 487 De bugUt ils . Log ( " C o n f i g u r a t i o n " ) ; 488 D ebugU tils . Log ( " Number of v a l u e s i s : " + t h i s . num_values . T o S t r i n g ( ) ) ; 489 D ebugU tils . Log ( " P l a y e r ’ s names i s : " + t h i s . concat_string_names ) ; 490 / / Log ( " W ait ing t i me i s : " + t h i s . w a i t _ t i m e . T o S t r i n g ( ) ) ; 491 D eb ugU ti ls . Log ( " Number of low v a l u e i s : " + t h i s . l ow _ valu e . T o S t r i n g ( ) ) ; 492 D eb ugU ti ls . Log ( " Number of hig h v a l u e i s : " + t h i s . h i g h _ v a l u e . T o S t r i n g ( ) ) ; 493 De bug Ut ils . Log ( " The p o s i t i o n of t h e v a l u es i s : " + t h i s . p o s _ v a l u e s ) ; 494 De bug Utils . Log ( " The o r d e r i n g of t h e v a l u e s i s : " + t h i s . o r d _ v a l u e s ) ; 495 De bug Ut ils . Log ( " The 1 s t c a t eg o ry i s : " + t h i s . c a t e g o r i a 1 ) ; 496 De bug Ut ils . Log ( " The 2nd c a t eg o ry i s : " + t h i s . c a t e g o r i a 2 ) ; 497 De bug Ut ils . Log ( " The 3 rd c at e g o r y i s : " + t h i s . c a t e g o r i a 3 ) ; 498 D ebu gUt ils . Log ( " The IP f o r t h e T ea cher C o n t r o l i s : " + g e t I P A d d r e s s ( ) ) ; 499 De bug Ut ils . Log ( "Game" ) ; 500 } 501 502 / / C o n f i g u r a c i o n d e l s o c k e t d e l r o b o t 503 void ConfigRobotSocket () 504 { 505 S t r i n g ip = P l a y e r P r e f s . G e t S t r i n g ( RobotIP ) ; 506 t h i s . mySocket_robot = new T c p C l i e n t ( ip , 8080 ) ; 507 t h i s . t h e S t r e a m _ r o b o t = mySocket_robot . GetStream ( ) ; 508 t h i s . t h e W r i t e r _ r o b o t = new S t re a mW ri t er ( t h e S t r e a m _ r o b o t ) ; 509 t h i s . t h e R e a d e r _ r o b o t = new StreamReader ( t h e S t r e a m _ r o b o t ) ; 510 } 511 512 void ConfigTeacherSocket () 513 { 514 t e a c h e r _ t h r e a d = new System . T hr ea di ng . Thread ( ( ) => TeacherControlSocket () ) ; 515 t e a c h e r _ t h r e a d . IsBa ckgrou nd = t r u e ; 516 t e a c h e r _ t h r e a d . S t a r t ( ) ; 517 } This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 752 Deb ugU til s . Log ( "ROBOT: Message s e n t −−> " + game_message) ; 753 754 / / I r a e s p e r a r r e s p u e s t a 755 t h i s . s t a t e = S t a t e s . G_ WaitAn ticipa toryKe y2 ; 756 break ; 757 758 759 / / E spera r a que e l u s u a r i o mi re a l r o b o t 760 cas e S t a t e s . G_Wa itAnti cipato ryKey2 : 761 / / TODO: Espe rar r e c i b i r OK de NAO 762 i f ( t h i s . t h e S t r e a m _ r o b o t . D a t a A v a i l a b l e ) { 763 De bugU tils . Log ( "ROBOT: User l ooked r o b o t " ) ; 764 / / E sperar r e s p u e s t a 765 r e c e i v e _ m e s s a g e _ f r o m _ r o b o t ( ) ; 766 767 t h i s . s t a t e = S t a t e s . G_IndicateNumber2Find ; 768 769 t h i s . i n t e r f a c e _ t e a c h e r _ m e s s a g e = " 9\ 0 " ; 770 se n dM es sa g eT ea c he rC on t ro l ( t h i s . interface_teacher_message) ; 771 } 772 773 / / o b ie n ’No resp onde ’ por p a r t e de l a instructora 774 i f ( t h i s . t e a c h e r _ i n t e r f a c e _ m e s s a g e == "M" ) { 775 Deb ug Uti ls . Log ( "TEACHER: User does no t look r o b o t " ) ; 776 t e a c h e r _ i n t e r f a c e _ m e s s a g e = " " ; 777 t h i s . s t a t e = S t a t e s . G_IndicateNumber2Find ; 778 779 / / Av i sa r c o n t r o l a d o r NAO con una ’V ’ 780 / / P repa rar mensaje para hacer c l a v e anticipacion 781 game_message = ( ( char ) RobotHeaders . EndVision ) . T o S t r i n g ( ) ; 782 / / E nvi ar mensaje 783 t h i s . s e n d _ t e x t _ 2 _ r o b o t ( game_message ) ; 784 Deb ug Uti ls . Log ( "ROBOT: Message s e n t −−> " + game_message) ; 785 / / E sperar r e s p u e s t a 786 r e c e i v e _ m e s s a g e _ f r o m _ r o b o t ( ) ; 787 788 789 t h i s . i n t e r f a c e _ t e a c h e r _ m e s s a g e = " 9\ 0 " ; 790 se n dM es sa g eT ea c he rC on t ro l ( t h i s . interface_teacher_message) ; 791 792 This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 793 } 794 break ; 795 796 797 / / Apar e cer v a l o r e s en l a p a n t a l l a 798 / / I n d i c a r v a l o r a e n co n t r ar en l a i n t e r f í c i e 799 cas e S t a t e s . G_IndicateNumber2Find : 800 / / Apar e cer v a l o r e s en p a n t a l l a 801 ShowButtons ( ) ; 802 803 / / S e l e c c i o n a r v al o r a l e a t o r i o 804 t h i s . v a l u e _ s e l e c t e d = t h i s . v a l u e s [ ( Uni tyEn gine . Random . Range ( 0 , t h i s . v a l u e s . Length − 1 ) ) ] . T o S t r i n g ( ) ; 805 Deb ugU til s . Log ( "ACTIVITY : The number s e l e c t e d i s −−> " + t h i s . v a l u e _ s e l e c t e d ) ; 806 / / I n d i c a r a l u s u a r i o e l numero a bu scar 807 game_message = ( ( char ) RobotHeaders . Talk ) . T o S t r i n g ( ) + " Toca e l nú mero " + t h i s . v a l u e _ s e l e c t e d ; 808 / / E nvi ar mensaje 809 t h i s . s e n d _ t e x t _ 2 _ r o b o t ( game_message ) ; 810 Deb ugU til s . Log ( "ROBOT: Message s e n t −−> " + game_message) ; 811 r e c e i v e _ m e s s a g e _ f r o m _ r o b o t ( ) ; 812 813 814 t h i s . s t a t e = S t a t e s . G_WaitNumber2Find ; 815 816 break ; 817 818 819 / / Comprovar b o t o n e s p r e si o n ad o s , en cas o c o r r e c t o , seguir 820 cas e States . G_WaitNumber2Find : 821 i f ( t h i s . b u t t o n _ c l i c k e d ) { 822 823 t h i s . b u t t o n _ c l i c k e d = f a l s e ; 824 825 / / Save v a l u e i n de l o g f i l e 826 De bugUt ils . Log ( "ACTIVITY : The b u t t o n p r e s s e d i s −−> " + t h i s . b u t t o n _ v a l u e ) ; 827 / / Comprovar s i es e l v a l o r que t o ca va presionar 828 i f ( t h i s . b u t t o n _ v a l u e == t h i s . v a l u e _ s e l e c t e d ) { 829 830 t h i s . randomIndex = UnityEn gine . Random . Range ( 0 , WellDonePhras es . Length ) ; This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 831 message = ( ( char ) RobotHeaders . Talk ) . T o S t r i n g ( ) + ( W el lDoneP hr as es [ t h i s . randomIndex ] . C o n t a i n s ( " {0} " ) ? s t r i n g . Format ( WellDonePhrases [ t h i s . randomIndex ] , t h i s . names [ 0 ] ) : WellDonePhrases [ t h i s . randomIndex ] ) ; 832 833 t h i s . s e n d _ t e x t _ 2 _ r o b o t ( message ) ; 834 Deb ug Uti ls . Log ( "ROBOT: Message s e n t −−> " + message ) ; 835 r e c e i v e _ m e s s a g e _ f r o m _ r o b o t ( ) ; 836 837 / / Cambiar de e s t a d o 838 t h i s . s t a t e = S t a t e s . G_IndicateCategory2Say ; 839 } 840 else { 841 message = ( ( char ) RobotHeaders . Talk ) . T o S t r i n g ( ) + " Ui , e s t e e s e l " + t h i s . b u t t o n _ v a l u e + " . Toca e l " + t h i s . v a l u e _ s e l e c t e d + " . " ; 842 t h i s . s e n d _ t e x t _ 2 _ r o b o t ( message ) ; 843 Deb ug Uti ls . Log ( "ROBOT: Message s e n t −−> " + message ) ; 844 r e c e i v e _ m e s s a g e _ f r o m _ r o b o t ( ) ; 845 } 846 } 847 848 849 break ; 850 851 852 / / I n c i c a r c a t e g o r i a a d e c i r X e le me n t o s 853 cas e S t a t e s . G_ I n d ic a t eC a t eg o r y 2S a y : 854 / / Creamos l a f r a s e a d e c i r por e l r o b o t seg un l a c a t e g o r i a de cada loo p 855 game_message = ( ( char ) RobotHeaders . Talk ) . T o S t r i n g ( ) ; 856 swi tch ( t h i s . l o o p _ t i m e s ) { 857 / / ANIMALES 858 cas e 0 : 859 c at e g o r y = t h i s . c a t e g o r i a 1 ; 860 game_message += " Ahora , dime " + t h i s . v a l u e _ s e l e c t e d + " " + c a t e g o r y + " . " ; 861 862 break ; 863 864 / / COLORES This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 865 cas e 1 : 866 c at e g o r y = t h i s . c a t e g o r i a 2 ; 867 game_message += " Ahora , dime " + t h i s . v a l u e _ s e l e c t e d + " " + c a t e g o r y + " . " ; 868 break ; 869 870 / / FRUTAS 871 cas e 2 : 872 c at e g o r y = t h i s . c a t e g o r i a 3 ; 873 game_message += " Ahora , dime " + t h i s . v a l u e _ s e l e c t e d + " " + c a t e g o r y + " . " ; 874 break ; 875 } 876 877 / / Env iar e l mensaje a d e c i r 878 t h i s . s e n d _ t e x t _ 2 _ r o b o t ( game_message ) ; 879 Deb ugU til s . Log ( "ROBOT: Message s e n t −−> " + game_message) ; 880 r e c e i v e _ m e s s a g e _ f r o m _ r o b o t ( ) ; 881 882 t h i s . i n t e r f a c e _ t e a c h e r _ m e s s a g e = " 4\ 0 " ; 883 se nd M es sa ge T ea ch er C on tr ol ( t h i s . interface_teacher_message) ; 884 885 t h i s . s t a t e = S t a t e s . G_WaitCategory2Say ; 886 break ; 887 888 889 / / E sperar r e s p u e s t a de l a i n s t r u c t o r a 890 / / y c o n t e s t a r acorde 891 / / y poner p a n t a l l a en bl anc o 892 cas e S t a t e s . G_WaitCategory2Say : 893 / / comprovar r e s p u e s t a d e l u s u a r i o y r e s po n de r 894 / / C o n t e s t a mal 895 i f ( t h i s . t e a c h e r _ i n t e r f a c e _ m e s s a g e == " I " ) { 896 t e a c h e r _ i n t e r f a c e _ m e s s a g e = " " ; 897 i f ( t h i s . v a l u e _ s e l e c t e d == 1 . T o S t r i n g ( ) ) { 898 message = ( ( char ) RobotHeaders . Talk ) . T o S t ri n g ( ) + " ¿ Q u ie re s p e n s a r l o un poco má s ? Lo s a b e s s e gu r o . Dime " + t h i s . v a l u e _ s e l e c t e d + " " + c a t e g o r y ; 899 } 900 else { 901 message = ( ( char ) RobotHeaders . Talk ) . T o S t ri n g ( ) + " ¿ Q u ie re s p e n s a r l o un poco má s ? Lo s a b e s s e gu r o . Dime " + t h i s . v a l u e _ s e l e c t e d + " " + c a t e g o r y ; This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 902 } 903 904 t h i s . s e n d _ t e x t _ 2 _ r o b o t ( message ) ; 905 Deb ug Uti ls . Log ( "ROBOT: Message s e n t −−> " + message ) ; 906 r e c e i v e _ m e s s a g e _ f r o m _ r o b o t ( ) ; 907 } 908 909 / / C on t e s t a b ie n o no c o n t e s t a 910 e l s e i f ( t h i s . t e a c h e r _ i n t e r f a c e _ m e s s a g e == "C" | | t h i s . t e a c h e r _ i n t e r f a c e _ m e s s a g e == "M" ) { 911 912 / / C o n t e s t a b i e n 913 i f ( t h i s . t e a c h e r _ i n t e r f a c e _ m e s s a g e == "C" ) { 914 915 t h i s . randomIndex = UnityEn gine . Random . Range ( 0 , WellDonePhras es . Length ) ; 916 message = ( ( char ) RobotHeaders . Talk ) . T o S t r i n g ( ) + ( W el lDoneP hr as es [ t h i s . randomIndex ] . C o n t a i n s ( " {0} " ) ? s t r i n g . Format ( WellDonePhrases [ t h i s . randomIndex ] , t h i s . names [ 0 ] ) : WellDonePhrases [ t h i s . randomIndex ] ) ; 917 918 919 } 920 921 //No contesta 922 e l s e i f ( t h i s . t e a c h e r _ i n t e r f a c e _ m e s s a g e == " M" ) { 923 924 message = ( ( char ) RobotHeaders . Talk ) . T o S t r i n g ( ) + t h i s . names [ 0 ] + " , vamos a s e g u i r . " ; 925 926 } 927 t h i s . t e a c h e r _ i n t e r f a c e _ m e s s a g e = " " ; 928 / / Enviamos mensaje a d e c i r 929 t h i s . s e n d _ t e x t _ 2 _ r o b o t ( message ) ; 930 Deb ug Uti ls . Log ( "ROBOT: Message s e n t −−> " + message ) ; 931 r e c e i v e _ m e s s a g e _ f r o m _ r o b o t ( ) ; 932 / / Aumentamos l a s v u e l t a s 933 t h i s . l o o p _ t i m e s += 1 ; 934 935 / / Comprovamos s i hemos t erm ina do l o s b u c l e s 936 i f ( t h i s . l o o p _ t i m e s >= 3) { 937 t h i s . s t a t e = S t a t e s . EndG_SayThanks ; 938 } This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 939 else { 940 t h i s . s t a t e = S t a t e s . G _A nti ci pat io nKe y1 ; 941 } 942 943 / / poner p a n t a l l a en bla nco 944 / / H i de B ut t o ns ( ) ; 945 } 946 947 break ; 948 949 950 / / INICIO DEL FINAL 951 / / −−−−−−−−−−−−−−−− 952 953 / / Mostrar por p a n t a l l a g r a c ia s 954 / / Env iar g r a c i a s a nao 955 cas e S t a t e s . EndG_SayThanks : 956 957 t h i s . i n t e r f a c e _ t e a c h e r _ m e s s a g e = " 8\ 0 " ; 958 se nd M es sa ge T ea ch er C on tr ol ( t h i s . interface_teacher_message) ; 959 960 / / Cambiar p a n t a l l a 961 Hi deB ut to ns ( ) ; 962 t h i s . t i t l e _ t x t . gameObject . S e t A c t i v e ( t r u e ) ; 963 t h i s . name_txt . gameObject . S e t A c t i v e ( t r u e ) ; 964 t h i s . name_txt . S e t Te x t ( " ¡GRACIAS " + t h i s . names [ 0 ] + " ! " ) ; 965 Deb ugUt ils . Log ( "ACTIVITY : Shown f i n a l s c r e e n " ) ; 966 / / Hablar r o b o t 967 game_message = ( ( char ) RobotHeaders . Talk ) . T o S t r i n g ( ) + " G r a c i a s ! Lo ha s hecho muy b i e n ! Vamos a b a i l a r ! " ; 968 / / Env iar e l mensaje a d e c i r 969 t h i s . s e n d _ t e x t _ 2 _ r o b o t ( game_message ) ; 970 Deb ugU til s . Log ( "ROBOT: Message s e n t −−> " + game_message) ; 971 r e c e i v e _ m e s s a g e _ f r o m _ r o b o t ( ) ; 972 973 Thread . S le ep ( 10 00 0) ; 974 975 t h i s . s t a t e = S t a t e s . EndG_Dance ; 976 977 break ; 978 979 980 / / Env iar mensaje para que b a i l e 981 cas e S t a t e s . EndG_Dance : 982 message = ( ( char ) RobotHeaders . DanceSamba ) . This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). T o S tr i n g ( ) + t h i s . m u s i c a F i n a l +"+"+ t h i s . baileFinal ; 983 / / Env iar e l mensaje a d e c i r 984 t h i s . s e n d _ t e x t _ 2 _ r o b o t ( message ) ; 985 D ebugU til s . Log ( "ROBOT: Message s e n t −−> " + message ) ; 986 t h i s . s t a t e = S t a t e s . EndG_WaitDance ; 987 988 break ; 989 990 991 / / E sperar f i n d el b a i l e 992 cas e S t a t e s . EndG_WaitDance : 993 / / E sperar f i n de b a i l e 994 r e c e i v e _ m e s s a g e _ f r o m _ r o b o t ( ) ; 995 t h i s . s t a t e = S t a t e s . E ndG_ Acti vity Like d ; 996 997 break ; 998 999 1000 / / Env iar mensaje s i l e ha g us ta do a c t i v i d a d 1001 cas e States . EndG_ActivityLiked : 1002 1003 t h i s . i n t e r f a c e _ t e a c h e r _ m e s s a g e = " 4\ 0 " ; 1004 se nd M es sa ge T ea ch er C on tr ol ( t h i s . interface_teacher_message) ; 1005 1006 / / Hablar r o b o t 1007 t h i s . randomIndex = UnityEn gine . Random . Range ( 0 , ActivityLikedPhrases .Length) ; 1008 game_message = ( ( char ) RobotHeaders . Talk ) . T o S t ri ng ( ) + ( A c t i v i t y L i k e d P h r a s e s [ t h i s . randomIndex ] . C o n t a i n s ( " {0} " ) ? s t r i n g . Format ( A c t i v i t y L i k e d P h r a s e s [ t h i s . randomIndex ] , t h i s . names [ 0 ] ) : A c t i v i t y L i k e d P h r a s e s [ t h i s . randomIndex ] ) ; 1009 / / Env iar e l mensaje a d e c i r 1010 t h i s . s e n d _ t e x t _ 2 _ r o b o t ( game_message ) ; 1011 D ebugU til s . Log ( "ROBOT: Message s e n t −−> " + game_message) ; 1012 r e c e i v e _ m e s s a g e _ f r o m _ r o b o t ( ) ; 1013 t h i s . s t a t e = S t a t e s . En dG_Wai tActivi tyLike d ; 1014 break ; 1015 1016 1017 / / E sperar r e s p u e s t a 1018 / / Dar r e s p u e s t a v e r b a l en f u n ci o n r e s p u e s t a 1019 cas e S t a t e s . EndG _WaitA ctivit yLiked : 1020 / / Esp erar que s i , que no o nada This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 1021 i f ( t h i s . t e a c h e r _ i n t e r f a c e _ m e s s a g e == " I " | | t h i s . t e a c h e r _ i n t e r f a c e _ m e s s a g e == "C" | | t h i s . t e a c h e r _ i n t e r f a c e _ m e s s a g e == "M" ) { 1022 1023 1024 message = ( ( char ) Rob ot He aders . T alk ) . T o S t r i n g ( ) ; 1025 i f ( t h i s . t e a c h e r _ i n t e r f a c e _ m e s s a g e == "C" ) { 1026 message += " ¡ G en i a l ! " ; 1027 } 1028 / / I m p o r t a n t e que se a e l s e i f para e l c aso que no c o n t e s t e 1029 e l s e i f ( t h i s . t e a c h e r _ i n t e r f a c e _ m e s s a g e == " I " ) { 1030 message += " S i e n t o o í r eso . . . " ; 1031 } 1032 t e a c h e r _ i n t e r f a c e _ m e s s a g e = " " ; 1033 t h i s . randomIndex = UnityEn gine . Random . Range ( 0 , GoodByePhrases . Length ) ; 1034 message += ( GoodByePhrases [ t h i s . randomIndex ] . C o n t a i n s ( " {0} " ) ? s t r i n g . Format ( GoodByePhrases [ t h i s . randomIndex ] , t h i s . names [ 0 ] ) : GoodByePhrases [ t h i s . randomIndex ] ) ; 1035 t h i s . s e n d _ t e x t _ 2 _ r o b o t ( message ) ; 1036 Deb ug Uti ls . Log ( "ROBOT: Message s e n t −−> " + message ) ; 1037 r e c e i v e _ m e s s a g e _ f r o m _ r o b o t ( ) ; 1038 1039 / / Hacemos a di ó s con l a mano 1040 message = ( ( char ) Rob ot He aders . Wave ) . T o S t r i n g ( ) ; 1041 t h i s . s e n d _ t e x t _ 2 _ r o b o t ( message ) ; 1042 Deb ug Uti ls . Log ( "ROBOT: Message s e n t −−> " + message ) ; 1043 r e c e i v e _ m e s s a g e _ f r o m _ r o b o t ( ) ; 1044 1045 / / Matamos t h r e a d de l a c omuni ca cio n con e l c o n t r o l de l a i n s t r u c t o r a 1046 stopTeacherServer () ; 1047 1048 / / Comunicamos a l r o b o t que hemos te rm in ad o 1049 game_message = ( ( char ) RobotHeaders . F i n i s h ) . T o S t r i n g ( ) ; 1050 t h i s . s e n d _ t e x t _ 2 _ r o b o t ( game_message ) ; 1051 Deb ug Uti ls . Log ( "ROBOT: Message s e n t −−> " + game_message) ; 1052 Deb ug Uti ls . Log ( "ACTIVITY : The a c t i v i t y has f i n i s h e d " ) ; This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 1053 / / Cargamos p a n t a l l a f i n a l para s a l i r 1054 SceneManager . LoadScene ( "EndGame" ) ; 1055 1056 } 1057 1058 break ; 1059 1060 } 1061 1062 i f ( t h i s . t e a c h e r _ i n t e r f a c e _ m e s s a g e == "F" ) { 1063 t h i s . t e a c h e r _ i n t e r f a c e _ m e s s a g e = " " ; 1064 t h i s . s t a t e = S t a t e s . EndG_SayThanks ; 1065 } 1066 1067 } 1068 1069 1070 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 1071 / / S o c k et Messages p r o c e s s f u n c t i o n s 1072 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 1073 1074 p r i v a t e static b yt e [ ] S tr i n g To B y te A r r ay ( s t r i n g hex ) { 1075 return Enumerable . Range ( 0 , hex . Length ) 1076 . Where ( x => x % 2 == 0) 1077 . S e l e c t ( x => Co nvert . ToByte ( hex . S u b s t r i n g ( x , 2 ) , 16) ) 1078 . ToArray ( ) ; 1079 } 1080 1081 p r i v a t e s t r i n g c o n v e r t _ h e x _ t o _ a s c i i ( s t r i n g hex_message ) { 1082 1083 1084 s t r i n g a s c i i = s t r i n g . Empty ; 1085 1086 b y te [ ] b y t e s = S tr in g To By te Ar ra y ( hex_message ) ; 1087 a s c i i = Encoding . UTF8 . G e t S t r i n g ( b y t e s ) ; 1088 return a s c i i ; 1089 1090 } 1091 1092 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 1093 / / Robot C o n t r o l l e r s o c k e t f u n c t i o n s 1094 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 1095 p r i v a t e void s e n d _ t e x t _ 2 _ r o b o t ( s t r i n g message ) { 1096 b y te [ ] b y t e s = Encoding . UTF8 . GetBytes ( message ) ; 1097 s t r i n g hex_message = B i t C o n v e r t e r . T oS tr i ng ( b y t es ) . Repla ce ( "−" , s t r i n g . Empty ) . ToLower ( ) ; 1098 t h i s . t h e W r i t e r _ r o b o t . Writ e ( hex_message ) ; 1099 t h i s . t h e W r i t e r _ r o b o t . Fl us h ( ) ; This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 1100 } 1101 1102 p r i v a t e s t r i n g r e c e i v e _ m e s s a g e _ f r o m _ r o b o t ( ) { 1103 b y t e [ ] myReadBuffer = new b y t e [ 6 ] ; 1104 1105 t h i s . t h e S t r e a m _ r o b o t . Read ( myReadBuffer , 0 , myReadBuffer . Length ) ; 1106 s t r i n g hexhex_message = B i t C o n v e r t e r . T oS tr i ng ( myReadBuffer ) . Repl ace ( "−" , s t r i n g . Empty ) . ToLower ( ) ; 1107 1108 string ascii = convert_hex_to_ascii ( convert_hex_to_ascii (hexhex_message) ) ; 1109 1110 De bug Ut ils . Log ( " So cke t Robot : Received −−> OK" ) ; 1111 1112 return a s c i i ; 1113 1114 1115 } 1116 1117 1118 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 1119 / / Teacher C o n t r o l l e r s o c k e t f u n c t i o n s 1120 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 1121 1122 p r i v a t e bool I s P r i v a t e I p v 4 A d d r e s s ( b y te [ ] a d d r e s s ) 1123 { 1124 v ar o c t e t 1 = a d d r e s s [ 0 ] ; 1125 v ar o c t e t 2 = a d d r e s s [ 1 ] ; 1126 1127 / / 1 0. x . x . x − 1 0 . 2 5 5 . 2 5 5 . 2 5 5 1128 i f ( o c t e t 1 == 10) 1129 return true ; 1130 1131 / / 1 7 2 . 1 6 . x . x − 1 7 2 . 3 1 . 2 5 5 . 2 5 5 1132 i f ( o c t e t 1 == 172 && o c t e t 2 >= 16 && o c t e t 2 <= 31) 1133 return true ; 1134 1135 / / 1 9 2 . 1 6 8 . x . x − 1 9 2 . 1 6 8 . 2 5 5 . 2 5 5 1136 i f ( o c t e t 1 == 192 && o c t e t 2 == 168) 1137 return true ; 1138 1139 return f a l s e ; 1140 } 1141 1142 p r i v a t e s t r i n g g e t I P A d d r e s s ( ) 1143 { 1144 I P Ho st En tr y h o s t ; 1145 s t r i n g l o c a l I P = " " ; This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 1396 } 1397 } 1398 1399 } 1400 GameObject newButton = I n s t a n t i a t e ( bu tt o n , new V ec t or2 ( x , y ) , new Q u a t e r n i o n ( 0 , 0 , 0 , 0 ) ) ; 1401 newButton . GetComponent < Butto n > ( ) . o nC li ck . A d dL i st e ne r ( d e l e g a t e { B u t t o n s C a l l b a c k ( newButton . GetComponentInChildren <TextMeshProUGUI > ( ) . t e x t ) ; }) ; 1402 newButton . t r a n s f o r m . S e t P a r e n t ( can vas . t r an sf or m , f a l s e ) ; 1403 1404 t h i s . b u t t o n s [ i ] = newButton ; 1405 Deb ugU ti ls . Log ( "ACTIVITY : Number shown a t p o s i t i o n " + i . T o S t r i n g ( ) + " −−> " + v a l u e s [ i ] . T o S t r i n g ( ) ) ; 1406 1407 } 1408 1409 } 1410 1411 p r i v a t e void Hid eB ut to ns ( ) { 1412 De bug Ut ils . Log ( "ACTIVITY : Numbers hi dde n " ) ; 1413 for (i n t i = 0 ; i < t h i s . num_values ; i ++) { 1414 t h i s . b u t t o n s [ i ] . S e t A c t i v e ( f a l s e ) ; 1415 1416 } 1417 } 1418 p r i v a t e void ShowButtons () { 1419 for (i n t i = 0 ; i < t h i s . num_values ; i ++) { 1420 t h i s . b u t t o n s [ i ] . S e t A c t i v e ( t r u e ) ; 1421 1422 } 1423 } 1424 1425 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 1426 / / BUTTONS FUNCTIONS 1427 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 1428 p u b l i c void B u t t o n s C a l l b a c k ( s t r i n g number ) { 1429 t h i s . b u t t o n _ c l i c k e d = t r u e ; 1430 t h i s . b u t t o n _ v a l u e = number ; 1431 } 1432 } This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). File 6: Menu.cs 1 u s i n g System . C o l l e c t i o n s ; 2 u s i n g System . C o l l e c t i o n s . Ge ne ri c ; 3 u s i n g U ni t yEng ine ; 4 u s i n g U ni t yEng ine . SceneManagement ; 5 6 p u b l i c c l a s s Menu : MonoBehaviour 7 { 8/ / S t a r t i s c a l l e d b e f o r e t h e f i r s t frame u pda te 9void S t a r t ( ) 10 { 11 12 } 13 14 / / Update i s c a l l e d once per frame 15 void Update ( ) 16 { 17 18 } 19 p u b l i c void I n i c i a r ( ) { 20 SceneManager . LoadScene ( " C o n f i g u r a t i o n " ) ; 21 } 22 23 p u b l i c void S a l i r ( ) { 24 A p p l i c a t i o n . Q uit ( ) ; 25 Debug . Log ( " Qu it " ) ; 26 } 27 } This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). File 7: PlayersConfiguration.cs 1 u s i n g System . C o l l e c t i o n s ; 2 u s i n g System . C o l l e c t i o n s . Ge ne ri c ; 3 u s i n g U ni t yEng ine ; 4 u s i n g U ni t yEng ine . SceneManagement ; 5 u s i n g U ni t yEng ine . UI ; 6 u s i n g TMPro ; 7 8 p u b l i c c l a s s P l a y e r s C o n f i g u r a t i o n : MonoBehaviour 9 { 10 11 / / C o n s t a n t e s para e n v i a r i n f o r m a c i o n 12 p r i v a t e s t r i n g LowValue = " LowValue " ; 13 p r i v a t e s t r i n g HighValue = " HighValue " ; 14 p r i v a t e s t r i n g NumValues = " NumValues " ; 15 p r i v a t e s t r i n g NumPlayers = " NumPlayers " ; 16 p r i v a t e s t r i n g PosValues = " PosValues " ; 17 p r i v a t e s t r i n g OrdValues = " OrdValues " ; 18 p r i v a t e s t r i n g RobotIP = " RobotIP " ; 19 p r i v a t e s t r i n g NamePlayers = " NamePlayers " ; 20 21 / / V a r i a b l e s de l a i n t e r f i c i e 22 p u b l i c GameObject tmp_u2 ; 23 p u b l i c GameObject tmp_u3 ; 24 p u b l i c GameObject i f _u 2 ; 25 p u b l i c GameObject i f _u 3 ; 26 27 p u b l i c TMP_InputField I n p u t F i e l d _ u 1 ; 28 p u b l i c TMP_InputField I n p u t F i e l d _ u 2 ; 29 p u b l i c TMP_InputField I n p u t F i e l d _ u 3 ; 30 31 / / V a r i a b l e s nombre 32 p r i v a t e s t r i n g name1 ; 33 p r i v a t e s t r i n g name2 ; 34 p r i v a t e s t r i n g name3 ; 35 private int num_players ; 36 37 / / S t a r t i s c a l l e d b e f o r e t h e f i r s t frame u pda te 38 void S t a r t ( ) 39 { 40 t h i s . name1 = " " ; 41 t h i s . name2 = " " ; 42 t h i s . name3 = " " ; 43 t h i s . num_players = P l a y e r P r e f s . G et I n t ( NumPlayers ) ; 44 Debug . Log ( t h i s . num_players ) ; 45 46 / / Por d e f e c t o ac t i va m o s t od o s l o s u s u a r i o s 47 tmp_u3 . S e t A c t i v e ( t r u e ) ; This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 48 i f _ u 3 . S e t A c t i v e ( t r u e ) ; 49 tmp_u2 . S e t A c t i v e ( t r u e ) ; 50 i f _ u 2 . S e t A c t i v e ( t r u e ) ; 51 52 / / Y comprovamos c u a n t o s son para i r e l i m i n a n d o nombres 53 i f ( t h i s . num_players <= 2) { 54 tmp_u3 . S e t A c t i v e ( f a l s e ) ; 55 i f _ u 3 . S e t A c t i v e ( f a l s e ) ; 56 i f ( t h i s . num_players == 1) { 57 tmp_u2 . S e t A c t i v e ( f a l s e ) ; 58 i f _ u 2 . S e t A c t i v e ( f a l s e ) ; 59 } 60 } 61 } 62 63 / / Update i s c a l l e d once per frame 64 void Update ( ) 65 { 66 67 } 68 69 p u b l i c void CheckNames () { 70 i f ( t h i s . name1 == " " ) { 71 t h i s . I n p u t F i e l d _ u 1 . image . c o l o r = Col or . r ed ; 72 } 73 else { 74 t h i s . I n p u t F i e l d _ u 1 . image . c o l o r = Col or . w hit e ; 75 } 76 i f ( t h i s . name2 == " " ) { 77 t h i s . I n p u t F i e l d _ u 2 . image . c o l o r = Col or . r ed ; 78 } 79 else { 80 t h i s . I n p u t F i e l d _ u 2 . image . c o l o r = Col or . w hit e ; 81 } 82 i f ( t h i s . name3 == " " ) { 83 t h i s . I n p u t F i e l d _ u 3 . image . c o l o r = Col or . r ed ; 84 } 85 else { 86 t h i s . I n p u t F i e l d _ u 3 . image . c o l o r = Col or . w hit e ; 87 } 88 } 89 90 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 91 / / BUTTONS FUNCTIONS 92 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 93 p u b l i c void Continuar () { 94 t h i s . CheckNames ( ) ; 95 i f ( t h i s . name1 != " " & t h i s . num_players == 1) { 96 P l a y e r P r e f s . S e t S t r i n g ( NamePlayers , name1 ) ; This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 97 SceneManager . LoadScene ( "Game" ) ; 98 } 99 e l s e i f ( t h i s . name1 != " " & t h i s . name2 != " " & t h i s . num_players == 2) { 100 P l a y e r P r e f s . S e t S t r i n g ( NamePlayers , name1+" _"+name2 ) ; 101 SceneManager . LoadScene ( "Game_2" ) ; 102 } 103 e l s e i f ( t h i s . name1 != " " & t h i s . name2 != " " & t h i s . name3 != " " & t h i s . num_players == 3) { 104 P l a y e r P r e f s . S e t S t r i n g ( NamePlayers , name1+" _"+name2+" _ "+name3 ) ; 105 SceneManager . LoadScene ( "Game" ) ; 106 } 107 } 108 109 p u b l i c void A t r a s ( ) { 110 SceneManager . LoadScene ( " F i n a l C o n f i g u r a t i o n " ) ; 111 } 112 113 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 114 / / INPUTFIELD FUNCTIONS 115 / / −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 116 p u b l i c void CallbackName1 ( s t r i n g s ) { 117 t h i s . name1 = s ; 118 } 119 120 p u b l i c void CallbackName2 ( s t r i n g s ) { 121 t h i s . name2 = s ; 122 } 123 124 p u b l i c void CallbackName3 ( s t r i n g s ) { 125 t h i s . name3 = s ; 126 } 127 } This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). File 8: WriteDebugToFile.cs 1 u s i n g System . C o l l e c t i o n s ; 2 u s i n g System . C o l l e c t i o n s . Ge ne ri c ; 3 u s i n g U ni t yEng ine ; 4 u s i n g System . IO ; 5 u s i n g U ni t yEng ine . UI ; 6 u s i n g System ; 7 u s i n g System . Runtime . I n t e r o p S e r v i c e s ; 8 9 p u b l i c c l a s s WriteDebugToFile : MonoBehaviour 10 { 11 12 / / User 1 −−> c h i l d 13 / / User 2 −−> e d u c a t o r 14 / / User 3 −−> o t h e r c h i l d 15 16 private static s t r i n g NamePlayers = " NamePlayers " ; 17 private static s t r i n g folderName = " Div InTe chSes ion1 / L o g F i l e s " ; 18 s t r i n g f i l e n a m e = " " ; 19 s t r i n g [ ] names ; 20 p r i v a t e boo l f l a g _ s t a r t e d = f a l s e ; 21 long dtime = new System . Da teT im eOf fs et ( System . DateTime . UtcNow ) . ToUn ixTime Millis econds ( ) ; 22 23 p u b l i c static s t r i n g G et F o ld e r ( ) 24 { 25 i f ( A p p l i c a t i o n . p l a t f o r m == Runt ime Pla tfor m . Android ) 26 { 27 return A p p l i c a t i o n . p e r s i s t e n t D a t a P a t h ; 28 } 29 else 30 { 31 return En vi ronment . G e t F o l d e r P a t h ( Envir on me nt . S p e c i a l F o l d e r . U s e r P r o f i l e ) ; 32 } 33 } 34 35 void OnEnable () 36 { 37 De bug Ut ils . OnLog += HandleLog ; 38 } 39 40 void OnDisable () 41 { 42 De bug Ut ils . OnLog −= HandleLog ; 43 } 44 This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE). 45 p u b l i c static D i r e c t o r y I n f o S a f e C r e a t e D i r e c t o r y ( s t r i n g pa th ) 46 { 47 / / Gene r ate i f you don ’ t ch eck i f t h e d i r e c t o r y e x i s t s 48 i f ( D i r e c t o r y . E x i s t s ( p at h ) ) 49 { 50 return n u l l ; 51 } 52 return D i r e c t o r y . C r e a t e D i r e c t o r y ( pa th ) ; 53 } 54 55 / / S t a r t i s c a l l e d b e f o r e t h e f i r s t frame u pda te 56 void S t a r t ( ) 57 { 58 s t r i n g c o n c a t _ s t r i n g _ n a m e s = P l a y e r P r e f s . G e t S t r i n g ( NamePlayers) ; 59 t h i s . names = c o n c a t _ s t r i n g _ n a m e s . S p l i t ( char . P a r s e ( " _ " ) ) ; 60 61 s t r i n g f o l d e r P a t h = Path . Combine ( G et F o ld e r ( ) , folderName ) ; 62 / / Debug . Log ( " El f o l d e r P a t h v a l : " + f o l d e r P a t h ) ; 63 S a f e C r e a t e D i r e c t o r y ( f o l d e r P a t h ) ; 64 t h i s . f i le na m e = f o l d e r P a t h + " / Lo gF il e " + " _ " + t h i s . names [ 0 ] + " _ " + dt ime + " . t x t " ; 65 f l a g _ s t a r t e d = t r u e ; 66 } 67 68 private void HandleLog ( s t r i n g message ) 69 { 70 i f ( ! f l a g _ s t a r t e d ) { 71 S t a r t ( ) ; 72 } 73 / / E s c r i b e e l mens aje de l og en e l a r c h i v o de l og 74 u s i n g ( S t re a m W ri t e r w r i t e r = new S t r e am W r i te r ( fi le n am e , t r u e ) ) 75 { 76 long ti me = new System . DateT ime Of fse t ( System . DateTime . UtcNow ) . ToUni xTimeM illisec onds ( ) ; 77 w r i t e r . Wr it eL in e ( " [ " + ti me + " ] " + message ) ; 78 w r i t e r . F lu sh ( ) ; 79 w r i t e r . Cl ose ( ) ; 80 } 81 82 } 83 84 } This research was supported by the Spanish National Program of Projects of Knowledge Generation 2022 with the reference PID2022-140284OB-I00, of the Program to Boost Scientific and Technical Research and its Transfer, from the Spanish National Plan for Scientific, Technical, and Innovation Research 2021-2023, titled “Uses of robotics to improve the instrumental skills of students with autism spectrum disorder through the development of new inclusive contexts. (DivInTech)”. (AEI/FEDER, UE).