home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / alex_trax.swf / scripts / __Packages / com / neodelight / game / PlayerProp.as < prev    next >
Encoding:
Text File  |  2007-10-01  |  1.2 KB  |  57 lines

  1. class com.neodelight.game.PlayerProp
  2. {
  3.    var def;
  4.    var pValue;
  5.    var pMin;
  6.    var pMax;
  7.    function PlayerProp(min, max, def, act)
  8.    {
  9.       if(min == undefined)
  10.       {
  11.          min = 4.9e-324;
  12.       }
  13.       if(max == undefined)
  14.       {
  15.          max = 1.7976931348623157e+308;
  16.       }
  17.       this.min = min;
  18.       this.max = max;
  19.       this.def = com.neodelight.std.XMath.toNumber(def);
  20.       this.value = act != undefined ? act : def;
  21.    }
  22.    function set value(value)
  23.    {
  24.       this.pValue = Math.max(this.min,Math.min(this.max,value));
  25.    }
  26.    function get value()
  27.    {
  28.       return this.pValue;
  29.    }
  30.    function set min(min)
  31.    {
  32.       this.pMin = min;
  33.       this.pValue = Math.max(this.min,Math.min(this.max,this.pValue));
  34.    }
  35.    function get min()
  36.    {
  37.       return this.pMin;
  38.    }
  39.    function set max(max)
  40.    {
  41.       this.pMax = max;
  42.       this.pValue = Math.max(this.min,Math.min(this.max,this.pValue));
  43.    }
  44.    function get max()
  45.    {
  46.       return this.pMax;
  47.    }
  48.    function reset()
  49.    {
  50.       this.value = this.def;
  51.    }
  52.    function toString()
  53.    {
  54.       return "[PlayerProp {value:" + this.value + ", def:" + this.def + " min:" + this.min + ", max:" + this.max + "}]";
  55.    }
  56. }
  57.