home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Aventura / climatechaos.swf / scripts / __Packages / Control.as < prev    next >
Encoding:
Text File  |  2008-09-12  |  5.3 KB  |  171 lines

  1. class Control extends Object
  2. {
  3.    var talking;
  4.    var photoing;
  5.    var stopping;
  6.    var environment;
  7.    var old_angle;
  8.    var character;
  9.    var opposites;
  10.    var angle_speeds;
  11.    var L;
  12.    var R;
  13.    var U;
  14.    var D;
  15.    var angle;
  16.    function Control(p_env, p_character)
  17.    {
  18.       super();
  19.       this.talking = false;
  20.       this.photoing = false;
  21.       p_env.setControl(this);
  22.       this.stopping = false;
  23.       this.environment = p_env;
  24.       this.old_angle = 0;
  25.       this.character = p_character;
  26.       this.character.gotoAndStop(5);
  27.       this.opposites = [null,5,null,7,null,1,null,3,null];
  28.       this.angle_speeds = [null,{x:0,y:-11},{x:6,y:-9},{x:8,y:0},{x:6,y:9},{x:0,y:11},{x:-6,y:9},{x:-8,y:0},{x:-6,y:-9}];
  29.    }
  30.    function stopToTalk()
  31.    {
  32.       this.character.body.gotoAndStop(1);
  33.       this.talking = true;
  34.       this.environment.hit_center = _root.convo;
  35.    }
  36.    function stopTalking()
  37.    {
  38.       this.talking = false;
  39.    }
  40.    function stopToPhoto()
  41.    {
  42.       this.character.body.gotoAndStop(1);
  43.       this.photoing = true;
  44.    }
  45.    function stopPhotoing()
  46.    {
  47.       this.photoing = false;
  48.    }
  49.    function use()
  50.    {
  51.       if(!this.talking && !this.photoing)
  52.       {
  53.          _root.splash._visible = false;
  54.          this.L = Key.isDown(37) || Key.isDown(65);
  55.          this.R = Key.isDown(39) || Key.isDown(68);
  56.          this.U = Key.isDown(38) || Key.isDown(87);
  57.          this.D = Key.isDown(40) || Key.isDown(83);
  58.          this.angle = 0;
  59.          var _loc3_ = 0;
  60.          if(!this.L && !this.R && !this.U && this.D)
  61.          {
  62.             this.angle = 1;
  63.          }
  64.          else if(this.L && !this.R && !this.U && this.D)
  65.          {
  66.             this.angle = 2;
  67.          }
  68.          else if(this.L && !this.R && !this.U && !this.D)
  69.          {
  70.             this.angle = 3;
  71.          }
  72.          else if(this.L && !this.R && this.U && !this.D)
  73.          {
  74.             this.angle = 4;
  75.          }
  76.          else if(!this.L && !this.R && this.U && !this.D)
  77.          {
  78.             this.angle = 5;
  79.          }
  80.          else if(!this.L && this.R && this.U && !this.D)
  81.          {
  82.             this.angle = 6;
  83.          }
  84.          else if(!this.L && this.R && !this.U && !this.D)
  85.          {
  86.             this.angle = 7;
  87.          }
  88.          else if(!this.L && this.R && !this.U && this.D)
  89.          {
  90.             this.angle = 8;
  91.          }
  92.          else if(this.L && this.R && !this.U && !this.D)
  93.          {
  94.             _loc3_ = 1;
  95.          }
  96.          else if(!this.L && !this.R && this.U && this.D)
  97.          {
  98.             _loc3_ = 2;
  99.          }
  100.          if(this.angle == 0)
  101.          {
  102.             if(this.old_angle > 0)
  103.             {
  104.                this.character.gotoAndStop(this.old_angle);
  105.                this.character.body.gotoAndStop(5);
  106.                if(!this.stopping)
  107.                {
  108.                   this.stopping = true;
  109.                }
  110.                else
  111.                {
  112.                   this.stopping = false;
  113.                }
  114.                this.environment.moveBy(this.angle_speeds[this.old_angle].x / 2,this.angle_speeds[this.old_angle].y / 2);
  115.             }
  116.             else
  117.             {
  118.                this.stopping = false;
  119.                this.character.body.gotoAndStop(1);
  120.             }
  121.          }
  122.          else if(_loc3_ == 0)
  123.          {
  124.             this.stopping = false;
  125.             if(this.opposites[this.angle] == this.old_angle)
  126.             {
  127.                this.character.gotoAndStop(this.angle + 9);
  128.                this.environment.moveBy(this.angle_speeds[this.old_angle].x / 2,this.angle_speeds[this.old_angle].y / 2);
  129.             }
  130.             else if(this.old_angle == 0)
  131.             {
  132.                this.character.gotoAndStop(this.angle);
  133.                this.character.body.gotoAndPlay(3);
  134.                this.environment.moveBy(this.angle_speeds[this.angle].x / 2,this.angle_speeds[this.angle].y / 2);
  135.             }
  136.             else
  137.             {
  138.                this.character.gotoAndStop(this.angle);
  139.                this.character.body.gotoAndStop(4);
  140.                this.environment.moveBy(this.angle_speeds[this.angle].x,this.angle_speeds[this.angle].y);
  141.             }
  142.          }
  143.          else if(_loc3_ == 1 && this.old_angle == 3)
  144.          {
  145.             this.character.gotoAndStop(16);
  146.             this.environment.moveBy(this.angle_speeds[this.old_angle].x / 2,this.angle_speeds[this.old_angle].y / 2);
  147.          }
  148.          else if(_loc3_ == 1 && this.old_angle == 7)
  149.          {
  150.             this.character.gotoAndStop(12);
  151.             this.environment.moveBy(this.angle_speeds[this.old_angle].x / 2,this.angle_speeds[this.old_angle].y / 2);
  152.          }
  153.          else if(_loc3_ == 2 && this.old_angle == 1)
  154.          {
  155.             this.character.gotoAndStop(14);
  156.             this.environment.moveBy(this.angle_speeds[this.old_angle].x / 2,this.angle_speeds[this.old_angle].y / 2);
  157.          }
  158.          else if(_loc3_ == 2 && this.old_angle == 5)
  159.          {
  160.             this.character.gotoAndStop(10);
  161.             this.environment.moveBy(this.angle_speeds[this.old_angle].x / 2,this.angle_speeds[this.old_angle].y / 2);
  162.          }
  163.          if(!this.stopping)
  164.          {
  165.             this.old_angle = this.angle;
  166.          }
  167.          this.character.swapDepths(this.environment.pos_y);
  168.       }
  169.    }
  170. }
  171.