// Для ботов и мультиплеерных игроков public void GetHit() { return; if (orderHits[playerCurHit].x1 == null && orderHits[playerCurHit].x2 == null) { return; // Долен ходить локальный игрок } OneHit p; if (orderHits[playerCurHit].x1 != null) { // ходит бот BotController bc = orderHits[playerCurHit].x1; p = bc.ScorePointsGetTop(); MakeHit(p, playerCurHit + 1); if (!win) { UpdateAllAfterHit(p); } } else { // очевидно - ход игрока в инетике } GetHit(); }
public bool win; // была ли победа // Use this for initialization void Start() { BotController.gm = this; OneHit.gm = this; BoCoCell.gm = this; BoCoCell.bcs = bcs; modeGame = LocalDB._def_ModeGame; countPlayers = LocalDB._def_CountPlayers; orderHits = new Typple2 <BotController, InternetPlayer> [countPlayers]; playerCurHit = 0; win = false; if (modeGame == 0) { // гарантированно 1 игрок, и либо 2 либо 3 бота countRealPlayers = 1; countBots = countPlayers - 1; bcs = new BotController[countBots]; ips = null; for (int i = 0, j = 0; i < countPlayers; i++) { // номер цвета соответствует номеру хода по порядку // i+1 потому что цвет: 1 2 3, а i: 0 1 2 if (LocalDB._def_ColorPlayer1 != i + 1) { bcs[j] = new BotController(i + 1); orderHits[i] = new Typple2 <BotController, InternetPlayer>(bcs[j], null); j++; } else { orderHits[i] = new Typple2 <BotController, InternetPlayer>(null, null); } } } else if (modeGame == 1) { if (countPlayers == 2) { countRealPlayers = 2; countBots = 0; bcs = null; } else // countPlayers==3 { countRealPlayers = LocalDB._def_CountRealPlayers; countBots = countPlayers - countRealPlayers; bcs = (countBots > 0) ? new BotController[countBots] : null; // a,b:6-a-b 1,2:3 1,3:2 2,3:1 Эта штука нужна для определения хода бота, либо оставшегося игрока int lastPlayer = 6 - LocalDB._def_ColorPlayer1 - LocalDB._def_ColorPlayer2; if (countBots == 1) { bcs[0] = new BotController(lastPlayer); orderHits[lastPlayer - 1] = new Typple2 <BotController, InternetPlayer>(bcs[0], null); } else { orderHits[lastPlayer - 1] = new Typple2 <BotController, InternetPlayer>(null, null); } } ips = null; // -1 потому что синему должен соответствовать 1 элемент а красному 2, в реальности элементы массива отсчитываются с 0 orderHits[LocalDB._def_ColorPlayer1 - 1] = new Typple2 <BotController, InternetPlayer>(null, null); orderHits[LocalDB._def_ColorPlayer2 - 1] = new Typple2 <BotController, InternetPlayer>(null, null); } else // gameType==2 {/* * if (countPlayers == 2) * { * countRealPlayers = 2; * countBots = 0; * * bcs = null; * ips = new InternetPlayer[1]; * } * else // countPlayers==3 * { * countRealPlayers = LocalDB._def_CountRealPlayers; * countBots = countPlayers - countRealPlayers; * * bcs = (countBots>0) ? new BotController[countBots] : null; * ips = new InternetPlayer[countRealPlayers-1]; * }*/ } BoCoCell.bcs = bcs; GetHit(); OnStart(); }