public override void Init(IEntity entity) { base.Init(entity); _entity = entity; entity.Bind <ITextComponent>(c => { _textComponent = c; c.PropertyChanged += onTextPropertyChanged; }, c => { _textComponent = null; c.PropertyChanged -= onTextPropertyChanged; }); entity.Bind <IImageComponent>(c => _imageComponent = c, _ => _imageComponent = null); entity.Bind <IUIEvents>(c => { _uiEvents = c; c.MouseDown.Subscribe(onMouseDown); c.LostFocus.Subscribe(onMouseDownOutside); }, c => { _uiEvents = null; c.MouseDown.Unsubscribe(onMouseDown); c.LostFocus.Unsubscribe(onMouseDownOutside); }); entity.Bind <IInObjectTreeComponent>(c => _tree = c, _ => _tree = null); entity.Bind <IHasRoomComponent>(c => _room = c, _ => _room = null); entity.Bind <IVisibleComponent>(c => _visibleComponent = c, _ => _visibleComponent = null); _game.Events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute); _caretFlashCounter = (int)CaretFlashDelay; _withCaret = _game.Factory.UI.GetLabel(entity.ID + " Caret", "|", 1f, 1f, 0f, 0f, config: new AGSTextConfig(autoFit: AutoFit.LabelShouldFitText)); _withCaret.Pivot = new PointF(0f, 0f); _withCaret.TextBackgroundVisible = false; entity.Bind <IAnimationComponent>(c => { c.PropertyChanged += onAnimationPropertyChanged; _animationComponent = c; updateBorder(); }, c => { c.PropertyChanged -= onAnimationPropertyChanged; _animationComponent = null; updateBorder(); }); entity.Bind <IDrawableInfoComponent>(c => { _drawableComponent = c; c.PropertyChanged += onDrawableChanged; onRenderLayerChanged(); }, c => { c.PropertyChanged -= onDrawableChanged; _drawableComponent = null; }); }
public override void AfterInit() { _entity.Bind <IAnimationComponent>( c => { _animationComponent = c; _animationComponent.PropertyChanged += onAnimationChanged; onSomethingChanged(); }, c => { _animationComponent = null; _animationComponent.PropertyChanged -= onAnimationChanged; onSomethingChanged(); }); _entity.Bind <IHasRoomComponent>( c => { _room = c; refreshAreaScaling(); subscribeRoom(); onSomethingChanged(); }, c => { unsubscribeRoom(c); _room = null; refreshAreaScaling(); onSomethingChanged(); }); _entity.Bind <IScaleComponent>( c => { _scale = c; c.PropertyChanged += onScaleChanged; onSomethingChanged(); }, c => { c.PropertyChanged -= onScaleChanged; _scale = null; onSomethingChanged(); }); _entity.Bind <ITranslateComponent>( c => { _translate = c; c.PropertyChanged += onTranslateChanged; onSomethingChanged(); }, c => { c.PropertyChanged -= onTranslateChanged; _translate = null; onSomethingChanged(); } ); _entity.Bind <IJumpOffsetComponent>( c => { _jump = c; c.PropertyChanged += onJumpOffsetChanged; onSomethingChanged(); }, c => { c.PropertyChanged -= onJumpOffsetChanged; _jump = null; onSomethingChanged(); } ); _entity.Bind <IRotateComponent>( c => { _rotate = c; c.PropertyChanged += onRotateChanged; onSomethingChanged(); }, c => { c.PropertyChanged -= onRotateChanged; _rotate = null; onSomethingChanged(); } ); _entity.Bind <IImageComponent>( c => { _image = c; subscribeLabelRenderer(); c.PropertyChanged += onImageChanged; onSomethingChanged(); }, c => { c.PropertyChanged -= onImageChanged; _image = null; onSomethingChanged(); } ); _entity.Bind <IDrawableInfoComponent>( c => { _drawable = c; c.PropertyChanged += onDrawableChanged; onSomethingChanged(); }, c => { c.PropertyChanged -= onDrawableChanged; _drawable = null; onSomethingChanged(); }); _entity.Bind <IInObjectTreeComponent>( c => { _tree = c; _parent = _tree.TreeNode.Parent; _tree.TreeNode.OnParentChanged.Subscribe(onParentChanged); _parent?.OnMatrixChanged.Subscribe(onSomethingChanged); onSomethingChanged(); }, c => { c.TreeNode.OnParentChanged.Unsubscribe(onParentChanged); c.TreeNode.Parent?.OnMatrixChanged.Unsubscribe(onSomethingChanged); _tree = null; _parent = null; onSomethingChanged(); }); }
private ButtonAnimation getAnimation(IAnimationComponent container, ButtonAnimation animation) { if (animation.Border == null || container == null || container.Border == null) return animation; ButtonAnimation newAnimation = new ButtonAnimation(AGSBorders.Multiple(container.Border, animation.Border), animation.TextConfig, animation.Tint); newAnimation.Animation = animation.Animation; return newAnimation; }
public ICharacter GetCharacter(string id, IOutfit outfit, IAnimationComponent container) { TypedParameter outfitParam = new TypedParameter(typeof(IOutfit), outfit); TypedParameter idParam = new TypedParameter(typeof(string), id); TypedParameter animationParam = new TypedParameter(typeof(IAnimationComponent), container); ICharacter character = _resolver.Container.Resolve <ICharacter>(outfitParam, idParam, animationParam); return(character); }
public override void Init(IEntity entity) { base.Init(entity); _entity = entity; entity.Bind <IDrawableInfoComponent>(c => _drawableInfo = c, _ => _drawableInfo = null); entity.Bind <IAnimationComponent>(c => _obj = c, _ => _obj = null); entity.Bind <IScaleComponent>(c => _scale = c, _ => _scale = null); entity.Bind <IPixelPerfectComponent>(c => _pixelPerfect = c, _ => _pixelPerfect = null); entity.Bind <IBoundingBoxComponent>(c => _boundingBox = c, _ => _boundingBox = null); }
public AnimationSubscriber(IEntity obj, Action onSomethingChanged) { _animationComponentBinding = obj.Bind <IAnimationComponent>(c => _animationComponent = c, _ => _animationComponent = null); _obj = obj; _onSomethingChanged = onSomethingChanged; _lastAnimation = null; _lastSprite = null; _lastX = float.MinValue; _lastZ = float.MinValue; }
public override void Init() { base.Init(); Entity.Bind <IAnimationComponent>(c => _animation = c, _ => _animation = null); Entity.Bind <ITranslateComponent>(c => _translate = c, _ => _translate = null); Entity.Bind <IOutfitComponent>(c => _outfit = c, _ => _outfit = null); Entity.Bind <IHasRoomComponent>(c => _room = c, _ => _room = null); Entity.Bind <IDrawableInfoComponent>(c => _drawable = c, _ => _drawable = null); Entity.Bind <IFaceDirectionComponent>(c => _faceDirection = c, _ => _faceDirection = null); }
public override void Init(IEntity entity) { base.Init(entity); entity.Bind <IAnimationComponent>(c => { IAnimationComponent animation = entity.GetComponent <IAnimationComponent>(); TypedParameter animationParam = new TypedParameter(typeof(IAnimationComponent), animation); _pixelPerfect = _resolver.Container.Resolve <IPixelPerfectCollidable>(animationParam); }, c => { c.Dispose(); _pixelPerfect = null; }); }
private async Task <AnimationCompletedEventArgs> animateWithTimeout(IAnimationComponent container, Task <AnimationCompletedEventArgs> task) { Task <AnimationCompletedEventArgs> timeoutTask = Task.Run(async() => { await Task.Delay(10000); return((AnimationCompletedEventArgs)null); }); Task <AnimationCompletedEventArgs> result = await Task.WhenAny(task, timeoutTask); Assert.AreEqual(task, result, "Animation timeout for " + container.GetType().Name); return(result.Result); }
public AGSCharacter(string id, Resolver resolver, IOutfit outfit) : base(id, resolver) { _hasRoomComponent = AddComponent <IHasRoomComponent>(); Bind <IHasRoomComponent>(c => _hasRoomComponent = c, _ => {}); _animationComponent = AddComponent <IAnimationComponent>(); Bind <IAnimationComponent>(c => _animationComponent = c, _ => {}); _inObjectTreeComponent = AddComponent <IInObjectTreeComponent>(); Bind <IInObjectTreeComponent>(c => _inObjectTreeComponent = c, _ => {}); _colliderComponent = AddComponent <IColliderComponent>(); Bind <IColliderComponent>(c => _colliderComponent = c, _ => {}); _visibleComponent = AddComponent <IVisibleComponent>(); Bind <IVisibleComponent>(c => _visibleComponent = c, _ => {}); _enabledComponent = AddComponent <IEnabledComponent>(); Bind <IEnabledComponent>(c => _enabledComponent = c, _ => {}); _customPropertiesComponent = AddComponent <ICustomPropertiesComponent>(); Bind <ICustomPropertiesComponent>(c => _customPropertiesComponent = c, _ => {}); _drawableInfoComponent = AddComponent <IDrawableInfoComponent>(); Bind <IDrawableInfoComponent>(c => _drawableInfoComponent = c, _ => {}); _shaderComponent = AddComponent <IShaderComponent>(); Bind <IShaderComponent>(c => _shaderComponent = c, _ => {}); _translateComponent = AddComponent <ITranslateComponent>(); Bind <ITranslateComponent>(c => _translateComponent = c, _ => {}); _imageComponent = AddComponent <IImageComponent>(); Bind <IImageComponent>(c => _imageComponent = c, _ => {}); _borderComponent = AddComponent <IBorderComponent>(); Bind <IBorderComponent>(c => _borderComponent = c, _ => { }); _scaleComponent = AddComponent <IScaleComponent>(); Bind <IScaleComponent>(c => _scaleComponent = c, _ => {}); _rotateComponent = AddComponent <IRotateComponent>(); Bind <IRotateComponent>(c => _rotateComponent = c, _ => {}); _pixelPerfectComponent = AddComponent <IPixelPerfectComponent>(); Bind <IPixelPerfectComponent>(c => _pixelPerfectComponent = c, _ => {}); _modelMatrixComponent = AddComponent <IModelMatrixComponent>(); Bind <IModelMatrixComponent>(c => _modelMatrixComponent = c, _ => {}); _boundingBoxComponent = AddComponent <IBoundingBoxComponent>(); Bind <IBoundingBoxComponent>(c => _boundingBoxComponent = c, _ => {}); _worldPositionComponent = AddComponent <IWorldPositionComponent>(); Bind <IWorldPositionComponent>(c => _worldPositionComponent = c, _ => {}); _faceDirectionComponent = AddComponent <IFaceDirectionComponent>(); Bind <IFaceDirectionComponent>(c => _faceDirectionComponent = c, _ => {}); _outfitComponent = AddComponent <IOutfitComponent>(); Bind <IOutfitComponent>(c => _outfitComponent = c, _ => {}); _inventoryComponent = AddComponent <IInventoryComponent>(); Bind <IInventoryComponent>(c => _inventoryComponent = c, _ => {}); _followComponent = AddComponent <IFollowComponent>(); Bind <IFollowComponent>(c => _followComponent = c, _ => {}); _hotspotComponent = AddComponent <IHotspotComponent>(); Bind <IHotspotComponent>(c => _hotspotComponent = c, _ => {}); beforeInitComponents(resolver, outfit); InitComponents(); afterInitComponents(resolver, outfit); }
public AGSButton(string id, Resolver resolver) : base(id, resolver) { _uIEvents = AddComponent <IUIEvents>(); Bind <IUIEvents>(c => _uIEvents = c, _ => {}); _skinComponent = AddComponent <ISkinComponent>(); Bind <ISkinComponent>(c => _skinComponent = c, _ => {}); _hasRoomComponent = AddComponent <IHasRoomComponent>(); Bind <IHasRoomComponent>(c => _hasRoomComponent = c, _ => {}); _animationComponent = AddComponent <IAnimationComponent>(); Bind <IAnimationComponent>(c => _animationComponent = c, _ => {}); _inObjectTreeComponent = AddComponent <IInObjectTreeComponent>(); Bind <IInObjectTreeComponent>(c => _inObjectTreeComponent = c, _ => {}); _colliderComponent = AddComponent <IColliderComponent>(); Bind <IColliderComponent>(c => _colliderComponent = c, _ => {}); _visibleComponent = AddComponent <IVisibleComponent>(); Bind <IVisibleComponent>(c => _visibleComponent = c, _ => {}); _enabledComponent = AddComponent <IEnabledComponent>(); Bind <IEnabledComponent>(c => _enabledComponent = c, _ => {}); _customPropertiesComponent = AddComponent <ICustomPropertiesComponent>(); Bind <ICustomPropertiesComponent>(c => _customPropertiesComponent = c, _ => {}); _drawableInfoComponent = AddComponent <IDrawableInfoComponent>(); Bind <IDrawableInfoComponent>(c => _drawableInfoComponent = c, _ => {}); _shaderComponent = AddComponent <IShaderComponent>(); Bind <IShaderComponent>(c => _shaderComponent = c, _ => {}); _translateComponent = AddComponent <ITranslateComponent>(); Bind <ITranslateComponent>(c => _translateComponent = c, _ => {}); _imageComponent = AddComponent <IImageComponent>(); Bind <IImageComponent>(c => _imageComponent = c, _ => {}); _borderComponent = AddComponent <IBorderComponent>(); Bind <IBorderComponent>(c => _borderComponent = c, _ => { }); _scaleComponent = AddComponent <IScaleComponent>(); Bind <IScaleComponent>(c => _scaleComponent = c, _ => {}); _rotateComponent = AddComponent <IRotateComponent>(); Bind <IRotateComponent>(c => _rotateComponent = c, _ => {}); _pixelPerfectComponent = AddComponent <IPixelPerfectComponent>(); Bind <IPixelPerfectComponent>(c => _pixelPerfectComponent = c, _ => {}); _modelMatrixComponent = AddComponent <IModelMatrixComponent>(); Bind <IModelMatrixComponent>(c => _modelMatrixComponent = c, _ => {}); _boundingBoxComponent = AddComponent <IBoundingBoxComponent>(); Bind <IBoundingBoxComponent>(c => _boundingBoxComponent = c, _ => {}); _worldPositionComponent = AddComponent <IWorldPositionComponent>(); Bind <IWorldPositionComponent>(c => _worldPositionComponent = c, _ => {}); _textComponent = AddComponent <ITextComponent>(); Bind <ITextComponent>(c => _textComponent = c, _ => {}); _buttonComponent = AddComponent <IButtonComponent>(); Bind <IButtonComponent>(c => _buttonComponent = c, _ => {}); beforeInitComponents(resolver); InitComponents(); afterInitComponents(resolver); }
public override void Init(IEntity entity) { base.Init(entity); entity.Bind <IImageComponent>(c => { TypedParameter imageParam = new TypedParameter(typeof(IHasImage), c); _scale = _resolver.Container.Resolve <IScale>(imageParam); _scale.PropertyChanged += onScalePropertyChanged; }, c => { _scale = null; c.PropertyChanged -= onScalePropertyChanged; }); entity.Bind <IAnimationComponent>(c => _animation = c, _ => _animation = null); }
public override void Init(IEntity entity) { _entity = entity; base.Init(entity); entity.Bind <IModelMatrixComponent>(c => { c.OnMatrixChanged.Subscribe(onHitTextBoxShouldChange); _matrix = c; }, c => { c.OnMatrixChanged.Unsubscribe(onHitTextBoxShouldChange); _matrix = null; }); entity.Bind <ICropSelfComponent>(c => { c.PropertyChanged += onCropShouldChange; _crop = c; }, c => { c.PropertyChanged -= onCropShouldChange; _crop = null; }); entity.Bind <IImageComponent>(c => c.PropertyChanged += onImageChanged, c => c.PropertyChanged -= onImageChanged); entity.Bind <IAnimationComponent>(c => _animation = c, _animation => _animation = null); entity.Bind <IDrawableInfoComponent>(c => { c.PropertyChanged += onDrawableChanged; _drawable = c; }, c => { c.PropertyChanged -= onDrawableChanged; _drawable = null; }); entity.Bind <ITextureOffsetComponent>(c => { c.PropertyChanged += onTextureOffsetChanged; _textureOffset = c; onAllViewportsShouldChange(); }, c => { c.PropertyChanged -= onTextureOffsetChanged; _textureOffset = null; onAllViewportsShouldChange(); }); }
private void updateHitTestBox(IAnimationComponent animation, IDrawableInfoComponent drawable, IModelMatrixComponent matrix) { var modelMatrices = matrix.GetModelMatrices(); var modelMatrix = modelMatrices.InVirtualResolutionMatrix; Size resolution; PointF resolutionFactor; bool resolutionMatches = AGSModelMatrixComponent.GetVirtualResolution(false, _settings.VirtualResolution, drawable, null, out resolutionFactor, out resolution); var sprite = animation.Animation.Sprite; float width = sprite.BaseSize.Width / resolutionFactor.X; float height = sprite.BaseSize.Height / resolutionFactor.Y; _intermediateBox = _boundingBoxBuilder.BuildIntermediateBox(width, height, ref modelMatrix); _hitTestBox = _boundingBoxBuilder.BuildHitTestBox(ref _intermediateBox); }
public AGSInventoryWindow(string id, Resolver resolver, IImage image) : base(id, resolver) { _uIEvents = AddComponent <IUIEvents>(); Bind <IUIEvents>(c => _uIEvents = c, _ => {}); _skinComponent = AddComponent <ISkinComponent>(); Bind <ISkinComponent>(c => _skinComponent = c, _ => {}); _hasRoom = AddComponent <IHasRoomComponent>(); Bind <IHasRoomComponent>(c => _hasRoom = c, _ => {}); _animationComponent = AddComponent <IAnimationComponent>(); Bind <IAnimationComponent>(c => _animationComponent = c, _ => {}); _inObjectTree = AddComponent <IInObjectTreeComponent>(); Bind <IInObjectTreeComponent>(c => _inObjectTree = c, _ => {}); _collider = AddComponent <IColliderComponent>(); Bind <IColliderComponent>(c => _collider = c, _ => {}); _visibleComponent = AddComponent <IVisibleComponent>(); Bind <IVisibleComponent>(c => _visibleComponent = c, _ => {}); _enabledComponent = AddComponent <IEnabledComponent>(); Bind <IEnabledComponent>(c => _enabledComponent = c, _ => {}); _customPropertiesComponent = AddComponent <ICustomPropertiesComponent>(); Bind <ICustomPropertiesComponent>(c => _customPropertiesComponent = c, _ => {}); _drawableInfo = AddComponent <IDrawableInfoComponent>(); Bind <IDrawableInfoComponent>(c => _drawableInfo = c, _ => {}); _hotspotComponent = AddComponent <IHotspotComponent>(); Bind <IHotspotComponent>(c => _hotspotComponent = c, _ => {}); _shaderComponent = AddComponent <IShaderComponent>(); Bind <IShaderComponent>(c => _shaderComponent = c, _ => {}); _translateComponent = AddComponent <ITranslateComponent>(); Bind <ITranslateComponent>(c => _translateComponent = c, _ => {}); _imageComponent = AddComponent <IImageComponent>(); Bind <IImageComponent>(c => _imageComponent = c, _ => {}); _scaleComponent = AddComponent <IScaleComponent>(); Bind <IScaleComponent>(c => _scaleComponent = c, _ => {}); _rotateComponent = AddComponent <IRotateComponent>(); Bind <IRotateComponent>(c => _rotateComponent = c, _ => {}); _pixelPerfectComponent = AddComponent <IPixelPerfectComponent>(); Bind <IPixelPerfectComponent>(c => _pixelPerfectComponent = c, _ => {}); _modelMatrixComponent = AddComponent <IModelMatrixComponent>(); Bind <IModelMatrixComponent>(c => _modelMatrixComponent = c, _ => {}); _boundingBoxComponent = AddComponent <IBoundingBoxComponent>(); Bind <IBoundingBoxComponent>(c => _boundingBoxComponent = c, _ => {}); _inventoryWindowComponent = AddComponent <IInventoryWindowComponent>(); Bind <IInventoryWindowComponent>(c => _inventoryWindowComponent = c, _ => {}); beforeInitComponents(resolver, image); InitComponents(); afterInitComponents(resolver, image); }
public static void StartAnimation(this ButtonAnimation button, IAnimationComponent animationComponent, ITextComponent textComponent, IImageComponent imageComponent, IBorderComponent borderComponent) { if (button == null) { return; } var animation = button.Animation; if (animation != null && animation.Frames.Count > 0) { animationComponent?.StartAnimation(animation); } var border = button.Border; if (border != null && borderComponent != null) { borderComponent.Border = border; } var textConfig = button.TextConfig; if (textConfig != null && textComponent != null) { textComponent.TextConfig = textConfig; } if (imageComponent != null) { var image = button.Image; if (image != null) { imageComponent.Image = image; } var tint = button.Tint; if (tint != null) { imageComponent.Tint = tint.Value; } } }
public override void Init(IEntity entity) { base.Init(entity); entity.Bind <IAnimationComponent>(c => _animation = c, _ => _animation = null); entity.Bind <ITextComponent>(c => _text = c, _ => _text = null); entity.Bind <IImageComponent>(c => _image = c, _ => _image = null); entity.Bind <IUIEvents>(c => { _events = c; c.MouseEnter.Subscribe(onMouseEnter); c.MouseLeave.Subscribe(onMouseLeave); c.MouseUp.Subscribe(onMouseUp); }, c => { _events = null; c.MouseEnter.Unsubscribe(onMouseEnter); c.MouseLeave.Unsubscribe(onMouseLeave); c.MouseUp.Unsubscribe(onMouseUp); }); }
private void selectObject(ITreeStringNode node) { var obj = node.Properties.Entities.GetValue(Fields.Entity); _inspector.Inspector.Show(obj); var animation = obj.GetComponent <IAnimationComponent>(); var visibleComponent = obj.GetComponent <IVisibleComponent>(); var image = obj.GetComponent <IImageComponent>(); if (animation != null) { _lastSelectedObject = animation; IBorderStyle border = null; border = animation.Border; _lastObjectBorder = border; IBorderStyle hoverBorder = AGSBorders.Gradient(new FourCorners <Color>(Colors.Yellow, Colors.Yellow.WithAlpha(150), Colors.Yellow.WithAlpha(150), Colors.Yellow), 1, true); if (border == null) { animation.Border = hoverBorder; } else { animation.Border = AGSBorders.Multiple(border, hoverBorder); } } if (visibleComponent != null) { _lastMaskVisible = visibleComponent.Visible; _lastSelectedMaskVisible = visibleComponent; visibleComponent.Visible = true; } if (image != null && image.Opacity == 0) { _lastOpacity = image.Opacity; _lastSelectedMaskImage = image; image.Opacity = 100; } }
private void unselect() { var lastSelectedObject = _lastSelectedObject; var lastSelectedMaskVisible = _lastSelectedMaskVisible; var lastSelectedMaskImage = _lastSelectedMaskImage; if (lastSelectedObject != null) { lastSelectedObject.Border = _lastObjectBorder; } if (lastSelectedMaskVisible != null) { lastSelectedMaskVisible.Visible = _lastMaskVisible; } if (lastSelectedMaskImage != null) { lastSelectedMaskImage.Opacity = _lastOpacity; } _lastSelectedObject = null; _lastObjectBorder = null; _lastMaskVisible = false; _lastOpacity = 0; }
public AGSPixelPerfectCollidable(IAnimationComponent animation) { _animation = animation; _animation.OnAnimationStarted.Subscribe(refreshPixelPerfect); }
public override void Init() { base.Init(); Entity.Bind <IAnimationComponent>(c => _obj = c, _ => _obj = null); Entity.Bind <ITranslateComponent>(c => _translate = c, _ => _translate = null); }
public Teleporter(IAnimationComponent animationComponent, params IComponent[] components) : base(animationComponent, components) { }
public Enemy(IAnimationComponent animationComponent, params IComponent[] components) : base(animationComponent, components) { }
public Player(IAnimationComponent animationComponent, params IComponent[] components) : base(animationComponent, components) { }
public GameObject(IAnimationComponent animationComponent, params IComponent[] components) { _animationComponent = animationComponent; _components = components.OrderBy(o => o.Order).ToList(); }
public MovableGameObject(IAnimationComponent animationComponent, params IComponent[] components) : base(animationComponent, components) { }
public Decoration(IAnimationComponent animationComponent, params IComponent[] components) : base(animationComponent, components) { }