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);
            }
        }
Example #2
0
        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);
            }
        }