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

  1. class HUD extends MovieClip
  2. {
  3.    var possible_items;
  4.    var held_items;
  5.    var descriptions;
  6.    var info;
  7.    var infos;
  8.    var tbar;
  9.    var slot3;
  10.    var onEnterFrame;
  11.    function HUD()
  12.    {
  13.       super();
  14.       AsBroadcaster.initialize(this);
  15.       this.possible_items = ["blank","rain_disk","sun_disk","snow_disk","thunder_disk","special_disk"];
  16.       this.possible_items.push("small_shell","large_shell","bucket_spade","gold_watch","umbrella");
  17.       this.possible_items.push("voucher","map_poster","souvenir_hat","hula_doll","head_dress");
  18.       this.possible_items.push("blank","scale_1","scale_2","scale_3","scale_4","scale_5");
  19.       this.held_items = ["blank","blank","blank","blank"];
  20.       this.descriptions = {};
  21.       this.descriptions.blank = "";
  22.       this.descriptions.rain_disk = "A mysterious stone disk with a rain design";
  23.       this.descriptions.sun_disk = "A mysterious stone disk with a sun design";
  24.       this.descriptions.snow_disk = "A mysterious stone disk with a snow design";
  25.       this.descriptions.thunder_disk = "A mysterious stone disk with a lightning design";
  26.       this.descriptions.special_disk = "A souvenir stone disk with an awesome design";
  27.       this.descriptions.small_shell = "A small sea shell";
  28.       this.descriptions.large_shell = "A regular sea shell";
  29.       this.descriptions.bucket_spade = "A seaside bucket and spade";
  30.       this.descriptions.gold_watch = "A priceless antique gold watch";
  31.       this.descriptions.umbrella = "A pink umbrella";
  32.       this.descriptions.voucher = "A gift shop voucher";
  33.       this.descriptions.map_poster = "A souvenir poster print of an old map";
  34.       this.descriptions.souvenir_hat = "A souvenir tropical cap";
  35.       this.descriptions.hula_doll = "A souvenir dancing hula doll";
  36.       this.descriptions.head_dress = "A tribal head-dress";
  37.       this.descriptions.scale_1 = "An oddly shaped glittering scale";
  38.       this.descriptions.scale_2 = "An oddly shaped glittering scale";
  39.       this.descriptions.scale_3 = "An oddly shaped glittering scale";
  40.       this.descriptions.scale_4 = "An oddly shaped glittering scale";
  41.       this.descriptions.scale_5 = "An oddly shaped glittering scale";
  42.       var _loc3_ = 0;
  43.       while(_loc3_ < 4)
  44.       {
  45.          this.setItem("blank",_loc3_);
  46.          this["slot" + _loc3_].onRelease = function()
  47.          {
  48.             if(this._parent.possible_items[this._currentframe] == "map_poster")
  49.             {
  50.                Story.lookAtMap();
  51.             }
  52.             else
  53.             {
  54.                this._parent.broadcastMessage("useItem",this._parent.possible_items[this._currentframe]);
  55.             }
  56.          };
  57.          this["slot" + _loc3_].onRollOver = function()
  58.          {
  59.             this._parent.setText(this._parent.descriptions[this._parent.possible_items[this._currentframe]]);
  60.          };
  61.          this["slot" + _loc3_].onRollOut = function()
  62.          {
  63.             this._parent.setText("");
  64.          };
  65.          _loc3_ = _loc3_ + 1;
  66.       }
  67.    }
  68.    function returnItems()
  69.    {
  70.       var _loc2_ = [];
  71.       for(var _loc3_ in this.held_items)
  72.       {
  73.          _loc2_[_loc3_] = this.held_items[_loc3_];
  74.       }
  75.       return _loc2_;
  76.    }
  77.    function updateItems(p_items)
  78.    {
  79.       var _loc2_ = 0;
  80.       while(_loc2_ < 4)
  81.       {
  82.          this.setItem(p_items[_loc2_],_loc2_);
  83.          _loc2_ = _loc2_ + 1;
  84.       }
  85.    }
  86.    function setText(p_text)
  87.    {
  88.       this.info.text = p_text;
  89.       this.infos.text = p_text;
  90.       if(p_text == "" || p_text == undefined)
  91.       {
  92.          this.tbar._visible = false;
  93.       }
  94.       else
  95.       {
  96.          this.tbar._visible = true;
  97.       }
  98.    }
  99.    function setPhoto()
  100.    {
  101.       var _loc2_ = "Take photo of " + this.checkPhoto();
  102.       this.setText(_loc2_);
  103.    }
  104.    function checkPhoto()
  105.    {
  106.       if(_root.e == undefined)
  107.       {
  108.          return "the tutorial";
  109.       }
  110.       if(_root.e.hit_center != _root)
  111.       {
  112.          return _root.e.hit_center.photo_name;
  113.       }
  114.       return "the ground";
  115.    }
  116.    function pickupItem(item)
  117.    {
  118.       var _loc2_ = 0;
  119.       while(_loc2_ < 4)
  120.       {
  121.          if(this.held_items[_loc2_] == "blank")
  122.          {
  123.             this.setItem(item,_loc2_);
  124.             return true;
  125.          }
  126.          _loc2_ = _loc2_ + 1;
  127.       }
  128.       this.setText("Inventory Full");
  129.       return false;
  130.    }
  131.    function hasItem(p_item)
  132.    {
  133.       var _loc2_ = 0;
  134.       while(_loc2_ < 4)
  135.       {
  136.          if(this.held_items[_loc2_] == p_item)
  137.          {
  138.             return true;
  139.          }
  140.          _loc2_ = _loc2_ + 1;
  141.       }
  142.       return false;
  143.    }
  144.    function usedItem(item)
  145.    {
  146.       var _loc3_ = -1;
  147.       var _loc2_ = 0;
  148.       while(_loc2_ < 4)
  149.       {
  150.          if(this.held_items[_loc2_] == item)
  151.          {
  152.             _loc3_ = _loc2_;
  153.          }
  154.          _loc2_ = _loc2_ + 1;
  155.       }
  156.       if(_loc3_ == -1)
  157.       {
  158.          return false;
  159.       }
  160.       _loc2_ = _loc3_;
  161.       while(_loc2_ < 3)
  162.       {
  163.          this.setItem(this.held_items[_loc2_ + 1],_loc2_);
  164.          _loc2_ = _loc2_ + 1;
  165.       }
  166.       this.held_items[3] = "blank";
  167.       this.slot3.gotoAndStop("blank");
  168.       return true;
  169.    }
  170.    function setItem(item, position)
  171.    {
  172.       this.held_items[position] = item;
  173.       if(item == "blank")
  174.       {
  175.          this["slot" + position].gotoAndStop("blank");
  176.       }
  177.       else
  178.       {
  179.          this["slot" + position].gotoAndStop(item);
  180.          this["slot" + position]._xscale = this["slot" + position]._yscale = 0;
  181.          this["slot" + position].onEnterFrame = function()
  182.          {
  183.             this._xscale = this._yscale += 30;
  184.             if(this._xscale > 58.1)
  185.             {
  186.                this._xscale = this._yscale = 58.1;
  187.                this.onEnterFrame = function()
  188.                {
  189.                };
  190.             }
  191.          };
  192.       }
  193.    }
  194. }
  195.