home *** CD-ROM | disk | FTP | other *** search
/ Level 2000 August / Level_2000-08_cd1.bin / Demos / Vampire / Vampire_Demo.exe / Codex.nob / DoorSwitch.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-22  |  2.5 KB  |  83 lines

  1. public class DoorSwitch extends Codex {
  2.    private float _speed = 10.0F;
  3.    private float _openTime;
  4.    private CodexThing _switchThing;
  5.    private CodexThing door;
  6.    private int doorGuid;
  7.    private boolean bOpen;
  8.    private boolean bActive;
  9.    public static String[] _params = new String[]{"Movement speed;150.0", "Open Time;0", "Switch"};
  10.  
  11.    public DoorSwitch(float speed, float openTime, CodexThing switchThing) {
  12.       this._speed = speed;
  13.       this._openTime = openTime;
  14.       this._switchThing = new CodexThing(((Codex)switchThing).GetGUID());
  15.       ((Codex)this).CaptureThing(this._switchThing.GetGUID());
  16.       this.doorGuid = ((Codex)this).GetClassThing();
  17.       this.door = new CodexThing(this.doorGuid);
  18.       if (this.door.GetDescriptionID().equalsIgnoreCase("PROP")) {
  19.          this.door.SetDescriptionID("GEN_DOOR");
  20.       }
  21.  
  22.       if (this._switchThing.GetDescriptionID().equalsIgnoreCase("PROP")) {
  23.          this._switchThing.SetDescriptionID("GEN_SWITCH");
  24.       }
  25.  
  26.    }
  27.  
  28.    public void clicked(int guid, int clickerGuid, int captureId) {
  29.       if (!this.bActive) {
  30.          if (guid == this.doorGuid) {
  31.             new CodexSound("locked_large_02.WAV", 300.0F, 600.0F, 100, 0, 0, clickerGuid);
  32.             CodexConsole.PrintNLS(clickerGuid, 0, "GEN_OPENELSEWHERE");
  33.          } else {
  34.             this.bActive = true;
  35.             if (!this.bOpen) {
  36.                this.door.MoveToFrame(1, this._speed);
  37.                this.bOpen = true;
  38.             } else {
  39.                this.door.MoveToFrame(0, this._speed);
  40.                this.bOpen = false;
  41.             }
  42.  
  43.          }
  44.       }
  45.    }
  46.  
  47.    public void beginscene(int clientGuid, int captureID) {
  48.       this.door.SetThingFlags(8192);
  49.    }
  50.  
  51.    public void arrived(int thingGuid, int frameNum, int captureId) {
  52.       this.bOpen = frameNum != 0;
  53.       if (this.bOpen) {
  54.          if ((double)this._openTime > (double)0.0F) {
  55.             ((Codex)this).SetTimer(this._openTime);
  56.          } else {
  57.             this.bActive = false;
  58.          }
  59.       }
  60.  
  61.       if (!this.bOpen) {
  62.          this.bActive = false;
  63.       }
  64.  
  65.    }
  66.  
  67.    public void restore(int flags) {
  68.       this.bOpen = CodexSequence.RestoreBoolean();
  69.    }
  70.  
  71.    public void save(int flags) {
  72.       CodexSequence.SaveBoolean(this.bOpen);
  73.    }
  74.  
  75.    public void timer(int timerID, float arg0, float arg1, float arg2, float arg3) {
  76.       if (this.bOpen) {
  77.          this.door.MoveToFrame(0, this._speed);
  78.          this.bOpen = false;
  79.       }
  80.  
  81.    }
  82. }
  83.