解法1 #1

Open
opened 2025-09-21 17:22:08 +00:00 by yeziuku · 1 comment
Owner
if (_gamingQueue.Map != null)
{
    GameMap map = _gamingQueue.Map;
    HashSet<Grid> allocated = [];
    List<Grid> allGrids = [.. map.Grids.Values];
    if (isTeam && tgq != null && team1 != null && team2 != null)
    {
        // 团队模式放置角色
        List<Character> team1Members = [.. team1.Members];
        List<Character> team2Members = [.. team2.Members];

        // 队伍一在左,优先选择X和Y坐标都较小的格子
        List<Grid> team1PreferredGrids = [.. allGrids.OrderBy(g => g.X).ThenBy(g => g.Y)];

        // 队伍二在右,优先选择X和Y坐标都较大的格子
        List<Grid> team2PreferredGrids = [.. allGrids.OrderByDescending(g => g.X).ThenByDescending(g => g.Y)];

        // 使用新的私有方法放置队伍一角色
        await PlaceTeamCharacters(team1Members, team1PreferredGrids, allocated, map, _gamingQueue, Controller, allGrids, team1.Name);

        // 使用新的私有方法放置队伍二角色
        await PlaceTeamCharacters(team2Members, team2PreferredGrids, allocated, map, _gamingQueue, Controller, allGrids, team2.Name);
    }
    else
    {
        // 非团队模式,随机放置角色
        foreach (Character character in characters)
        {
            character.NormalAttack.GamingQueue = _gamingQueue;
            Grid grid = Grid.Empty;
            do
            {
                grid = allGrids[Random.Shared.Next(allGrids.Count)];
            }
            while (allocated.Contains(grid));
            allocated.Add(grid);
            map.SetCharacterCurrentGrid(character, grid);
        }
    }
    await Controller.SetGameMap(map);
    _gamingQueue.SelectTargetGrid += GamingQueue_SelectTargetGrid;
    _gamingQueue.CharacterMove += GamingQueue_CharacterMove;
}
```cs if (_gamingQueue.Map != null) { GameMap map = _gamingQueue.Map; HashSet<Grid> allocated = []; List<Grid> allGrids = [.. map.Grids.Values]; if (isTeam && tgq != null && team1 != null && team2 != null) { // 团队模式放置角色 List<Character> team1Members = [.. team1.Members]; List<Character> team2Members = [.. team2.Members]; // 队伍一在左,优先选择X和Y坐标都较小的格子 List<Grid> team1PreferredGrids = [.. allGrids.OrderBy(g => g.X).ThenBy(g => g.Y)]; // 队伍二在右,优先选择X和Y坐标都较大的格子 List<Grid> team2PreferredGrids = [.. allGrids.OrderByDescending(g => g.X).ThenByDescending(g => g.Y)]; // 使用新的私有方法放置队伍一角色 await PlaceTeamCharacters(team1Members, team1PreferredGrids, allocated, map, _gamingQueue, Controller, allGrids, team1.Name); // 使用新的私有方法放置队伍二角色 await PlaceTeamCharacters(team2Members, team2PreferredGrids, allocated, map, _gamingQueue, Controller, allGrids, team2.Name); } else { // 非团队模式,随机放置角色 foreach (Character character in characters) { character.NormalAttack.GamingQueue = _gamingQueue; Grid grid = Grid.Empty; do { grid = allGrids[Random.Shared.Next(allGrids.Count)]; } while (allocated.Contains(grid)); allocated.Add(grid); map.SetCharacterCurrentGrid(character, grid); } } await Controller.SetGameMap(map); _gamingQueue.SelectTargetGrid += GamingQueue_SelectTargetGrid; _gamingQueue.CharacterMove += GamingQueue_CharacterMove; } ```
Author
Owner

注意:战斗不能,只能对自己使用物品

注意:战斗不能,只能对自己使用物品
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Oshima-Studios/FunGame-Testing#1
No description provided.