public override void SetTransitionEvents() { // Get Unit Action Menu GameObject unitActionMenuObject = GameObject.Find("Unit Action Menu"); UnitActionMenu unitActionMenu = null; if (unitActionMenuObject != null) unitActionMenu = unitActionMenuObject.GetComponent<UnitActionMenu>(); StateTransition deselectingUnit = GetTransitionByID(TransitionID.Previous); if (deselectingUnit != null) { // 1. Disable Input DisableInputEvent disableInput = new DisableInputEvent(EventID.DisableInput, this, new EventArgs<InputHandler>(stateMachine.InputHandler)); deselectingUnit.AddEvent(disableInput, CoroutineID.Execute); // 2. Hide Expanded Unit GUI UnitWindow unitWindow = GameObject.Find("Unit Window").GetComponent<UnitWindow>(); HideWindowEvent hideUnitWindow = new HideWindowEvent(EventID.HideUnitWindow, this, new EventArgs<Window>(unitWindow)); deselectingUnit.AddEvent(hideUnitWindow, CoroutineID.Execute); // 3. Hide Movement Area of Selected Unit // 4. Hide Movement Line within Movement Area HideMovementAreaEvent hideMovementArea = new HideMovementAreaEvent(EventID.HideMovementArea, this, new EventArgs<Pathfinder>(stateMachine.Pathfinder)); deselectingUnit.AddEvent(hideMovementArea, CoroutineID.Execute); // 5. Deselect Unit DeselectUnitEvent deselectUnit = new DeselectUnitEvent(EventID.DeselectUnit, this, new EventArgs<Actors.Cursor>(stateMachine.MouseCursor)); deselectingUnit.AddEvent(deselectUnit, CoroutineID.Execute); // 6. Enable Input EnableInputEvent enableInput = new EnableInputEvent(EventID.EnableInput, this, new EventArgs<InputHandler>(stateMachine.InputHandler)); deselectingUnit.AddEvent(enableInput, CoroutineID.Execute); } StateTransition confirmingUnitMove = GetTransitionByID(TransitionID.Next); if (confirmingUnitMove != null) { // 1. Disable Input DisableInputEvent disableInput = new DisableInputEvent(EventID.DisableInput, this, new EventArgs<InputHandler>(stateMachine.InputHandler)); confirmingUnitMove.AddEvent(disableInput, CoroutineID.Execute); // 2. Disable Movement Area // 3. Disable Movement Line HideMovementAreaEvent hideMovementArea = new HideMovementAreaEvent( EventID.HideMovementArea, this, new EventArgs<Pathfinder>(stateMachine.Pathfinder)); confirmingUnitMove.AddEvent(hideMovementArea, CoroutineID.Execute); // 4. Move unit to selected node MoveUnitEvent moveUnit = new MoveUnitEvent(EventID.MoveUnit, this, new EventArgs<Actors.Cursor, Pathfinder, float>(stateMachine.MouseCursor, stateMachine.Pathfinder, 0.1f)); confirmingUnitMove.AddEvent(moveUnit, CoroutineID.Execute); // 4. Pan Camera to Selected Unit PanCameraToSelectedUnitObjectEvent panCameraToSelectedUnitObject = new PanCameraToSelectedUnitObjectEvent( EventID.PanCameraToSelectedUnitObject, this, new EventArgs<CameraHandler, Actors.Cursor, float>(stateMachine.CameraHandler, stateMachine.MouseCursor, 1.0f)); confirmingUnitMove.AddEvent(panCameraToSelectedUnitObject, CoroutineID.Execute); // 5. Show Unit Action Menu ShowWindowEvent showWindow = new ShowWindowEvent(EventID.ShowWindow, this, new EventArgs<Window>(unitActionMenu)); confirmingUnitMove.AddEvent(showWindow, CoroutineID.Execute); // 6. Enable Keyboard EnableKeyboardEvent enableKeyboard = new EnableKeyboardEvent(EventID.EnableKeyboard, this, new EventArgs<InputHandler>(stateMachine.InputHandler)); confirmingUnitMove.AddEvent(enableKeyboard, CoroutineID.Execute); } }
public override void SetTransitionEvents() { // Get Unit Action Menu GameObject unitActionMenuObject = GameObject.Find("Unit Action Menu"); UnitActionMenu unitActionMenu = null; if (unitActionMenuObject != null) unitActionMenu = unitActionMenuObject.GetComponent<UnitActionMenu>(); // Get Confirm Action Menu GameObject confirmActionMenuObject = GameObject.Find("Confirm Action Menu"); ConfirmUnitActionMenu confirmActionMenu = null; if (confirmActionMenuObject != null) confirmActionMenu = confirmActionMenuObject.GetComponent<ConfirmUnitActionMenu>(); StateTransition cancellingUnitMove = GetTransitionByID(TransitionID.Previous); if (cancellingUnitMove != null) { // 1. Disable Input DisableInputEvent disableInput = new DisableInputEvent(EventID.DisableInput, this, new EventArgs<InputHandler>(stateMachine.InputHandler)); cancellingUnitMove.AddEvent(disableInput, CoroutineID.Execute); // 2. Hide Unit Action Menu HideWindowEvent hideWindow = new HideWindowEvent(EventID.HideWindow, this, new EventArgs<Window>(unitActionMenu)); cancellingUnitMove.AddEvent(hideWindow, CoroutineID.Execute); // 3. Move unit back to original location MoveUnitEvent moveUnit = new MoveUnitEvent(EventID.MoveUnit, this, new EventArgs<Actors.Cursor, Pathfinder, float>(stateMachine.MouseCursor, stateMachine.Pathfinder, 0.1f)); cancellingUnitMove.AddEvent(moveUnit, CoroutineID.Undo); // 4. Move camera to selected unit PanCameraToSelectedUnitObjectEvent panCameraToSelectedUnitObject = new PanCameraToSelectedUnitObjectEvent( EventID.PanCameraToSelectedUnitObject, this, new EventArgs<CameraHandler, Actors.Cursor, float>(stateMachine.CameraHandler, stateMachine.MouseCursor, 1.0f)); cancellingUnitMove.AddEvent(panCameraToSelectedUnitObject, CoroutineID.Execute); // 5. Enable Movement Area // 6. Enable Movement Line ShowMovementAreaEvent showMovementArea = new ShowMovementAreaEvent( EventID.ShowMovementArea, this, new EventArgs<Pathfinder, Actors.Cursor>(stateMachine.Pathfinder, stateMachine.MouseCursor)); cancellingUnitMove.AddEvent(showMovementArea, CoroutineID.Execute); // 7. Enable Input EnableInputEvent enableInput = new EnableInputEvent(EventID.EnableInput, this, new EventArgs<InputHandler>(stateMachine.InputHandler)); cancellingUnitMove.AddEvent(enableInput, CoroutineID.Execute); } StateTransition confirmingUnitAction = GetTransitionByID(TransitionID.Next); if (confirmingUnitAction != null) { // 1. Disable Input DisableInputEvent disableInput = new DisableInputEvent(EventID.DisableInput, this, new EventArgs<InputHandler>(stateMachine.InputHandler)); confirmingUnitAction.AddEvent(disableInput, CoroutineID.Execute); // 2. Hide Unit Action Menu HideWindowEvent hideWindow = new HideWindowEvent(EventID.HideWindow, this, new EventArgs<Window>(unitActionMenu)); confirmingUnitAction.AddEvent(hideWindow, CoroutineID.Execute); // 3. Show Confirm Unit Action UI (only if capture/wait command) ShowWindowEvent showWindow = new ShowWindowEvent(EventID.ShowWindow, this, new EventArgs<Window>(confirmActionMenu)); confirmingUnitAction.AddEvent(showWindow, CoroutineID.Execute); // 4. Enable Keyboard EnableKeyboardEvent enableKeyboard = new EnableKeyboardEvent(EventID.EnableKeyboard, this, new EventArgs<InputHandler>(stateMachine.InputHandler)); confirmingUnitAction.AddEvent(enableKeyboard, CoroutineID.Execute); } }