home *** CD-ROM | disk | FTP | other *** search
/ Equipe de France et Bonbons / EquipeFrancePromoCD.iso / pages / cs_cadbury / loadergfx.swf / scripts / __Packages / PlayerOrientationHandler.as < prev    next >
Encoding:
Text File  |  2006-03-19  |  5.3 KB  |  203 lines

  1. class PlayerOrientationHandler
  2. {
  3.    var currentAngleDEG;
  4.    var currentOrient;
  5.    var currentFrame;
  6.    var currentFlashAngle;
  7.    var oldAngleDEG;
  8.    var oldOrient;
  9.    var oldFrame;
  10.    var oldFlashAngle;
  11.    var orientAngle;
  12.    function PlayerOrientationHandler()
  13.    {
  14.       this.currentAngleDEG = 0;
  15.       this.currentOrient = "Not Yet Invoked";
  16.       this.currentFrame = -1;
  17.       this.currentFlashAngle = -1;
  18.       this.oldAngleDEG = this.currentAngleDEG;
  19.       this.oldOrient = this.currentOrient;
  20.       this.oldFrame = this.currentFrame;
  21.       this.oldFlashAngle = this.currentFlashAngle;
  22.       this.orientAngle = new Object();
  23.       this.orientAngle.N = -90;
  24.       this.orientAngle.E = 0;
  25.       this.orientAngle.S = 90;
  26.       this.orientAngle.WS = 180;
  27.       this.orientAngle.WN = -180;
  28.    }
  29.    function getPlayerOrientation(angleDEG, type)
  30.    {
  31.       var _loc5_ = 15;
  32.       var _loc2_ = new Object();
  33.       _loc2_.orient = "Error";
  34.       _loc2_.frame = -1;
  35.       _loc2_.flash = -1;
  36.       if(angleDEG >= this.orientAngle.N - _loc5_ && angleDEG <= this.orientAngle.N + _loc5_)
  37.       {
  38.          _loc2_.orient = "N";
  39.          _loc2_.flash = -90;
  40.          if(type == "mobile")
  41.          {
  42.             _loc2_.frame = 33;
  43.          }
  44.          if(type == "static")
  45.          {
  46.             _loc2_.frame = 69;
  47.          }
  48.          if(type == "tacle")
  49.          {
  50.             _loc2_.frame = 97;
  51.          }
  52.       }
  53.       if(angleDEG >= this.orientAngle.E - _loc5_ && angleDEG <= this.orientAngle.E + _loc5_)
  54.       {
  55.          _loc2_.orient = "E";
  56.          _loc2_.flash = 0;
  57.          if(type == "mobile")
  58.          {
  59.             _loc2_.frame = 49;
  60.          }
  61.          if(type == "static")
  62.          {
  63.             _loc2_.frame = 71;
  64.          }
  65.          if(type == "tacle")
  66.          {
  67.             _loc2_.frame = 109;
  68.          }
  69.       }
  70.       if(angleDEG >= this.orientAngle.S - _loc5_ && angleDEG <= this.orientAngle.S + _loc5_)
  71.       {
  72.          _loc2_.orient = "S";
  73.          _loc2_.flash = 90;
  74.          if(type == "mobile")
  75.          {
  76.             _loc2_.frame = 1;
  77.          }
  78.          if(type == "static")
  79.          {
  80.             _loc2_.frame = 65;
  81.          }
  82.          if(type == "tacle")
  83.          {
  84.             _loc2_.frame = 73;
  85.          }
  86.       }
  87.       if(angleDEG >= this.orientAngle.WS - _loc5_ && angleDEG <= this.orientAngle.WS || angleDEG >= this.orientAngle.WN && angleDEG <= this.orientAngle.WN + _loc5_)
  88.       {
  89.          _loc2_.orient = "W";
  90.          _loc2_.flash = 180;
  91.          if(type == "mobile")
  92.          {
  93.             _loc2_.frame = 17;
  94.          }
  95.          if(type == "static")
  96.          {
  97.             _loc2_.frame = 67;
  98.          }
  99.          if(type == "tacle")
  100.          {
  101.             _loc2_.frame = 85;
  102.          }
  103.       }
  104.       if(angleDEG > this.orientAngle.E + _loc5_ && angleDEG < this.orientAngle.S - _loc5_)
  105.       {
  106.          _loc2_.orient = "SE";
  107.          _loc2_.flash = 45;
  108.          if(type == "mobile")
  109.          {
  110.             _loc2_.frame = 57;
  111.          }
  112.          if(type == "static")
  113.          {
  114.             _loc2_.frame = 72;
  115.          }
  116.          if(type == "tacle")
  117.          {
  118.             _loc2_.frame = 115;
  119.          }
  120.       }
  121.       if(angleDEG > this.orientAngle.S + _loc5_ && angleDEG < this.orientAngle.WS - _loc5_)
  122.       {
  123.          _loc2_.orient = "SW";
  124.          _loc2_.flash = 135;
  125.          if(type == "mobile")
  126.          {
  127.             _loc2_.frame = 9;
  128.          }
  129.          if(type == "static")
  130.          {
  131.             _loc2_.frame = 66;
  132.          }
  133.          if(type == "tacle")
  134.          {
  135.             _loc2_.frame = 79;
  136.          }
  137.       }
  138.       if(angleDEG > this.orientAngle.WN + _loc5_ && angleDEG < this.orientAngle.N - _loc5_)
  139.       {
  140.          _loc2_.orient = "NW";
  141.          _loc2_.flash = -135;
  142.          if(type == "mobile")
  143.          {
  144.             _loc2_.frame = 25;
  145.          }
  146.          if(type == "static")
  147.          {
  148.             _loc2_.frame = 68;
  149.          }
  150.          if(type == "tacle")
  151.          {
  152.             _loc2_.frame = 91;
  153.          }
  154.       }
  155.       if(angleDEG < this.orientAngle.E - _loc5_ && angleDEG > this.orientAngle.N + _loc5_)
  156.       {
  157.          _loc2_.orient = "NE";
  158.          _loc2_.flash = -45;
  159.          if(type == "mobile")
  160.          {
  161.             _loc2_.frame = 41;
  162.          }
  163.          if(type == "static")
  164.          {
  165.             _loc2_.frame = 70;
  166.          }
  167.          if(type == "tacle")
  168.          {
  169.             _loc2_.frame = 103;
  170.          }
  171.       }
  172.       this.oldAngleDEG = this.currentAngleDEG;
  173.       this.oldOrient = this.currentOrient;
  174.       this.oldFrame = this.currentFrame;
  175.       this.oldFlashAngle = this.currentFlashAngle;
  176.       this.currentAngleDEG = angleDEG;
  177.       this.currentOrient = _loc2_.orient;
  178.       this.currentFrame = _loc2_.frame;
  179.       this.currentFlashAngle = _loc2_.flash;
  180.       return _loc2_;
  181.    }
  182.    function getOldAngleDEG()
  183.    {
  184.       return this.oldAngleDEG;
  185.    }
  186.    function getOldOrient()
  187.    {
  188.       return this.oldOrient;
  189.    }
  190.    function getOldFrame()
  191.    {
  192.       return this.oldFrame;
  193.    }
  194.    function isFrameChanged()
  195.    {
  196.       return this.oldFrame != this.currentFrame;
  197.    }
  198.    function trace()
  199.    {
  200.       trace("PlayerOrientationHandler(orient,frame,angleDEG) = (" + this.currentOrient + "," + this.currentFrame + "," + this.currentAngleDEG + ")");
  201.    }
  202. }
  203.