如何修复我的 2D roguelike 地牢游戏中此程序生成代码中的 CS1525 错误?

How do I fix CS1525 error in this procedural generation code in my 2D roguelike dungeon game?

Unity C# 编码的新手。我正在编写一个脚本来实现 2D roguelike 游戏中的程序生成。我的想法是使用枚举来表示 4 个方向(上、下、左、右),然后选择一个随机方向从预制件中生成一个房间。然后下一个房间将通过相同的方法生成。这是我的代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RoomGenerator : MonoBehaviour
{
    public enum Direction { up, down, left, right };
    public Direction direction;
    [Header("Room Information")]
    public GameObject roomPrefab;
    public int roomNumber;
    public Color startColor, endColor;

    [Header("Position Controller")]
    public Transform generatorPoint;
    public float xOffset;
    public float yOffset;
    public List<GameObject> rooms = new List<GameObject>();


    void Start()
    {
        for (int = 0; i < roomNumber, int++)
        {
            rooms.Add(Instantiate(roomPrefab, transform.position, Quaternion.identity));
            ChangePointPosition();
        }

    }


    void Update()
    {
        
    }

    public void ChangePointPosition()
    {
        direction = (Direction)Random.Range(0,4);

        switch(direction)
        {
            case Direction.up:
                generatorPoint.position += new Vector3 (0, yOffset, 0);
                break;
            case Direction.down:
                generatorPoint.position += new Vector3 (0, -yOffset, 0);
                break;
            case Direction.left:
                generatorPoint.position += new Vector3 (-xOffset, 0, 0);
                break;
            case Direction.right:
                generatorPoint.position += new Vector3 (xOffset, 0, 0);
                break;
        }
    }
}

Unity 说“错误 CS1525:无效的表达式项 'int'”。这怎么可能?我错过了什么?请帮忙。提前致谢!

您的 for 循环中缺少变量名称:

 for (int i = 0; i < roomNumber, int++)