private void MakeMove(PlacePosition pos) { _boardGridMarks[pos.X, pos.Y] = _currentPlayerId; _movePositions.Add(pos); var matchedRow = Logic.FindMatchedRow(_boardGridMarks); var drawed = _movePositions.Count >= Rule.BoardSize * Rule.BoardSize; var nextTurnPlayerId = (matchedRow == null && drawed == false) ? 3 - _currentPlayerId : 0; NotifyToAllObservers((id, o) => o.MakeMove(_currentPlayerId, pos, nextTurnPlayerId)); if (matchedRow != null) { EndGame(_currentPlayerId); } else if (drawed) { EndGame(0); } else { ScheduleTurnTimeout(_movePositions.Count); _currentPlayerId = nextTurnPlayerId; } }
private void FixedUpdate() { //this for loop controls what node each racer is headed twoard foreach (GameObject racer in racers) { PlacePosition pp = racer.GetComponent <PlacePosition>(); pp._destinationLocation = checkpointsArray[pp.indexOfPositionHeadedToward]; Debug.Log(pp.indexOfPositionHeadedToward); Debug.Log(pp.GetDistance()); if (pp.GetDistance() < 10 && pp.updatedOnce == false) { pp.updatedOnce = true; Debug.Log("updating index..."); pp.indexOfPositionHeadedToward++; if (pp.indexOfPositionHeadedToward > checkpointsArray.Length - 1) { pp.indexOfPositionHeadedToward = 0; } StartCoroutine(pp.updateController()); } //need some sort of min / max distant checker that will compare across each racer /*if (minDistance > pp.GetDistance()) * { * minDistance = pp.GetDistance(); * GameObject minDistanceRacer = pp.gameObject; * minDistanceRacer.GetComponent<PlacePosition>().UpdatePosition(1); * }*/ } }
// // GET: /Manage/Index public ActionResult Index(ManageMessageId?message) { if (message.HasValue) { ViewBag.StatusMessage = message == ManageMessageId.ChangePasswordSuccess ? Strings.ChangedPasswordSuccess : message == ManageMessageId.Error ? Errors.RequestError : message == ManageMessageId.ChangeDataSuccess ? Strings.ChangePersonalDataSuccess : ""; ViewBag.StatusIsError = (message == ManageMessageId.Error); } var user = GetUser(); var reservations = (db.Repo <Reservation>() as IReservationsRepo).GetReservationsForUser(user) .ConvertAll(r => new ReservationViewModel { ID = r.ID, Showing = r.Showing, ReservationDate = r.ReservationDate, Places = PlacePosition.FromPlaces(r.Places) .OrderBy(p => (p.y * RoomConfig.RoomWidth) + p.x) .ToList(), CancelUrl = Url.Action("CancelReservation", "ReservationFlow", new { id = r.ID }), }); var model = new IndexViewModel { Name = user.Name, Surname = user.Surname, Email = user.Email, Reservations = reservations }; return(View(model)); }
void IGameObserver.MakeMove(int playerId, PlacePosition pos, int nextTurnPlayerId) { _boardGridMarks[pos.X, pos.Y] = playerId; if (_isPlaying && nextTurnPlayerId == _playerId) { RunTask(() => ThinkAndMakeMoveAsync()); } }
public void TestPlaceName() { Assert.AreEqual("A1", PlacePosition.PlaceName( new PlacePosition { x = 0, y = 0 })); Assert.AreEqual("L18", PlacePosition.PlaceName( new PlacePosition { x = 17, y = 11 })); }
void IGamePlayerSync.MakeMove(PlacePosition pos, long playerUserId) { var playerId = GetPlayerId(playerUserId); if (playerId != _currentPlayerId) { throw new ResultException(ResultCodeType.NotYourTurn); } if (pos.X < 0 || pos.X >= Rule.BoardSize || pos.Y < 0 || pos.Y >= Rule.BoardSize || _boardGridMarks[pos.X, pos.Y] != 0) { throw new ResultException(ResultCodeType.BadPosition); } MakeMove(pos); }
void IGameObserver.MakeMove(int playerId, PlacePosition pos, int nextTurnPlayerId) { Debug.Log(string.Format("IGameObserver.MakeMove {0} {1} {2}", playerId, pos, nextTurnPlayerId)); Board.SetMark(pos.X, pos.Y, _myPlayerId == playerId ? 1 : 2); SetPlayerTurn(nextTurnPlayerId); }