home *** CD-ROM | disk | FTP | other *** search
- // %PARAMETERS = "CH20LIST C:\UT2004"
- //Identifies the package
- //Actor.uc
-
- //Class preconditions:
- //This class depends on the Element class.
- //The test driver for this class is CH20_04LIST
-
- class Actor extends Commandlet;
-
- //#1 Class attributes
- struct sInterpretation{
- var string szDirection;
- var string szActorReading;
- var int iActorVersion;
- };
-
- var private int iLen;
- var private string szName;
- var private Vector vPosition;
- var private string szCurrentSpeech;
- var private string szInterpretation;
- var private string szAppearance;
- var private string szPropUse;
- var private Array<sInterpretation> rgInterpretations;
-
- //#2
- //-------------------setCurrentSpeech----------------------
- //Unchanged from Element or script
- public function setCurrentSpeech(string speechFromEle){
- szCurrentSpeech = speechFromEle;
- }
-
- //#3
- //---------------performCurrentSpeech-----------------------
- public function performCurrentSpeech(){
- Log(" " $ Caps(szName) $ ": " );
- Log(" [" $ szInterpretation $ "] ");
- Log(" [" $ szPropUse $ "] ");
- Log(" " $ szCurrentSpeech );
- }
-
- //#4
- //--------------------getName------------------------------
- //Name of character
- public function string getName(){
- return szName;
- }
-
- //------------------setName--------------------------------
- //Name of character
- public function setName(string nameOfActor){
- szName = nameOfActor;
- }
-
- //#5
- //-------------------moveTo--------------------------------
- //Move character to vector coordinates
- public function moveTo(Vector posOfActor){
- vPosition = posOfActor;
- }
-
- //#6
- //---------------setPropUse------------------------------
- //Add instructions on how to use a prop, if it is
- //something in hand
- public function setPropUse(string actorUseOf){
- szPropUse = actorUseOf;
- }
-
- //---------------getPropUse------------------------------
- public function string getPropUse(){
- return szPropUse;
- }
-
- //#7
- //-------------------setAppearance------------------------
- //Describe character's appearance
- public function setAppearance(string appOfActor){
- szAppearance = appOfActor;
- }
-
- //-------------------getAppearance------------------------
- //Character's appearance
- public function string getAppearance(){
- return szAppearance;
- }
-
- //#8
- //------------------addInterpretation-----------------------
- //Given a direction from the Element (or director)
- //create a corresponding interpretation for character (Actor)
- //can use when delivering a speech
- public function addInterpretation(string dirFromEle,
- string interByActor,
- optional int actVer ){
- local sInterpretation locInterp;
-
- locInterp.szDirection = dirFromEle;
- locInterp.szActorReading = interByActor;
-
- if(actVer <= 0){
- actVer = 0;
- }
- locInterp.iActorVersion = actVer;
-
- //Test for the validity of data
- if(Len(dirFromEle) != 0){
- //insert at end of array
- iLen = rgInterpretations.Length;
- rgInterpretations.Insert(iLen, 1);
-
- //insert the new direction-interpretation element
- iLen = rgInterpretations.Length;
- rgInterpretations[iLen] = locInterp;
-
- }else{
- Log(" Must provide text for direction.");
- }
- }
-
- //#9
- //---------------------getInterpretation--------------------
- //Given a direction from the Element (or director)
- //get the Actor's interpretation of it, if it exists
- //Otherwise, use the direction from the Element
- //Precondition: You must first set the interpretation
-
- public function string getInterpretation(string dirFromEle,
- optional int actVer){
- local int iCtr;
- local bool fFlag;
- fFlag = false;
- iLen = rgInterpretations.Length;
- iCtr = 0;
- if(actVer <= 0){
- actVer = 0;
- }
-
- while(iCtr < iLen){
- if(dirFromEle == rgInterpretations[iCtr].szDirection &&
- actVer == rgInterpretations[iCtr].iActorVersion ){
- fFlag = true;
- //Assign the corresponding interpretation by the
- //character to the current interpretation
- szInterpretation = rgInterpretations[iCtr].szActorReading;
- break;
- }//end if
- iCtr++;
- }//end while
-
- //If no instance of the translation has been found
- //Then use the director's instructions
- if(fFlag == false){
- szInterpretation = " Actor has no interpretation of " $ dirFromEle;
- }
- return szInterpretation;
- }
-
-