public override void SetTransitionEvents() { StateTransition selectingBackMenuOption = GetTransitionByID(TransitionID.Previous); if (selectingBackMenuOption != null) { DisableCursorEvent disableCursor = new DisableCursorEvent(EventID.DisableCursor, this, new EventArgs<InputHandler>(stateMachine.InputHandler)); selectingBackMenuOption.AddEvent(disableCursor, CoroutineID.Execute); CursorInfo cursorInfo = GameObject.Find("Cursor Info").GetComponent<CursorInfo>(); HideWindowEvent hideCursorInfoEvent = new HideWindowEvent(EventID.HideCursorInfo, this, new EventArgs<Window>(cursorInfo)); selectingBackMenuOption.AddEvent(hideCursorInfoEvent, CoroutineID.Execute); TurnInfo turnInfo = GameObject.Find("Turn Info").GetComponent<TurnInfo>(); HideWindowEvent hideTurnInfoEvent = new HideWindowEvent(EventID.HideTurnInfo, this, new EventArgs<Window>(turnInfo)); selectingBackMenuOption.AddEvent(hideTurnInfoEvent, CoroutineID.Execute); FactionInfo factionInfo = GameObject.Find("Faction Info").GetComponent<FactionInfo>(); HideWindowEvent hideFactionInfoEvent = new HideWindowEvent(EventID.HideFactionInfo, this, new EventArgs<Window>(factionInfo)); selectingBackMenuOption.AddEvent(hideFactionInfoEvent, CoroutineID.Execute); GameObject backMenuObject = GameObject.Find("Back Menu"); BackMenu backMenu = null; if (backMenuObject != null) backMenu = backMenuObject.GetComponent<BackMenu>(); ShowWindowEvent showWindow = new ShowWindowEvent(EventID.ShowWindow, this, new EventArgs<Window>(backMenu)); selectingBackMenuOption.AddEvent(showWindow, CoroutineID.Execute); } StateTransition movingUnit = GetTransitionByID(TransitionID.Next); if (movingUnit != null) { // 1. Disable Input DisableInputEvent disableInput = new DisableInputEvent(EventID.DisableInput, this, new EventArgs<InputHandler>(stateMachine.InputHandler)); movingUnit.AddEvent(disableInput, CoroutineID.Execute); // 2. Select Unit SelectUnitEvent selectUnit = new SelectUnitEvent(EventID.SelectUnit, this, new EventArgs<Actors.Cursor>(stateMachine.MouseCursor)); movingUnit.AddEvent(selectUnit, CoroutineID.Execute); // 3. Show Expanded Unit GUI UnitWindow unitWindow = GameObject.Find("Unit Window").GetComponent<UnitWindow>(); ShowUnitWindowEvent showUnitWindow = new ShowUnitWindowEvent (EventID.ShowUnitWindow, this, new EventArgs<UnitWindow, Actors.Cursor>(unitWindow, stateMachine.MouseCursor)); movingUnit.AddEvent(showUnitWindow, 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)); movingUnit.AddEvent(panCameraToSelectedUnitObject, CoroutineID.Execute); // 5. Show Movement Area of Selected Unit // 6. Show Movement Line within Movement Area ShowMovementAreaEvent showMovementArea = new ShowMovementAreaEvent( EventID.ShowMovementArea, this, new EventArgs<Pathfinder, Actors.Cursor>(stateMachine.Pathfinder, stateMachine.MouseCursor)); movingUnit.AddEvent(showMovementArea, CoroutineID.Execute); // 7. Enable Input EnableInputEvent enableInput = new EnableInputEvent(EventID.EnableInput, this, new EventArgs<InputHandler>(stateMachine.InputHandler)); movingUnit.AddEvent(enableInput, 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); } }