示例#1
0
        private double ConstructTimeValue(JsValue[] arguments, bool useUtc)
        {
            if (arguments.Length < 2)
            {
                throw new ArgumentOutOfRangeException("arguments", "There must be at least two arguments.");
            }

            var y     = TypeConverter.ToNumber(arguments[0]);
            var m     = (int)TypeConverter.ToInteger(arguments[1]);
            var dt    = arguments.Length > 2 ? (int)TypeConverter.ToInteger(arguments[2]) : 1;
            var h     = arguments.Length > 3 ? (int)TypeConverter.ToInteger(arguments[3]) : 0;
            var min   = arguments.Length > 4 ? (int)TypeConverter.ToInteger(arguments[4]) : 0;
            var s     = arguments.Length > 5 ? (int)TypeConverter.ToInteger(arguments[5]) : 0;
            var milli = arguments.Length > 6 ? (int)TypeConverter.ToInteger(arguments[6]) : 0;

            for (int i = 2; i < arguments.Length; i++)
            {
                if (double.IsNaN(TypeConverter.ToNumber(arguments[i])))
                {
                    return(double.NaN);
                }
            }

            if ((!double.IsNaN(y)) && (0 <= TypeConverter.ToInteger(y)) && (TypeConverter.ToInteger(y) <= 99))
            {
                y += 1900;
            }

            var finalDate = DatePrototype.MakeDate(DatePrototype.MakeDay(y, m, dt),
                                                   DatePrototype.MakeTime(h, min, s, milli));

            return(useUtc ? finalDate : PrototypeObject.Utc(finalDate));
        }
示例#2
0
        public override void Load(PrototypeObject data)
        {
            if (data == null)
            {
                return;
            }

            WeaponData weapon = data as WeaponData;

            weaponUI = ResourceUtils.AddAndGetComponent <WeaponUI>(GlobalDefinitions.RESOURCE_PATH_WEAPON + weapon.resourceID);
            weaponUI.transform.SetParent(owner.componentsHolder.transform);
            weaponUI.transform.localPosition = new Vector2(weapon.offsetX, weapon.offsetY);
            weaponUI.transform.localScale    = Vector2.one;
            weaponUI.Initialize(weapon);
        }
示例#3
0
        /// <summary>
        /// http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.3
        /// </summary>
        public ObjectInstance Construct(JsValue[] arguments, JsValue newTarget)
        {
            if (arguments.Length == 0)
            {
                return(Construct(DateTime.UtcNow));
            }
            else if (arguments.Length == 1)
            {
                if (arguments[0] is DateInstance date)
                {
                    return(Construct(date.PrimitiveValue));
                }

                var v = TypeConverter.ToPrimitive(arguments[0]);
                if (v.IsString())
                {
                    return(Construct(((JsNumber)Parse(Undefined, Arguments.From(v)))._value));
                }

                return(Construct(TimeClip(TypeConverter.ToNumber(v))));
            }
            else
            {
                var y     = TypeConverter.ToNumber(arguments.At(0));
                var m     = TypeConverter.ToNumber(arguments.At(1));
                var dt    = TypeConverter.ToNumber(arguments.At(2, JsNumber.One));
                var h     = TypeConverter.ToNumber(arguments.At(3, JsNumber.PositiveZero));
                var min   = TypeConverter.ToNumber(arguments.At(4, JsNumber.PositiveZero));
                var s     = TypeConverter.ToNumber(arguments.At(5, JsNumber.PositiveZero));
                var milli = TypeConverter.ToNumber(arguments.At(6, JsNumber.PositiveZero));

                var yInteger = TypeConverter.ToInteger(y);
                if (!double.IsNaN(y) && 0 <= yInteger && yInteger <= 99)
                {
                    y += 1900;
                }

                var finalDate = DatePrototype.MakeDate(
                    DatePrototype.MakeDay(y, m, dt),
                    DatePrototype.MakeTime(h, min, s, milli));

                return(Construct(TimeClip(PrototypeObject.Utc(finalDate))));
            }
        }
 public abstract void Load(PrototypeObject data);
示例#5
0
 public override JsValue Call(JsValue thisObject, JsValue[] arguments)
 {
     return(PrototypeObject.ToString(Construct(Arguments.Empty), Arguments.Empty));
 }
 public override void Load(PrototypeObject data)
 {
     this.skillData = data as SkillData;
 }