Пример #1
0
        private TapResult singleTapRemoveComponentMenu(Vector2 tapLocation, ref ActorManager gameActorMgr)
        {
            TapResult menuResult = removeMenu.HandleSingleTap(tapLocation);

            if (menuResult == TapResult.removeComponent)
            {
                this.hideRemoveComponentMenu();
                ComponentType removedComponent = gameActorMgr.RemoveCurrentComponent();
                addMenu.ComponentRemovedFromStage(removedComponent);
                return TapResult.removeComponent;
            }

            if (menuResult == TapResult.closedMenu)
            {
                this.hideRemoveComponentMenu();
            }

            if (menuResult == TapResult.spinLeft)
            {
                /*Rotate 45° counter-clockwise*/
                gameActorMgr.RotateCurrentComponent(45f);
                return menuResult;
            }
            else if (menuResult == TapResult.spinRight)
            {
                /*Rotate 45° clockwise*/
                gameActorMgr.RotateCurrentComponent(-45f);
                return menuResult;
            }

            return TapResult.tappedNothing;
        }
Пример #2
0
        private TapResult singleTapAddComponentMenu(Vector2 tapLocation, ref ActorManager gameActorMgr)
        {
            TapResult menuResult = addMenu.handleSingleTap(tapLocation);

            if (menuResult == TapResult.addComponent)
            {
                // hide the addComponent menu.
                this.hideAddComponentMenu();
                MachineComponent newComponent = addMenu.getNewComponent();
                gameActorMgr.AddComponent(newComponent);

                // zoom the view in.
                FinalGame.zoomIn();
                this.zoomButton.Label = "Zoom-Out";
            }

            return menuResult;
        }
Пример #3
0
        private TapResult singleTapNoMenuState(Vector2 tapLocation, ref ActorManager gameActorMgr)
        {
            TapResult result = TapResult.tappedNothing;

            // test to see if the tapLocation touched any of the buttons in the hudbar.
            float tapY = tapLocation.Y;
            float tapX = tapLocation.X;

            float componentTop = componentsButton.CenterY + componentsButton.Height / 2;
            float componentBottom = componentsButton.CenterY - componentsButton.Height / 2;
            float componentLeft = componentsButton.CenterX - componentsButton.Width / 2;
            float componentRight = componentsButton.CenterX + componentsButton.Width / 2;

            // did user touch outside componentsButton button?
            if (tapY > componentTop || tapY < componentBottom || tapX < componentLeft || tapX > componentRight)
            {
                //removeButtonState = false;
            }
            else
            {
                //this.remove.Color = Color.Green;
                if (FinalGame.allowMovement == true)
                {
                    this.showAddComponentMenu();
                }

                result = TapResult.addComponent;
                return result;
            }

            float zoomTop = zoomButton.CenterY + zoomButton.Height / 2;
            float zoomBottom = zoomButton.CenterY - zoomButton.Height / 2;
            float zoomLeft = zoomButton.CenterX - zoomButton.Width / 2;
            float zoomRight = zoomButton.CenterX + zoomButton.Width / 2;

            // did user touch outside zoomButton button?
            if (tapY > zoomTop || tapY < zoomBottom || tapX < zoomLeft || tapX > zoomRight)
            {
                //removeButtonState = false;
            }
            else
            {
                if (FinalGame.allowMovement == true)
                {
                    FinalGame.ToggleZoom();

                    // toggle visible text.
                    if (zoomButton.Label == "Zoom-In")
                    {
                        zoomButton.Label = "Zoom-Out";
                    }
                    else
                    {
                        zoomButton.Label = "Zoom-In";
                    }

                    result = TapResult.zoom;
                    return result;
                }
            }

            float goStopTop = goStopButton.CenterY + goStopButton.Height / 2;
            float goStopBottom = goStopButton.CenterY - goStopButton.Height / 2;
            float goStopLeft = goStopButton.CenterX - goStopButton.Width / 2;
            float goStopRight = goStopButton.CenterX + goStopButton.Width / 2;

            // did user touch outside goStopButton button?
            if (tapY > goStopTop || tapY < goStopBottom || tapX < goStopLeft || tapX > goStopRight)
            {
                // do nothing.
            }
            else
            {
                // zoom out view
                FinalGame.zoomOut();
                this.zoomButton.Label = "Zoom-In";

                // start spawner
                gameActorMgr.ToggleSpawner();

                // toggle button art.
                if (goStopButton.Texture == "goButton")
                {
                    goStopButton.Texture = "stopButton";
                    goStopButton.Label = "STOP";
                    goStopButton.LabelColor = Color.White;
                }
                else
                {
                    goStopButton.Texture = "goButton";
                    goStopButton.Label = "GO";
                    goStopButton.LabelColor = Color.White;
                }

                result = TapResult.goStop;
                return result;
            }

            return result;
        }
Пример #4
0
 private TapResult dblTapNoMenuState(Vector2 tapLocation, ref ActorManager gameActorMgr)
 {
     return TapResult.tappedNothing;
     // do nothing...
 }
Пример #5
0
        // handle when the user has single-tapped on the screen.
        public TapResult HandleSingleTap(Vector2 tapLocation, ref ActorManager gameActorMgr)
        {
            tapLocation = screenToWorld(tapLocation);

            switch (this.currentState)
            {
                case (InGameMenuState.noMenu):
                    return this.singleTapNoMenuState(tapLocation, ref gameActorMgr);
                    break; //Is break really needed when we're returning? --Tony
                case (InGameMenuState.addComponentMenu):
                    return this.singleTapAddComponentMenu(tapLocation, ref gameActorMgr);
                    break;
                case (InGameMenuState.removeComponentMenu):
                    return this.singleTapRemoveComponentMenu(tapLocation, ref gameActorMgr);
                    break;
                default:
                    return TapResult.tappedNothing;
            }
        }
Пример #6
0
        // handle when the user has double-tapped on the screen.
        public void handleDoubleTap(Vector2 tapLocation, ref ActorManager gameActorMgr)
        {
            tapLocation = screenToWorld(tapLocation);

            switch (this.currentState)
            {
                case (InGameMenuState.noMenu):
                    this.dblTapNoMenuState(tapLocation, ref gameActorMgr);
                    break;
                case (InGameMenuState.addComponentMenu):
                    this.dblTapAddComponentMenu(tapLocation);
                    break;
                case (InGameMenuState.removeComponentMenu):
                    this.dblTapRemoveComponentMenu(tapLocation);
                    break;
            }
        }
Пример #7
0
        internal void UnloadLevel()
        {
            background.RemoveFromAutoDrawSet();

            // remove environment objects, components, spawner(and coins), receptacle...
            levelActorMgr.Unload();
            levelActorMgr = null;
        }
Пример #8
0
        internal void InitializeLevel()
        {
            XNACS1Base.World.SetWorldCoordinate(Vector2.Zero, width);

            hardCodedLevelNumber = levelNumber;

            background = new XNACS1Rectangle(
               new Vector2(XNACS1Base.World.WorldDimension.X / 2, (XNACS1Base.World.WorldDimension.Y / 2) - (XNACS1Base.World.WorldDimension.Y * HudBar.hudSize / 2)),
               XNACS1Base.World.WorldDimension.X, XNACS1Base.World.WorldDimension.Y - (XNACS1Base.World.WorldDimension.Y * HudBar.hudSize), backgroundImage);
            //background.RemoveFromAutoDrawSet();
            //background.AddToAutoDrawSet();
            levelActorMgr = new ActorManager(background.Width, background.Height, hardCodedLevelNumber);

            switch (hardCodedLevelNumber)
            {
                case 0:
                    buildLevelOne();
                    break;
                case 1:
                    buildLevelTwo();
                    break;
                case 2:
                    buildLevelThree();
                    break;
                case 3:
                    buildLevelFour();
                    break;
            }
        }