Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.60 KB | None | 0 0
  1. //C#
  2.  
  3.  
  4.  
  5. // -----------------------------------------------------------------------------
  6. //                            GLOBAL VARIABLES
  7. // -----------------------------------------------------------------------------
  8.  
  9.  
  10.  
  11. string myMessage = "Hello !";
  12.  
  13.  
  14. // -----------------------------------------------------------------------------
  15. //                      FUNCTIONS / CLASS / STRUCTURES
  16. // -----------------------------------------------------------------------------
  17.  
  18.  
  19. class MyClass
  20. {
  21.    
  22.     // test d'une méthode utilisant des arguments de types integer du LSL
  23.     public LSL_Types.LSLInteger Calc( LSL_Types.LSLInteger x, LSL_Types.LSLInteger y )
  24.     {
  25.         return x + y;
  26.     }
  27.    
  28.     // test d'une méthode static avec le type int comme argument
  29.     public static string Test( int test )
  30.     {
  31.         // switch
  32.         switch( test )
  33.         {
  34.             case 0:
  35.                 return "aucun";
  36.             case 1:
  37.                 return "un seul !";
  38.             case 2:
  39.                 return "seulement deux !";
  40.             case 3:
  41.                 return "trois !";
  42.             default:
  43.                 return "trop grand";    
  44.         }
  45.     }
  46.    
  47.    
  48. }
  49.  
  50.  
  51.  
  52. // structure
  53. public struct OSAvatar
  54. {
  55.     public int Number;
  56.     public string Name;  
  57. }
  58.  
  59.  
  60.  
  61. // méthode de la class default du script
  62. public void MySay( string message )
  63. {
  64.     llSay( 0, "/me (OS-C# Test): " + message );  
  65. }
  66.  
  67.  
  68. // -----------------------------------------------------------------------------
  69. //                                  LSL EVENTS
  70. // -----------------------------------------------------------------------------
  71.  
  72.  
  73.  
  74. public void default_event_state_entry()
  75. {
  76.    
  77.    // on crée 2 integer du LSL  
  78.    LSL_Types.LSLInteger lslint1 = 12;
  79.    LSL_Types.LSLInteger lslint2 = 6;
  80.    
  81.    // instance de la class MyClass
  82.    MyClass ob = new MyClass();
  83.    
  84.    // test de la méthode Calc de la class MyClass
  85.    LSL_Types.LSLInteger result = ob.Calc( lslint1, lslint2 );
  86.    
  87.    // on utilise la fonction llSay du LSL pour afficher le résultat de notre opération
  88.    llSay( 0, "Le resultat de la methode Calc est : " + result.ToString() );
  89.    
  90.    // type int du C#
  91.    int myInt = 2;
  92.    
  93.    // test de la méthode static Test de MyClass
  94.    llSay( 0, "description de notre int : " + MyClass.Test(myInt) );
  95.    
  96.    
  97.    // test d'une structure
  98.    OSAvatar BlackShade = new OSAvatar();
  99.    BlackShade.Number = 6;
  100.    BlackShade.Name = "Time Paradox";
  101.    
  102.    // fonction MySay
  103.    MySay( "nom de l'avatar : " + BlackShade.Name + ". numero : " + BlackShade.Number.ToString() );
  104.    
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement