2

これに対する答えは、私の脳がそれを見せているほど難しいものではないと確信していますが、これを理解することはできないようです。

開始するゲームのタイマーを設定しようとしています。ほとんどの場合、基本を理解するためのチュートリアルが続きます。チュートリアルとして正確なコードを使用して新しいプロジェクトを作成しましたが、同じエラーが継続的に発生します。チュートリアルでコードが完全に実行されるのを見たにもかかわらず...

助けていただければ幸いです。コードを修正するだけでなく、どこで混乱したのか、その理由を教えていただければ幸いです。私はこれを学習プロジェクトとしてやっているので、将来これを防ぐ方法を知りたいです。前もって感謝します!

ああ、それが重要かどうかはわかりませんが、私はMicrosoft Visual C#2010Expressを使用しています。

4エラー、同じメッセージ。10、66、67、および72行目。

using System;
using System.Collections.Generic;

namespace rout3reset
{
public class RogueLike
{
    static bool isGameAlive = true; 
    static Player player;
    static System.Timers.Timer World; //timer declare

    public class Player //
    {
        public char CHR = '@'; // Symbol for player
        public Vector position; // X, Y coordinates tracker
        public string Name = "";
        public short Health = 25; // Base health
        public short Mana = 25; // Base Mana
        public Player() //player constructor
        {
            position = new Vector(1, 1); // sets spawn point
        }
        public void Update() // get handle controls
        {

        }
    }
    public class AI //
    {

    }

    public class Tree //
    {

    }

    public class Vector
    {
        public short X;
        public short Y;
        public Vector(short X, short Y) // Main constructor
        {
            this.X = X;
            this.Y = Y;
        }
        public Vector() // Overload of 1
        {
            this.X = 0;
            this.Y = 0;
        }
    }

    static void Main(string[] args)
    {
        Initialize();
        do
        {
            player.Update();
        }
        while (isGameAlive);
    }

    static void Initialize()
    {
        World = new System.Timers.Timer(50); //Sets timer elapse point (50 milliseconds)
        World.Elapsed += new System.Timers.ElapsedEventHandler(Draw); //Start timer
        World.Start();
        player = new Player();
    }

    static void Draw(object sender, System.Timers.ElapsedEventArgs e) // Handles world timer tick
    {
        Console.Clear();
        Console.WriteLine("########################################"); //40 Spaces wide by 20 spaces tall
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("#--------------------------------------#");
        Console.WriteLine("########################################");

        Console.WriteLine("-{0} HP: {1} MP: {2}", player.Name, player.Health, player.Mana); //STAT BAR  

        Console.SetCursorPosition(player.position.X, player.position.Y); //sets proper char position for player symbol
        Console.Write(player.CHR); //draws the players char
    }
    static void Updateworld() //update non-player, non-antagonist objects (trees, etc)
    {

    }

}

}

4

1 に答える 1

3

MSDNによると、これSystem.Timers.TimerはSystem.dllからのものです。

名前空間:System.Timers

アセンブリ:システム(System.dll内)

への参照が欠落しているようですSystem.dll。参照していることを確認してください。

ここに画像の説明を入力してください

于 2013-03-27T05:05:58.463 に答える