Example #1
0
        public Game(int _tileSize, Vector2 _worldSize, Viewport viewport, UI _ui, bool _visible)
            : base(_visible)
        {
            CollisionTile = Red;
            StartTile = Blue;
            TriggerTile = Pink;
            GoalTile = Green;
            MiscleanousTile = Yellow;
            EffectTile = Orange;
            InteractTile = Cyan;
            EnemyTile = Purple;
            ItemTile = Brown;

            tileSize = _tileSize;
            worldSize = _worldSize;
            camera = new Camera(viewport, new Rectangle(0, 0, (int)worldSize.X * tileSize, (int)worldSize.Y * tileSize));
            tileManager = new GameTileManager(tileSize);
            tileManager.NewWorld(tileSize, new Vector2(worldSize.X, worldSize.Y));
            km = new KeyboardManager();

            ui = _ui;
            ui.SetTileSheet(tileManager.GetTileSheet());
            ui.GameUI();
        }
Example #2
0
 public void Input()
 {
     KeyboardManager km = new KeyboardManager();
     if (pressedKey == false && Keyboard.GetState().GetPressedKeys().Length > 0)
     {
         if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "Space")
         {
             inputedName += "_";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "D1")
         {
             inputedName += "1";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "D2")
         {
             inputedName += "2";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "D3")
         {
             inputedName += "3";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "D4")
         {
             inputedName += "4";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "D5")
         {
             inputedName += "5";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "D6")
         {
             inputedName += "6";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "D7")
         {
             inputedName += "7";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "D8")
         {
             inputedName += "8";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "D9")
         {
             inputedName += "9";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "OemPeriod")
         {
             inputedName += ".";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "OemComma")
         {
             inputedName += ",";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "OemMinus")
         {
             inputedName += "-";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "OemPlus")
         {
             inputedName += "+";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "Right")
         {
             //inputedName += "";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "Left")
         {
             //inputedName += "";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "Up")
         {
             //inputedName += "";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "Enter")
         {
             //inputedName += "";
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "Back")
         {
             /*if (inputedName.Length > 0) {
                 inputedName.Remove(0, inputedName.Last<char>());
             }*/
             string rememberInput = inputedName;
             inputedName = "";
             for (int i = 0; i < rememberInput.Length - 1; i++)
             {
                 inputedName += rememberInput[i];
             }
         }
         else if (Keyboard.GetState().GetPressedKeys()[0].ToString() == "Down")
         {
             //inputedName += "";
         }
         else
         {
             inputedName += Keyboard.GetState().GetPressedKeys()[0].ToString();
         }
         UpdateText();
         pressedKey = true;
     }
     if (pressedKey == true && Keyboard.GetState().GetPressedKeys().Length <= 0)
     {
         pressedKey = false;
     }
 }
Example #3
0
 public void KeyboardCheck()
 {
     KeyboardManager km = new KeyboardManager();
     if (km.CheckKeyState(Keys.L, true))
     {
         //6tileManager.LoadWorld();
     }
     if (PressedE == false)
     {
         if (km.CheckKeyState(Keys.E, true) || km.CheckKeyState(Keys.RightShift, true))
         {
             PressedE = true;
             int playerTile = (int)(((int)((player.Y + player.origin.Y) / 32) * 50) + ((player.X + player.origin.X) / 32));
             Tile tile = tileManager.collisionTiles[playerTile];
             if (tile.sheetPoint == InteractTile)
             {
                 foreach (InteractableTerrain terrain in Levers)
                 {
                     if (tile.CollisionRectangle().Intersects(terrain.CollisionRectangle()))
                     {
                         Trigger(tileManager.GetNumber(tileManager.collisionTiles.IndexOf(tile)));
                         if (terrain.currentSprite.X == 0)
                         {
                             terrain.Switch(new Point(1, 0));
                         }
                         else
                         {
                             terrain.Switch(new Point(0, 0));
                         }
                     }
                 }
             }
         }
     }
     else
     {
         if (km.CheckKeyState(Keys.E, false) == false && km.CheckKeyState(Keys.RightShift, false) == false)
         {
             PressedE = false;
         }
     }
     if (km.CheckKeyState(Keys.P, true))
     {
         ui.gameMenu.SwitchVisibility();
         if (Paused)
         {
             Paused = false;
         }
         else
         {
             Paused = true;
         }
     }
 }