예제 #1
0
    /**********************************************协程*/
    //IEnumerator JudgeConnected()
    //{
    //    while (!PhotonNetwork.connected)
    //    {
    //        yield return 0;
    //    }
    //    PanelChange(lobby);
    //    PanelChange(ChooseGame);
    //    StartCoroutine(JudgeDisconnected());
    //}


    //IEnumerator JudgeDisconnected() {
    //    while (PhotonNetwork.connected) {
    //        yield return 0;
    //    }
    //    PanelChange(Information);
    //    InformationText.GetComponent<Text>().text = "已经掉线";
    //    Application.LoadLevel("Start");
    //}
    ///**********************************************/

    //public static void ChangeRoomPanel() {
    //    PanelChange(room);
    //}

    //static public void OutUpdate() {
    //    myPhotonView.RPC("UpdateRoomInfo", PhotonTargets.AllBuffered);
    //}

    //public void restar() {
    //    TypedLobby yl = new TypedLobby();
    //    PhotonNetwork.JoinLobby(yl);
    //    Application.LoadLevel("五子棋");
    //}


    //public void OnSee() {
    //    Application.LoadLevelAdditive("game");
    //}

    //public void OnBackChooseGame() {
    //    PanelChange(ChooseGame);
    //    PanelChange(panel);
    //    PhotonNetwork.LeaveLobby();
    //}

    //public void OnJoinGobang() {
    //    TypedLobby tl = new TypedLobby();
    //    tl.Name = "Gobang";
    //    PhotonNetwork.JoinLobby(new TypedLobby() { Name = "Gobang" });
    //}

    //public void OnJoinBlokus() {
    //    PhotonNetwork.JoinLobby(new TypedLobby() { Name = "Blokus" });
    //}

    //public void OnLobby() {
    //    print("点击加入游戏大厅");
    //    TypedLobby yl = new TypedLobby();
    //    yl.Name = "五子棋";
    //    PhotonNetwork.JoinLobby(yl);
    //    PhotonNetwork.ConnectUsingSettings("v1.1");
    //}

    //public void OnRoom() {
    //    Application.LoadLevelAdditive("game");

    //    if (IsNameNull()) {
    //        return;
    //    }
    //    print("点击加入房间");
    //    yourName = GameObject.Find("GetName").GetComponent<Text>().text;
    //    InformationText.GetComponent<Text>().text = "正在加入房间...";
    //    PanelChange(Information);
    //    PhotonNetwork.JoinRandomRoom();

    //}

    public void createRoom()
    {
        print("创房间");
        if (isRoomNameNull())
        {
            return;
        }
        promptText.text = "creating...";
        showPanel(promptPanel);
        string roomName = roomNameInput.text;


        //RoomOptions roomOptions = null;
        //if (PhotonNetwork.lobby.Name.Equals("Gobang")) {
        //    roomOptions = new RoomOptions() { IsVisible = true, MaxPlayers = 2 };
        //} else {
        //    roomOptions = new RoomOptions() { IsVisible = true, MaxPlayers = 4 };
        //}
        //GameCache.roomNameRequest = roomName;
        //  = GameObject.Find("ToggleGroup").GetComponent<ToggleGroup>();
        if (toggleFour.isOn)
        {
            NetManager.Instance.TransferMessage(MessageFormater.createRoom(roomName, GameType.BLOKUS_FOUR));
        }
        else
        {
            NetManager.Instance.TransferMessage(MessageFormater.createRoom(roomName, GameType.BLOKUS_TWO));
        }

        //PhotonNetwork.CreateRoom(str, roomOptions, TypedLobby.Default);
    }
예제 #2
0
    public void onRegister()
    {
        string account          = registerAccountText.text;
        string password         = registerPasswordText.text;
        string repeatedPassword = registerRepeatedPasswordText.text;

        if (account.Length < 6 || password.Length < 6)
        {
            showPromptWithButtonMessage("Password must be no fewer than six");
            return;
        }

        if (!System.Text.RegularExpressions.Regex.IsMatch(account, "^[0-9a-zA-Z]+$"))
        {
            showPromptWithButtonMessage("Can only be made up of letters and numbers");
            return;
        }

        if (!password.Equals(repeatedPassword))
        {
            showPromptWithButtonMessage("Two passwords are different");
            return;
        }

        if (registerTimeTemp > 0)
        {
            showPromptWithButtonMessage("Too frequent operation");
            return;
        }

        NetManager.Instance.TransferMessage(MessageFormater.formatRegisterMessage(account, password));
        registerTimeTemp = REGISTER_REQUEST_TIME_INTERVAL_SECONDS;
    }
예제 #3
0
 public MessageGenerator(MessageFormater <TMessageTemplate, TMessage> formater,
                         MessageTemplateFactory <TMessageTemplate> templateFactory, TokenGenerator tokenGenerator)
 {
     this.formater        = formater;
     this.templateFactory = templateFactory;
     this.tokenGenerator  = tokenGenerator;
 }
        public static ListOutput OutputList(ulong userId, params string[] input)
        {
            if (input.Length != 1)
            {
                throw GetListManagerException(ListErrorMessage.General.WrongFormat);
            }

            CustomList list = GetList(userId, input[0]);

            CheckPermissionWrite(userId, list);

            if (list.Count() == 0)
            {
                throw GetListManagerException(ListErrorMessage.General.ListIsEmpty_list, input[0]);
            }

            Func <int, int, int> GetLonger = (i1, i2) => { return(i1 > i2 ? i1 : i2); };

            var maxItemLength = 0;
            var values        = new string[list.Count(), 1];

            for (int i = 0; i < list.Count(); i++)
            {
                var row = $"{(i+1).ToString()}: {list.Contents[i]}";
                values[i, 0]  = row;
                maxItemLength = GetLonger(maxItemLength, row.Length);
            }
            maxItemLength = GetLonger(maxItemLength, list.Name.Length);

            var    tableSettings = new MessageFormater.TableSettings(list.Name, -(maxItemLength), false);
            string output        = MessageFormater.CreateTable(tableSettings, values);

            return(GetListOutput(output, list.Permission));
        }
예제 #5
0
    private void judgeAround(int x, int y)
    {
        bool judgeSuccess = false;
        int  lastX        = x;
        int  lastY        = y;

        if (judgeOverall(x, y))
        {
            judgeSuccess = true;
        }
        else
        {
            foreach (ChessPoint point in getAroundPoints(x, y))
            {
                if (judgeOverall(point.x, point.y))
                {
                    judgeSuccess = true;
                    lastX        = point.x;
                    lastY        = point.y;
                    break;
                }
            }
        }

        if (judgeSuccess)
        {
            MessageBean         message       = MessageFormater.formatChessDoneMessage(lastX, lastY, CurrentSquareName, CurrentSquare.rotationFlag, CurrentSquare.symmetryFlag, CurrentSquare.model);
            BLOKUSChessDoneInfo chessDoneInfo = ProtobufHelper.DederializerFromBytes <BLOKUSChessDoneInfo>(message.data);
            GameObject.Find("BlokusUIController").GetComponent <BlokusUIController>().tryChess(chessDoneInfo);
            //  chessDone(chessDoneInfo);
        }
    }
 private void OnBack()
 {
     NetManager.Instance.TransferMessage(MessageFormater.formatLeaveRoomMessage());
     GameCache.inRoomListPanel = true;
     myUIController.hidePanel(myUIController.blokusRoomPanel);
     myUIController.showPanel(myUIController.roomListPanel);
 }
예제 #7
0
    //public void sendChatMessageYourself(string message) {
    //    string str = getColor(color) + " player lose";
    //    //   SendMessageToAll(str);
    //}

    public void OnSendMessage()
    {
        print("按下发送按钮");
        string str = "<color=" + getColor(myBlokusController.myColor) + ">" + GameCache.account + ":\n  " + /*"(player):" +*/ inputInfo.text + "</color>";

        NetManager.Instance.TransferMessage(MessageFormater.formatChatInGameMessage(str));
    }
    public void onSendMessage()
    {
        print("按下发送按钮");
        string str = GameCache.account + ":\n  " + /*"(player):" +*/ inputInfo.text;

        NetManager.Instance.TransferMessage(MessageFormater.formatChatInRoomMessage(str));
    }
 public void OnBlue()
 {
     if (GameCache.myColor != Color.BLUE)
     {
         NetManager.Instance.TransferMessage(MessageFormater.chooseColor(GameCache.account, GameCache.roomName, Color.BLUE));
     }
 }
 public void OnYellow()
 {
     if (GameCache.myColor != Color.YELLOW)
     {
         NetManager.Instance.TransferMessage(MessageFormater.chooseColor(GameCache.account, GameCache.roomName, Color.YELLOW));
     }
 }
예제 #11
0
    //void OnPhotonRandomJoinFailed()  //加入随机房间失败
    //{
    //    print("随机房间加入失败");
    //    UISureText.text = "加入房间失败!";
    //    PanelChange(message);
    //    PanelChange(Information);
    //    OnReceivedRoomListUpdate();
    //}



    void OnRoomListUpdate(BLOKUSRoomList roomInfos)   //房间列表更新
    {
        //print("改变");

        foreach (GameObject gameObject in roomList)
        {
            Destroy(gameObject);
        }
        roomList.Clear();
        foreach (BLOKUSRoomInfo roomInfo in roomInfos.roomItems)
        {
            GameObject room = Instantiate(roomItem, roomContent.transform, false);
            roomList.Add(room);
            // room.transform.SetParent(roomContent.transform);

            RoomItemData roomItemData = room.GetComponent <RoomItemData>();
            roomItemData.roomName      = roomInfo.roomName;
            roomItemData.connectPlayer = roomInfo.currentPlayers;
            roomItemData.roomStatus    = roomInfo.RoomStatus;
            if (roomInfo.gameType == GameType.BLOKUS_FOUR)
            {
                roomItemData.maxPlayer = 4;
            }
            else
            {
                roomItemData.maxPlayer = 2;
            }

            roomItemData.ShowRoomInfo();

            room.GetComponent <Button>().onClick.AddListener(delegate {
                NetManager.Instance.TransferMessage(MessageFormater.formatJoinRoomMessage(roomInfo.roomName));
            });
        }
    }
예제 #12
0
    public void Start()
    {
        myUIController     = GameObject.Find("UIController").GetComponent <UIController>();
        myBlokusController = GameObject.Find("BlokusController").GetComponent <BlokusController>();
        NetManager.Instance.TransferMessage(MessageFormater.formatInitPlayerInfoInGameMessage());

        StartCoroutine(JudgeTimeOut());   //开启协程
                                          //   InitBlokusRoomUIInfo();
    }
예제 #13
0
    public void lose(LoseParam loseParam)
    {
        lock (lockObject) {
            int color     = loseParam.color;
            int gameEvent = loseParam.gameEvent;
            if (myBlokusController.loseColor[color] == 1 ||
                myBlokusController.gameOver ||
                myBlokusController.loseCount == myBlokusController.MAX_PLAYERS_COUNT - 1)
            {
                return;
            }

            if (myBlokusController.MAX_PLAYERS_COUNT - myBlokusController.loseCount == 2)
            {
                int nextColor = myBlokusController.getNextColor(color);
                if (color == myBlokusController.myColor)
                {
                    if (GameEvent.TIME_CONSUME == gameEvent)
                    {
                        NetManager.Instance.TransferMessage(MessageFormater.formatLoseMessage());
                    }
                    ShowMessage(getColor(nextColor) + " player win!");
                }
                else if (nextColor == myBlokusController.myColor)
                {
                    NetManager.Instance.TransferMessage(MessageFormater.formatWinMessage());
                    ShowMessage("Congratulations to you on winning this match!");
                }
                else
                {
                    ShowMessage(getColor(nextColor) + " player win!");
                }
                chatInGame(getColor(color) + " player lose!");
                chatInGame(getColor(nextColor) + " player win!");
                myBlokusController.lose(color);
                myBlokusController.gameOver = true;
                return;
            }

            if (color == myBlokusController.myColor)
            {
                ShowMessage("you lose!");  //下棋截止时间到,
                if (GameEvent.TIME_CONSUME == gameEvent)
                {
                    NetManager.Instance.TransferMessage(MessageFormater.formatLoseMessage());
                }
                //  NetManager.Instance.TransferMessage(MessageFormater.formatLoseMessage());
            }
            else
            {
                ShowMessage(getColor(color) + " player lose!");//"下棋截止时间到," +
            }
            chatInGame(getColor(color) + " player lose!");
            myBlokusController.lose(color);
            Debug.Log("lock  end*********************************!!!!!!!!!1");
        }
    }
    //public void OnBackLobby()
    //{
    //    UIControl.PanelChange(myUIControl.BlokusRoom);
    //    UIControl.PanelChange(myUIControl.ChooseGame);
    //    PhotonNetwork.LeaveRoom();
    //   // StartCoroutine(GoToBlokus());
    // //   PhotonNetwork.JoinLobby(new TypedLobby() { Name = "Blokus" });
    //}

    //public void  OnReady()
    //{
    //    if (IsSuitcolor())
    //    {
    //        ExitGames.Client.Photon.Hashtable ht = PhotonNetwork.player.AllProperties;
    //        ht["ready"] = ht["ready"].ToString().Equals("已准备") ? "未准备" : "已准备";
    //        PhotonNetwork.player.SetCustomProperties(ht);
    //        myPhotonView.RPC("UpDateBlokusRoomInfo", PhotonTargets.All); //所有人更新信息
    //    }
    //    if (IsAllReady())
    //    {
    //        myPhotonView.RPC("BlokusStart", PhotonTargets.All); //所有人更新信息
    //    }
    //}

    public void OnRed()
    {
        if (GameCache.myColor != Color.RED)
        {
            NetManager.Instance.TransferMessage(MessageFormater.chooseColor(GameCache.account, GameCache.roomName, Color.RED));
        }
        //    ExitGames.Client.Photon.Hashtable ht = PhotonNetwork.player.AllProperties;
        //ht["color"] = "red";
        //PhotonNetwork.player.SetCustomProperties(ht);
        //myPhotonView.RPC("UpDateBlokusRoomInfo", PhotonTargets.All); //所有人更新信息
    }
        public async Task <IActionResult> BlockCustomer(Customer customer, [FromQuery] Format format)
        {
            string message = string.Empty;

            if (customer != null)
            {
                message = MessageFormater.GetMessage(customer, format, MessageType.Block);
            }
            await _messagingService.SendMessageAsync(customer.UserId, message);

            return(StatusCode(200, $"User with id {customer.UserId} successfully blocked"));
        }
        public async Task <IActionResult> RegisterCustomer(Customer customer, [FromQuery] Format format)
        {
            string message = string.Empty;

            if (customer != null)
            {
                message = MessageFormater.GetMessage(customer, format, MessageType.Register);
            }
            await _messagingService.SendMessageAsync(customer.UserId, message);

            return(StatusCode(201, customer));
        }
예제 #17
0
 public void OnGiveUp()
 {
     if (myBlokusController.loseCount < myBlokusController.MAX_PLAYERS_COUNT - 1)
     {
         if (myBlokusController.loseColor[myBlokusController.myColor] == 0)
         {
             //myBlokusController.giveUp(myBlokusController.myColor);
             NetManager.Instance.TransferMessage(MessageFormater.formatGiveUpMessage(myBlokusController.myColor));
         }
         else
         {
             ShowMessage("you have lost already");
         }
     }
 }
예제 #18
0
 internal void chessDoneOutSide(BLOKUSChessDoneInfo chessDoneInfoTemp, bool sure)
 {
     Destroy(currentCenterTemp);
     Destroy(tempSquare);
     if (sure)
     {
         lock (SURE_LOCK) {
             if (CurrentColor == myColor)
             {
                 GameObject.Find("Canvas").GetComponent <ChoosePanel>().DestoryBtn();
                 NetManager.Instance.TransferMessage(MessageFormater.formatChessDoneMessage(chessDoneInfoTemp));
                 chessDone(chessDoneInfoTemp);
             }
         }
     }
 }
예제 #19
0
    private void Update()
    {
        timeTemp -= Time.deltaTime;
        if (timeTemp < 0)
        {
            if (GameCache.inRoomListPanel)
            {
                NetManager.Instance.TransferMessage(MessageFormater.formatRoomListMessage());
            }
            timeTemp = UPDATE_ROOM_LIST_TIME_INTERVAL_SECONDS;
        }

        if (registerTimeTemp > 0)
        {
            registerTimeTemp -= Time.deltaTime;
        }
    }
예제 #20
0
    public void onLogout()
    {
        showPanel(loginPanel);
        hidePanel(settingPanel);
        hidePanel(roomListPanel);
        GameCache.inRoomListPanel = false;
        NetManager.Instance.TransferMessage(MessageFormater.formatLogoutMessage());



        try {
            GameObject gameObject = GameObject.Find("BlokusCamera");
            if (gameObject != null)
            {
                GameObject.Find("StartCamera").GetComponent <Camera>().enabled  = true;
                GameObject.Find("BlokusCamera").GetComponent <Camera>().enabled = false;

                foreach (GameObject g in BlokusUIController.allChess)
                {
                    Destroy(g);
                }
                BlokusController blokusController = GameObject.Find("BlokusController").GetComponent <BlokusController>();
                Destroy(blokusController.currentCenter);
                Destroy(blokusController.tempSquare);
                Destroy(blokusController.currentCenterTemp);
                //OnGiveUp();
                // myUIController.showPanel(myUIController.blokusRoomPanel);
                if (GameCache.gameType == GameType.BLOKUS_FOUR)
                {
                    Application.UnloadLevel("Blokus");
                }
                else
                {
                    Application.UnloadLevel("BlokusTP");
                }
            }
        } catch (Exception e) {
        }

        //}
    }
예제 #21
0
        private ListOutput OutputList(UserInfo userInfo, ListPermission permission, params string[] input)
        {
            if (input.Length != 1)
            {
                throw GetListManagerException(ListErrorMessage.General.WrongFormat);
            }

            CustomList list = GetList(input[0]);

            ThrowIfMissingReadPermission(userInfo, list);

            if (list.Count() == 0)
            {
                throw GetListManagerException(ListErrorMessage.General.ListIsEmpty_list, input[0]);
            }

            Func <int, int, int> GetLonger = (i1, i2) => { return(i1 > i2 ? i1 : i2); };

            var maxItemLength = 0;
            var values        = new string[list.Count(), 1];

            for (int i = 0; i < list.Count(); i++)
            {
                var row = $"{(i + 1).ToString()}: {list.Contents[i]}";
                values[i, 0]  = row;
                maxItemLength = GetLonger(maxItemLength, row.Length);
            }
            maxItemLength = GetLonger(maxItemLength, list.Name.Length);

            var    tableSettings = new MessageFormater.TableSettings(list.Name, -(maxItemLength), false);
            string output        = MessageFormater.CreateTable(tableSettings, values);

            var outputPermission = permission == ListPermission.PRIVATE ? list.PermissionByRole.First().Value : permission;

            return(GetListOutput(output, outputPermission));
        }
예제 #22
0
        private static string FormMessage(NotificationInfo info)
        {
            var message = MessageFormater.FormNotificationMassage(info);

            return(message);
        }
 public WallMessageFormater(MessageFormater messageFormater)
 {
     this.messageFormater = messageFormater;
 }
예제 #24
0
 private void checkVersion()
 {
     TransferMessage(MessageFormater.formatCheckVersionMessage(VERSION));
 }
예제 #25
0
 public void login()
 {
     //  GameCache.accountReqest = accountText.text;
     NetManager.Instance.TransferMessage(MessageFormater.formatLoginMessage(accountText.text, passwordText.text));
 }
예제 #26
0
 public void onGoToRankPanel()
 {
     NetManager.Instance.TransferMessage(MessageFormater.formatRankInfoMessagae());
     hidePanel(roomListPanel);
     showPanel(rankPanel);
 }
예제 #27
0
 public void onRefreshRank()
 {
     NetManager.Instance.TransferMessage(MessageFormater.formatRankInfoMessagae());
 }
예제 #28
0
        private ListOutput GetAll(UserInfo userInfo, ListPermission outputPermission)
        {
            if (Lists.Count == 0)
            {
                throw GetListManagerException(ListErrorMessage.General.NoLists);
            }

            Func <int, int, int> GetLonger = (i1, i2) => { return(i1 > i2 ? i1 : i2); };

            var tableValuesList = new Dictionary <String, String>();

            for (int i = 0; i < Lists.Count; i++)
            {
                CustomList l = Lists[i];
                if (l.IsAllowedToList(userInfo))
                {
                    tableValuesList.Add(l.Name, $"{l.Count()} {GetNounPlural("item", l.Count())}");
                }
            }
            var maxItemLength = 0;
            var tableValues   = new string[tableValuesList.Count, 2];

            for (int i = 0; i < tableValues.GetLength(0); i++)
            {
                var keyPair = tableValuesList.ElementAt(i);
                tableValues[i, 0] = keyPair.Key;
                tableValues[i, 1] = keyPair.Value;
                maxItemLength     = GetLonger(maxItemLength, keyPair.Key.Length);
                maxItemLength     = GetLonger(maxItemLength, keyPair.Value.Length);
            }

            var header = new[] { "List name", "Item count" };

            foreach (string s in header)
            {
                maxItemLength = GetLonger(maxItemLength, s.Length);
            }
            var    tableSettings = new MessageFormater.TableSettings("All lists", header, -(maxItemLength), true);
            string output        = MessageFormater.CreateTable(tableSettings, tableValues);
            var    count         = 0;

            for (int i = 0; i < output.Length; i++)
            {
                if (output[i] == '\n')
                {
                    if (count == 8)
                    {
                        output = output.Insert(i, LineIndicator);
                        break;
                    }
                    else
                    {
                        count++;
                    }
                }
            }

            var returnValue = GetListOutput(output, outputPermission);

            returnValue.listenForReactions = true;
            return(returnValue);
        }
예제 #29
0
 public void onGoToProfilePanel()
 {
     profileAccount.text = GameCache.account;
     NetManager.Instance.TransferMessage(MessageFormater.formatProfileMessage(GameCache.account));
     showPanel(profilePanel);
 }
 public WallMessageFormater(MessageFormater messageFormater)
 {
     this.messageFormater = messageFormater;
 }
예제 #31
0
 public void onGoToProfilePanel(String account)
 {
     profileAccount.text = account;
     NetManager.Instance.TransferMessage(MessageFormater.formatProfileMessage(account));
     showPanel(profilePanel);
 }