public InputManager(GameScene scene)
 {
     SetScene(scene);
     keyMgr = new KeyManager(scene);
     ptrMgr = new PointerManager(scene);
     pad = new GamePad();
 }
Esempio n. 2
0
 private void SetScene(GameScene scene)
 {
     this.scene = scene;
     if(scene.kind == Scene.LOAD){
         load = (LoadScene)scene;
     }else if (scene.kind == Scene.INTRO){
         intro = (IntroScene)scene;
     }else if(scene.kind == Scene.ACTION){
         action = (ActionScene)scene;
     }else if(scene.kind == Scene.EDITOR){
         editor = (EditorScene)scene;
     }
 }
Esempio n. 3
0
        public void Query(GameScene scene)
        {
            //Gets Input
            if (TouchPanel.GetCapabilities().IsConnected){
                TouchCollection coll = TouchPanel.GetState();
                oldState = currentState;
                bool[] tempState = new bool[9];
                foreach (TouchLocation loc in coll){
                    bool touchDPad = (Global.Distance(DPadCenter, loc.Position) <= DPadRect.Width / 2f);
                    if (touchDPad && (loc.Position.Y < -Math.Abs(loc.Position.X - DPadCenter.X) + DPadCenter.Y)) tempState[0] = true;
                    if (touchDPad && (loc.Position.Y > Math.Abs(loc.Position.X - DPadCenter.X) + DPadCenter.Y)) tempState[1] = true;
                    if (touchDPad && (loc.Position.X < -Math.Abs(loc.Position.Y - DPadCenter.Y) + DPadCenter.X)) tempState[2] = true;
                    if (touchDPad && (loc.Position.X > Math.Abs(loc.Position.Y - DPadCenter.Y) + DPadCenter.X)) tempState[3] = true;
                    if (Global.Distance(ACenter, loc.Position) <= ARect.Width / 2f) tempState[4] = true;
                    if (Global.Distance(BCenter, loc.Position) <= BRect.Width / 2f) tempState[5] = true;
                    if (loc.Position.X >= EnterRect.X && loc.Position.X < EnterRect.X + EnterRect.Width && loc.Position.Y >= EnterRect.Y && loc.Position.Y < EnterRect.Y + EnterRect.Height) tempState[6] = true;
                    if (loc.Position.X >= AltRect.X && loc.Position.X < AltRect.X + AltRect.Width && loc.Position.Y >= AltRect.Y && loc.Position.Y < AltRect.Y + AltRect.Height) tempState[7] = true;
                    if (loc.Position.X >= HomeRect.X && loc.Position.X < HomeRect.X + EnterRect.Width && loc.Position.Y >= HomeRect.Y && loc.Position.Y < HomeRect.Y + HomeRect.Height) tempState[8] = true;
                }
                currentState = tempState;
            }
            //Query for it here...
            if (scene.kind == Scene.INTRO){
            }else if(scene.kind == Scene.ACTION){
                ActionScene action = (ActionScene)scene;
                if (currentState[(int)Buttons.Up]){
                    if (action.mode == ActionScene.Mode.OVERWORLD){
                            action.tileMap.player.Move(Model.Entities.Terrain.Tile.Direction.NORTH);
                    }else if (action.mode == ActionScene.Mode.BATTLE)
                        action.battleMap.GetPlayer().Move(Model.Entities.Terrain.Tile.Direction.NORTH);
                }else if (currentState[(int)Buttons.Down]){
                    if (action.mode == ActionScene.Mode.OVERWORLD){
                            action.tileMap.player.Move(Model.Entities.Terrain.Tile.Direction.SOUTH);
                    }else if (action.mode == ActionScene.Mode.BATTLE)
                        action.battleMap.GetPlayer().Move(Model.Entities.Terrain.Tile.Direction.SOUTH);
                }else if (currentState[(int)Buttons.Left]){
                    if (action.mode == ActionScene.Mode.OVERWORLD)
                        action.tileMap.player.Move(Model.Entities.Terrain.Tile.Direction.WEST);
                    else if (action.mode == ActionScene.Mode.BATTLE)
                        action.battleMap.GetPlayer().Move(Model.Entities.Terrain.Tile.Direction.WEST);
                }
                else if (currentState[(int)Buttons.Right]){
                    if (action.mode == ActionScene.Mode.OVERWORLD)
                        action.tileMap.player.Move(Model.Entities.Terrain.Tile.Direction.EAST);
                    else if (action.mode == ActionScene.Mode.BATTLE)
                        action.battleMap.GetPlayer().Move(Model.Entities.Terrain.Tile.Direction.EAST);
                }
                else{
                    if (action.mode == ActionScene.Mode.BATTLE)
                        action.battleMap.GetPlayer().MoveReleased();
                }
                if (!oldState[(int)Buttons.Down] && currentState[(int)Buttons.Down]){
                    if (action.dialog.visible){
                        if (action.dialog.options != null)
                            if (action.dialog.optionCursor >= action.dialog.options.Length - 1)
                                action.dialog.optionCursor = 0;
                            else
                                action.dialog.optionCursor++;
                    }
                }
                if (!oldState[(int)Buttons.Up] && currentState[(int)Buttons.Up]){
                    if (action.dialog.visible){
                        if (action.dialog.options != null)
                            if (action.dialog.optionCursor <= 0)
                                action.dialog.optionCursor = action.dialog.options.Length - 1;
                            else
                                action.dialog.optionCursor--;
                    }
                }
                if (!oldState[(int)Buttons.A] && currentState[(int)Buttons.A]){
                    if (action.mode == ActionScene.Mode.OVERWORLD){
                        action.tileMap.player.AButton();
                    }
                }
                if (currentState[(int)Buttons.B]){

                }
                if (currentState[(int)Buttons.Enter]){
                    if (action.mode == ActionScene.Mode.OVERWORLD)
                        action.tileMap.SetLighting(true);
                    else if (action.mode == ActionScene.Mode.BATTLE)
                        action.battleMap.SetNightTime(true);
                }
                if (currentState[(int)Buttons.Alt]){
                    if (action.mode == ActionScene.Mode.OVERWORLD)
                        action.tileMap.SetLighting(false);
                    else if (action.mode == ActionScene.Mode.BATTLE)
                        action.battleMap.SetNightTime(false);
                }
                if (currentState[(int)Buttons.Home]){
                }
            }
            else if(scene.kind == Scene.LOAD){
            }else if(scene.kind == Scene.EDITOR){
            }
        }
 public void SwitchScenes(GameScene newScene)
 {
     SetScene(newScene);
 }
 public PointerManager(GameScene scene)
 {
     SetScene(scene);
     lastPos = new Vector2(0.0f);
 }
Esempio n. 6
0
 public KeyManager(GameScene scene)
 {
     SetScene(scene);
 }
 public void SwitchScenes(GameScene newScene)
 {
     SetScene(newScene);
     keyMgr.SwitchScenes(newScene);
     ptrMgr.SwitchScenes(newScene);
 }
 public void SwitchScenes(Scene newScene)
 {
     SoundEffect s = contentManager.Load<SoundEffect>("Audio/SFX/switch");
     s.Play();
     if (scene.kind != newScene){
         scene.Stop();
         scene.Suspend();
         if (newScene == Scene.LOAD){
             scene = load;
         }else if (newScene == Scene.INTRO){
             scene = intro;
         }else if (newScene == Scene.ACTION){
             scene = action;
         }else if (newScene == Scene.EDITOR){
             scene = editor;
         }
         scene.running = true;
         scene.Activate();
         input.SwitchScenes(scene);
     }
 }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Set the sharing mode of the graphics device to turn on XNA rendering
            SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(true);
            spriteBatch = new SpriteBatch(SharedGraphicsDeviceManager.Current.GraphicsDevice);
            Global.GraphicsDevice = spriteBatch.GraphicsDevice;
            SetWindowSize();

            load = new LoadScene(this);
            scene = load;
            load.Initialize();
            load.running = true;

            timer.Start();
            base.OnNavigatedTo(e);
        }