因此,在编程方面,尤其是在 c# 中,我是一个新手,我有一个需要帮助的错误?
因此,我正在尝试创建一个 rpg 系统,我首先开始使用战斗系统,我刚刚开始存储在 Form1.cs 中的代码就是这样
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public class Variables{
public Graphics character;
private void Form1_Load(object sender, EventArgs e){
}
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Up:
Player.Top = Player.Top - 5;
Battle.Steps = Battle.Steps + 10;
break;
case Keys.Down:
Player.Top = Player.Top + 5;
Battle.Steps = Battle.Steps + 10;
break;
case Keys.Left:
Player.Left = Player.Left - 5;
Battle.Steps = Battle.Steps + 10;
break;
case Keys.Right:
Player.Left = Player.Left + 5;
Battle.Steps = Battle.Steps + 10;
break;
}
if (Battle.Steps == 100)
{
Battle.Fight = true;
}
}
}
}
Battle.cs 是
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WindowsFormsApplication1
{
public class Battle
{
public static bool Fight {get; set;}
public static int Steps;
public void Fight (){
if (Fight == true)
{
}
}
}
}
Ambiguity between 'WindowsFormsApplication1.Battle.Fight' and 'WindowsFormsApplication1.Battle.Fight()'
但是,当我尝试访问表单 1 中的变量以及尝试在 Battle.cs 中进行编辑时, 我收到了一个错误错误 。我该如何解决这个问题,或者有更好的方法吗?