//Pendiente //IGameEntity gameEntity; public override void Awake() { base.Awake(); entity = GetComponent <IGameEntity>(); currentlySelected = false; controller = GameObject.Find("GameController"); player = controller.GetComponent <Player>(); _collider = GetComponent <Collider>(); selectedRect = SelectionOverlay.CalculateBox(_collider); }
/// <summary> /// Adjust the texture initally, needed for the buildings /// </summary> public void AdjustTexture() { selectedRect = SelectionOverlay.CalculateBox(_collider); Vector3 position = this.gameObject.transform.position; position.y = _collider.bounds.max.y + (_collider.bounds.size.y * .5f); // move the plane a little bit from the center plane.transform.position = position; // rotate the plain to its original position plane.transform.rotation = _LifeBarDefaultRotation; }
public void AddControl(XmlNode controlDefinition, Control control) { SelectionOverlay overlay = new SelectionOverlay(control, controlDefinition, wixFiles); Controls.Add(overlay); overlay.ItemChanged += new SelectionOverlayItemHandler(OnItemChanged); overlay.ItemDeleted += new SelectionOverlayItemHandler(OnItemDeleted); overlay.SelectionChanged += new SelectionOverlayItemHandler(OnSelectionChanged); String nodeId = controlDefinition.Attributes["Id"].Value; controlMap.Add(nodeId, overlay); }
public ArrangeAdorner(UIElement adornedElement) : base(adornedElement) { SelectionRenderMode = RenderMode.None; ResizeHandleRenderMode = RenderMode.None; SelectionFill = null; SelectionStroke = new SolidColorBrush(Color.FromRgb(0x00, 0x00, 0xFF)); SelectionStrokeThickness = 2.0; HandleFill = new SolidColorBrush(Color.FromRgb(0xFF, 0xFF, 0xFF)); HandleStroke = new SolidColorBrush(Color.FromRgb(0x00, 0x00, 0x00)); HandleStrokeThickness = 1.0; HandleSize = 10; mVisualChildren = new VisualCollection(this); mSelectionOverlay = new SelectionOverlay(this); mVisualChildren.Add(mSelectionOverlay); InitializeResizeHandles(); }
public override void Start() { base.Start(); fire(Actions.CREATED, this.gameObject); if (entity.info.isBuilding == true) { selectedBox = SelectionOverlay.CreateTexture(false); plane = SelectionOverlay.getPlane(gameObject, selectedBox, true); } else { bool ownUnit = entity.info.race == player.race; selectedBox = SelectionOverlay.CreateTexture(ownUnit); plane = SelectionOverlay.getPlane(gameObject, selectedBox, false); } //ponemos el plane dentro del gameobject _LifeBarDefaultRotation = plane.transform.rotation; plane.transform.parent = transform; entity.doIfUnit(unit => { unit.register(Unit.Actions.DIED, onUnitDied); }); // only apply for units of the player if (entity.info.isUnit && player.race == race) { RetrieveLightSelection(); } else { _unitSelection = null; } currentlySelected = false; _selectionVisible = true; _attackedEntity = false; AdjustTexture(); }
protected virtual void LateUpdate() { // only updates the texture if there's been a change in the healthy -> improves quite a lot the results in the profiler inspector if (_lastHealth != entity.healthPercentage) { _lastHealth = entity.healthPercentage; healthRatio = _lastHealth / 100f; SelectionOverlay.UpdateTexture(plane, selectedBox, healthRatio); } if (_attackedEntity || (currentlySelected && entity.info.isUnit)) { selectedRect = SelectionOverlay.CalculateBox(_collider); Vector3 position = this.gameObject.transform.position; position.y = _collider.bounds.max.y + (_collider.bounds.size.y * .5f); // move the plane a little bit from the center plane.transform.position = position; // rotate the plain to its original position plane.transform.rotation = _LifeBarDefaultRotation; if (!_selectionVisible) { plane.SetActive(true); _selectionVisible = true; } } else { if (_selectionVisible) { plane.SetActive(false); _selectionVisible = false; } } }
private void SynchronizeButtonStatus() { if (SelectionOverlay != null && SelectionOverlay.IsEnabled()) { switch (SelectionOverlay.TrackMode) { case TrackMode.Point: viewModel.IsPointChecked = true; GisEditor.ActiveMap.Cursor = GisEditorCursors.DrawPoint; break; case TrackMode.Rectangle: viewModel.IsRectangleChecked = true; GisEditor.ActiveMap.Cursor = GisEditorCursors.DrawRectangle; break; case TrackMode.Circle: viewModel.IsCircleChecked = true; GisEditor.ActiveMap.Cursor = GisEditorCursors.DrawCircle; break; case TrackMode.Polygon: viewModel.IsPolygonChecked = true; GisEditor.ActiveMap.Cursor = GisEditorCursors.DrawPolygon; break; case TrackMode.Line: viewModel.IsLineChecked = true; GisEditor.ActiveMap.Cursor = GisEditorCursors.DrawLine; break; } } else { viewModel.UncheckAllSelectionButton(); } }
private SelectionOverlay CreateOrGetSelectionOverlay(bool mouseDownOnCreate = true) { Logger.Trace(string.Format("{0} args: {1}", this.GetTraceInfo(), string.Join(", ", mouseDownOnCreate))); SelectionOverlay el = FindSelectionOverlay(); if (el == null) { el = new SelectionOverlay(mouseDownOnCreate); el.OnElementMove += SelectionOverlay_OnElementMove; el.OnElementResize += SelectionOverlay_OnElementResize; el.OnStartMove += SelectionOverlay_OnStartMove; //el.OnStopMove += SelectionOverlay_OnStopMove; el.OnOperationFinalized += SelectionOverlay_OnOperationFinalized; Canvas.SetZIndex(el, 10000); this.DisplayCanvas.Children.Add(el); el.PullThickness = (int)(SelectionOverlay.DefaultThickness / this.ViewScale); } return el; }
private void SelectionOverlay_OnElementResize(object sender, SelectionOverlay.ResizeEventArgs e) { bool posChangeNeeded = new SelectionOverlay.ResizeEventArgs.Direction[] { SelectionOverlay.ResizeEventArgs.Direction.TopRight, SelectionOverlay.ResizeEventArgs.Direction.Top, SelectionOverlay.ResizeEventArgs.Direction.TopLeft, SelectionOverlay.ResizeEventArgs.Direction.Left, SelectionOverlay.ResizeEventArgs.Direction.BotLeft }.Contains(e.Dir); var metrics = e.Element.GetCanvasMetrics(); if (posChangeNeeded) { metrics.X -= e.DeltaX; metrics.Y -= e.DeltaY; } if (metrics.Width + e.DeltaX >= 0) metrics.Width += e.DeltaX; if (metrics.Height + e.DeltaY >= 0) metrics.Height += e.DeltaY; if (e.Element is FrameworkElement) { var fElement = e.Element as FrameworkElement; var data = fElement.Tag as TAG_CanvasChildElement; if (data == null) return; if (posChangeNeeded) { AddInManager.Instance.MainFile.SetKey(string.Join("/", data.Key, "x"), ToSqfString(FieldTypeEnum.XField, metrics.X)); AddInManager.Instance.MainFile.SetKey(string.Join("/", data.Key, "y"), ToSqfString(FieldTypeEnum.YField, metrics.Y)); } AddInManager.Instance.MainFile.SetKey(string.Join("/", data.Key, "w"), ToSqfString(FieldTypeEnum.WField, metrics.Width)); AddInManager.Instance.MainFile.SetKey(string.Join("/", data.Key, "h"), ToSqfString(FieldTypeEnum.HField, metrics.Height)); } }
private void SelectionOverlay_OnElementMove(object sender, SelectionOverlay.MoveEventArgs e) { var metrics = e.Element.GetCanvasMetrics(); metrics.X += e.DeltaX; metrics.Y += e.DeltaY; if (e.Element is FrameworkElement) { var fElement = e.Element as FrameworkElement; var data = fElement.Tag as TAG_CanvasChildElement; if (data == null) return; AddInManager.Instance.MainFile.SetKey(string.Join("/", data.Key, "x"), ToSqfString(FieldTypeEnum.XField, metrics.X)); AddInManager.Instance.MainFile.SetKey(string.Join("/", data.Key, "y"), ToSqfString(FieldTypeEnum.YField, metrics.Y)); } }
private void load() { EnableCardSelection.Value = false; EnableTileSelection.Value = false; EnablePlayerSelection.Value = false; RelativeSizeAxes = Axes.Both; InternalChildren = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = Colour4.Black }, new FillFlowContainer { RelativeSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Children = new Drawable[] { new FillFlowContainer { RelativeSizeAxes = Axes.Both, Height = .1f, Direction = FillDirection.Horizontal, Children = new Drawable[] { new BasicScrollContainer(Direction.Horizontal) { RelativeSizeAxes = Axes.Both, Width = .8f, ScrollbarOverlapsContent = false, Child = new PlayerPreviewContainer(), }, new SimpleIconButton(FontAwesome.Solid.SignOutAlt) { Action = exitRoom, }, }, }, new BoardsContainer { Height = .6f, Boards = game.GameBoards.ToList() }, new Container { RelativeSizeAxes = Axes.Both, Height = .3f, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = Colour4.Bisque }, new PlayerHandContainer() }, }, }, }, selectOverlay = new SelectionOverlay(), sendOverlay = new SendArgumentOverlay() }; }