新しい XNA プロジェクトを開始しましたが、クラス間の通信で問題が発生しています。基本的に、私はタイルベースのプラットフォーマーのフレームワークを作成しており、現時点では 2 つの非常に単純なクラスがあります。
1 つのクラス Tile(Tile.cs) には、TileCollision という名前の列挙型と、Tile という名前の構造体が含まれています。
もう一つはレベル(Level.cs)です。TileCollision を参照しようとしたり、Tile を作成しようとしたりするたびに、現在のコンテキストには存在しないと表示されます。
この 2 つのクラスを会話させるために他に何か必要なことはありますか? それらは同じ名前空間にあり、コンパイルされた DLL などではないため、参照を追加する必要はありません。私が逃したものがわからない。
Tile.cs のコードは次のとおりです。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace PoriPlatformer
{
class Tile
{
    // Controls the collision detection and response behavior of a tile.
    enum TileCollision
    {
        // A passable tile is one which does not hinder player motion at all, Example: Air
        Passable = 0,
        // An impassible tile is one which does not allow the player to move through it at all
        // It is completely solid.
        Impassable = 1,
        // A platform tile is one which behaves like a passable tile except when the player
        // is above it. A player can jump up through the platform as well as move past it
        // to the left and right, but can not fall through the top of it. 
        Platform = 2,
    }
    struct Tile
    {
        public Texture2D Texture;
        public TileCollision Collision;
        public const int Width = 40;
        public const int Height = 32;
        public static readonly Vector2 Size = new Vector2(Width, Height);
        // Constructs a new tile
        public Tile(Texture2D texture, TileCollision collision)
        {
            Texture = texture;
            Collision = collision;
        }
    }
}
 }
Level.cs の問題のあるコードは次のとおりです。
// Loads an individual tile's appearance and behavior.
    private Tile LoadTile(char tileType, int x, int y)
    {
        switch (tileType)
        {
            // Blank space
            case '.':
                return new Tile(null, TileCollision.Passable);
            // Passable platform
            case '~':
                return LoadTile("platform", TileCollision.Platform);
            // Impassable block
            case '#':
                return LoadTile("block", TileCollision.Impassable);
            case '_':
                return LoadTile("ground", TileCollision.Impassable);
            default:
                throw new NotSupportedException(String.Format("Unsupported tile type character '{0}' at position {1}, {2}.", tileType, x, y));
        }
    }
Level.cs の下線部分はTileCollision