home *** CD-ROM | disk | FTP | other *** search
- import vrml.Event;
- import vrml.field.ConstSFBool;
- import vrml.field.ConstSFString;
- import vrml.field.ConstSFTime;
- import vrml.field.SFBool;
- import vrml.field.SFNode;
- import vrml.field.SFRotation;
- import vrml.field.SFTime;
- import vrml.field.SFVec3f;
- import vrml.node.Script;
- import vs.Vscp;
-
- public class cannon extends Script {
- static int EVENT_VOID;
- static int EVENT_BOOL = 1;
- static int EVENT_TIME = 2;
- // $FF: renamed from: X int
- static int field_0;
- // $FF: renamed from: Y int
- static int field_1 = 1;
- // $FF: renamed from: Z int
- static int field_2 = 2;
- static int DEGREE = 3;
- float Radian = (180F / (float)Math.PI);
- SFNode CannonNode;
- SFBool CannonSwitch;
- SFVec3f RocketmanPosition;
- SFRotation RocketmanRotation;
- SFTime CannonTrueSound_stop;
- SFTime CannonTrueSound_start;
- SFTime CannonFalseSound_stop;
- SFTime CannonFalseSound_start;
- SFTime CannonStartSound_stop;
- SFTime CannonStartSound_start;
- int CannonSwitchFlg;
- int CannonMoveCnt = -1;
- float BulletAng;
- float BulletOrgY;
- float BulletOrgZ = -80.0F;
- float BulletAccel;
- float BulletY;
- float BulletZ;
-
- public void initialize() {
- this.CannonNode = (SFNode)((Script)this).getField("CannonNode");
- this.CannonSwitch = (SFBool)((Script)this).getEventOut("CannonTimer_enabled");
- this.RocketmanPosition = (SFVec3f)((Script)this).getEventOut("CannonRocketman_position");
- this.RocketmanRotation = (SFRotation)((Script)this).getEventOut("CannonRocketman_rotation");
- this.CannonTrueSound_stop = (SFTime)((Script)this).getEventOut("CannonTrueSound_stop");
- this.CannonTrueSound_start = (SFTime)((Script)this).getEventOut("CannonTrueSound_start");
- this.CannonFalseSound_stop = (SFTime)((Script)this).getEventOut("CannonFalseSound_stop");
- this.CannonFalseSound_start = (SFTime)((Script)this).getEventOut("CannonFalseSound_start");
- this.CannonStartSound_stop = (SFTime)((Script)this).getEventOut("CannonStartSound_stop");
- this.CannonStartSound_start = (SFTime)((Script)this).getEventOut("CannonStartSound_start");
- }
-
- public void processEvent(Event var1) {
- String var2 = var1.getName();
- double var3 = var1.getTimeStamp();
- if (var2.equals("CannonSw1Click")) {
- this.CannonSw1Click((ConstSFBool)var1.getValue(), var3);
- } else if (var2.equals("CannonSw2Click")) {
- this.CannonSw2Click((ConstSFBool)var1.getValue(), var3);
- } else if (var2.equals("CannonSw3Click")) {
- this.CannonSw3Click((ConstSFBool)var1.getValue(), var3);
- } else if (var2.equals("CannonMove")) {
- this.CannonMove((ConstSFTime)var1.getValue(), var3);
- } else {
- if (var2.equals("CannonStartShare")) {
- this.CannonStartShare((ConstSFString)var1.getValue(), var3);
- }
-
- }
- }
-
- void cannon_init() {
- float[] var1 = new float[3];
- var1[field_0] = 0.0F;
- var1[field_1] = this.BulletOrgY;
- var1[field_2] = this.BulletOrgZ;
- this.RocketmanPosition.setValue(var1);
- }
-
- public void soundSwitch(double var1, boolean var3, boolean var4) {
- double var7 = var1 + (double)5.0F;
- if (var3) {
- if (var4) {
- this.CannonTrueSound_start.setValue(var1);
- this.CannonTrueSound_stop.setValue(var7);
- } else {
- this.CannonFalseSound_start.setValue(var1);
- this.CannonFalseSound_stop.setValue(var7);
- }
- } else if (var4) {
- this.CannonTrueSound_stop.setValue(var1);
- } else {
- this.CannonFalseSound_stop.setValue(var1);
- }
- }
-
- public void CannonSw1Click(ConstSFBool var1, double var2) {
- this.CannonSwitchChk(var1, var2, 1);
- }
-
- public void CannonSw2Click(ConstSFBool var1, double var2) {
- this.CannonSwitchChk(var1, var2, 2);
- }
-
- public void CannonSw3Click(ConstSFBool var1, double var2) {
- this.CannonSwitchChk(var1, var2, 3);
- }
-
- public void CannonSwitchChk(ConstSFBool var1, double var2, int var4) {
- if (!var1.getValue()) {
- if (this.CannonSwitchFlg < 4) {
- if (var4 != this.CannonSwitchFlg) {
- int var5 = var4 - this.CannonSwitchFlg;
- if (var5 == 1) {
- ++this.CannonSwitchFlg;
- this.soundSwitch(var2, true, true);
- if (this.CannonSwitchFlg == 3) {
- this.CannonStart(var2);
- Vscp.sendApplSpecificMsgWithDist(this.CannonNode, "CannonStartShare", "dummy", 4);
- return;
- }
- } else {
- this.CannonSwitchFlg = 0;
- this.soundSwitch(var2, true, false);
- }
-
- }
- }
- }
- }
-
- public void CannonStartShare(ConstSFString var1, double var2) {
- this.CannonStart(var2);
- }
-
- public void CannonStart(double var1) {
- this.CannonSwitchFlg = 4;
- this.CannonStartSound_start.setValue(var1);
- double var3 = var1 + (double)10.0F;
- this.CannonStartSound_stop.setValue(var3);
- this.CannonMoveCnt = 0;
- this.BulletAng = 45.0F;
- this.BulletY = this.BulletOrgY;
- this.BulletZ = this.BulletOrgZ;
- this.BulletAccel = 5.0F;
- this.CannonSwitch.setValue(true);
- }
-
- public void CannonMove(ConstSFTime var1, double var2) {
- float[] var4 = new float[3];
- float[] var5 = new float[4];
- float var6 = 3.0F;
- float var8 = 5.0F;
- float var7 = var8 / 15.0F;
- if (this.CannonMoveCnt < 0) {
- this.CannonSwitch.setValue(false);
- this.cannon_init();
- } else if (this.CannonMoveCnt < 30) {
- var5[field_0] = 1.0F;
- var5[field_1] = 0.0F;
- var5[field_2] = 0.0F;
- var5[DEGREE] = this.BulletAng / this.Radian;
- this.RocketmanRotation.setValue(var5);
- this.BulletAng += var6;
- var4[field_0] = 0.0F;
- var4[field_1] = this.BulletY;
- var4[field_2] = this.BulletZ + 10.0F;
- this.RocketmanPosition.setValue(var4);
- this.BulletZ += var8;
- this.BulletY += this.BulletAccel;
- this.BulletAccel -= var7;
- } else if (this.CannonMoveCnt == 30) {
- var5[field_0] = 1.0F;
- var5[field_1] = 1.0F;
- var5[field_2] = 1.0F;
- var5[DEGREE] = 0.0F;
- this.RocketmanRotation.setValue(var5);
- this.BulletY = this.BulletOrgY;
- } else if (this.CannonMoveCnt < 60) {
- var4[field_0] = 0.0F;
- var4[field_1] = this.BulletY;
- var4[field_2] = this.BulletZ;
- this.RocketmanPosition.setValue(var4);
- this.BulletZ -= var8;
- } else if (this.CannonMoveCnt == 60) {
- this.BulletZ = this.BulletOrgZ;
- var4[field_0] = 0.0F;
- var4[field_1] = this.BulletY;
- var4[field_2] = this.BulletZ;
- this.RocketmanPosition.setValue(var4);
- this.CannonSwitchFlg = 0;
- this.CannonSwitch.setValue(false);
- }
-
- ++this.CannonMoveCnt;
- }
- }
-