Example #1
0
    //--------------------------- 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);
    }
Example #2
0
    //--------------------------- 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);
    }
Example #3
0
    //------------------------ 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);
    }
Example #4
0
    //------------------------ 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);
    }
Example #5
0
 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();
     }
 }
Example #6
0
    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);
        }
    }
Example #7
0
    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);
        }
    }
Example #8
0
    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);
            }
        }
    }
Example #9
0
    //--------------------------- Get cells ---------------------------//

    private void GetCells()
    {
        SyncanoWrapper.Please().Get <CellData>(OnCellsDownloaded);
    }
Example #10
0
    //------------------------ Room ------------------------//

    private void GetRoom()
    {
        ShowLoadingScreen();
        SyncanoWrapper.Please().Get <RoomData>(Constants.ROOM_ID, OnRoomDownloaded);
    }