예제 #1
0
    private void Server_EventPluginMessageOnProcess(string command, string action, EsObject eso)
    {
        if (command == "getHandRobot")
        {
            if (eso.variableExists("players"))
            {
                foreach (EsObject obj in eso.getEsObjectArray("players"))
                {
                    string username        = obj.getString("userName");
                    PlayerControllerChan p = GameModelChan.GetPlayer(username);
                    if (obj.getIntegerArray("hand").Length != p.mCardHand.Count)
                    {
                        Debug.LogWarning("Số lượng card không phù hợp giũa client và server: " + p.username);
                    }
                    else
                    {
                        if (p.mCardHand.FindAll(c => c.CardId == -1).Count == 0)
                        {
                            return;
                        }

                        foreach (int cardId in obj.getIntegerArray("hand"))
                        {
                            ECard card = p.mCardHand.Find(c => c.CardId == cardId);
                            if (card == null)
                            {
                                p.mCardHand.Find(c => c.CardId == -1).CardId = cardId;
                            }
                        }
                    }
                }
            }
        }
    }
예제 #2
0
    private void DoCreateGame(int betting, int timePlay)
    {
        WaitingView.Show("Đang tạo phòng");
        int rulePlaying = 0;

        Debug.Log("DoCreateGame");
        EsObject gameConfig = new EsObject();

        string roomName = txtRoomName.value;

        if (string.IsNullOrEmpty(roomName))
        {
            roomName = "Bàn chơi của " + GameManager.Instance.mInfo.username;
        }

        gameConfig.setString(LobbyChan.DEFINE_LOBBY_NAME, roomName);
        gameConfig.setString(LobbyChan.DEFINE_LOBBY_PASWORD, txtPassword.value.Trim());
        gameConfig.setInteger(LobbyChan.DEFINE_BETTING, betting);

        if (!cbGaNhai.value && !cbNuoiGa.value)
        {
            showGa = (int)LobbyChan.EGaRule.none;
        }

        gameConfig.setInteger(LobbyChan.DEFINE_USING_NUOI_GA, showGa);    //true nuoi ga false ga nhai
        gameConfig.setBoolean(LobbyChan.DEFINE_USING_AUTO_BAT_BAO, true); //true
        gameConfig.setBoolean(LobbyChan.DEFINE_USING_AUTO_U, true);       //true
        rulePlaying = ruleMain[0].value ? 1 : ruleMain[1].value ? 2 : ruleMain[2].value ? 3 : 1;
        gameConfig.setInteger(LobbyChan.DEFINE_RULE_FULL_PLAYING, rulePlaying);
        gameConfig.setStringArray(LobbyChan.DEFINE_INVITED_USERS, new string[0]);
        gameConfig.setInteger(LobbyChan.DEFINE_PLAY_ACTION_TIME, timePlay);// defalt 20s

        GameManager.Server.DoRequestPlugin(Utility.SetEsObject(Fields.RESPONSE.CREATE_GAME,
                                                               new object[] { "config", gameConfig }));
    }
예제 #3
0
 public void OnBettingValueChange(EsObject eso)
 {
     if (eso.variableExists("valid"))
     {
         btnJoinBet.gameObject.collider.enabled   = eso.getBoolean("valid");
         btnChangeBet.gameObject.collider.enabled = eso.getBoolean("valid");
         if (!eso.getBoolean("valid"))
         {
             btnJoinBet.gameObject.GetComponentInChildren <UISprite>().color   = new Color(1f, 1f, 1f, 90f / 255f);
             btnChangeBet.gameObject.GetComponentInChildren <UISprite>().color = new Color(1f, 1f, 1f, 90f / 255f);
         }
         else
         {
             btnJoinBet.gameObject.GetComponentInChildren <UISprite>().color   = new Color(1f, 1f, 1f, 1f);
             btnChangeBet.gameObject.GetComponentInChildren <UISprite>().color = new Color(1f, 1f, 1f, 1f);
         }
     }
     if (eso.variableExists("bettings"))
     {
         InitUser(eso.getEsObjectArray("bettings"));
     }
     if (eso.variableExists("maxChipAllow"))
     {
         parent.maxChipAllow = eso.getLong("maxChipAllow");
     }
 }
        // Send transform to all other users
		public void DoSend() {
            EsObject data = new EsObject();
            data.setString(PluginTags.ACTION, PluginTags.POSITION_UPDATE_REQUEST);

            // set the X, Y coords that AS3 clients will see, which are integers and just vert, horiz.
            // only needed if there are AS3 clients in the same room
            //data.setInteger(PluginTags.TARGET_X, getAS3positionX());  // uncomment if AS3 clients will be in the room
            //data.setInteger(PluginTags.TARGET_Y, getAS3positionY());  // uncomment if AS3 clients will be in the room

            // set the position and rotation coords that Unity clients will use
            data.setFloat(PluginTags.POSITION_X, this.position.x);
            data.setFloat(PluginTags.POSITION_Y, this.position.y);
            data.setFloat(PluginTags.POSITION_Z, this.position.z);
            data.setFloat(PluginTags.ROTATION_X, this.rotation.x);
            data.setFloat(PluginTags.ROTATION_Y, this.rotation.y);
            data.setFloat(PluginTags.ROTATION_Z, this.rotation.z);
            data.setFloat(PluginTags.ROTATION_W, this.rotation.w);

            //Debug.Log("NetworkTransform.DoSend");

            NetworkController nc = getNetworkController();
            if (nc != null)
            {
                nc.sendToPlugin(data);
            }
            else
            {
                Debug.Log("DoSend can't send because controller is null");
            }

		}
    public PlayerControllerChan(EsObject es)
        : base(es)
    {
        SetDataOther(es);

        summary.inHand = new List <int>();
    }
예제 #6
0
 public CommandEsObject(PluginMessageEvent e, string command, string action, EsObject eso)
 {
     this.command = command;
     this.action  = action;
     this.eso     = eso;
     this.e       = e;
 }
예제 #7
0
    protected virtual void OnPluginMessage(PluginMessageEvent e)
    {
        EsObject eso     = e.Parameters;
        string   command = eso.getString(Fields.COMMAND);
        string   action  = string.Empty;

        if (eso.variableExists(Fields.ACTION))
        {
            action = eso.getString(Fields.ACTION);
        }

        Debug.Log(this.GetType().ToString() + ": " + "time :" + System.DateTime.Now.ToString() + "eso :" + eso);

        if (command == "joinGame" || listWaitingGameplay.Count > 0)
        {
            Debug.LogWarning("CServer -> Gameplay chờ command : " + command);
            if (command == "joinGame")
            {
                ProcessGeneral(command, action, eso);
                listWaitingGameplay.Add(null);
            }
            else
            {
                listWaitingGameplay.Add(new CommandEsObject(e, command, action, eso));
            }
        }
        else
        {
            ProcessPluginMessage(e, command, action, eso);
        }
    }
예제 #8
0
    private void DoCreateGame(int betting)
    {
        Debug.Log("DoCreateGame");
        EsObject gameConfig = new EsObject();

        string roomName = txtRoomName.value;

        if (string.IsNullOrEmpty(roomName))
        {
            roomName = "Bàn chơi của " + GameManager.Instance.mInfo.username;
        }

        gameConfig.setString(LobbyPhom.DEFINE_LOBBY_NAME, roomName);
        gameConfig.setString(LobbyPhom.DEFINE_LOBBY_PASWORD, txtPassword.value.Trim());
        gameConfig.setInteger(LobbyPhom.DEFINE_BETTING, betting);

        gameConfig.setBoolean(LobbyPhom.DEFINE_USING_U_TRON_RULE, ruleSub[0].value);     //Ù tròn
        gameConfig.setBoolean(LobbyPhom.DEFINE_USING_U_XUONG_RULE, ruleSub[1].value);    //Ù Xuông
        gameConfig.setBoolean(LobbyPhom.DEFINE_USING_XAO_KHAN_RULE, ruleSub[2].value);   // Xào Khan
        gameConfig.setBoolean(LobbyPhom.DEFINE_USING_DEN_CHONG_RULE, ruleSub[3].value);  //Đền Chồng
        gameConfig.setBoolean(LobbyPhom.DEFINE_USING_CHOT_CHONG_RULE, ruleSub[4].value); //Chốt Chồng

        gameConfig.setBoolean(LobbyPhom.DEFINE_USING_TYPE_RULE, ruleMain[0].value);      //True Cơ bản, False Nâng Cao

        gameConfig.setStringArray(LobbyPhom.DEFINE_INVITED_USERS, new string[0]);

        GameManager.Server.DoRequestPlugin(Utility.SetEsObject(Fields.RESPONSE.CREATE_GAME,
                                                               new object[] { "config", gameConfig }));
    }
예제 #9
0
 public void SetData(EsObject es)
 {
     if (es.variableExists("userId"))
     {
         this.userId = es.getInteger("userId");
     }
     if (es.variableExists("userName"))
     {
         lblName.text = es.getString("userName");
     }
     if (es.variableExists("avatar"))
     {
         this.avatarUrl = es.getString("avatar");
     }
     if (es.variableExists("point"))
     {
         int point = es.getInteger("point");
         lblPoint.text = point.ToString();
         if (point > 0)
         {
             spPoint.spriteName = "";
         }
         else
         {
             spPoint.spriteName = "";
         }
         NGUITools.SetActive(spPoint.gameObject, true);
     }
     OnShowAvatar();
 }
예제 #10
0
    private void DoCreateGame(int betting)
    {
        WaitingView.Show("Đang tạo bàn");
        Debug.Log("DoCreateGame");
        EsObject gameConfig = new EsObject();

        string roomName = txtRoomName.value;

        if (string.IsNullOrEmpty(roomName))
        {
            roomName = "Bàn chơi của " + GameManager.Instance.mInfo.username;
        }

        gameConfig.setInteger(LobbyTLMN.DEFINE_GAME_TYPE_TLMN,
                              ruleMain[0].value ? (int)LobbyTLMN.GameConfig.GameTypeLTMN.DEM_LA : (int)LobbyTLMN.GameConfig.GameTypeLTMN.XEP_HANG);

        gameConfig.setString(LobbyTLMN.DEFINE_LOBBY_NAME, roomName);
        gameConfig.setString(LobbyTLMN.DEFINE_LOBBY_PASWORD, txtPassword.value.Trim());
        gameConfig.setInteger(LobbyTLMN.DEFINE_BETTING, betting);

        gameConfig.setBoolean(LobbyTLMN.DEFINE_USING_CHATCHONG_RULE, ruleSub[0].value);

        gameConfig.setBoolean(LobbyTLMN.DEFINE_USING_TYPE_RULE, ruleMain[0].value);//True Cơ bản, False Nâng Cao

        gameConfig.setStringArray(LobbyTLMN.DEFINE_INVITED_USERS, new string[0]);

        GameManager.Server.DoRequestPlugin(Utility.SetEsObject(Fields.RESPONSE.CREATE_GAME,
                                                               new object[] { "config", gameConfig }));
    }
예제 #11
0
 public void SetData(EsObject es)
 {
     if (es.variableExists("result"))
     {
         lblResult.text = "Kết quả: " + es.getString("result");
     }
     if (es.variableExists("gameId"))
     {
         gameId = es.getInteger("gameId");
     }
     if (gameId <= 0)
     {
         //disable button view
     }
     if (es.variableExists("players"))
     {
         EsObject[] esObject = es.getEsObjectArray("players");
         for (int i = 0; i < esObject.Length; i++)
         {
             GameObject obj  = (GameObject)GameObject.Instantiate(popupUserPrefab);
             PopupUser  user = obj.GetComponent <PopupUser>();
             user.SetData(esObject[i]);
             obj.transform.parent = gridUser.transform;
         }
     }
     gridUser.Reposition();
 }
예제 #12
0
 public EsObject toEsObject()
 {
     EsObject obj = new EsObject();
     obj.setInteger(GameConstants.ID, key);
     obj.setBoolean(GameConstants.COLOR_IS_BLACK, isColorBlack());
     return obj;
 }
예제 #13
0
    public override void SetDataSummary(EsObject obj)
    {
        Debug.LogWarning(username + " : " + obj);

        if (obj.variableExists("disconnected"))
        {
            summary.disconnected         = obj.getBoolean("disconnected");
            summaryTLMN.disconnectedTLMN = obj.getBoolean("disconnected");
        }
        if (obj.variableExists("moneyExchange"))
        {
            long.TryParse(obj.getString("moneyExchange"), out summaryTLMN.moneyExchangeTLMN);
        }
        if (obj.variableExists("sumPoint"))
        {
            summary.sumPoint         = obj.getInteger("sumPoint");
            summaryTLMN.sumPointTLMN = obj.getInteger("sumPoint");
        }
        if (obj.variableExists("pointLoss"))
        {
            summaryTLMN.pointLoss = obj.getInteger("pointLoss");
        }
        if (obj.variableExists("sumRank"))
        {
            summary.sumRank         = obj.getInteger("sumRank");
            summaryTLMN.sumRankTLMN = obj.getInteger("sumRank");
        }
        if (obj.variableExists("hand"))
        {
            summary.inHand         = new List <int>(obj.getIntegerArray("hand"));
            summaryTLMN.inHandTLMN = new List <int>(obj.getIntegerArray("hand"));
        }
    }
예제 #14
0
    public void SetingConfig(EsObject esConfig)
    {
        if (esConfig.variableExists(DEFINE_LOBBY_NAME))
        {
            nameLobby = esConfig.getString(DEFINE_LOBBY_NAME);
        }
        if (esConfig.variableExists(DEFINE_BETTING))
        {
            betting = esConfig.getInteger(DEFINE_BETTING);
        }
        if (esConfig.variableExists(DEFINE_INVITED_USERS))
        {
            invitedUsers = esConfig.getStringArray(DEFINE_INVITED_USERS);
        }

        GameConfig config = new GameConfig(
            esConfig.getBoolean(DEFINE_USING_TYPE_RULE),

            esConfig.getBoolean(DEFINE_USING_U_TRON_RULE),
            esConfig.getBoolean(DEFINE_USING_U_XUONG_RULE),
            esConfig.getBoolean(DEFINE_USING_XAO_KHAN_RULE),
            esConfig.getBoolean(DEFINE_USING_DEN_CHONG_RULE),
            esConfig.getBoolean(DEFINE_USING_CHOT_CHONG_RULE));

        if (esConfig.variableExists(DEFINE_LOBBY_PASWORD))
        {
            config.password = esConfig.getString(DEFINE_LOBBY_PASWORD);
        }
        this.config = config;
    }
예제 #15
0
    internal void ShowPreview(EsObject eso)
    {
        if (!eso.variableExists("next"))
        {
            next = -1;
        }
        else
        {
            next = eso.getInteger("next");
        }

        if (!eso.variableExists("prev"))
        {
            previous = -1;
        }
        else
        {
            previous = eso.getInteger("prev");
        }

        if (eso.variableExists("winner"))
        {
            winner = eso.getString("winner");
        }
        if (eso.variableExists("bettings"))
        {
            InitUser(eso.getEsObjectArray("bettings"));
        }
        ShowOrHideButtonNext();
        ShowOrHideButtonPrev();
    }
    private void SpawnRemotePlayer(EsObject obj)
    {
        Debug.Log("SpawnRemotePlayer");
		// Just spawn remote player at a very remote point
        Debug.Log("getting position");
        Vector3 pos = NetworkTransform.getPlayerPosition(obj);
        Debug.Log("getting rotation");
        Quaternion rot = NetworkTransform.getPlayerRotation(obj);
        //Give remote player a name like "remote_<id>" to easily find him then
        Debug.Log("getting player name");

        string name = getPlayerName(obj);

        // belt and suspenders section
        GameObject gobj = GameObject.Find("remote_" + name);
        if (gobj != null)
        {
            return;     // already spawned this user
        }
        // end belt and suspenders section

        Debug.Log("name is " + name);


        UnityEngine.Object remotePlayer = Instantiate(remotePlayerPrefab, pos, rot);
		
        remotePlayer.name = "remote_" + name;
		
		//Start receiving trasnform synchronization messages
		(remotePlayer as Component).SendMessage("StartReceiving");

        // show the remote player's name
        (remotePlayer as Component).SendMessage("ShowName", name);
				
	}
예제 #17
0
 /// <summary>
 /// Khởi tạo cho gift qua đối tượng esobject
 /// </summary>
 public Announcement(EsObject eso)
 {
     //this.index = index;
     //this.description = description;
     this.money      = eso.getInteger("moneyGift");
     type            = Type.Gift;
     this.currentDay = eso.getBoolean("currentDate");
 }
예제 #18
0
    void _DoPluginLogin(EsObject param)
    {
        PluginRequest request = new PluginRequest();

        request.PluginName = Fields.REQUEST.LOGIN_PLUGIN;
        request.Parameters = param;
        DoRequest(request);
    }
예제 #19
0
    public static PopupTournament Create(EsObject es)
    {
        GameObject popuptournament = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Tournament/PopupTournamentOverview"));

        popuptournament.name = "___PopupTournamentOverview";
        popuptournament.transform.position = new Vector3(15, 0, 0);
        popuptournament.GetComponent <PopupTournament>().CreateItem(es);
        return(popuptournament.GetComponent <PopupTournament>());
    }
예제 #20
0
 private void OnProcessPluginMessage(string command, string action, EsObject parameters)
 {
     if (command == Fields.REQUEST.COMMAND_GETGENERAL)
     {
         EsObject[] esObject = parameters.getEsObjectArray("users");
         for (int i = 0; i < esObject.Length; i++)
         {
         }
     }
 }
예제 #21
0
    public Messages(EsObject eso)
    {
        if (eso.variableExists("id"))
        {
            //id = eso.getInteger("id");
            id = eso.getString("id");
        }
        if (eso.variableExists("sender"))
        {
            sender = eso.getInteger("sender");
        }
        if (eso.variableExists("sender_name"))
        {
            sender_name = eso.getString("sender_name");
        }
        if (eso.variableExists("receiver"))
        {
            receiver = eso.getInteger("receiver");
        }
        if (eso.variableExists("receiver_name"))
        {
            receiver_name = eso.getString("receiver_name");
        }
        if (eso.variableExists("content"))
        {
            content = eso.getString("content");
        }

        if (eso.variableExists("time_sent"))
        {
            time_sent = DateTime.Parse(eso.getString("time_sent"));
        }

        if (eso.variableExists("read"))
        {
            read = eso.getBoolean("read");
        }
        if (eso.variableExists("status"))
        {
            status = eso.getInteger("status");
        }
        if (eso.variableExists("sender_avatar"))
        {
            sender_avatar = eso.getInteger("sender_avatar");
        }
        if (eso.variableExists("receiver_avatar"))
        {
            receiver_avatar = eso.getInteger("receiver_avatar");
        }
        if (eso.variableExists("type"))
        {
            type = eso.getInteger("type");
        }
    }
예제 #22
0
    public void InitUser(EsObject[] esoArr)
    {
        DestroyUser();
        for (int i = 0; i < esoArr.Length; i++)
        {
            EsObject           eso   = esoArr[i];
            PlayerBettingModel model = new PlayerBettingModel();;
            model.Player = GameModelChan.GetPlayer(eso.getString("userName"));
            if (model == null)
            {
                model = new PlayerBettingModel();
                model.Player.username = eso.getString("userName");
            }
            model.CardId = eso.getInteger("cardId");
            if (winner == eso.getString("userName"))
            {
                model.IsWinner = true;
            }
            else
            {
                model.IsWinner = false;
            }
            model.ETypeLaying = (ETypeLayingBetting)eso.getInteger("gaNgoaiType");
            model.ChipBetting = eso.getLong("value");
            PlayerBettingView bettingView = PlayerBettingView.Create(model, tableUser.transform);
            listBettingPlayer.Add(bettingView);
            if (eso.getString("userName") == GameManager.Instance.mInfo.username)
            {
                bettingView.gameObject.name = "__0";
            }
        }
        tableUser.repositionNow = true;
        // tableUser.Reposition();
        SetCenterUITable(tableUser);

        GameManager.Instance.FunctionDelay(delegate() {
            foreach (PlayerBettingView pv in listBettingPlayer)
            {
                if (pv.model.IsWinner != null)
                {
                    if (pv.model.IsWinner == true)
                    {
                        pv.iconChicken.gameObject.SetActive(true);
                    }
                    else
                    {
                        pv.lbMoney.gameObject.GetComponent <UILabel>().color = new Color(1f, 155f / 255f, 0f);
                        ECardTexture texture1 = pv.gameObject.GetComponentInChildren <ECardTexture>();
                        texture1.card.SetColor(new Color(1f, 1f, 1f, 90f / 255f));
                    }
                }
            }
        }, 0.1f);
    }
예제 #23
0
 void OnProcessPluginMessage(string command, string action, EsObject paremeters)
 {
     if (command == "error")
     {
         int id = paremeters.getInteger("error");
         if (id == 5)
         {
             NotificationView.ShowMessage("Vui lòng chờ ván bài cũ của bạn kết thúc.\n\nTrước khi tạo bàn mới.");
         }
     }
 }
예제 #24
0
    public static ResultXuongItemView Create(int index, Transform parent, EsObject eso)
    {
        GameObject obj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Gameplay/CuocU/ResultMoneyItemPrefab"));

        obj.name                    = string.Format("Result_{0:0000}", index);
        obj.transform.parent        = parent;
        obj.transform.localPosition = new Vector3(0f, 0f, -1f);
        obj.transform.localScale    = Vector3.one;
        ResultXuongItemView resultXuong = obj.GetComponent <ResultXuongItemView>();
        long   money    = long.Parse(eso.getString("moneyExchange"));
        string userName = eso.getString("userName");

        resultXuong.playerName.text = userName;
        resultXuong.money.color     = (money < 0) ? new Color(255 / 255f, 0f, 0f) : new Color(255 / 255f, 255 / 255f, 0f);
        string summary = eso.getString("description");

        //List<List<Gameplay.Summary>> groupedSummaryByAction = GameModel.game.summaryGame.GroupBy(sum => sum.action).Select(grp => grp.ToList()).ToList();
        //string summary = "";
        if (money >= 0)
        {
            //foreach (List<Gameplay.Summary> lstSum in groupedSummaryByAction)
            //{
            //    string description = "";
            //    long moneyExchage = 0;
            //    foreach (Gameplay.Summary sum in lstSum)
            //    {
            //        if (string.IsNullOrEmpty(description))
            //        {
            //            if (sum.action == Gameplay.Summary.EAction.LOSS_FINISH_TYPE)
            //                description = "Thắng" + " : ";
            //            else
            //                description = sum.description + " : ";
            //        }
            //        moneyExchage += sum.moneyExchange;
            //    }
            //    summary += description + moneyExchage + "\n";
            //}
            summary = summary + "Tổng : " + Utility.Convert.Chip(System.Math.Abs(money));
        }
        else
        {
            //foreach (List<Gameplay.Summary> lstSum in groupedSummaryByAction)
            //{
            //    Gameplay.Summary sum = lstSum.Find(s => s.sourcePlayer == userName);
            //    if (sum != null)
            //        summary += sum.description + " : -" + sum.moneyExchange + "\n";
            //}
            summary = summary + "Tổng : -" + Utility.Convert.Chip(System.Math.Abs(money));
        }
        resultXuong.money.text = summary;
        resultXuong.ReposionComponent();
        return(resultXuong);
    }
예제 #25
0
 void OnProcessPulginResponse(string command, string action, EsObject eso)
 {
     if (command == "checkUser")
     {
         if (eso.getBoolean("exist") == false)
         {
             NotificationView.ShowMessage("Người chơi không tồn tại.", 5f);
             return;
         }
         FindFriend(transform.GetComponentInChildren <PrefabMessageTabbarControllerView>().txtFindOtherFriend.value, eso.getInteger("avatar"));
     }
 }
예제 #26
0
    public void InitUser(EsObject[] esoArr)
    {
        while (listBettingPlayer.Count > 0)
        {
            GameObject.Destroy(listBettingPlayer[0].gameObject);
            listBettingPlayer.RemoveAt(0);
        }
        for (int i = 0; i < esoArr.Length; i++)
        {
            EsObject           eso   = esoArr[i];
            PlayerBettingModel model = new PlayerBettingModel();

            model.Player = GameModelChan.GetPlayer(eso.getString("userName"));
            if (model.Player == null)
            {
                model.Player          = new PlayerControllerChan();
                model.Player.username = eso.getString("userName");
            }
            if (!GameModelChan.game.dicUserBetting.ContainsKey(eso.getString("userName")))
            {
                GameModelChan.game.dicUserBetting.Add(eso.getString("userName"), false);
            }
            model.CardId      = eso.getInteger("cardId");
            model.ETypeLaying = (ETypeLayingBetting)eso.getInteger("gaNgoaiType");
            model.ChipBetting = eso.getLong("value");
            PlayerBettingView bettingView = PlayerBettingView.Create(model, tableUser.transform);
            listBettingPlayer.Add(bettingView);
            if (eso.getString("userName") == GameManager.Instance.mInfo.username)
            {
                parent.model = model;
                ShowButonJoin(model);
                bettingView.gameObject.name = "__0";
            }
        }
        tableUser.repositionNow = true;
        SetCenterUITable(tableUser);
        if (Array.Find <EsObject>(esoArr, eso => eso.getString("userName") == GameManager.Instance.mInfo.username) == null)
        {
            HideBothButton();
        }
        GameManager.Instance.FunctionDelay(delegate()
        {
            foreach (PlayerBettingView view in listBettingPlayer)
            {
                if (GameModelChan.game.dicUserBetting.ContainsKey(view.model.Player.username) && GameModelChan.game.dicUserBetting[view.model.Player.username])
                {
                    view.iconChange.gameObject.SetActive(true);
                    GameModelChan.game.dicUserBetting[view.model.Player.username] = false;
                }
            }
        }, 0.01f);
    }
예제 #27
0
 void OnProcessPluginMessage(string command, string action, EsObject paremeters)
 {
     if (command == Fields.RESPONSE.FULL_UPDATE)
     {
         EsObject[] children = paremeters.getEsObjectArray("children");
         listChannel.Clear();
         foreach (EsObject obj in children)
         {
             listChannel.Add(new ChannelPhom(obj));
         }
         OnDrawListChannel();
     }
 }
예제 #28
0
 public HallInfo(EsObject es)
 {
     if (es.variableExists("childId"))
     {
         this.hallId = es.getInteger("childId");
     }
     if (es.variableExists("roomName"))
     {
         this.roomName = es.getString("roomName");
     }
     if (es.variableExists("zoneName"))
     {
         this.zoneName = es.getString("zoneName");
     }
     if (es.variableExists("roomId"))
     {
         this.roomId = es.getInteger("roomId");
     }
     if (es.variableExists("zoneId"))
     {
         this.zoneId = es.getInteger("zoneId");
     }
     if (es.variableExists("description"))
     {
         this.decription = es.getString("description");
     }
     if (es.variableExists("maximumPlayers"))
     {
         this.maximumPlayers = es.getInteger("maximumPlayers");
     }
     if (es.variableExists("numberUsers"))
     {
         this.numberUsers = es.getInteger("numberUsers");
     }
     if (es.variableExists("icon"))
     {
         this.icon = es.getString("icon");
     }
     if (es.variableExists("logo"))
     {
         this.logo = es.getString("logo");
     }
     if (es.variableExists("gameIndex"))
     {
         this.gameIndex = es.getInteger("gameIndex");
     }
     if (es.variableExists("appId"))
     {
         this.gameId = es.getInteger("appId");
     }
 }
예제 #29
0
    internal void ShowIndividualCard(Electrotank.Electroserver5.Api.EsObject eso)
    {
        esObj = eso;
        DestroyCard();
        if (eso.variableExists("cards"))
        {
            int[] cardIds = eso.getIntegerArray("cards");
            for (int i = 0; i < cardIds.Length; i++)
            {
                if (parent.model != null)
                {
                    if (parent.model.CardId == cardIds[i])
                    {
                        FACardBettingView.Create(cardIds[i], tableCardFA.transform, gameObject.GetComponent <PanelBetting>()).gameObject.SetActive(false);
                        continue;
                    }
                }
                FACardBettingView cars = FACardBettingView.Create(cardIds[i], tableCardFA.transform, gameObject.GetComponent <PanelBetting>());
            }
            tableCardFA.Reposition();
            GameManager.Instance.FunctionDelay(delegate() { tableCardFA.transform.parent.localPosition = Vector3.zero; }, 0.01f);
        }

        GameManager.Instance.FunctionDelay(delegate()
        {
            if (parent.model != null)
            {
                if (parent.model.CardId != -1)
                {
                    ChanCard card = new ChanCard();
                    card.CardId   = parent.model.CardId;
                    card.parent   = cardParent;
                    card.Instantiate();
                    card.cardTexture.texture.width  = CARD_WIDTH;
                    card.cardTexture.texture.height = CARD_HIGHT;
                    GameObject.Destroy(card.gameObject.GetComponent <BoxCollider>());
                    lbCardBet.text = card.ToString();
                    cardId         = parent.model.CardId;
                }
                if (parent.model.ChipBetting == 0)
                {
                    lbChipBet.text = ((LobbyChan)GameManager.Instance.selectedLobby).betting.ToString();
                }
                else
                {
                    lbChipBet.text = parent.model.ChipBetting.ToString();
                }
                HideAllButton();
            }
        }, 0.15f);
    }
예제 #30
0
 void OnProcessPluginMessage(string command, string action, EsObject paremeters)
 {
     Debug.Log("Response request.Command:" + command + ",parameters:" + paremeters);
     if (command == Fields.RESPONSE.FULL_UPDATE)
     {
         EsObject[] children = paremeters.getEsObjectArray("children");
         listChannel.Clear();
         foreach (EsObject obj in children)
         {
             listChannel.Add(new ChannelTLMN(obj));
         }
         OnDrawListChannel();
     }
 }
	//This method is called when receiving remote transform
	// We update lastState here to know last received transform state
	void ReceiveTransform(EsObject data) {
        Debug.Log("ReceiveTransform.  receiveMode = " + receiveMode.ToString());
		if (receiveMode) {

            Vector3 pos = NetworkTransform.getPlayerPosition(data);
            Quaternion rot = NetworkTransform.getPlayerRotation(data);
            lastState.InitFromValues(pos, rot);
		
			// Adding next received state to the queue	
			NetworkTransform nextState = new NetworkTransform(this.gameObject);
			nextState.InitFromValues(pos, rot);
			queue.Enqueue(nextState);
		}
	}
예제 #32
0
    private void OnProcessPluginMessage(string command, string action, EsObject Parameters)
    {
        WaitingView.Instance.Close();
        if (command == Fields.REQUEST.COMMAND_REGISTERTOURNAMENT)
        {
            string message = "";
            if (Parameters.variableExists("message"))
            {
                message = Parameters.getString("message");
            }
            if (Parameters.getBoolean("result"))
            {
                TournamentView.Instance.btnRegister.gameObject.SetActive(false);
                TournamentView.Instance.detail.lblTournamentStatus.gameObject.SetActive(true);
                TournamentView.Instance.currentShow.info.isRegister = true;
                GameObject.Destroy(gameObject);
                //      NGUITools.SetActive(TableTournament, true);
                //      NGUITools.SetActive(RegisterForm, false);
                //      GameManager.Server.DoRequestPlugin(Utility.SetEsObject(Fields.REQUEST.COMMAND_GETGENERAL,
                //new object[] { "id", this.tournamentInfo.tournamentId }));
            }
            if (!string.IsNullOrEmpty(message))
            {
                NotificationView.ShowMessage(message);
            }
        }
        if (command == Fields.REQUEST.COMMAND_GETLISTREGISTER)
        {
            EsObject[] esObject = Parameters.getEsObjectArray("users");
            for (int i = 0; i < esObject.Length; i++)
            {
                users.Add(UserTournament.Create(esObject[i], gridUser.transform, userTournamentPrefab));
            }
            gridUser.Reposition();
        }
        if (command == Fields.REQUEST.COMMAND_GETGENERAL)
        {
            EsObject[] esObject = Parameters.getEsObjectArray("rounds");
            round1.SetData(esObject[0]);
            round2.SetData(esObject[1]);
            roud3.SetData(esObject[2]);
            round4.SetData(esObject[3]);
        }

        if (command == Fields.REQUEST.COMMAND_MATCH_LIST)
        {
            PopupTournament.Create(Parameters);
        }
    }
예제 #33
0
 void remoteRegistrationSucceeded(string deviceToken)
 {
     if (CurrentScene != ESceneName.LoginScreen)
     {
         EsObject eso = Utility.SetEsObject("updateDeviceToken", new object[] { "deviceToken", deviceToken, "platform", PlatformSetting.GetSamplePlatform.ToString() });
         Server.DoRequestPlugin(eso);
     }
     this.deviceToken = deviceToken;
     ServerWeb.StartThread(ServerWeb.URL_REQUEST_SAVE_ACCESSTOKEN, new object[] { ServerWeb.PARAM_DEVICE_TOKEN, deviceToken, ServerWeb.PARAM_PLATFORM, PlatformSetting.GetSamplePlatform.ToString() }, delegate(bool isDone, WWW response, IDictionary json)
     {
         if (isDone)
         {
         }
     });
 }
	//Get the remote user list and spawn all remote players that have already joinded before us
	public void SpawnRemotePlayers(EsObject[] list, string myname) {
        Debug.Log("SpawnRemotePlayers");
        Debug.Log("my name = " + myname);
        foreach (EsObject obj in list)
        {
            String thisPlayer = getPlayerName(obj);
            Debug.Log("processing " + thisPlayer);
            Debug.Log("obj = " + obj.ToString());
            if (!myname.Equals(thisPlayer))
            {
                Debug.Log("need to spawn remote");
                SpawnRemotePlayer(obj);
            }
        }
	}
예제 #35
0
    /**
     * Sends formatted EsObjects to the plugin
     */
    public void sendToPlugin(EsObject esob)
    {
        if (room != null && _es != null)
        {
            //build the request
            PluginRequest pr = new PluginRequest();
            pr.Parameters = esob;
            pr.RoomId = room.Id;
            pr.ZoneId = room.ZoneId;
            pr.PluginName = LobbyConstants.PLUGIN_NAME;

            //send it
            _es.Engine.Send(pr);
        }
    }
예제 #36
0
    void OnClickDone()
    {
        if (GameModelTLMN.CurrentState >= GameModelTLMN.EGameState.deal)
        {
            if (strPick.Trim() != "")
            {
                if (IS_TYPE_FORCE_ROBOT && lastPicks.Count > 0 && GameModelTLMN.CurrentState > GameModelTLMN.EGameState.deal)
                {
                    if (GameManager.GAME == EGame.TLMN)
                    {
                        GameManager.Server.DoRequestPluginGame(Utility.SetEsObject("forceRobotDiscard", new object[] {
                            "cards", lastPicks.ToArray(),
                            "player", GameModelTLMN.GetNextPlayer(GameModelTLMN.IndexInTurn).username
                        }));
                    }
                    else
                    {
                        GameManager.Server.DoRequestPluginGame(Utility.SetEsObject("forceRobotDiscard", new object[] {
                            "cardId", lastPick,
                            "player", GameModelTLMN.GetNextPlayer(GameModelTLMN.IndexInTurn).username
                        }));
                    }
                }
                else
                {
                    GameManager.Server.DoRequestPluginGame(Utility.SetEsObject("orderNextCard", new object[] {
                        "cardId", lastPick
                    }));
                }
            }
        }
        else
        {
            List <EsObject> lst = new List <EsObject>();
            GameModelTLMN.ListPlayer.ForEach(p =>
            {
                EsObject obj = new EsObject();
                obj.setString(Fields.GAMEPLAY.PLAYER, p.username);
                obj.setString("cards", string.IsNullOrEmpty(playerPick[p.slotServer]) ? "" : playerPick[p.slotServer].Trim());
                lst.Add(obj);
            });

            GameManager.Server.DoRequestPluginGame(Utility.SetEsObject("orderHands", new object[] {
                "handsOrdered", lst.ToArray()
            }));
        }
        OnButtonClick(null);
    }
 /**
  *  Sends a position update message to the plugin.
  */
 public void sendPositionUpdate(EsObject esob)
 {
     esob.setBoolean(PluginTags.USE_UDP, useUDP);
     sendToPlugin(esob);
 }
예제 #38
0
 public static Vector3 getPlayerPosition(EsObject data)
 {
     if (data.variableExists(PluginTags.POSITION_X))
     {
         return new Vector3(Convert.ToSingle(data.getFloat(PluginTags.POSITION_X)),
                                     //Convert.ToSingle(data.getFloat(PluginTags.POSITION_Y)) + 1.0f,
                                     1.0f,
                                     Convert.ToSingle(data.getFloat(PluginTags.POSITION_Z))
                                     );
     }
     else
     {
         // only needed if there are AS3 clients in the same room, or for user enters room
         return new Vector3(getUnityPostionXfromAS3(data), 1.0f, getUnityPostionZfromAS3(data));
     }
 }
    public void UserEnterRoom(EsObject obj)
    {
		//When remote user enters our room we spawn his object.
        Debug.Log("UserEnterRoom");
        SpawnRemotePlayer(obj);
	}
예제 #40
0
 public void handleStartGame(EsObject obj) {
     inGame = true;
     showReturnToLobbyButton = false;
     EsObject[] chips = obj.getEsObjectArray(GameConstants.CHANGED_CHIPS);
         //for (EsObject chipObj : chips) {
     for (int ii = 0; ii < chips.Length; ii++)
     {
         addOrUpdateOneChip(chips[ii]);
     }
 }
 private string getPlayerName(EsObject obj)
 {
     return obj.getString(PluginTags.USER_NAME);
 }
    private void handlePositionUpdateEvent(EsObject esob)
    {
        //Debug.Log("handlePositionUpdateEvent");
        string name = esob.getString(PluginTags.USER_NAME);
        if (name.Equals(_userName))
        {
            // my own position
            // unless the plugin is likely to enforce a position on me, just ignore this
        }
        else {
            // remote player position
            GameObject obj = GameObject.Find("remote_" + name);
            if (obj == null)
            {
                Debug.Log("remote_" + name + " not found");
                return;
            }
            else
            {
                // move the remote player to match
                //Debug.Log("asking remote player to move");
                obj.SendMessage("ReceiveTransform", esob);

            }
        }

    }
예제 #43
0
    public void handleTurnAnnouncement(EsObject obj)
    {
        audio.Play();
        String playerName = obj.getString(GameConstants.PLAYER_NAME);
        int seconds = obj.getInteger(GameConstants.TURN_TIME_LIMIT);

        if (null != clock)
        {
            clock.SetTimer(seconds);
        }
        bool isBlack = obj.getBoolean(GameConstants.COLOR_IS_BLACK);
        int[] legalMoves = obj.getIntegerArray(GameConstants.LEGAL_MOVES);

        clearLegalMoves();
        if (playerName == (me))
        {
            // it's my turn!
            if (myColor < 0)
            {
                myColor = GameConstants.BLACK;
                if (!isBlack)
                {
                    myColor = GameConstants.WHITE;
                }
            }
            setLegalMoves(legalMoves);
            canClick = true;
            errorMessage = "";
        }
        else
        {
            canClick = false;
        }

        if (isBlack)
        {
            waitingMessage = playerName + "'s turn: Black";
        } 
        else
        {
            waitingMessage = playerName + "'s turn: White";
        } 

    }
예제 #44
0
 // only needed if there are AS3 clients in the same room
 public static float getUnityPostionXfromAS3(EsObject data)
 {
     float targetX = data.getInteger(PluginTags.TARGET_X);
     return targetX / AS3_MULTIPLIER;
 }
예제 #45
0
 void handleGamesFoundEvent(EsObject esob)
 {
     EsObject[] esobs = esob.getEsObjectArray(LobbyConstants.GAMES_FOUND);
     for (int ii = 0; ii < LobbyConstants.NUM_ROWS; ii++)
     {
         AvailGame ag = playerGrid[ii];
         if (ii < esobs.Length)
         {
             EsObject obj = esobs[ii];
             ag.name = obj.getString(LobbyConstants.PLAYER_NAME);
             ag.gameId = obj.getInteger(LobbyConstants.ID);
         }
         else
         {
             ag.clear();
         }
     }
 }
예제 #46
0
    private QuickJoinGameRequest getBasicQuickJoinRequest()
    {
        QuickJoinGameRequest qjr = new QuickJoinGameRequest();
        qjr.GameType = GameConstants.PLUGIN_NAME;
        qjr.ZoneName = GameConstants.ZONE_NAME;
        qjr.Hidden = false;
        qjr.Locked = false;
        qjr.CreateOnly = false;

        EsObject initOb = new EsObject();
        initOb.setString(GameConstants.PLAYER_NAME, me);
        initOb.setBoolean(GameConstants.AI_OPPONENT, true);

        qjr.GameDetails = initOb;

        return qjr;
    }
예제 #47
0
 // only needed if there are AS3 clients in the same room
 public static float getUnityPostionZfromAS3(EsObject data)
 {
     float targetY = data.getInteger(PluginTags.TARGET_Y);
     targetY = (AS3_PANEL_HEIGHT - targetY);
     return targetY / AS3_MULTIPLIER;
 }
예제 #48
0
 private void sendInitMeRequest()
 {
     EsObject obj = new EsObject();
     obj.setString(GameConstants.ACTION, GameConstants.INIT_ME);
     sendToPlugin(obj);
 }
예제 #49
0
 public void handleMoveEvent(EsObject obj) {
     // only happens if it's good
     EsObject[] changedChips = obj.getEsObjectArray(GameConstants.CHANGED_CHIPS, null);
     if (changedChips != null) {
         // update the board
         for (int ii = 0; ii < changedChips.Length; ii++)
         {
             addOrUpdateOneChip(changedChips[ii]);
         }
     }
 }
예제 #50
0
 public void handleMoveResponse(EsObject obj)
 {
     // only happens if there's an error
     String error = obj.getString(GameConstants.ERROR_MESSAGE);
     Debug.Log("handleMoveResponse ERROR: " + error);
     errorMessage = "ERROR: " + error;
 }
 private void handleUserListResponse(EsObject esob)
 {
     //Debug.Log("handleUserListResponse");
     EsObject[] players = esob.getEsObjectArray(PluginTags.USER_STATE);
     getPlayerSpawnController().SpawnRemotePlayers(players, _userName);
 }
 private void SendAnimationMessageToRemotePlayerObject(EsObject data)
 {
     string name = data.getString(PluginTags.USER_NAME);
     if (!name.Equals(_userName))
     {  // If it's not myself
         //Find user object with such Id
         GameObject obj = GameObject.Find("remote_" + name);
         if (obj == null)
         {
             Debug.Log("remote_" + name + " not found");
             return;
         }
         else
         {
             // send the remote player animation message
             Debug.Log("send the remote player animation message");
             string anim = data.getString(PluginTags.AVATAR_STATE_EVENT, "");
             if (anim.Length > 0)
             {
                 obj.SendMessage("PlayAnimation", anim);
             }
             else
             {
                 // this could be some other type of AVATAR_STATE_EVENT
                 // such as the one that the plugin sends that changes the 
                 // emotion of the user, for the AS3 clients.  Unity clients 
                 // currently ignore these emotion changes.
             }
         }
     }
 }
 private void handleUserExitEvent(EsObject esob)
 {
     //Debug.Log("handleUserExitEvent");
     string name = esob.getString(PluginTags.USER_NAME);
     getPlayerSpawnController().UserLeaveRoom(name);
     SendMessage("AddChatMessage", name + " left the room.");
 }
예제 #54
0
    public void handleGameOver(EsObject obj)
    {
        audio.Play();
        canClick = false;
        showReturnToLobbyButton = true;
        String winner = obj.getString(GameConstants.WINNER, "");
        // If we want to display the individual scores, this 
        // unpacks the info and stores it in model for view to get. (JAVA version)
        //        HashMap scoresMap = new HashMap<String, Integer>();
        //        if (obj.variableExists(GameConstants.SCORE)) {
        //            EsObject[] scores = obj.getEsObjectArray(GameConstants.SCORE);
        //            for (EsObject playerObj : scores) {
        //                String name = playerObj.getString(GameConstants.PLAYER_NAME);
        //                int points = playerObj.getInteger(GameConstants.SCORE);
        //                scoresMap.put(name, points);
        //            }
        //            model.setScores(scoresMap);
        //        }

        waitingMessage = "Game Over";
        errorMessage = "Winner: " + winner;
    }
예제 #55
0
    private void JoinRoom()
    {
        //request used to create a room
		QuickJoinGameRequest qjr = new QuickJoinGameRequest();
		qjr.GameType = LobbyConstants.PLUGIN_NAME;
		qjr.ZoneName = LobbyConstants.ZONE_NAME;
		qjr.Hidden = false;
		qjr.Locked = false;
		qjr.CreateOnly = false;
		
		EsObject initOb = new EsObject();
		
		qjr.GameDetails = initOb;
		
		_es.Engine.Send(qjr);

        waitingMessage = "QuickJoinGameRequest sent for lobby";

        Debug.Log("QuickJoinGameRequest sent for ReversiLobby");
    }
예제 #56
0
 private void addOrUpdateOneChip(EsObject chipObj)
 {
     int id = chipObj.getInteger(GameConstants.ID);
     bool isBlack = chipObj.getBoolean(GameConstants.COLOR_IS_BLACK);
     int color = GameConstants.BLACK;
     if (!isBlack)
     {
         color = GameConstants.WHITE;
     }
     Chip chip = board[id];
     chip.setColor(color);
     Debug.Log("addOrUpdateOneChip: " + id);
 }
예제 #57
0
        public static Quaternion getPlayerRotation(EsObject data)
        {
            if (data.variableExists(PluginTags.POSITION_X))
            {
                return new Quaternion(Convert.ToSingle(data.getFloat(PluginTags.ROTATION_X)),
                                        Convert.ToSingle(data.getFloat(PluginTags.ROTATION_Y)),
                                        Convert.ToSingle(data.getFloat(PluginTags.ROTATION_Z)),
                                        Convert.ToSingle(data.getFloat(PluginTags.ROTATION_W))
                                        );
            }
            else
            {
                // only needed if there are AS3 clients in the same room, or for user enters room
                return new Quaternion(0, 0, 0, 1);
            }

        }
    // I don't understand why this is here - see what happens if it's removed???
	void FixedUpdate() {
		if (remoteUser!=null) {
			SpawnRemotePlayer(remoteUser);
			remoteUser = null;	
		}
	}
	void SendAnimationMessage(string message) {
        EsObject data = new EsObject();
        data.setString(PluginTags.ACTION, PluginTags.AVATAR_STATE_REQUEST);
        data.setString(PluginTags.AVATAR_STATE_EVENT, message);
        getNetworkController().sendToPlugin(data);
	}
예제 #60
0
 public void handleGameRestart(EsObject obj)
 {
     myColor = -1;
     initBoard();
     waitingMessage = "Waiting for game to start";
     errorMessage = "";
     inGame = false;  // wait until the game starts to display the board
     sendInitMeRequest();
 }