2016-08-23 6 views
0

私は私の個人的な使用のためのフレームワークを作成しています。それで環境、エンティティ、アイテムなどを作成できます... 今、私はちょうどそれを使って何かを作り、やっています。その場所にはその種のモンスターが必要ですが、新しい武器を鍛造するのに役立つ鍛冶屋がいるかもしれません。それはテキストベースのゲームなので、テキストをその場所にリンクしたいと思っています。プレイヤーの位置に基づいて要素(テキスト、イベント)を追加する

私はそうのようなワールドクラスに移入されるリストを持っている

Environment.Environments.Add(new Environment("Dark Forest", "A very dark... very frightening place...", true, true)); 

ここで大きな悪いコードです:

class Environment 
{  
    public string Name { get; private set; } 
    public string Description { get; private set; } 
    public bool ContainsItems { get; set; } 
    public bool ContainsEntities { get; set; } 
    public static List<Environment> Environments = new List<Environment>(); 

    public Environment(string name, string description, bool containsItems, bool containEntities) 
    { 
     Name = name; 
     Description = description; 
     ContainsItems = containsItems; 
     ContainsEntities = containEntities; 
    } 

    public void SetLocation() 
    { 
     Console.Clear(); 
     Console.ForegroundColor = ConsoleColor.Cyan; 
     Console.WriteLine(); 
     DisplayText("You arrived at {0}", Name); 
     DisplayText(Description); 
     Console.ReadKey(); 

     if (ContainsItems) 
     { 
      Console.ForegroundColor = ConsoleColor.Yellow; 
      DisplayText("If you look carefully, you might find something valuable!"); 
      if(ContainsEntities) 
      { 
       Console.ForegroundColor = ConsoleColor.Red; 
       DisplayText("Proceed with caution, some monsters hides here!"); 
      }    
     } 
     Console.ForegroundColor = ConsoleColor.White;    
    } 
} 

は、私がリンクされているイベントの追加など、さまざまなものを試してみました私の命令「見てください」の1つに、私のニーズに合ったツールであるかどうかは分かりません。今まではイベントを使用したことはありませんでした。だから、もしあなたがこれのようなものを実装しようとしたら、どうやってそれをやりますか?

答えて

1

私は場所を持つグリッドシステムを作成します。 x/y座標を詳細の集合(ItemsとCreatures(独自の意味を持つ "entity"を使用しないでください)で与えます。

+1

まさに私が探していたものです、ありがとうございました! – Maxwell

関連する問題