//--------------------------- Get food ---------------------------// public void GetFood() { Dictionary <string, string> payload = new Dictionary <string, string>(); payload.Add("room_id", model.RoomId.ToString()); SyncanoWrapper.Please().CallScriptEndpoint(Constants.ENDPOINT_GET_FOOD_ID, Constants.ENDPOINT_GET_FOOD, OnFoodsDownloaded, payload); }
//--------------------------- Get players ---------------------------// public void GetPlayers() { Dictionary <string, string> payload = new Dictionary <string, string>(); payload.Add("room_id", model.RoomId.ToString()); SyncanoWrapper.Please().CallScriptEndpoint(Constants.ENDPOINT_GET_ALL_PLAYERS_ID, Constants.ENDPOINT_GET_ALL_PLAYERS, OnPlayersDownloaded, payload); }
//------------------------ Start ------------------------// private void StartGame(long playerId, long roomId) { Dictionary <string, string> payload = new Dictionary <string, string>(); payload.Add("player_id", playerId.ToString()); payload.Add("room_id", roomId.ToString()); SyncanoWrapper.Please().CallScriptEndpoint(Constants.ENDPOINT_START_GAME_ID, Constants.ENDPOINT_START_GAME, OnGameStarted, payload); }
//------------------------ Join ------------------------// private void JoinRoom(string nick, long roomId) { menuPanel.SetLoadingMode(); Dictionary <string, string> payload = new Dictionary <string, string>(); payload.Add("nickname", nick); payload.Add("room_id", roomId.ToString()); SyncanoWrapper.Please().CallScriptEndpoint(Constants.ENDPOINT_JOIN_ROOM_ID, Constants.ENDPOINT_JOIN_ROOM, OnRoomJoined, payload); }
private IEnumerator SendCellPositions(List <CellData> cells) { if (cells != null) { syncCells.AddRange(cells); foreach (var item in syncCells) { yield return(SyncanoWrapper.Please().Save(item, null)); } syncCells.Clear(); } }
private void PickFoodAndEat() { if (isEatingFood == false && foodToEat.Count > 0) { isEatingFood = true; currentlyEatenFood = foodToEat[0]; Dictionary <string, string> payload = new Dictionary <string, string>(); payload.Add("cell_id", currentlyEatenFood.Key.ToString()); payload.Add("food_id", currentlyEatenFood.Value.ToString()); payload.Add("room_id", model.RoomId.ToString()); SyncanoWrapper.Please().CallScriptEndpoint(Constants.ENDPOINT_TRY_EAT_FOOD_ID, Constants.ENDPOINT_TRY_EAT_FOOD, OnTryEatFoodFinished, payload); } }
private void PickCellAndEat() { if (isEatingCell == false && cellsToEat.Count > 0) { isEatingCell = true; currentlyEatenCell = cellsToEat[0]; Dictionary <string, string> payload = new Dictionary <string, string>(); payload.Add("player_cell_id", currentlyEatenCell.Key.ToString()); payload.Add("cell_id", currentlyEatenCell.Value.ToString()); payload.Add("room_id", model.RoomId.ToString()); SyncanoWrapper.Please().CallScriptEndpoint(Constants.ENDPOINT_TRY_EAT_CELL_ID, Constants.ENDPOINT_TRY_EAT_CELL, OnTryEatCellFinished, payload); } }
private IEnumerator PlayerHeartbeat() { while (isRunning) { if (model.Player != null) { model.Player.revisionCounter++; // Increment to change updated at date. yield return(SyncanoWrapper.Please().Save(model.Player, OnPlayerSaved)); yield return(new WaitForSeconds(PLAYER_HEARTBEAT_INTERVAL)); } else { yield return(null); } } }
//--------------------------- Get cells ---------------------------// private void GetCells() { SyncanoWrapper.Please().Get <CellData>(OnCellsDownloaded); }
//------------------------ Room ------------------------// private void GetRoom() { ShowLoadingScreen(); SyncanoWrapper.Please().Get <RoomData>(Constants.ROOM_ID, OnRoomDownloaded); }