Exemplo n.º 1
0
        public static void HandleInput(GameTime gameTime, PlayableCharacter unit)
        {
            previousKeyboardState = currentKeyboardState;
            currentKeyboardState = Keyboard.GetState();

            //if (currentKeyboardState.GetPressedKeys().Length == 0)
            //{
            //    // Idle
            //}

            //Reset any currently ongoing animation
            if (currentKeyboardState.IsKeyDown(Keys.R) && previousKeyboardState.IsKeyUp(Keys.R))
            {
                unit.ResetAnimation();
            }

            if (currentKeyboardState != previousKeyboardState)
            {
                if (!unit.IsAttackingRanged)
                {
                    //unit.ResetAnimationCounter();
                }
                unit.MakeUnitIdle();
            }

            // Move Right
            if (currentKeyboardState.IsKeyDown(Keys.Right))
            {
                unit.ValidateMovementRight();
            }

            // Move Left
            if (currentKeyboardState.IsKeyDown(Keys.Left))
            {
                unit.ValidateMovementLeft();
            }

            // Jumping
            if (currentKeyboardState.IsKeyDown(Keys.Up)
                && previousKeyboardState.IsKeyUp(Keys.Up))
            {
                unit.ValidateJump();
            }

            // RangedAttack

            if (currentKeyboardState.IsKeyDown(Keys.A)
                && currentKeyboardState.IsKeyDown(Keys.S)
                && previousKeyboardState.IsKeyUp(Keys.S))
            {
                unit.ComboStageCounter += 2;
                unit.ValidateRangedAttack();
            }
            else if (currentKeyboardState.IsKeyDown(Keys.A)
               && previousKeyboardState.IsKeyUp(Keys.A))
            {
                unit.ValidateRangedAttack();
            }
        }
Exemplo n.º 2
0
        public Camera2D(GraphicsDevice device)
        {
            transform = Matrix.Identity;
            position = Vector2.Zero;
            chaseTarget = null;
            zoom = 0.99f;
            rotation = 0;

            viewport = device.Viewport;
        }
Exemplo n.º 3
0
 public void SetChaseTarget(PlayableCharacter chaseTarget)
 {
     this.chaseTarget = chaseTarget;
 }
Exemplo n.º 4
0
 public static void InitializeLevel(string level)
 {
     using (StreamReader reader = new StreamReader("Content/Levels/" + level + ".txt"))
     {
         string line = "";
         int lineCount = 0;
         string[] levelBounds = reader.ReadLine().Split(',');
         Engine.LevelBounds = new Rectangle(0, 0, int.Parse(levelBounds[0])*128, int.Parse(levelBounds[1])*128);
         while ((line = reader.ReadLine()) != null)
         {
             for (int i = 0; i < line.Length; i++)
             {
                 switch (line[i])
                 {
                     // Player and Enemies
                     case 's':
                         player = new Midori.GameObjects.Units.PlayableCharacters.Midori(new Vector2(i * 128, lineCount * 128));
                         break;
                     case 'g':
                         enemies.Add(new Ghost(new Vector2(i * 128, lineCount * 128)));
                         break;
                     case 'b':
                         enemies.Add(new Bush(new Vector2(i * 128, lineCount * 128)));
                         break;
                     // Tiles
                     case '!':
                         tiles.Add(new WallTile(new Vector2(i * 128, lineCount * 128), TileType.LeftWallTile));
                         break;
                     case 'i':
                         tiles.Add(new WallTile(new Vector2(i * 128, lineCount * 128), TileType.RightWallTile));
                         break;
                     case '\'':
                         tiles.Add(new InnerGroundTile(new Vector2(i * 128, lineCount * 128)));
                         break;
                     case '(':
                         tiles.Add(new GroundTile(new Vector2(i * 128, lineCount * 128), TileType.StartPlatformTile));
                         break;
                     case '_':
                         tiles.Add(new GroundTile(new Vector2(i * 128, lineCount * 128), TileType.MiddlePlatformTile));
                         break;
                     case ')':
                         tiles.Add(new GroundTile(new Vector2(i * 128, lineCount * 128), TileType.EndPlatformTile));
                         break;
                     case '-':
                         tiles.Add(new GroundTile(new Vector2(i * 128, lineCount * 128), TileType.MiddleGroundTile));
                         break;
                     case '[':
                         tiles.Add(new GroundTile(new Vector2(i * 128, lineCount * 128), TileType.StartGroundTile));
                         break;
                     case ']':
                         tiles.Add(new GroundTile(new Vector2(i * 128, lineCount * 128), TileType.EndGroundTile));
                         break;
                     case '}':
                         tiles.Add(new GroundTile(new Vector2(i * 128, lineCount * 128), TileType.LeftCornerGroundTile));
                         break;
                     case '{':
                         tiles.Add(new GroundTile(new Vector2(i * 128, lineCount * 128), TileType.RightCornerGroundTile));
                         break;
                 }
             }
             lineCount++;
         }
     }
 }