Ejemplo n.º 1
0
            }   // end of EditWorldParametersUpdateObj Activate()

            public override void Deactivate()
            {
                if (active)
                {
                    shared.editWorldParameters.Deactivate(false);
                    HelpOverlay.Pop();

                    if (EditWorldParameters.CameraSetMode)
                    {
                        parent.CurrentUpdateMode = UpdateMode.EditObject;
                    }
                    else if (EditWorldParameters.NextLevelMode)
                    {
                        parent.CurrentUpdateMode = UpdateMode.SelectNextLevel;
                    }
                    else if (shared.editWorldParameters.IsInProgrammingTileMode())
                    {
                        parent.CurrentUpdateMode = UpdateMode.EditObject;
                    }
                    else
                    {
                        parent.CurrentUpdateMode = UpdateMode.ToolMenu;
                    }

                    Instrumentation.StopTimer(timerInstrument);

                    base.Deactivate();
                }
            }
        }   // end of Activate()

        /// <summary>
        ///
        /// </summary>
        /// <param name="saveChanges">Should the updated values be saved out to the reflex?</param>
        public void Deactivate(bool saveChanges)
        {
            if (active)
            {
                brightnessSlider.Selected = false;
                durationSlider.Selected   = true;
                ledGrid.Selected          = false;
                bar.Selected = false;

                rightStickPosition = rightStickPositionBrightness;

                // Copy changes to reflex?
                if (saveChanges)
                {
                    // Push the current pattern back to the reflex.
                    pattern.LEDs = ledGrid.LEDs;
                    reflex.microbitPatterns[modifierIndex] = (MicroBitPattern)pattern.Clone();

                    // TODO Copy the duration to all the other pattern modifiers?
                }

                HelpOverlay.Pop();
                active = false;
            }
        }   // end of Deactivate()
Ejemplo n.º 3
0
        /// <summary>
        /// Override this to provide a place to clean up
        /// anything that needs it on a per-use basis.
        /// </summary>
        public virtual void OnDeactivate()
        {
            prevBrushIndex = shared.editBrushIndex;

            // Deactivate any pickers.
            if (PickerX != null)
            {
                PickerX.Active = false;
                PickerX        = null;
            }
            if (PickerY != null)
            {
                PickerY.Active = false;
                PickerY        = null;
            }

            inGame.ShowCursor();
            inGame.Cursor3D.Rep          = Cursor3D.Visual.Edit;
            inGame.Cursor3D.DiffuseColor = new Vector4(0.5f, 0.9f, 0.8f, 0.3f);

            inGame.Terrain.EndSelection();
            VirtualMap.SuppressWaterUpdate = false;

            shared.editBrushSizeActive = false;

            HelpOverlay.Pop();

            // Shut down all the terrain editing sounds just to be sure.
            Foley.StopPaint();
            Foley.StopEarthDown();
            Foley.StopEarthUp();
            Foley.StopEraseLand();
            Foley.StopLowerWater();
            Foley.StopRaiseWater();
        }
            }   // end of TopLevelPaletteUpdateObj Update()

            private void SetHelpOverlay()
            {
                HelpOverlay.Pop();
                switch (curMode)
                {
                case UpdateMode.RunSim:
                    HelpOverlay.Push("TopLevelPaletteRunSim");
                    break;

                case UpdateMode.EditObject:
                    HelpOverlay.Push("TopLevelPaletteEditObject");
                    break;

                case UpdateMode.ToolBox:
                    HelpOverlay.Push("TopLevelPaletteToolBox");
                    break;

                case UpdateMode.EditWorldParameters:
                    HelpOverlay.Push("TopLevelPaletteEditWorldParameters");
                    break;

                case UpdateMode.EditObjectParameters:
                    HelpOverlay.Push("TopLevelPaletteEditObjectParameters");
                    break;
                }
            }   // end of TopLevelPalette SetHelpOverlay()
Ejemplo n.º 5
0
        }   // and of Activate()

        public void Deactivate()
        {
            active  = false;
            diffuse = null;
            HelpOverlay.Pop();
            CommandStack.Pop(commandMap);
        }   // end of Deactivate()
Ejemplo n.º 6
0
            }   // end of RunSimUpdateObj Activate()

            public override void Deactivate()
            {
                if (active)
                {
                    active = false;

                    if (parent.cursorClone != null)
                    {
                        parent.cursorClone.Deactivate();
                        parent.cursorClone = null;
                    }
                    // Deactivate the PreGame if any.
                    if (parent.PreGame != null)
                    {
                        parent.PreGame.Active = false;
                    }

                    CommandStack.Pop(commandMap);
                    HelpOverlay.Pop();

                    Instrumentation.StopTimer(timerInstrument);

#if !NETFX_CORE
                    MicrobitManager.ReleaseDevices();
#endif

                    base.Deactivate();

                    //          ObjectAnalysis oa = new ObjectAnalysis();
                    //oa.beginAnalysis("out.txt");
                }
            }   // end of RunSimUpdateObj Deactivate()
Ejemplo n.º 7
0
        }   // end of Activate()

        public void Deactivate()
        {
            if (Active)
            {
                if (prevLanguage != XmlOptionsData.Language)
                {
                    changeLanguageMessage.Activate(useRtCoords: true);
                    grid.Active = true; // Keep grid active.
                    return;
                }

                grid.Active = false;
                HelpOverlay.Pop();      // Pop off the help overlay for the current options element.

                CommandStack.Pop(commandMap);
                HelpOverlay.Pop();      // Pop off the help for the options menu.

                // Prevent the button pressed from leaking into runtime.
                GamePadInput.IgnoreUntilReleased(Buttons.B);

                active = false;

                touched = (PlayerIndex)(-1);

                GamePadInput.ClearAllWasPressedState();

                MainMenu.Instance.LiveFeedDirty = true;
            }
        }   // end of Deactivate()
Ejemplo n.º 8
0
        }   // end of HandleMouseInput()

        public override void Update(PerspectiveUICamera camera)
        {
            if (Active)
            {
                if (Hidden)
                {
                    if (HelpOverlay.Peek() == (UseAltOverlay ? altHelpOverlay : helpOverlay))
                    {
                        HelpOverlay.Pop();
                    }
                }
                else
                {
                    if (Actions.MaterialFabric.WasPressed)
                    {
                        Actions.MaterialFabric.ClearAllWasPressedState();

                        FabricMode = true;
                        RefreshPositions();
                    }

                    if (Actions.MaterialCubic.WasPressed)
                    {
                        Actions.MaterialCubic.ClearAllWasPressedState();

                        FabricMode = false;
                        RefreshPositions();
                    }

                    HelpOverlay.ReplaceTop(UseAltOverlay ? altHelpOverlay : helpOverlay);
                }
            }

            base.Update(camera);
        }
Ejemplo n.º 9
0
 protected void SetOverlay(string overlay)
 {
     if (HelpOverlay.Peek() != overlay)
     {
         HelpOverlay.Pop();
         HelpOverlay.Push(overlay);
     }
 }
Ejemplo n.º 10
0
            }   // end of PreGameDesc Activate()

            protected override void Deactivate()
            {
                // Restart the game clock.
                //Time.Paused = false;
                Time.ClockRatio = 1.0f;

                HelpOverlay.Pop();

                base.Deactivate();
            }   // end of PreGameDesc Deactivate()
Ejemplo n.º 11
0
        override public void Deactivate()
        {
            if (state != States.Inactive)
            {
                HelpOverlay.Pop();

                pendingState             = States.Inactive;
                BokuGame.objectListDirty = true;
            }
        }
Ejemplo n.º 12
0
            }   // end of PreGameBase Activate()

            protected virtual void Deactivate()
            {
                CommandStack.Pop(commandMap);
                if (HelpOverlay.Peek() == "PreGame")
                {
                    HelpOverlay.Pop();
                }
                // If the pre-game has messed with the clock, restore it.
                Time.ClockRatio = 1.0f;
            }   // end of PreGameBase Deactivate()
Ejemplo n.º 13
0
            }   // end of EditWorldParametersUpdateObj Activate()

            public override void Deactivate()
            {
                if (active)
                {
                    HelpOverlay.Pop();

                    parent.CurrentUpdateMode = UpdateMode.EditWorldParameters;

                    base.Deactivate();
                }
            }
Ejemplo n.º 14
0
        }   // end of RoadTool Update()

        #endregion Public

        #region Internal
        protected override void SelectOverlay()
        {
            if (StretchGoing && rightTriggered)
            {
                HelpOverlay.Pop();
                HelpOverlay.Push(@"RoadToolRightTrig");
            }
            else
            {
                base.SelectOverlay();
            }
        }
Ejemplo n.º 15
0
            }   // end of TweakObjectUpdateObj Activate()

            public override void Deactivate()
            {
                base.Deactivate();

                ColorPalette.Active = false;
                RemoveAura();

                // Force the camera back to not having an offset.
                shared.camera.SetDefaultHeightOffset(shared.CursorPosition, 0.5f);

                shared.editWayPoint.Clear();

                HelpOverlay.Pop();
            } // end of TweakObjectUpdateObj Deactivate()
        }   // end of Activate()

        public void Deactivate()
        {
            if (active)
            {
                active = false;

                HelpOverlay.Pop();
                CommandStack.Pop(commandMap);
                if (onExit != null)
                {
                    onExit(this);
                }
            }
        }   // end of Deactivate()
Ejemplo n.º 17
0
        public void Deactivate()
        {
            if (active)
            {
                grid.Active = false;

                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Pop(commandMap);
                HelpOverlay.Pop();

                InGame.inGame.RenderWorldAsThumbnail = false;

                active = false;
            }
        }
Ejemplo n.º 18
0
        public void Deactivate()
        {
            if (active)
            {
                if (activeTool != null)
                {
                    activeTool.Active = false;
                }

                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Pop(commandMap);
                HelpOverlay.Pop();
                active = false;
            }
        }
Ejemplo n.º 19
0
        override public void Deactivate()
        {
            if (state != States.Inactive)
            {
                // Make sure VirutalKeyboard is also shut down.
                VirtualKeyboard.Deactivate();

                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Pop(commandMap);

                state = States.Inactive;

                HelpOverlay.Pop();

                updateObj.Deactivate();
            }
        }
            }   // end of PreGameRacingWithDesc Activate()

            protected override void Deactivate()
            {
                // Restart the game clock.
                //Time.Paused = false;
                Time.ClockRatio = 1.0f;

                texture1 = null;
                texture2 = null;
                texture3 = null;

                // We need to be sure this really needs popping.  It may be off already.
                if (HelpOverlay.Peek() == @"PreGameDescription")
                {
                    HelpOverlay.Pop();
                }

                base.Deactivate();
            }   // end of PreGameRacingWithDesc Deactivate()
Ejemplo n.º 21
0
        /// <summary>
        /// Override which overlay to be showing.
        /// </summary>
        protected override void SelectOverlay()
        {
            HelpOverlay.Pop();
            string helpStart = HelpOverlayStartID == null ? HelpOverlayID : HelpOverlayStartID;
            string helpGoing = HelpOverlayGoingID == null ? HelpOverlayID : HelpOverlayGoingID;

            if (rightTriggered)
            {
                HelpOverlay.Push(@"LevelToolRightTrig");
            }
            else
            if (StretchGoing)
            {
                HelpOverlay.Push(helpGoing);
            }
            else
            {
                HelpOverlay.Push(helpStart);
            }
        }
Ejemplo n.º 22
0
        }                    // end of Activate

        public void Deactivate()
        {
            if (state != States.Inactive)
            {
                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Pop(commandMap);

                state = States.Inactive;

                HelpOverlay.Pop();

                // Turn off thumbnail rendering if needed.
                if (!prevRenderWorldAsThumbnail)
                {
                    InGame.inGame.RenderWorldAsThumbnail = false;
                }
                Time.Paused = false;
            }
        }
Ejemplo n.º 23
0
        }   // end of Activate

        override public void Deactivate()
        {
            if (state != States.Inactive)
            {
                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Pop(commandMap);

                state = States.Inactive;
                if (shared.examplesGrid != null)
                {
                    shared.examplesGrid.Active = false;
                }

                InGame.inGame.RenderWorldAsThumbnail = false;

                HelpOverlay.Pop();

                Instrumentation.StopTimer(timerInstrument);
            }
        }
Ejemplo n.º 24
0
        protected void NavCard(int indexCard)
        {
            Debug.Assert(indexCard >= 0 && indexCard < listControls.Count);
            if (indexCard != this.indexActiveCard)
            {
                // Update help overlay.
                if (indexCard == 0)
                {
                    // Moving to the handle.
                    HelpOverlay.Pop();
                    // Decide which overlay to push...
                    if (ReflexPanel.CutPasteBuffer == null)
                    {
                        HelpOverlay.Push("RowHandleEmptyPasteBuffer");
                    }
                    else
                    {
                        HelpOverlay.Push("RowHandleFullPasteBuffer");
                    }
                }
                else if (indexActiveCard == 0 || indexActiveCard == -1)
                {
                    // Moving away from the handle OR moving to a newly created row.
                    HelpOverlay.Pop();
                    HelpOverlay.Push("Tile");
                }

                // update card state
                IControl card;
                if (this.indexActiveCard >= 0 && this.indexActiveCard < listControls.Count)
                {
                    card     = listControls[this.indexActiveCard] as IControl;
                    card.Hot = false;
                }
                this.indexActiveCard = indexCard;
                card     = listControls[this.indexActiveCard] as IControl;
                card.Hot = true;
            }
        }
Ejemplo n.º 25
0
        public override void Deactivate()
        {
            base.Deactivate();

            if (state != States.Inactive && pendingState != States.Inactive)
            {
                pendingState = States.Inactive;
                this.composedObjectPending = null;
                BokuGame.objectListDirty   = true;

                for (int i = 0; i < Count; ++i)
                {
                    GroupData groupData = this[i] as GroupData;
                    if (groupData != null)
                    {
                        UiSelector uiSelector = groupData.selectorGroup as UiSelector;
                        if (uiSelector != null)
                        {
                            uiSelector.Deactivate();
                        }
                    }
                }

                if (typePicker != null)
                {
                    typePicker.OnGetType     = holdOnGet;
                    typePicker.OnSetType     = holdOnSet;
                    typePicker.OnPickType    = holdOnPick;
                    typePicker.Active        = false;
                    typePicker.Hidden        = true;
                    typePicker.UseAltOverlay = false;
                    typePicker = null;
                }

                HelpOverlay.Pop();
            }
        }   // end of Deactivate()
Ejemplo n.º 26
0
        override public void Deactivate()
        {
            if (state != States.Inactive && pendingState != States.Inactive)
            {
                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Pop(commandMap);
                HelpOverlay.Pop();
                shared.menu.Active = false;

                pendingState             = States.Inactive;
                BokuGame.objectListDirty = true;

                InGame.inGame.RenderWorldAsThumbnail = false;

                Instrumentation.StopTimer(timerInstrument);

                Foley.StopMenuLoop();

                Time.Paused = false;

                AuthUI.HideAllDialogs();
            }
        }
Ejemplo n.º 27
0
            }   // end of RunSimUpdateObj c'tor

            /// <summary>
            /// RunSimUpdateObj Update()
            /// </summary>
            /// <param name="camera"></param>
            public override void Update()
            {
                base.Update();

                parent.Camera.Update();

                float secs = Time.WallClockFrameSeconds;

                ThoughtBalloonManager.Update(shared.camera);
                SaidStringManager.Update();
#if !NETFX_CORE
                MicrobitManager.Update();
#endif

                // Start with visible cursor.
                parent.cursor3D.Activate();
                parent.cursor3D.Rep    = Cursor3D.Visual.RunSim;
                parent.cursor3D.Hidden = false;

                //
                // Determine the correct camera mode.
                //

                //
                //  The priorities used to determine the camera mode when the game is running are:
                //
                //  1)  First person.  This can be either via programming or because the user zoomed
                //      into a bot the camera was following.
                //  2)  Follow mode caused by bot(s) programmed with "follow" camera view.
                //  3)  World tweak screen fixed camera or fixed offset camera.
                //  4)  Follow mode caused by user controlled bot(s).
                //  5)  Free camera.
                //

                // Start with a fake loop to break out of.
                while (true)
                {
                    Terrain terrain = InGame.inGame.Terrain;    // Just a shortcut.

                    //
                    // Always use edit mode when the game is paused except during victory on level with one of the fixed cameras
                    // or when game is paused for a bot to speak (modal text display).
                    //
                    bool victoryActive = VictoryOverlay.ActiveGameOver || VictoryOverlay.ActiveWinner;
                    bool speaking      = InGame.inGame.shared.smallTextDisplay.Active || InGame.inGame.shared.scrollableTextDisplay.Active;
                    if (Time.Paused && !((terrain.FixedCamera || terrain.FixedOffsetCamera) && victoryActive) && !speaking)
                    {
                        CameraInfo.Mode = CameraInfo.Modes.Edit;
                        CameraInfo.CameraFocusGameActor = null;
                        break;
                    }

                    //
                    // 1) First person
                    //
                    if (CameraInfo.FirstPersonActive)
                    {
                        CameraInfo.Mode = CameraInfo.Modes.Actor;

                        // We're following a single actor so update the FollowActor camera values.
                        shared.camera.FollowCameraValid = false;

                        // Turn off 3d cursor since we don't need it.
                        parent.cursor3D.Deactivate();
                        if (parent.cursorClone != null)
                        {
                            parent.cursorClone.Deactivate();
                            parent.cursorClone = null;
                        }
                        break;
                    }

                    //
                    // 2)  Follow mode caused by bot(s) programmed with "follow" camera view.
                    //
                    if (CameraInfo.ProgrammedFollowList.Count > 0)
                    {
                        // Note that even though we looked at the count of bot programmed to
                        // have the camera follow them, for this mode we want to keep all
                        // deserving bots in camera.  So, the rest of this section will use
                        // the merged follow list instead of just the programmed follow list.

                        SetUpCameraFollowMode();

                        break;
                    }

                    //
                    // 3) World tweak fixed cameras.  Note for fixed offset we have to let
                    //    the later modes do their stuff and then override the camera.
                    //

                    if (terrain.FixedCamera)
                    {
                        CameraInfo.Mode = CameraInfo.Modes.FixedTarget;
                        CameraInfo.CameraFocusGameActor = null;

                        // Turn off 3d cursor since we don't need it.
                        parent.cursor3D.Deactivate();
                        if (parent.cursorClone != null)
                        {
                            parent.cursorClone.Deactivate();
                            parent.cursorClone = null;
                        }

                        break;
                    }

                    //
                    // 4) Follow mode caused by user controlled bot(s).
                    //
                    if (CameraInfo.MergedFollowList.Count > 0)
                    {
                        SetUpCameraFollowMode();

                        break;
                    }

                    //
                    // 5) Free!
                    //
                    // Not following an actor.
                    CameraInfo.Mode = CameraInfo.Modes.Edit;
                    CameraInfo.CameraFocusGameActor = null;

                    // Turn on 3d cursor in case we previously disabled it.
                    parent.cursor3D.Activate();
                    parent.CreateCursorClone();
                    parent.cursor3D.Hidden = false;

                    // We have no camera restrictions, so keep track of what the user is doing.
                    shared.camera.PlayValid      = true;
                    shared.camera.PlayCameraFrom = shared.camera.From;
                    shared.camera.PlayCameraAt   = shared.camera.At;

                    shared.camera.FollowCameraValid = false;


                    // Final break just to be sure the loop exits.
                    break;
                }

                //
                // Now that we're done, we need to check again to see if
                // we should be in FixedOffsetMode.
                //
                if (!Time.Paused && InGame.inGame.Terrain.FixedOffsetCamera && !CameraInfo.FirstPersonActive)
                {
                    CameraInfo.Mode = CameraInfo.Modes.FixedOffset;
                }

                // Zero out any offset while running.
                float t = Math.Min(Time.GameTimeFrameSeconds, 1.0f);
                shared.camera.HeightOffset = MyMath.Lerp(shared.camera.HeightOffset, 0.0f, t);

                //
                bool inputFocus = CommandStack.Peek() == commandMap;

                // Move the camera.
                switch (CameraInfo.Mode)
                {
                case CameraInfo.Modes.Edit:
                    MoveCameraEditMode(inputFocus, false);
                    break;

                case CameraInfo.Modes.Actor:
                    MoveCameraActorMode(true, false);
                    break;

                case CameraInfo.Modes.FixedTarget:
                    MoveCameraFixedTargetMode(inputFocus);
                    break;

                case CameraInfo.Modes.FixedOffset:
                    MoveCameraFixedOffsetMode(inputFocus);
                    break;

                case CameraInfo.Modes.MultiTarget:
                    MoveCameraMultiTargetMode(inputFocus, false);
                    break;
                }

                shared.camera.Update();

                // Update terrain.
                parent.terrain.Update(shared.camera);

                // Update the list of objects using our local camera.
                for (int i = 0; i < updateList.Count; i++)
                {
                    UpdateObject obj = (UpdateObject)updateList[i];
                    obj.Update();
                }
                parent.UpdateObjects();

                /// Pregame must update after parent.UpdateObjects, in case it
                /// decides to switchToMiniHub
                if (InGame.inGame.preGame != null)
                {
                    InGame.inGame.preGame.Update();
                }

                // Update the particle system.
                shared.particleSystemManager.Update();
                DistortionManager.Update();
                FirstPersonEffectMgr.Update();

                // This must be done after all brains are updated.
                Scoreboard.Update(shared.camera);

                // Update the TextDisplays.  Ignored if not active.
                shared.scrollableTextDisplay.Update(shared.camera);
                shared.smallTextDisplay.Update(shared.camera);

                VictoryOverlay.Update();

                // Do the input processing after object update because there will be order of operation issue if we don't
                //
                // Check if we have input focus.  Don't do any input
                // related update if we don't.
                if (inputFocus)
                {
                    // Grab the current state of the gamepad.
                    GamePadInput pad = GamePadInput.GetGamePad0();

                    // Switch to Mini-Hub?
                    if (Actions.MiniHub.WasPressed)
                    {
                        Actions.MiniHub.ClearAllWasPressedState();

                        //parent.ResetSim(CurrentLevelFilename());

                        // Needed to make sure that deactivated objects are actually removed from
                        // the list otherwise they may get saved along with the newly activated ones.
                        //parent.Refresh(BokuGame.gameListManager.updateList, BokuGame.gameListManager.renderList);

                        parent.SwitchToMiniHub();
                        return;
                    }

                    //handle swipe to return to edit for touch input
                    if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                    {
                        SwipeGestureRecognizer swipeGesture = TouchGestureManager.Get().SwipeGesture;
                        if (swipeGesture.WasRecognized &&
                            swipeGesture.SwipeDirection == Directions.North)
                        {
#if NETFX_CORE
                            float halfWidth = (float)BokuGame.bokuGame.Window.ClientBounds.Width * 0.5f;
                            float height    = (float)BokuGame.bokuGame.Window.ClientBounds.Height;
#else
                            float halfWidth = (float)XNAControl.Instance.ClientSize.Width * 0.5f;
                            float height    = (float)XNAControl.Instance.ClientSize.Height;
#endif

                            //center half of the screen width-wise
                            float minX = halfWidth - (halfWidth * k_TouchExitAreaWidthPercent);
                            float maxX = halfWidth + (halfWidth * k_TouchExitAreaWidthPercent);

                            //bottom 20% height-wise
                            float minY = height - (height * k_TouchExitAreaHeightPercent);


                            Vector2 pos = swipeGesture.InitialPosition;
                            if (pos.X >= minX && pos.X <= maxX && pos.Y >= minY)
                            {
                                // User did a swipe from the bottom of the screen, enter edit mode
                                InGame.inGame.CurrentUpdateMode = UpdateMode.EditObject;
                                InGame.inGame.CurrentUpdateMode = UpdateMode.TouchEdit;

                                Foley.PlayPressStart();
                                return;
                            }
                        }

                        // HACKHACK (****) Put in a tap recognizer since swipe seems to fail.
                        {
                            TapGestureRecognizer hackTapGesture = TouchGestureManager.Get().TapGesture;
                            if (hackTapGesture.WasTapped())
                            {
#if NETFX_CORE
                                float halfWidth = (float)BokuGame.bokuGame.Window.ClientBounds.Width * 0.5f;
                                float height    = (float)BokuGame.bokuGame.Window.ClientBounds.Height;
#else
                                float halfWidth = (float)XNAControl.Instance.ClientSize.Width * 0.5f;
                                float height    = (float)XNAControl.Instance.ClientSize.Height;
#endif

                                //center area of the screen width-wise
                                float minX = halfWidth - (halfWidth * 0.1f);
                                float maxX = halfWidth + (halfWidth * 0.1f);

                                //bottom 10% height-wise
                                float minY = height - (height * 0.1f);

                                Vector2 pos = hackTapGesture.Position;
                                if (pos.X >= minX && pos.X <= maxX && pos.Y >= minY)
                                {
                                    // User did a tap on the bottom of the screen, enter edit mode
                                    InGame.inGame.CurrentUpdateMode = UpdateMode.EditObject;
                                    InGame.inGame.CurrentUpdateMode = UpdateMode.TouchEdit;

                                    Foley.PlayPressStart();
                                    return;
                                }
                            }
                        }
                    }

                    bool gameOver = VictoryOverlay.GameOver;

                    if (Time.Paused && !gameOver)
                    {
                        // We must be in user induced pause mode.
                        if (Actions.Unpause.WasPressed)
                        {
                            Actions.Unpause.ClearAllWasPressedState();

                            Time.Paused = false;
                            HelpOverlay.Pop();
                        }
                    }
                    else
                    {
                        if (gameOver)
                        {
                            // Game over man!  Let the user restart if they want.
                            if (Actions.Restart.WasPressed)
                            {
                                Actions.Restart.ClearAllWasPressedState();

                                InGame.inGame.ResetSim(preserveScores: false, removeCreatablesFromScene: true, keepPersistentScores: false);
                                // Since we're going right back into RunSim mode we need to first inline.
                                ApplyInlining();
                            }
                        }

                        // Open ToolMenu.
                        if (Actions.ToolMenu.WasPressed)
                        {
                            Actions.ToolMenu.ClearAllWasPressedState();

                            parent.CurrentUpdateMode = UpdateMode.ToolMenu;
                            Foley.PlayPressStart();
                            return;
                        }

                        // Pause?
                        // We want to make pause hard to get into so it requires both triggers and both stickButtons to be pressed.
                        if ((pad.LeftStickButton.IsPressed && pad.RightStickButton.IsPressed && pad.LeftTriggerButton.IsPressed && pad.RightTriggerButton.IsPressed) || Actions.Pause.WasPressed)
                        {
                            Actions.Pause.ClearAllWasPressedState();

                            if (!Time.Paused)
                            {
                                Time.Paused = true;
                                HelpOverlay.Push("PauseGame");
                                GamePadInput.GetGamePad0().IgnoreLeftStickUntilZero();
                                GamePadInput.GetGamePad0().IgnoreRightStickUntilZero();
                            }
                        }
                    }
                }

                // Force the the HelpOverlay to be correct.
                if (!Time.Paused || VictoryOverlay.Active)
                {
                    if (InGame.inGame.PreGame != null && InGame.inGame.PreGame.Active)
                    {
                        if (HelpOverlay.Depth() != 1 || HelpOverlay.Peek() != "RunSimulationPreGame")
                        {
                            HelpOverlay.Clear();
                            HelpOverlay.Push("RunSimulationPreGame");
                        }
                    }
                    else
                    {
                        if (HelpOverlay.Depth() != 1 || HelpOverlay.Peek() != "RunSimulation")
                        {
                            HelpOverlay.Clear();
                            HelpOverlay.Push("RunSimulation");
                        }
                    }
                }
                else
                {
                    // We're paused.
                    if (HelpOverlay.Depth() != 2 || HelpOverlay.Peek(1) != "RunSimulation")
                    {
                        HelpOverlay.Clear();
                        HelpOverlay.Push("RunSimulation");
                        HelpOverlay.Push("PauseGame");
                    }
                }

                // When in run mode, allow the user to click on the "Press [esc] to edit" text as if it was a button.
                if (MouseInput.Left.WasPressed)
                {
                    Point mousePos = MouseInput.Position;
                    if (HelpOverlay.MouseHitBottomText(mousePos))
                    {
                        // Switch to edit mode.
                        InGame.inGame.CurrentUpdateMode = UpdateMode.EditObject;
                    }
                }
                TapGestureRecognizer tapGesture = TouchGestureManager.Get().TapGesture;
                if (tapGesture.WasTapped())
                {
                    // JW - Until we have proper Touch help overlays, we are still using the mouse/keyboard
                    // overlays. The mouse handling code for these depends on being able to 'absorb' pressed
                    // info to hide it from later callers. Our touch stuff doesn't (and really shouldn't)
                    // do this. So, we handle cases here based on what type of overlay is being displayed.
                    if (HelpOverlay.Peek() == "RunSimulationPreGame")
                    {
                        // Tap during instructions: just begin game.
                        InGame.inGame.PreGame.Active = false;
                    }

                    // Also test if running sim for tapping on "tap to edit" at bottom.
                    if (HelpOverlay.Peek() == "RunSimulation")
                    {
                        Point pos = new Point((int)tapGesture.Position.X, (int)tapGesture.Position.Y);
                        if (HelpOverlay.MouseHitBottomText(pos))
                        {
                            // Switch to edit mode.
                            InGame.inGame.CurrentUpdateMode = UpdateMode.EditObject;
                        }
                    }
                }
            }   // end of RunSimUpdateObj Update()
            }   // end of PreGameRacingWithDesc c'tor

            public override void Update()
            {
                if (Active)
                {
                    if (showingDescription)
                    {
                        // Waiting for A to be pressed.
                        if (Actions.Select.WasPressed)
                        {
                            Actions.Select.ClearAllWasPressedState();

                            showingDescription = false;
                            startTime          = Time.WallClockTotalSeconds;
                            HelpOverlay.Pop();

                            // Don't let current pressed state leak into game.
                            GamePadInput.IgnoreUntilReleased(Buttons.A);
                        }

                        if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                        {
                            // Check if user click on bottom text.
                            if (MouseInput.Left.WasPressed && HelpOverlay.MouseHitBottomText(MouseInput.Position))
                            {
                                showingDescription = false;
                                startTime          = Time.WallClockTotalSeconds;
                                HelpOverlay.Pop();

                                MouseInput.Left.ClearAllWasPressedState();
                            }
                        }

                        if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                        {
                            // Check if user click on bottom text.
                            if (TouchGestureManager.Get().TapGesture.WasTapped() &&
                                HelpOverlay.MouseHitBottomText(TouchInput.GetAsPoint(TouchInput.GetOldestTouch().position))
                                )
                            {
                                showingDescription = false;
                                startTime          = Time.WallClockTotalSeconds;
                                HelpOverlay.Pop();
                            }
                        }
                    }
                    else
                    {
                        int oldPhase = phase;
                        phase = (int)Math.Ceiling(startTime + duration - Time.WallClockTotalSeconds);
                        if (oldPhase != phase)
                        {
                            if ((phase < cueNames.Length) && (phase >= 0))
                            {
                                BokuGame.Audio.GetCue(cueNames[phase]).Play();
                            }
                        }
                        if (Time.WallClockTotalSeconds > startTime + duration)
                        {
                            // We're done.
                            Active = false;
                        }

                        // Check if user click on bottom text.
                        if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                        {
                            // Check if user click on bottom text.
                            if (TouchGestureManager.Get().TapGesture.WasTapped() &&
                                HelpOverlay.MouseHitBottomText(TouchInput.GetAsPoint(TouchInput.GetOldestTouch().position))
                                )
                            {
                                Active = false;
                            }
                        }
                        else if (MouseInput.Left.WasPressed && HelpOverlay.MouseHitBottomText(MouseInput.Position))
                        {
                            Active = false;
                            MouseInput.Left.ClearAllWasPressedState();
                        }
                    }
                }

                base.Update();
            }   // end of PreGameRacingWithDesc Update()
Ejemplo n.º 29
0
            public override void Update()
            {
                // Check for input focus.
                if (commandMap == CommandStack.Peek())
                {
                    GamePadInput pad = GamePadInput.GetGamePad0();

                    if (Actions.Select.WasPressed)
                    {
                        Actions.Select.ClearAllWasPressedState(3);

                        parent.MoveReflex(null, null);
                    }

                    /*
                     * // Replaced w/ auto blank line feature.
                     * if(pad.ButtonY.WasPressed)
                     * {
                     *  parent.InsertReflex(null, null);
                     *
                     *  GamePadInput.ClearAllWasPressedState(3);
                     * }
                     */

                    // Cut.
                    if (Actions.Cut.WasPressed)
                    {
                        Actions.Cut.ClearAllWasPressedState(3);

                        reflexBlock.Init(this.parent.LineNumber - 1);
                        reflexBlock.Cut();
                    }

                    // Copy
                    if (Actions.X.WasPressed)
                    {
                        Actions.X.ClearAllWasPressedState();

                        // Update the cut/paste buffer with the current ReflexData.
                        reflexBlock.Init(this.parent.LineNumber - 1);
                        reflexBlock.Copy();

                        HelpOverlay.Pop();
                        if (ReflexPanel.CutPasteBuffer == null)
                        {
                            HelpOverlay.Push("RowHandleEmptyPasteBuffer");
                        }
                        else
                        {
                            HelpOverlay.Push("RowHandleFullPasteBuffer");
                        }
                    }

                    // Paste
                    if (Actions.Paste.WasPressed)
                    {
                        Actions.Paste.ClearAllWasPressedState(3);

                        reflexBlock.Init(this.parent.LineNumber - 1);
                        reflexBlock.Paste();
                    }
                }   // end of if we have input focus.

                // Ensure the reflex has the correct indent.
                //ReflexPanel curPanel = (ReflexPanel)parent.parent;
                //curPanel.AnimatePanelIndent(false);
            }   // end of Update()
Ejemplo n.º 30
0
 public override void Deactivate()
 {
     CommandStack.Pop(commandMap);
     HelpOverlay.Pop();
 }