コード例 #1
0
ファイル: Map.cs プロジェクト: Xirdneth/XNA-Monogame
        public void LoadContent(ContentManager content, Map map, string mapID)
        {
            layer = new Layer();
            collision = new Collision();
            id = mapID;

            layer.LoadContent(map, "Layer1");
            collision.LoadContent(content, mapID);
        }
コード例 #2
0
ファイル: Player.cs プロジェクト: Xirdneth/XNA-Monogame
        public override void Update(GameTime gameTime, InputManager inputManager, Collision col, Layers layer)
        {
            moveAnimation.IsActive = true;
            if (inputManager.KeyDown(Keys.Right, Keys.D))
            {
                moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 2);
                position.X += moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            else if (inputManager.KeyDown(Keys.Left, Keys.A))
            {
                moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 1);
                position.X -= moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            else if (inputManager.KeyDown(Keys.Down, Keys.S))
            {
                moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 0);
                position.Y += moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            else if (inputManager.KeyDown(Keys.Up, Keys.W))
            {
                moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 3);
                position.Y -= moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            else
            {
                moveAnimation.IsActive = false;
            }

            for (int i = 0; i < col.CollisionMap.Count; i++)
            {
                for (int j = 0; j < col.CollisionMap[i].Count; j++)
                {
                    if (col.CollisionMap[i][j] == "x") //check only for obstructed tiles
                    {
                        if (position.X + moveAnimation.FrameWidth < j * layer.TileDimensions.X ||
                            position.X > j * layer.TileDimensions.X + layer.TileDimensions.X ||
                            position.Y + moveAnimation.FrameHeight < i * layer.TileDimensions.Y ||
                            position.Y > i * layer.TileDimensions.Y + layer.TileDimensions.Y)
                        {
                            //no collision
                        }
                        else
                        {
                            position = moveAnimation.Position; //move animation position is last frame position
                        }
                    }
                }
            }

            moveAnimation.Position = position;
            ssAnimation.Update(gameTime, ref moveAnimation);
        }
コード例 #3
0
ファイル: Enemy.cs プロジェクト: Xirdneth/XNA-Monogame
 public override void Update(GameTime gameTime, InputManager inputManager, Collision col, Layers layer)
 {
 }
コード例 #4
0
ファイル: Entity.cs プロジェクト: Xirdneth/XNA-Monogame
 public virtual void Update(GameTime gameTime, InputManager inputManager, Collision col, Layers layer)
 {
 }