private void StartAddLink(ConnectorElement connStart, Point mousePoint) { if (document.Action == DesignerAction.Connect) { this.connStart = connStart; this.connEnd = new ConnectorElement(connStart.ParentElement); connEnd.Location = connStart.Location; IMoveController ctrl = (IMoveController)((IControllable)connEnd).GetController(); ctrl.Start(mousePoint); isAddLink = true; switch (document.LinkType) { case (LinkType.Straight): linkLine = new StraightLinkElement(connStart, connEnd); break; case (LinkType.RightAngle): linkLine = new RightAngleLinkElement(connStart, connEnd); break; } linkLine.Visible = true; linkLine.BorderColor = Color.FromArgb(150, Color.Black); linkLine.BorderWidth = 1; this.Invalidate(linkLine, true); OnElementConnecting(new ElementConnectEventArgs(connStart.ParentElement, null, linkLine)); } }
public static GameActionResult HandlePlayerMoveKeys(KeyboardState keyboardState, KeyboardState previousState, IMoveController moveController) { if (keyboardState.IsKeyDown(Keys.Up) && !previousState.IsKeyDown(Keys.Up)) { return(moveController.MovePlayer(new Offset(0, -1))); } if (keyboardState.IsKeyDown(Keys.Down) && !previousState.IsKeyDown(Keys.Down)) { return(moveController.MovePlayer(new Offset(0, 1))); } if (keyboardState.IsKeyDown(Keys.Left) && !previousState.IsKeyDown(Keys.Left)) { return(moveController.MovePlayer(new Offset(-1, 0))); } if (keyboardState.IsKeyDown(Keys.Right) && !previousState.IsKeyDown(Keys.Right)) { return(moveController.MovePlayer(new Offset(1, 0))); } return(null); }
[SetUp] public void Init() { move = GetMoveMock (); move.LessThanVMagnitude ().Returns (true); move.IsGrounded ().Returns (true); cMove = GetControllerMock (move); }
public void Start() { _moveController = GetComponent <IMoveController>(); _characterController = GetComponentInParent <CharacterController>(); if (_characterController == null) { _characterController = transform.parent.gameObject.AddComponent <CharacterController>(); } }
// Use this for initialization void Start() { shotController = GetComponent <IShotController>(); moveController = GetComponent <IMoveController>(); aimController = GetComponent <IAimController>(); ballController = ballObject.GetComponent <Projectiler>(); rb = GetComponent <Rigidbody>(); AudioSource[] clips = GetComponents <AudioSource>(); runSound = clips[0]; shotSound = clips[1]; cStateMovePrev = new Vector2(); }
private void Remove(IMoveController moveController, ColocateCoordinateView colocateCoordinateView) { Error error = Error.NOT_ERROR; do { origin = colocateCoordinateView.GetCoordinate(); error = moveController.ValidateOrigin(origin); if (error != Error.NOT_ERROR) { io.Writeln("" + error); } } while (error != Error.NOT_ERROR); moveController.Remove(origin); }
private void Put(IMoveController moveController, ColocateCoordinateView colocateCoordinateView) { Models.Coordinate target; Error error = Error.NOT_ERROR; do { target = colocateCoordinateView.GetCoordinate(); error = moveController.ValidateTarget(origin, target); if (error != Error.NOT_ERROR) { io.Writeln("" + error); } } while (error != Error.NOT_ERROR); moveController.Put(target); }
private void StartAddLink(ConnectorElement connStart, Point mousePoint) { if (document.Action == DesignerAction.Connect) { this.connStart = connStart; this.connEnd = new ConnectorElement(connStart.ParentElement); connEnd.Location = connStart.Location; IMoveController ctrl = (IMoveController)((IControllable)connEnd).GetController(); ctrl.Start(mousePoint); isAddLink = true; linkLine = CreateElementInstance(connStart, connEnd); this.Invalidate(linkLine, true); OnElementConnecting(new ElementConnectEventArgs(connStart.ParentElement, null, linkLine)); } }
private void UpdateLinkPosition(NodeElement node) { foreach (ConnectorElement conn in node.Connectors) { foreach (BaseElement el in conn.Links) { BaseLinkElement lnk = (BaseLinkElement)el; IController ctrl = ((IControllable)lnk).GetController(); if (ctrl is IMoveController) { IMoveController mctrl = (IMoveController)ctrl; if (!mctrl.IsMoving) { lnk.NeedCalcLink = true; } } else { lnk.NeedCalcLink = true; } if (lnk is ILabelElement) { LabelElement label = ((ILabelElement)lnk).Label; ILabelController lblCtrl = ControllerHelper.GetLabelController(lnk); if (lblCtrl != null) { lblCtrl.SetLabelPosition(); } else { label.PositionBySite(lnk); } label.Invalidate(); } } } }
private void LoadLevel(Level level) { gameMap = new GameMap(level.Map.StringRepresentation); if (level.BackgroundSoundFileName != null) { music = Content.Load <Song>("Sound/Level Music/" + level.BackgroundSoundFileName); MediaPlayer.Play(music); MediaPlayer.IsRepeating = true; } moveController = new MoveController(gameMap); gameState = new GameState(gameMap.ObjectivesCount) { CurrentState = GameState.State.Playing }; graphics.PreferredBackBufferWidth = gameMap.Width * Config.CellSize + Config.DefaultFrameOffset * 2; graphics.PreferredBackBufferHeight = gameMap.Height * Config.CellSize + Config.DefaultFrameOffset * 2; graphics.ApplyChanges(); previousState = Keyboard.GetState(); }
private void _SetController(IMoveController obj) { _MoveController = obj; }
public TransmissionControllerAdapter(IMoveController controller) { _controller = controller; }
public void Start(Point mousePoint, Document document, OnElementMovingDelegate onElementMovingDelegate) { this.document = document; this.onElementMovingDelegate = onElementMovingDelegate; // Get Controllers moveCtrl = new IMoveController[document.SelectedElements.Count]; IMoveController[] moveLabelCtrl = new IMoveController[document.SelectedElements.Count]; for(int i = document.SelectedElements.Count - 1; i >= 0; i--) { moveCtrl[i] = ControllerHelper.GetMoveController(document.SelectedElements[i]); if ((moveCtrl[i] != null) && (moveCtrl[i].CanMove)) { onElementMovingDelegate(new ElementEventArgs(document.SelectedElements[i])); moveCtrl[i].Start(mousePoint); //ILabelElement - Move Label inside the element if ((document.SelectedElements[i] is ILabelElement) && (ControllerHelper.GetLabelController(document.SelectedElements[i]) == null)) { LabelElement label = ((ILabelElement) document.SelectedElements[i]).Label; moveLabelCtrl[i] = ControllerHelper.GetMoveController(label); if ((moveLabelCtrl[i] != null) && (moveLabelCtrl[i].CanMove)) moveLabelCtrl[i].Start(mousePoint); else moveLabelCtrl[i] = null; } } else moveCtrl[i] = null; } moveCtrl = (IMoveController[]) DiagramUtil.ArrayHelper.Append(moveCtrl, moveLabelCtrl); moveCtrl = (IMoveController[]) DiagramUtil.ArrayHelper.Shrink(moveCtrl, null); // Can't move only links bool isOnlyLink = true; foreach (IMoveController ctrl in moveCtrl) { // Verify if (ctrl != null) { ctrl.OwnerElement.Invalidate(); if (!(ctrl.OwnerElement is BaseLinkElement) && !(ctrl.OwnerElement is LabelElement)) { isOnlyLink = false; break; } } } if (isOnlyLink) { //End Move the Links foreach (IMoveController ctrl in moveCtrl) { if (ctrl !=null) ctrl.End(); } moveCtrl = new IMoveController[] {null}; } //Upper selecion point controller UpdateUpperSelectionPoint(); upperSelPointDragOffset.X = upperSelPoint.X - mousePoint.X; upperSelPointDragOffset.Y = upperSelPoint.Y - mousePoint.Y; isMoving = true; }
internal MoveEntity(Transform trans, IMoveController controller) { this.trans = trans; this.controller = controller; }
public void Visit(IMoveController moveController) { throw new System.NotImplementedException(); }
public void Start(Point mousePoint, Document document, OnElementMovingDelegate onElementMovingDelegate) { this.document = document; this.onElementMovingDelegate = onElementMovingDelegate; // Get Controllers moveCtrl = new IMoveController[document.SelectedElements.Count]; IMoveController[] moveLabelCtrl = new IMoveController[document.SelectedElements.Count]; for (int i = document.SelectedElements.Count - 1; i >= 0; i--) { moveCtrl[i] = ControllerHelper.GetMoveController(document.SelectedElements[i]); if (moveCtrl[i] != null && moveCtrl[i].CanMove) { onElementMovingDelegate(new ElementEventArgs(document.SelectedElements[i])); moveCtrl[i].Start(mousePoint); //ILabelElement - Move Label inside the element if (document.SelectedElements[i] is ILabelElement && ControllerHelper.GetLabelController(document.SelectedElements[i]) == null) { LabelElement label = ((ILabelElement)document.SelectedElements[i]).Label; moveLabelCtrl[i] = ControllerHelper.GetMoveController(label); if (moveLabelCtrl[i] != null && moveLabelCtrl[i].CanMove) { moveLabelCtrl[i].Start(mousePoint); } else { moveLabelCtrl[i] = null; } } } else { moveCtrl[i] = null; } } moveCtrl = (IMoveController[])ArrayHelper.Append(moveCtrl, moveLabelCtrl); moveCtrl = (IMoveController[])ArrayHelper.Shrink(moveCtrl, null); // Can't move only links bool isOnlyLink = true; foreach (IMoveController ctrl in moveCtrl) { // Verify if (ctrl != null) { ctrl.OwnerElement.Invalidate(); if (!(ctrl.OwnerElement is BaseLinkElement) && !(ctrl.OwnerElement is LabelElement)) { isOnlyLink = false; break; } } } if (isOnlyLink) { //End Move the Links foreach (IMoveController ctrl in moveCtrl) { if (ctrl != null) { ctrl.End(); } } moveCtrl = new IMoveController[] { null }; } //Upper selecion point controller UpdateUpperSelectionPoint(); upperSelPointDragOffset.X = upperSelPoint.X - mousePoint.X; upperSelPointDragOffset.Y = upperSelPoint.Y - mousePoint.Y; isMoving = true; }
private void MoveControllerProviderOnUnsupply(IMoveController move_controller) { gameObject.SetActive(false); }
public void Start(Point mousePoint, Document document, OnElementMovingDelegate onElementMovingDelegate) { _document = document; _onElementMovingDelegate = onElementMovingDelegate; // Get Controllers _moveCtrl = new IMoveController[document.SelectedElements.Count]; var moveLabelCtrl = new IMoveController[document.SelectedElements.Count]; for (var i = document.SelectedElements.Count - 1; i >= 0; i--) { _moveCtrl[i] = ControllerHelper.GetMoveController(document.SelectedElements[i]); if ((_moveCtrl[i] != null) && (_moveCtrl[i].CanMove)) { onElementMovingDelegate(new ElementEventArgs(document.SelectedElements[i])); _moveCtrl[i].Start(mousePoint); //ILabelElement - Move Label inside the element if ((document.SelectedElements[i] is ILabelElement) && (ControllerHelper.GetLabelController(document.SelectedElements[i]) == null)) { var label = ((ILabelElement)document.SelectedElements[i]).Label; moveLabelCtrl[i] = ControllerHelper.GetMoveController(label); if ((moveLabelCtrl[i] != null) && (moveLabelCtrl[i].CanMove)) { moveLabelCtrl[i].Start(mousePoint); } else { moveLabelCtrl[i] = null; } } } else { _moveCtrl[i] = null; } } _moveCtrl = (IMoveController[])DiagramUtil.ArrayHelper.Append(_moveCtrl, moveLabelCtrl); _moveCtrl = (IMoveController[])DiagramUtil.ArrayHelper.Shrink(_moveCtrl, null); // Can't move only links var isOnlyLink = true; foreach (var ctrl in _moveCtrl) { // Verify if (ctrl == null) { continue; } ctrl.OwnerElement.Invalidate(); if ((ctrl.OwnerElement is BaseLinkElement) || (ctrl.OwnerElement is LabelElement)) { continue; } isOnlyLink = false; break; } if (isOnlyLink) { //End Move the Links foreach (var ctrl in _moveCtrl) { if (ctrl != null) { ctrl.End(); } } _moveCtrl = new IMoveController[] { null }; } //Upper selecion point controller UpdateUpperSelectionPoint(); _upperSelPointDragOffset.X = _upperSelPoint.X - mousePoint.X; _upperSelPointDragOffset.Y = _upperSelPoint.Y - mousePoint.Y; IsMoving = true; }
private void _SetMoveController(IMoveController obj) { _MoveController = obj; }
public void SetMoveController(IMoveController iMoveController) { this.iMoveController = iMoveController; }
private CharaMoveController GetControllerMock(IMoveController move) { var cMove = Substitute.For<CharaMoveController> (); cMove.SetMoveController (move); return cMove; }
public Controller(IMoveController moveController, IFireController fireController) { _moveController = moveController; _fireController = fireController; }
private void _ClearMoveController(IMoveController obj) { _MoveController = null; }
protected override void OnMouseMove(MouseEventArgs e) { if (e.Button == MouseButtons.None) { this.Cursor = Cursors.Arrow; Point mousePoint = Gsc2Goc(new Point(e.X, e.Y)); if ((resizeAction != null) && ((document.Action == DesignerAction.Select) || ((document.Action == DesignerAction.Connect) && (resizeAction.IsResizingLink)))) { this.Cursor = resizeAction.UpdateResizeCornerCursor(mousePoint); } if (document.Action == DesignerAction.Connect) { BaseElement mousePointerElementTMP = document.FindElement(mousePoint); if (mousePointerElement != mousePointerElementTMP) { if (mousePointerElementTMP is ConnectorElement) { mousePointerElement = mousePointerElementTMP; mousePointerElement.Invalidate(); this.Invalidate(mousePointerElement, true); } else if (mousePointerElement != null) { mousePointerElement.Invalidate(); this.Invalidate(mousePointerElement, true); mousePointerElement = null; } } } else { this.Invalidate(mousePointerElement, true); mousePointerElement = null; } } if (e.Button == MouseButtons.Left) { Point dragPoint = Gsc2Goc(new Point(e.X, e.Y)); if ((resizeAction != null) && (resizeAction.IsResizing)) { resizeAction.Resize(dragPoint); this.Invalidate(); } if ((moveAction != null) && (moveAction.IsMoving)) { moveAction.Move(dragPoint); this.Invalidate(); } if ((isMultiSelection) || (isAddSelection)) { Point p = Gsc2Goc(new Point(e.X, e.Y)); selectionArea.Size = new Size(p.X - selectionArea.Location.X, p.Y - selectionArea.Location.Y); selectionArea.Invalidate(); this.Invalidate(selectionArea, true); } if (isAddLink) { selectedElement = document.FindElement(dragPoint); if ((selectedElement is ConnectorElement) && (document.CanAddLink(connStart, (ConnectorElement)selectedElement))) { linkLine.Connector2 = (ConnectorElement)selectedElement; } else { linkLine.Connector2 = connEnd; } IMoveController ctrl = (IMoveController)((IControllable)connEnd).GetController(); ctrl.Move(dragPoint); //this.Invalidate(linkLine, true); //TODO base.Invalidate(); } } base.OnMouseMove(e); }
private void _ClearController(IMoveController obj) { _MoveController = null; }