Я делаю настольную игру в Unity с несколькими путями ветвления, где игроки могут решить, какой из них следовать.(Вспомните игровое поле Mario Part) Но ввод от игрока, по которому следовать, не работает.
Итак, у меня есть скрипт, в котором токены следуют по заданному пути и (Связанный список для пути) сцикл for, чтобы токены перемещали выделенное им количество.В этом цикле у меня есть оператор If, который проверяет, сколько путей есть у плитки, и, если их несколько, запускает отдельный скрипт, который приостанавливает игру и предлагает подсказку меню для игроков, чтобы выбрать один или другой путь.
Я попытался добавить несколько пунктов, чтобы продолжить игру в цикле, но они либо игнорируют ввод игрока, либо являются вводом, либо просто нарушают код.
`for (int i = 0; i < spacesToMove; i++)
{
if (final_Waypoint == null)
{
final_Waypoint = Starting_Waypoint;
}
else
{
if (final_Waypoint.Next_Waypoint == null || final_Waypoint.Next_Waypoint.Length == 0)
{
//we are overshooting the final waypoint, so just return some nulls in the array
//just break and we'll return the array, which is going to have nulls at the end.
Debug.Log(Current_Waypoint);
break;
}
else if (final_Waypoint.Next_Waypoint.Length > 1) // && if playerID == 0 so it only appears for players.
{
menu.Pause_for_Choice();
//if (menu.ButtonPress == true)
final_Waypoint = final_Waypoint.Next_Waypoint[menu.choice_int];
//***There's a bug here. It calls menu as per normal, and the game pauses.
//But when I click 'no', choice_int isn't updated first: this function finishes first,
//so this function gets old choice_int. THEN the button function executes.
Debug.Log("test 3 " + menu.choice_int);
}
else
{
final_Waypoint = final_Waypoint.Next_Waypoint[0];
}
}
listOfWaypoints[i] = final_Waypoint;
Debug.Log("i:" + i);
}
return listOfWaypoints;
}`
`{
public GameObject choice_Menu;
public bool isPaused = true;
public int choice_int=0;
public int choice_placeholder = 0;
public void Pause_for_Choice()
{
isPaused = true;
choice_Menu.SetActive(true);
Time.timeScale = 0;
}
public void Yes()
{
choice_placeholder = 0;
UnPause_Game();
}
public void No()
{
choice_placeholder = 1;
UnPause_Game();
}
public void UnPause_Game()
{
isPaused = false;
choice_Menu.SetActive(false);
Time.timeScale = 1;
}
}`