home *** CD-ROM | disk | FTP | other *** search
/ UnrealScript Game Programming All in One / UnrealScriptGameProgrammingAllInOne.iso / UGPAIOListings / UGPAIOListingsCh20 / CH20LIST / Classes / CH20_04LIST.uc < prev    next >
Encoding:
Text File  |  2006-02-27  |  4.6 KB  |  136 lines

  1. // %PARAMETERS = "CH20LIST C:\UT2004"
  2. //Identifies the package
  3. //CH20_04LIST.uc
  4.  
  5. //This class tests CH19LIST.Actor
  6.  
  7. class CH20_04LIST extends Commandlet;
  8. function int Main(string Args)
  9. {
  10.   //#1
  11.   local Element firstElement, secondElement;
  12.   local Actor firstActor, secondActor;
  13.  
  14.   firstElement = new class'Element';
  15.   secondElement = new class'Element';
  16.   firstActor = new class'Actor';
  17.   secondActor = new class'Actor';
  18.  
  19.   Log(Chr(10)$ " Testing the Actor class");
  20.  
  21.   //#2
  22.   firstElement.setElement("None",
  23.                          "Electra",
  24.                          "Am I to make thy rule of honor mine?",
  25.                          100);
  26.   firstElement.setDirection("Still and angry.");
  27.  
  28.   secondElement.setElement("None",
  29.                          "Chrysothemis",
  30.              "When thou art wise, then thou shalt guide us both.",
  31.                          105);
  32.    secondElement.setDirection("Fearful");
  33.  
  34.   //#3
  35.   //Test Actor using Element information
  36.   Log(Chr(10) $  Caps("  Start of Electra"));
  37.  
  38.   firstActor.addInterpretation(firstElement.getDirection(),
  39.               "Looking angrily at Chrysothemis.");
  40.  
  41.   Log("   Actor's interpretation of '"
  42.           $  firstElement.getDirection() $" ': "
  43.           $  Chr(10) $ "     "
  44.           $  firstActor.getInterpretation(firstElement.getDirection()) );
  45.  
  46.   firstActor.setCurrentSpeech( firstElement.getSpeech() );
  47.   firstActor.setName( firstElement.getElementName() );
  48.   firstActor.setAppearance("Dignified");
  49.   firstActor.setPropUse("Nothing in hands. Gestures only.");
  50.  
  51.   //Access data
  52.  
  53.   Log(Chr(10) $
  54.           "   Actor name: "        $ firstActor.getName());
  55.   Log(    "   Actor's interpretation: "
  56.           $ firstActor.getInterpretation(firstElement.getDirection()) );
  57.   Log(    "   Actor's prop use: "  $ firstActor.getPropUse());
  58.   Log(    "   Actor appearance: "  $ firstActor.getAppearance() );
  59.  
  60.   Log(Chr(10) $
  61.           "   Actor's current speech: ");
  62.   firstActor.performCurrentSpeech();
  63.  
  64. //#4
  65.   Log(
  66.   Chr(10) $"-------------------------------------------------------");
  67.  
  68.   //The default is to associate interpretation with version 0
  69.   firstActor.addInterpretation("Stand Still",
  70.                                "Continue to look at Chrysothemis.");
  71.  
  72.   firstActor.addInterpretation("Stand Still, 2",
  73.                                "Look at Chrysothemis and show grief.");
  74.  
  75.   Log("   Actor's interpretation of 'Stand Still': "
  76.           $  Chr(10) $ "     "
  77.           $   firstActor.getInterpretation("Stand Still") );
  78.  
  79.   Log("   Actor's interpretation of 'Stand Still 2': "
  80.           $  Chr(10) $ "     "
  81.           $   firstActor.getInterpretation("Stand Still, 2") );
  82.  
  83.   Log(
  84.   Chr(10) $"-------------------------------------------------------");
  85.  
  86.   //#5
  87.   //Test for invalid data
  88.   Log(Caps("  Invalid Data: "));
  89.   Log("   When no text for the direction is provided:");
  90.   firstActor.addInterpretation("",
  91.                                "Approach Chrysothemis " $
  92.                                "and look at the flowers.");
  93.   Log("");
  94.   Log("   When there is no corresponding direction:");
  95.   Log("   Actor's interpretation of 'Show Terror': "
  96.           $  Chr(10) $ "   "
  97.           $  firstActor.getInterpretation("Show Terror") );
  98.  
  99.  
  100.   Log(
  101.   Chr(10) $"-------------------------------------------------------");
  102.   //#6
  103.   //Test Actor using Element information
  104.    Log(Chr(10) $  Caps("  Start of Chrysothemis"));
  105.  
  106.   secondActor.addInterpretation(secondElement.getDirection(),
  107.                               "Looking meekly at Electra.");
  108.   Log("   Actor's interpretation of '"
  109.           $ secondElement.getDirection() $" ': "
  110.           $ Chr(10) $ "     "
  111.           $ secondActor.getInterpretation(secondElement.getDirection()) );
  112.  
  113.   secondActor.setCurrentSpeech( secondElement.getSpeech() );
  114.   secondActor.setName( secondElement.getElementName() );
  115.   secondActor.setAppearance("Reserved");
  116.   secondActor.setPropUse("Carries flowers.");
  117.  
  118.   Log(Chr(10) $
  119.       "   Actor name: "        $ secondActor.getName());
  120.   Log("   Actor's interpretation: "
  121.           $ secondActor.getInterpretation(secondElement.getDirection()) );
  122.   Log("   Actor's prop use: "  $ secondActor.getPropUse());
  123.   Log("   Actor appearance: "  $ secondActor.getAppearance() );
  124.  
  125.   Log(Chr(10) $ "   Actor's current speech: ");
  126.   secondActor.performCurrentSpeech();
  127.  
  128.   secondActor.addInterpretation("Show Relief",
  129.                                 "Approach Electra and hold up the flowers.");
  130.   Log("   Actor's interpretation of 'Show Relief': "
  131.           $  Chr(10) $ "     " 
  132.           $  secondActor.getInterpretation("Show Relief") );
  133.  
  134.   return 0;
  135. }
  136.