void MoveSelected() { Vector2Int dragOffsetInt = GameUtil.V3ToV2I(GameManager.Instance.dragOffset); Vector2Int oldDragOffsetInt = GameUtil.V3ToV2I(GameManager.Instance.oldDragOffset); if (dragOffsetInt != oldDragOffsetInt) { SnapToPosition(dragOffsetInt); if (BoardManager.CheckValidMove(dragOffsetInt, this.selectedList)) { this.selectionState = SelectionStateEnum.HOLDING; foreach (BlockObject selectedBlock in this.selectedList) { selectedBlock.SetState(BlockStateEnum.GHOST); } } else { this.selectionState = SelectionStateEnum.INVALID; foreach (BlockObject selectedBlock in this.selectedList) { selectedBlock.SetState(BlockStateEnum.INVALID); } } } }
public void BlockSelectorItemOnPointerDown(BlockData aBlockGhostData) { if (editMode == EditModeEnum.ADD && selectionState == SelectionStateEnum.DEFAULT) { print("EditorManager - PreviewBlock"); this.blockGhost = Instantiate(BoardManager.Instance.blockMaster); this.blockGhost.Init(aBlockGhostData); this.selectionState = SelectionStateEnum.HOLDING; } else { throw new System.Exception("Block selector item activated but editMode != ADD"); } }
private void Initialize(BackgroundCanvas mainCanvas, string filename, int ID) { _photoID = -1; _parentPhoto = null; _ID = ID; _currentBitmap = _primaryBitmap; if (null == _currentBitmap) { _currentBitmap = _alternateBitmap1; } _mainCanvas = mainCanvas; _parent = mainCanvas; _parentGroup = null; _childImage = new Image(); _childImage.Source = _currentBitmap; _canvas = new Canvas(); Child = _canvas; _canvas.Children.Add(_childImage); SetCurrentBitmap(); RenderTransform = new ScaleTransform(1.0, 1.0); BorderThickness = new Thickness(_mainCanvas.OptionDialog.BorderWidth); BorderBrush = Brushes.Black; Background = Brushes.White; if (_parentGroupID <= 0) { _parentGroupID = BackgroundCanvas.NOPARENT; } _pathName = filename; _fileName = System.IO.Path.GetFileName(_pathName); _defaultScale = new ScaleTransform(1.0, 1.0); _targetAnimationPos = new Point(); MouseEnter += OnMouseEnterHandler; MouseLeave += OnMouseLeaveHandler; MouseLeftButtonDown += MouseLeftButtonDownHandler; MouseLeftButtonUp += MouseLeftButtonUpHandler; MouseRightButtonDown += MouseRightButtonDownHandler; MouseMove += MouseMoveEventHandler; _selectState = SelectionStateEnum.None; _canvas.Width = MyWidth; _canvas.Height = MyHeight; }
public void BlockSelectorItemOnPointerUp() { if (editMode == EditModeEnum.ADD && selectionState == SelectionStateEnum.HOLDING) { if (BoardManager.CanAddBlockHere(this.blockGhost, GameUtil.V3ToV2I(GameManager.Instance.mousePos))) { BoardManager.Instance.AddBlock(this.blockGhost, GameUtil.V3ToV2I(GameManager.Instance.mousePos)); this.blockGhost.transform.SetParent(transform); } else { Destroy(this.blockGhost.gameObject); } this.selectionState = SelectionStateEnum.DEFAULT; this.blockGhost = null; } else { throw new System.Exception("Block selector block preview let go but editMode != ADD"); } }
public void SetEditMode(EditModeEnum aEditMode) { print("EditorManager - EditMode changed to " + aEditMode.ToString()); this.editMode = aEditMode; this.selectionState = SelectionStateEnum.DEFAULT; this.blockGhost = null; switch (this.editMode) { case EditModeEnum.ADD: this.placeView.SetActive(true); break; case EditModeEnum.REMOVE: this.placeView.SetActive(false); // this.placeView.enabled = false; break; case EditModeEnum.SELECT: this.placeView.SetActive(false); // this.placeView.enabled = false; break; } }
void Awake() { this.selectionState = SelectionStateEnum.DEFAULT; this.editMode = EditModeEnum.ADD; }
void Update() { switch (GameManager.Instance.mouseState) { case MouseStateEnum.DEFAULT: break; case MouseStateEnum.CLICKED: // this should only happen for one frame before mouseState changes to HELD this.clickedBlock = GetClickedBlock(); break; case MouseStateEnum.HELD: switch (this.selectionState) { case SelectionStateEnum.DEFAULT: if (this.clickedBlock != null && this.clickedBlock.state == BlockStateEnum.ACTIVE) { if (GameManager.Instance.dragOffset.y > PlayingManager.dragThreshold) { if (!BoardManager.IsBlocked(true, this.clickedBlock)) { // dragging up print("PlayingManager - dragging up block: " + clickedBlock); PauseTime(); SelectBlocks(BoardManager.SelectUp(this.clickedBlock)); this.selectionState = SelectionStateEnum.HOLDING; } } else if (GameManager.Instance.dragOffset.y < PlayingManager.dragThreshold * -1) { if (!BoardManager.IsBlocked(false, this.clickedBlock)) { // dragging down print("PlayingManager - dragging down block: " + clickedBlock); PauseTime(); SelectBlocks(BoardManager.SelectDown(this.clickedBlock)); this.selectionState = SelectionStateEnum.HOLDING; } } } break; case SelectionStateEnum.HOLDING: // move blocks MoveSelected(); break; case SelectionStateEnum.INVALID: // move blocks MoveSelected(); break; } break; case MouseStateEnum.UNCLICKED: // runs once for one frame before mouseState changes to DEFAULT print("PlayingManager - unclicked"); this.clickedBlock = null; switch (this.selectionState) { case SelectionStateEnum.DEFAULT: break; case SelectionStateEnum.HOLDING: foreach (BlockObject selectedBlock in this.selectedList) { selectedBlock.pos = selectedBlock.ghostPos; selectedBlock.SetState(BlockStateEnum.ACTIVE); } this.selectedList.Clear(); this.selectionState = SelectionStateEnum.DEFAULT; break; case SelectionStateEnum.INVALID: foreach (BlockObject selectedBlock in this.selectedList) { selectedBlock.SmoothMove(GameUtil.V2IOffsetV3(selectedBlock.size, selectedBlock.pos)); selectedBlock.ghostPos = selectedBlock.pos; selectedBlock.SetState(BlockStateEnum.ACTIVE); } this.selectedList.Clear(); this.selectionState = SelectionStateEnum.DEFAULT; break; } ResumeTime(); break; } switch (this.timeState) { case TimeStateEnum.NORMAL: foreach (MobObject mob in BoardManager.Instance.mobList) { foreach (IComponent component in mob.componentList) { component.DoFrame(); } } break; case TimeStateEnum.PAUSED: break; } }