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 cancellingUnitAction = GetTransitionByID(TransitionID.Previous);
            if (cancellingUnitAction != null)
            {
                // 1. Disable Input
                DisableInputEvent disableInput = new DisableInputEvent(EventID.DisableInput, this,
                    new EventArgs<InputHandler>(stateMachine.InputHandler));
                cancellingUnitAction.AddEvent(disableInput, CoroutineID.Execute);

                // 2. Hide Confirm Unit Action UI
                HideWindowEvent hideWindow = new HideWindowEvent(EventID.HideWindow, this, new EventArgs<Window>(confirmActionMenu));
                cancellingUnitAction.AddEvent(hideWindow, CoroutineID.Execute);

                // 3. Show Unit Action Menu
                ShowWindowEvent showWindow = new ShowWindowEvent(EventID.ShowWindow, this, new EventArgs<Window>(unitActionMenu));
                cancellingUnitAction.AddEvent(showWindow, CoroutineID.Execute);

                // 4. Enable Keyboard
                EnableKeyboardEvent enableKeyboard = new EnableKeyboardEvent(EventID.EnableKeyboard, this, new EventArgs<InputHandler>(stateMachine.InputHandler));
                cancellingUnitAction.AddEvent(enableKeyboard, CoroutineID.Execute);
            }

            StateTransition executingUnitAction = GetTransitionByID(TransitionID.Next);
            if (executingUnitAction != null)
            {
                // 1. Disable Input
                DisableInputEvent disableInput = new DisableInputEvent(EventID.DisableInput, this,
                    new EventArgs<InputHandler>(stateMachine.InputHandler));
                executingUnitAction.AddEvent(disableInput, CoroutineID.Execute);

                // 2. Hide Confirm Unit Action UI
                HideWindowEvent hideWindow = new HideWindowEvent(EventID.HideWindow, this, new EventArgs<Window>(confirmActionMenu));
                executingUnitAction.AddEvent(hideWindow, CoroutineID.Execute);
            }
        }
        public override void SetTransitionEvents()
        {
            StateTransition selectingUnit = GetTransitionByID(TransitionID.Next);
            if (selectingUnit != null)
            {
                DisableInputEvent disableInputEvent = new DisableInputEvent(EventID.DisableInput, this, new EventArgs<InputHandler>(stateMachine.InputHandler));
                selectingUnit.AddEvent(disableInputEvent, CoroutineID.Execute);

                // 1. Change active factions
                // 2. Change active units
                // 3. Increment turn counter
                ChangeActiveFactionEvent changeActiveFactionEvent = new ChangeActiveFactionEvent
                    (EventID.ChangeActiveFaction, this, new EventArgs<TurnHandler>(stateMachine.TurnHandler));
                selectingUnit.AddEvent(changeActiveFactionEvent, CoroutineID.Execute);

                // 4. Display turn GUI
                TurnIndicator turnIndicator = GameObject.Find("Turn Indicator").GetComponent<TurnIndicator>();
                ShowTurnIndicatorEvent showTurnIndicatorEvent = new ShowTurnIndicatorEvent
                    (EventID.ShowTurnIndicator, this, new EventArgs<TurnIndicator, float>(turnIndicator, 3.0f));
                selectingUnit.AddEvent(showTurnIndicatorEvent, CoroutineID.Execute);

                // 5. Pan to nearest active unit
                GameObject nearestActiveUnitObject = null;
                PanCameraToGameObjectEvent panCameraToGameObjectEvent = new PanCameraToGameObjectEvent
                    (EventID.PanCameraToNearestActiveUnit, this,
                    new EventArgs<CameraHandler, GameObject, float>(stateMachine.CameraHandler, nearestActiveUnitObject, 1.0f));
                selectingUnit.AddEvent(panCameraToGameObjectEvent, CoroutineID.Execute);

                // 6. Show Cursor Info
                CursorInfo cursorInfo = GameObject.Find("Cursor Info").GetComponent<CursorInfo>();
                ShowWindowEvent showCursorInfoEvent = new ShowWindowEvent(EventID.ShowCursorInfo, this, new EventArgs<Window>(cursorInfo));
                selectingUnit.AddEvent(showCursorInfoEvent, CoroutineID.Execute);

                // 7. Show Turn Info
                TurnInfo turnInfo = GameObject.Find("Turn Info").GetComponent<TurnInfo>();
                ShowWindowEvent showTurnInfoEvent = new ShowWindowEvent(EventID.ShowTurnInfo, this, new EventArgs<Window>(turnInfo));
                selectingUnit.AddEvent(showTurnInfoEvent, CoroutineID.Execute);

                // 8. Show Faction Info
                FactionInfo factionInfo = GameObject.Find("Faction Info").GetComponent<FactionInfo>();
                ShowWindowEvent showFactionInfoEvent = new ShowWindowEvent(EventID.ShowFactionInfo, this, new EventArgs<Window>(factionInfo));
                selectingUnit.AddEvent(showFactionInfoEvent, CoroutineID.Execute);

                // 9. Enable Input
                // 10. Enable Camera Drag
                EnableInputEvent enableInputEvent = new EnableInputEvent(EventID.EnableInput, this, new EventArgs<InputHandler>(stateMachine.InputHandler));
                selectingUnit.AddEvent(enableInputEvent, CoroutineID.Execute);
            }
        }
        public override void SetTransitionEvents()
        {
            // Get Back Menu
            GameObject backMenuObject = GameObject.Find("Back Menu");
            BackMenu backMenu = null;

            if (backMenuObject != null)
                backMenu = backMenuObject.GetComponent<BackMenu>();

            StateTransition cancellingBackMenu = GetTransitionByID(TransitionID.Previous);
            if (cancellingBackMenu != null)
            {
                HideWindowEvent hideWindow = new HideWindowEvent(EventID.HideWindow, this, new EventArgs<Window>(backMenu));
                cancellingBackMenu.AddEvent(hideWindow, CoroutineID.Execute);

                CursorInfo cursorInfo = GameObject.Find("Cursor Info").GetComponent<CursorInfo>();
                ShowWindowEvent showCursorInfoEvent = new ShowWindowEvent(EventID.ShowCursorInfo, this, new EventArgs<Window>(cursorInfo));
                cancellingBackMenu.AddEvent(showCursorInfoEvent, CoroutineID.Execute);

                TurnInfo turnInfo = GameObject.Find("Turn Info").GetComponent<TurnInfo>();
                ShowWindowEvent showTurnInfoEvent = new ShowWindowEvent(EventID.ShowTurnInfo, this, new EventArgs<Window>(turnInfo));
                cancellingBackMenu.AddEvent(showTurnInfoEvent, CoroutineID.Execute);

                FactionInfo factionInfo = GameObject.Find("Faction Info").GetComponent<FactionInfo>();
                ShowWindowEvent showFactionInfoEvent = new ShowWindowEvent(EventID.ShowFactionInfo, this, new EventArgs<Window>(factionInfo));
                cancellingBackMenu.AddEvent(showFactionInfoEvent, CoroutineID.Execute);

                EnableCursorEvent enableCursor = new EnableCursorEvent(EventID.EnableCursor, this,
                    new EventArgs<InputHandler>(stateMachine.InputHandler));
                cancellingBackMenu.AddEvent(enableCursor, CoroutineID.Execute);
            }

            StateTransition endingTurn = GetTransitionByID(TransitionID.Next);
            if (endingTurn != null)
            {
                HideWindowEvent hideWindow = new HideWindowEvent(EventID.HideWindow, this, new EventArgs<Window>(backMenu));
                endingTurn.AddEvent(hideWindow, CoroutineID.Execute);

                DisableInputEvent disableInputEvent =
                    new DisableInputEvent(EventID.DisableInput, this, new EventArgs<InputHandler>(stateMachine.InputHandler));
                endingTurn.AddEvent(disableInputEvent, CoroutineID.Execute);
            }
        }
Example #4
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()
        {
            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);
            }
        }