static public SharedValue Long(long l) { SharedValue value = new SharedValue(); value.l = l; return(value); }
protected override void OnEnd() { _direction = null; _speed = null; _unit = null; _body = null; }
protected override void OnStart() { _direction = Context.GetValue <SharedValue <FieldCoords> >(ActionConsts.UnitDirection); _speed = Context.GetValue <SharedValue <float> >(ActionConsts.UnitSpeed); _unit = Context.GetValue <GameEntity>(ActionConsts.Unit); _body = _unit.GetComponentInChildren <Rigidbody>(); }
protected override bool Init(object controller, object binding, DefinitionFile definition) { if (!base.Init(controller, binding, definition)) { return(false); } DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiExpandingBorder)); _expanded = DefinitionResolver.GetShared <bool>(Controller, Binding, file["Expanded"], true); _expandWidth = DefinitionResolver.Get <Length>(Controller, Binding, file["ExpandedWidth"], PositionParameters.Width); _expandHeight = DefinitionResolver.Get <Length>(Controller, Binding, file["ExpandedHeight"], PositionParameters.Height); _expandSpeed = DefinitionResolver.Get <int>(Controller, Binding, file["ExpandTime"], 0); _expandedValue = _expanded.Value ? 1 : 0; RegisterDelegate("CollapseFinished", file["CollapseFinished"]); RegisterDelegate("ExpandFinished", file["ExpandFinished"]); RegisterDelegate("ExpandStarted", file["ExpandStarted"]); if (_expandSpeed > 0) { _expandSpeed = 1000 / _expandSpeed; } else { _expandSpeed = 10000; } _expanded.ValueChanged += _expanded_ValueChanged; return(true); }
static public SharedValue Double(double d) { SharedValue value = new SharedValue(); value.d = d; return(value); }
static public SharedValue Boolean(bool b) { SharedValue value = new SharedValue(); value.b = b; return(value); }
static public SharedValue Integer(int i) { SharedValue value = new SharedValue(); value.i = i; return(value); }
protected override bool Init(object controller, object binding, DefinitionFile definition) { if (!base.Init(controller, binding, definition)) { return(false); } DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiImage)); _image = DefinitionResolver.GetShared <Texture2D>(Controller, Binding, file["Image"], null); _stretch = DefinitionResolver.Get <Stretch>(Controller, Binding, file["Stretch"], Stretch.Uniform); _color = DefinitionResolver.GetColorWrapper(Controller, Binding, file["Color"]) ?? new ColorWrapper(); _rotationSpeed = (float)DefinitionResolver.Get <double>(Controller, Binding, file["RotationSpeed"], 0); _scaleByUnit = DefinitionResolver.Get <bool>(Controller, Binding, file["ScaleByUnit"], true); _scale = DefinitionResolver.Get(Controller, Binding, file["Scale"], Scale.One); _image.ValueChanged += _image_ValueChanged; switch (DefinitionResolver.Get <ResampleFilter>(Controller, Binding, file["ResampleFilter"], ResampleFilter.Default)) { case ResampleFilter.Point: _samplerState = SamplerState.PointClamp; break; case ResampleFilter.Linear: _samplerState = SamplerState.LinearClamp; break; case ResampleFilter.Anisotropic: _samplerState = SamplerState.AnisotropicClamp; break; } return(true); }
static public SharedValue Char(char c) { SharedValue value = new SharedValue(); value.c = c; return(value); }
protected override bool Init(object controller, object binding, DefinitionFile definition) { if (!base.Init(controller, binding, definition)) { return(false); } DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiStackPanel)); StackMode = DefinitionResolver.Get(Controller, Binding, file["Mode"], Mode.Vertical); _spacing = DefinitionResolver.Get(Controller, Binding, file["Spacing"], Length.Zero); _padding = DefinitionResolver.Get(Controller, Binding, file["Padding"], Length.Zero); _notifyParentOnResize = DefinitionResolver.Get(Controller, Binding, file["NotifyParentOnResize"], true); _wrap = DefinitionResolver.Get(Controller, Binding, file["Wrap"], false); _horizontalContentAlignment = DefinitionResolver.Get(Controller, Binding, file["HorizontalContentAlignment"], HorizontalContentAlignment.Left); _verticalContentAlignment = DefinitionResolver.Get(Controller, Binding, file["VerticalContentAlignment"], VerticalContentAlignment.Top); _expanded = DefinitionResolver.GetShared(Controller, Binding, file["Expanded"], true); _expandSpeed = DefinitionResolver.Get(Controller, Binding, file["ExpandTime"], 0); _collapseSpeed = DefinitionResolver.Get(Controller, Binding, file["CollapseTime"], (int)_expandSpeed); _expandedValue = _expanded.Value ? 1 : 0; if (_expandSpeed > 0) { _expandSpeed = 1000 / _expandSpeed; } else { _expandSpeed = 10000; } if (_collapseSpeed > 0) { _collapseSpeed = 1000 / _collapseSpeed; } else { _collapseSpeed = 10000; } RegisterDelegate("CollapseFinished", file["CollapseFinished"]); RegisterDelegate("ExpandFinished", file["ExpandFinished"]); RegisterDelegate("ExpandStarted", file["ExpandStarted"]); TryInitChildren(definition); _expanded.ValueChanged += _expanded_ValueChanged; return(true); }
protected override bool Init(object controller, object binding, DefinitionFile definition) { if (!base.Init(controller, binding, definition)) { return(false); } DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiView)); _zoom = DefinitionResolver.GetShared <int>(Controller, Binding, file["Zoom"], 1); return(true); }
protected override bool Init(object controller, object binding, DefinitionFile definition) { if (!base.Init(controller, binding, definition)) { return(false); } DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiEditBoxBase)); Hint = DefinitionResolver.GetSharedString(Controller, Binding, file["Hint"]) ?? new SharedString(); _maxLength = DefinitionResolver.Get(Controller, Binding, file["MaxLength"], int.MaxValue); _inputType = DefinitionResolver.Get(Controller, Binding, file["InputType"], TextInputType.NormalText); _lostFocusCancels = DefinitionResolver.Get(Controller, Binding, file["CancelOnLostFocus"], false); _focusedShared = DefinitionResolver.GetShared(Controller, Binding, file["IsFocused"], false); _focusedShared.Value = false; string filter = DefinitionResolver.GetString(Controller, Binding, file["Filter"]); if (!filter.IsNullOrEmpty()) { _filter = new List <char>(filter.ToCharArray()); } _focusedShared.ValueChanged += (bool focused) => { if (focused) { CurrentlyFocused = this; } else if (CurrentlyFocused == this) { CurrentlyFocused = null; } }; if (_inputType == TextInputType.Password) { _password = new SharedString(); } RegisterDelegate("TextApply", file["TextApply"]); RegisterDelegate("TextChanged", file["TextChanged"]); RegisterDelegate("TextCancel", file["TextCancel"]); RegisterDelegate("LostFocus", file["LostFocus"]); RegisterDelegate("Return", file["Return"]); return(true); }
/// <summary> Retrieves the shared data by name. </summary> /// <typeparam name="T"> Generic type parameter. </typeparam> /// <param name="key"> The name of the shared data to retrieve. </param> /// <param name="sharedValue"> The value to retrieve. </param> public void Retrieve <T>(string key, out SharedValue <T> sharedValue) { SharedValue value; if (_sharedValues.TryGetValue(key, out value)) { sharedValue = (SharedValue <T>)value; } else { sharedValue = new SharedValue <T>(); _sharedValues.Add(key, sharedValue); } }
protected override bool Init(object controller, object binding, DefinitionFile definition) { if (!base.Init(controller, binding, definition)) { return(false); } DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiSlider)); _vertical = DefinitionResolver.Get <Mode>(Controller, Binding, file["Mode"], Mode.Horizontal) == Mode.Vertical; _maxValue = DefinitionResolver.GetShared <int>(Controller, Binding, file["MaxValue"], 100); _minValue = DefinitionResolver.GetShared <int>(Controller, Binding, file["MinValue"], 0); _value = DefinitionResolver.GetShared <int>(Controller, Binding, file["Value"], 0); RegisterDelegate("ValueChanged", file["ValueChanged"]); List <DefinitionFile> drawableFiles = file["ThumbDrawables"] as List <DefinitionFile>; if (drawableFiles != null) { foreach (var def in drawableFiles) { ButtonDrawable drawable = def.CreateInstance(Controller, Binding) as ButtonDrawable; if (drawable != null) { _thumbDrawables.Add(drawable); } } } drawableFiles = file["TrackDrawables"] as List <DefinitionFile>; if (drawableFiles != null) { foreach (var def in drawableFiles) { ButtonDrawable drawable = def.CreateInstance(Controller, Binding) as ButtonDrawable; if (drawable != null) { _trackDrawables.Add(drawable); } } } return(true); }
protected override bool Init(object controller, object binding, DefinitionFile definition) { if (!base.Init(controller, binding, definition)) { return(false); } DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiSeparatorLine)); _image = DefinitionResolver.GetShared <Texture2D>(Controller, Binding, file["Image"], null); _color = DefinitionResolver.GetColorWrapper(Controller, Binding, file["Color"]) ?? new ColorWrapper(); _scaleByUnit = DefinitionResolver.Get <bool>(Controller, Binding, file["ScaleByUnit"], true); _scale = (float)DefinitionResolver.Get <double>(Controller, Binding, file["Scale"], 1); _vertical = DefinitionResolver.Get <Mode>(Controller, Binding, file["Mode"], Mode.Horizontal) == Mode.Vertical; return(true); }
protected override bool Init(object controller, object binding, DefinitionFile definition) { if (!base.Init(controller, binding, definition)) { return(false); } DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiImage)); _image = DefinitionResolver.GetShared <Texture2D>(Controller, Binding, file["Image"], null); _stretch = DefinitionResolver.Get <Stretch>(Controller, Binding, file["Stretch"], Stretch.Uniform); _color = DefinitionResolver.GetColorWrapper(Controller, Binding, file["Color"]) ?? new ColorWrapper(); _rotationSpeed = (float)DefinitionResolver.Get <double>(Controller, Binding, file["RotationSpeed"], 0); _scaleByUnit = DefinitionResolver.Get <bool>(Controller, Binding, file["ScaleByUnit"], true); _scale = (float)DefinitionResolver.Get <double>(Controller, Binding, file["Scale"], 1); return(true); }
public static JsonValue CreateNumberValue(string value) { if (value.Contains(".") || value.Contains("e") || value.Contains("E")) { JsonValue jsonValue = new JsonValue(ValueType.Double, SharedValue.Double(double.Parse(value))); return(jsonValue); } else { long number = long.Parse(value); if (number > int.MaxValue || number < int.MinValue) { JsonValue jsonValue = new JsonValue(ValueType.Long, SharedValue.Long(number)); return(jsonValue); } else { JsonValue jsonValue = new JsonValue(ValueType.Integer, SharedValue.Integer((int)number)); return(jsonValue); } } }
public void SetShared <T>(string id, T value) { object variable; if (_variables.TryGetValue(id, out variable)) { SharedValue <T> shared = variable as SharedValue <T>; if (shared != null) { shared.Value = value; } else { throw new Exception(string.Format("Variable already has type and it is different than SharedValue<{0}>.", typeof(T).Name)); } } else { _variables.Add(id, new SharedValue <T>(value)); } }
internal StatementCompiler(IMetadataImporter metadataImporter, INamer namer, IErrorReporter errorReporter, ICompilation compilation, CSharpAstResolver resolver, IDictionary<IVariable, VariableData> variables, IDictionary<LambdaResolveResult, NestedFunctionData> nestedFunctions, IRuntimeLibrary runtimeLibrary, string thisAlias, ISet<string> usedVariableNames, NestedFunctionContext nestedFunctionContext, IMethod methodBeingCompiled, ITypeDefinition typeBeingCompiled, ExpressionCompiler expressionCompiler, SharedValue<int> nextLabelIndex, IVariable currentVariableForRethrow, IDictionary<object, string> currentGotoCaseMap) { _metadataImporter = metadataImporter; _namer = namer; _errorReporter = errorReporter; _compilation = compilation; _resolver = resolver; _variables = variables; _nestedFunctions = nestedFunctions; _runtimeLibrary = runtimeLibrary; _thisAlias = thisAlias; _usedVariableNames = usedVariableNames; _nestedFunctionContext = nestedFunctionContext; _methodBeingCompiled = methodBeingCompiled; _typeBeingCompiled = typeBeingCompiled; _currentVariableForRethrow = currentVariableForRethrow; _currentGotoCaseMap = currentGotoCaseMap; _nextLabelIndex = nextLabelIndex ?? new SharedValue<int>(1); _expressionCompiler = expressionCompiler ?? new ExpressionCompiler(compilation, metadataImporter, namer, runtimeLibrary, errorReporter, variables, nestedFunctions, v => CreateTemporaryVariable(v, _region), c => new StatementCompiler(_metadataImporter, _namer, _errorReporter, _compilation, _resolver, _variables, _nestedFunctions, _runtimeLibrary, thisAlias, _usedVariableNames, c, _methodBeingCompiled, _typeBeingCompiled), thisAlias, nestedFunctionContext, null, _methodBeingCompiled, _typeBeingCompiled); _result = new List<JsStatement>(); }
protected override bool Init(object controller, object binding, DefinitionFile definition) { if (!base.Init(controller, binding, definition)) { return(false); } DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiStackPanel)); StackMode = DefinitionResolver.Get <Mode>(Controller, Binding, file["Mode"], Mode.Vertical); _spacing = DefinitionResolver.Get <Length>(Controller, Binding, file["Spacing"], Length.Zero); _padding = DefinitionResolver.Get <Length>(Controller, Binding, file["Padding"], Length.Zero); _notifyParentOnResize = DefinitionResolver.Get <bool>(Controller, Binding, file["NotifyParentOnResize"], true); _wrap = DefinitionResolver.Get <bool>(Controller, Binding, file["Wrap"], false); _horizontalContentAlignment = DefinitionResolver.Get <HorizontalContentAlignment>(Controller, Binding, file["HorizontalContentAlignment"], HorizontalContentAlignment.Left); _verticalContentAlignment = DefinitionResolver.Get <VerticalContentAlignment>(Controller, Binding, file["VerticalContentAlignment"], VerticalContentAlignment.Top); _expanded = DefinitionResolver.GetShared <bool>(Controller, Binding, file["Expanded"], true); _expandSpeed = DefinitionResolver.Get <int>(Controller, Binding, file["ExpandTime"], 0); _expandedValue = _expanded.Value ? 1 : 0; if (_expandSpeed > 0) { _expandSpeed = 1000 / _expandSpeed; } else { _expandSpeed = 10000; } InitChildren(Controller, Binding, definition); return(true); }
protected override void OnStart() { _direction = Context.GetValue <SharedValue <FieldCoords> >(ActionConsts.UnitDirection); _input.OnMouseDown += InputOnOnClick; }
public JsonValue(ValueType valueType, SharedValue value) : this(valueType) { sharedValue = value; }
protected override bool Init(object controller, object binding, DefinitionFile definition) { if (!base.Init(controller, binding, definition)) { return(false); } TryInitChildren(definition); DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiContentSlider)); if (file["SelectedIndex"] is MethodName || file["SelectedIndex"] is FieldName) { object value = DefinitionResolver.GetValueFromMethodOrField(Controller, Binding, file["SelectedIndex"]); if (value is SharedValue <int> ) { _sharedSelectedIndex = value as SharedValue <int>; _selectedIndex = _sharedSelectedIndex.Value; } if (value is int) { _selectedIndex = (int)value; } } else { _selectedIndex = DefinitionResolver.Get <int>(Controller, Binding, file["SelectedIndex"], 0); } _cycle = DefinitionResolver.Get <bool>(Controller, Binding, file["Cycle"], false); double speed = DefinitionResolver.Get <double>(Controller, Binding, file["TransitionTime"], 500) / 1000.0; _transitionSpeed = (float)(speed > 0 ? 1 / speed : float.MaxValue); DefinitionFile transitionEffectFile = file["ShowTransitionEffectNext"] as DefinitionFile; if (transitionEffectFile != null) { _transitionEffectShowNext = transitionEffectFile.CreateInstance(Controller, Binding) as TransitionEffect; } transitionEffectFile = file["HideTransitionEffectNext"] as DefinitionFile; if (transitionEffectFile != null) { _transitionEffectHideNext = transitionEffectFile.CreateInstance(Controller, Binding) as TransitionEffect; } transitionEffectFile = file["ShowTransitionEffectPrev"] as DefinitionFile; if (transitionEffectFile != null) { _transitionEffectShowPrev = transitionEffectFile.CreateInstance(Controller, Binding) as TransitionEffect; } transitionEffectFile = file["HideTransitionEffectPrev"] as DefinitionFile; if (transitionEffectFile != null) { _transitionEffectHidePrev = transitionEffectFile.CreateInstance(Controller, Binding) as TransitionEffect; } transitionEffectFile = file["ShowTransitionEffect"] as DefinitionFile; if (transitionEffectFile != null) { if (_transitionEffectShowPrev == null) { _transitionEffectShowPrev = transitionEffectFile.CreateInstance(Controller, Binding) as TransitionEffect; } if (_transitionEffectShowNext == null) { _transitionEffectShowNext = transitionEffectFile.CreateInstance(Controller, Binding) as TransitionEffect; } } transitionEffectFile = file["HideTransitionEffect"] as DefinitionFile; if (transitionEffectFile != null) { if (_transitionEffectHidePrev == null) { _transitionEffectHidePrev = transitionEffectFile.CreateInstance(Controller, Binding) as TransitionEffect; } if (_transitionEffectHideNext == null) { _transitionEffectHideNext = transitionEffectFile.CreateInstance(Controller, Binding) as TransitionEffect; } } if (_transitionEffectHideNext == null) { if (_transitionEffectShowNext != null) { _transitionEffectHideNext = _transitionEffectShowNext.Reverse(); } } if (_transitionEffectHidePrev == null) { if (_transitionEffectShowPrev != null) { _transitionEffectHidePrev = _transitionEffectShowPrev.Reverse(); } } if (_children.Count > 0) { _current = _children[_selectedIndex]; } _previous = null; return(true); }
protected override bool Init(object controller, object binding, DefinitionFile definition) { if (!base.Init(controller, binding, definition)) { return(false); } DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiButton)); Icon = DefinitionResolver.GetShared <Texture2D>(Controller, Binding, file["Icon"], null); if (Icon == null) { Icon = new SharedValue <Texture2D>(); } _gestureMargin = DefinitionResolver.Get <Margin>(Controller, Binding, file["GestureMargin"], Margin.None); _text = DefinitionResolver.GetSharedString(Controller, Binding, file["Text"]); if (_text == null) { _text = new SharedString(); } if (file["Hold"] != null) { RegisterDelegate("Hold", file["Hold"]); _processHold = true; } RegisterDelegate("Release", file["Release"]); RegisterDelegate("Push", file["Push"]); RegisterDelegate("Click", file["Click"]); List <DefinitionFile> drawableFiles = file["Drawables"] as List <DefinitionFile>; if (file["Disabled"] != null && file["Enabled"] == null) { _enabledFlag = DefinitionResolver.GetShared <bool>(Controller, Binding, file["Disabled"], false); _enabledFlagInvert = true; } else { _enabledFlag = DefinitionResolver.GetShared <bool>(Controller, Binding, file["Enabled"], true); _enabledFlagInvert = false; } if (drawableFiles != null) { foreach (var def in drawableFiles) { ButtonDrawable drawable = def.CreateInstance(Controller, Binding) as ButtonDrawable; if (drawable != null) { _drawables.Add(drawable); } } } _pushSound = DefinitionResolver.Get <SoundEffect>(Controller, Binding, file["PushSound"], null); _releaseSound = DefinitionResolver.Get <SoundEffect>(Controller, Binding, file["ReleaseSound"], null); _actionSound = DefinitionResolver.Get <SoundEffect>(Controller, Binding, file["ActionSound"], null); ButtonMode = DefinitionResolver.Get <UiButtonMode>(Controller, Binding, file["Mode"], UiButtonMode.Release); _repeatStart = (float)DefinitionResolver.Get <int>(Controller, Binding, file["RepeatStart"], 0) / 1000f; _repeatInterval = (float)DefinitionResolver.Get <int>(Controller, Binding, file["RepeatInterval"], 0) / 1000f; return(true); }
protected override bool Init(object controller, object binding, DefinitionFile definition) { if(!base.Init(controller, binding, definition)) { return false; } DefinitionFileWithStyle file = new DefinitionFileWithStyle(definition, typeof(UiScrollBar)); _grid = DefinitionResolver.GetShared<AutomataGrid>(Controller, Binding, file["AutomataGrid"], null); _editEnabled = DefinitionResolver.GetShared<bool>(Controller, Binding, file["EditEnabled"], true); _zoom = DefinitionResolver.GetShared<double>(Controller, Binding, file["Zoom"], 16); _colors = DefinitionResolver.Get<Color[]>(Controller, Binding, file["Colors"], null); _gridColor = DefinitionResolver.GetColorWrapper(Controller, Binding, file["GridColor"]); _stateToPaint = DefinitionResolver.GetShared<int>(Controller, Binding, file["StateToPaint"], 0); _calculatedForSize = new Point(_grid.Value.Width, _grid.Value.Height); return true; }
public IntroductionBehavior(SharedValue <string> name, SharedValue <int> age) { Age = age; Name = name; }
public GatherGotoCaseAndDefaultDataVisitor(CSharpAstResolver resolver, SharedValue<int> nextLabelIndex) { _resolver = resolver; _nextLabelIndex = nextLabelIndex; }
protected override void OnEnd() { _input.OnMouseDown -= InputOnOnClick; _direction = null; }