예제 #1
0
    public MsgPlayerInfo GetPlayerInfoById(ulong pid)
    {
        foreach (var v in playersDic)
        {
            if (v.Value != null && v.Value.player_id != 0)
            {
                if (v.Value.player_id == pid)
                {
                    v.Value.teamType = v.Key == EPlayerPositionType.ETop ? (uint)EPlayersTeam.ETeamA : (uint)EPlayersTeam.ETeamB;
                    return(v.Value);
                }
            }
        }

        if (pid == PlayerInfo.Instance.mPlayerPid)
        {
            MsgPlayerInfo playerInfo = new MsgPlayerInfo();
            playerInfo.head_portrait = PlayerInfo.Instance.mPlayerData.headPortrait;
            playerInfo.money         = (uint)PlayerInfo.Instance.mPlayerData.money;
            playerInfo.name          = PlayerInfo.Instance.mPlayerData.name;
            playerInfo.sex           = (uint)PlayerInfo.Instance.mPlayerData.sex;
            playerInfo.player_id     = (uint)PlayerInfo.Instance.mPlayerData.pid;
            playerInfo.teamType      = (int)EPlayersTeam.ETeamA;
            playerInfo.goal          = PlayingGameInfo.Instance.mScore;
            return(playerInfo);
        }

        return(null);
    }
예제 #2
0
    public MsgPlayerInfo GetPlayerInfoByPos(EPlayerPositionType posType)
    {
        foreach (var value in playersDic)
        {
            if (value.Value != null)
            {
                if (value.Key == posType)
                {
                    return(value.Value);
                }
            }
        }

        if (EPlayerPositionType.ESelf == posType)
        {
            MsgPlayerInfo playerInfo = new MsgPlayerInfo();
            playerInfo.head_portrait = PlayerInfo.Instance.mPlayerData.headPortrait;
            playerInfo.money         = (uint)PlayerInfo.Instance.mPlayerData.money;
            playerInfo.name          = PlayerInfo.Instance.mPlayerData.name;
            playerInfo.player_id     = (uint)PlayerInfo.Instance.mPlayerData.pid;
            playerInfo.teamType      = (int)EPlayersTeam.ETeamA;
            return(playerInfo);
        }

        return(null);
    }
예제 #3
0
    /// <summary>
    /// 获取其他玩家的信息
    /// </summary>
    /// <param name="id"></param>
    private void GetShipData(ulong id)
    {
        //Debug.LogError("收到玩家信息"+id);
        ShipItemsProxy shipItemsProxy = GameFacade.Instance.RetrieveProxy(ProxyName.ShipItemsProxy) as ShipItemsProxy;
        // 飞船的
        IShip ship = shipItemsProxy.GetCurrentWarShip(id);

        if (ship != null)
        {
            FriendInfoVO vO = m_FriendProxy.GetFriend(id);
            if (vO != null)
            {
                MsgPlayerInfo msgPlayerInfo = new MsgPlayerInfo();
                msgPlayerInfo.Name = vO.Name;
                msgPlayerInfo.Tid  = vO.TID;
                msgPlayerInfo.UID  = vO.UID;
                msgPlayerInfo.Ship = ship;
                m_LeftSelectIndex  = (int)m_SocialSubClass;

                //OwnerView.OpenChildPanel(UIPanel.EscWatchPanel, msgPlayerInfo);
            }
        }
        else
        {
            Debug.Log("船的信息为空");
        }
    }
예제 #4
0
        private static void HandlePlayerInfo(NetworkMessage msg)
        {
            MsgPlayerInfo info = msg as MsgPlayerInfo;

            WriteLine("Players Were Updated ");
            foreach (var p in info.PlayerUpdates)
            {
                WriteLine(String.Format("\tID: {0} Attributes: {1} ", p.PlayerID, p.Attributes.ToString()));
            }
        }
예제 #5
0
 private void InitSnake(MsgRoomEnter roomEnterData)
 {
     // for (int i = 0; i < roomEnterData.PlayerList.Count; i++)
     {
         MsgPlayerInfo info        = roomEnterData.PlayerList[0];
         Vector3       StartVector = new Vector3(info.DirectionX, 0, info.DirectionY);
         m_SelfSnake   = CreateSnake(info.AccountId + "Snake", StartVector, info.SurplusLength, info.Speed);
         m_ToDirection = new Vector3(info.DirectionX, 0, info.DirectionY);
     }
 }
예제 #6
0
    /// <summary>
    /// 使用道具
    /// </summary>
    /// <param name="g"></param>
    public void OnHeadClick(GameObject g)
    {
        AudioManager.Instance.PlayClickBtnAudio();
        ContextManager.Instance.Push(new ToolsViewContext());
        GameObject    toolsGm = UIManagers.Instance.GetSingleUI(UIType.PropView);
        uint          pid     = RoomInfo.Instance.GetIdByName(g.name);
        MsgPlayerInfo data    = RoomInfo.Instance.GetPlayerInfoById(pid);

        toolsGm.GetComponent <UIToolsView>().SetData(data, pid);
    }
예제 #7
0
 void CopyClass(MsgPlayerInfo info, EPlayerPositionType posType)
 {
     if (playersDic[posType] == null)
     {
         return;
     }
     info.head_portrait = playersDic[posType].head_portrait;
     info.money         = playersDic[posType].money;
     info.name          = playersDic[posType].name;
     info.player_id     = playersDic[posType].player_id;
     info.sex           = playersDic[posType].sex;
     info.teamType      = playersDic[posType].teamType;
 }
예제 #8
0
        public void HandlePlayerInfo(NetworkMessage msg)
        {
            MsgPlayerInfo info = msg as MsgPlayerInfo;

            foreach (var p in info.PlayerUpdates)
            {
                Player player = GetPlayerByID(p.PlayerID);
                if (player != null)
                {
                    player.Attributes = p.Attributes;

                    if (PlayerInfoUpdated != null)
                    {
                        PlayerInfoUpdated.Invoke(this, player);
                    }
                }
            }
        }
예제 #9
0
    /// <summary>
    /// 通过其他Id获取其他玩家信息
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    MsgPlayerInfo GetArgsPlayerInfoById(List <MsgPlayerInfo> list, ulong id, EPlayerPositionType posType)
    {
        IEnumerator <MsgPlayerInfo> iters = list.GetEnumerator();

        while (iters.MoveNext())
        {
            if (iters.Current.player_id == id)
            {
                MsgPlayerInfo info = iters.Current;
                if (posType == EPlayerPositionType.ESelf || posType == EPlayerPositionType.ETop)
                {
                    info.teamType = (int)EPlayersTeam.ETeamA;
                }
                else
                {
                    info.teamType = (int)EPlayersTeam.ETeamB;
                }
                return(info);
            }
        }
        return(null);
    }
예제 #10
0
    public void SetData(MsgPlayerInfo data, ulong targetId /*, Vector3 startpos, Vector3 endpos*/)
    {
        this.targetId      = targetId;
        playerNameLab.text = data.name;
        idLab.text         = /*"ID: " +*/ data.player_id.ToString();

        if (data.player_id == PlayerInfo.Instance.mPlayerPid)
        {
            ipLab.text = /* "IP: " + */ PlayerInfo.Instance.GetIp;
            ipAds.text = PlayerInfo.Instance.mPlayerData.ipAds;
            string sprName = PlayerInfo.Instance.GetSexIsMan ? "porfile_man" : "porfile_woman";
            sexSpr.sprite       = ResourceManager.Instance.GetSpriteByName((int)EAtlasType.EMain, sprName);
            headTexture.texture = DataManager.Instance.GetTextureByName(ETextureName.EHeadTex1);
        }
        else
        {
            ipAds.text = data.ipAds;
            ipLab.text = /*"IP: " + */ data.ip;
            string sprName = data.sex == 1 ? "porfile_man" : "porfile_woman";
            sexSpr.sprite = ResourceManager.Instance.GetSpriteByName((int)EAtlasType.EMain, sprName);
            //  headTexture.mainTexture = DataManager.Instance.GetOtherPlayerHead(data.head_portrait);
            StartCoroutine(GlobalData.GetHeadTextureByIdx(headTexture, data.head_portrait));
        }
    }
예제 #11
0
    void SetPlayerData(EPlayerPositionType posType, MsgPlayerInfo args)
    {
        ClearPlayerReadyStatus(posType);
        bool isShow = args == null || args.player_id == 0 ? false : true;

        if (posType == EPlayerPositionType.ERight)
        {
            CheckShowJoinTween(rightHeadSpr.transform, RightContainer.activeSelf, isShow);
            RightContainer.SetActive(isShow);
            if (isShow)
            {
                StartCoroutine(GlobalData.GetHeadTextureByIdx(rightHeadSpr, args.head_portrait));
                rightName.text = args.name;
            }
        }
        else if (posType == EPlayerPositionType.ETop)
        {
            CheckShowJoinTween(topHeadSpr.transform, TopContainer.activeSelf, isShow);
            TopContainer.SetActive(isShow);
            if (isShow)
            {
                StartCoroutine(GlobalData.GetHeadTextureByIdx(topHeadSpr, args.head_portrait));
                topName.text = args.name;
            }
        }
        else
        {
            CheckShowJoinTween(leftHeadSpr.transform, leftContainer.activeSelf, isShow);
            leftContainer.SetActive(isShow);
            if (isShow)
            {
                StartCoroutine(GlobalData.GetHeadTextureByIdx(leftHeadSpr, args.head_portrait));
                leftName.text = args.name;
            }
        }
    }
예제 #12
0
 void UpdatePlayerInfoData(MsgPlayerInfo info, EPlayerPositionType playerPosType)
 {
     playersDic[playerPosType] = info;
 }
예제 #13
0
 public void AddNewPlayerDic(MsgPlayerInfo info)
 {
     playersDic[GetNextNewPlayerPosition()] = info;
 }
예제 #14
0
    public void ChangeTwoPlayerInfo(EPlayerPositionType applyPos, EPlayerPositionType toPos)
    {
        //自己的data永远不变
        if (applyPos == EPlayerPositionType.ESelf || toPos == EPlayerPositionType.ESelf)
        {
            MsgPlayerInfo tempRight = new MsgPlayerInfo();
            MsgPlayerInfo tempLeft  = new MsgPlayerInfo();
            MsgPlayerInfo tempTop   = new MsgPlayerInfo();
            CopyClass(tempRight, EPlayerPositionType.ERight);
            CopyClass(tempLeft, EPlayerPositionType.ELeft);
            CopyClass(tempTop, EPlayerPositionType.ETop);
            if (tempRight.name == null)
            {
                tempRight = null;
            }
            if (tempLeft.name == null)
            {
                tempLeft = null;
            }
            if (tempTop.name == null)
            {
                tempTop = null;
            }
            ClearPlayersDic();
            //Self 为apply ,则
            switch (toPos)
            {
            case EPlayerPositionType.ELeft:     //left==>right,right==>top,top==>left
                playersDic[EPlayerPositionType.ELeft]  = tempTop;
                playersDic[EPlayerPositionType.ERight] = tempLeft;
                playersDic[EPlayerPositionType.ETop]   = tempRight;
                break;

            case EPlayerPositionType.ERight:    //left==>top,right==>left,top==>right
                playersDic[EPlayerPositionType.ELeft]  = tempRight;
                playersDic[EPlayerPositionType.ERight] = tempTop;
                playersDic[EPlayerPositionType.ETop]   = tempLeft;
                break;

            case EPlayerPositionType.ETop:    //left==>right,right==>left,top==> top
                playersDic[EPlayerPositionType.ELeft]  = tempRight;
                playersDic[EPlayerPositionType.ERight] = tempLeft;
                playersDic[EPlayerPositionType.ETop]   = tempTop;
                break;

            case EPlayerPositionType.ESelf:
                switch (applyPos)
                {
                case EPlayerPositionType.ELeft:         //left==>right,right==>top,top==>left
                    playersDic[EPlayerPositionType.ELeft]  = tempTop;
                    playersDic[EPlayerPositionType.ERight] = tempLeft;
                    playersDic[EPlayerPositionType.ETop]   = tempRight;
                    break;

                case EPlayerPositionType.ERight:        //left==>top,right==>left,top==>right
                    playersDic[EPlayerPositionType.ELeft]  = tempRight;
                    playersDic[EPlayerPositionType.ERight] = tempTop;
                    playersDic[EPlayerPositionType.ETop]   = tempLeft;
                    break;

                case EPlayerPositionType.ETop:        //left==>right,right==>left,top==> top
                    playersDic[EPlayerPositionType.ELeft]  = tempRight;
                    playersDic[EPlayerPositionType.ERight] = tempLeft;
                    playersDic[EPlayerPositionType.ETop]   = tempTop;
                    break;
                }
                break;
            }
        }
        else
        {
            MsgPlayerInfo tempApply = new MsgPlayerInfo();
            MsgPlayerInfo tempTo    = new MsgPlayerInfo();
            CopyClass(tempApply, applyPos);
            CopyClass(tempTo, toPos);
            playersDic[applyPos] = tempTo;
            playersDic[toPos]    = tempApply;
        }
    }
예제 #15
0
        public virtual bool AddPlayer(ServerPlayer player)
        {
            player.Exited       += Player_Exited;
            player.Disconnected += Player_Exited;

            ServerHost.PreAddPlayer(player);

            if (player.ActualTeam == TeamColors.NoTeam)
            {
                return(false);
            }

            player.Info = new PlayerInfo();

            lock (PlayerList)
                PlayerList.Add(player);

            Logger.Log2("Player " + player.Callsign + " assigned to team " + player.ActualTeam.ToString());

            lock (Teams)
            {
                if (!Teams.ContainsKey(player.ActualTeam))
                {
                    TeamInfo team = new TeamInfo();
                    team.Team           = player.ActualTeam;
                    team.PlayerAdded   += Team_PlayerAdded;
                    team.PlayerRemoved += Team_PlayerRemoved;
                    Teams.Add(player.ActualTeam, team);
                }

                Teams[player.ActualTeam].Add(player);
                if (Teams[player.ActualTeam].Members.Count == 1)
                {
                    TeamInited?.Invoke(this, Teams[player.ActualTeam]);
                }
            }

            Flags.SendInitialFlagUpdate(player);

            // tell them about everyone except them
            ServerPlayer[] locals = null;

            lock (PlayerList)
                locals = PlayerList.ToArray();

            MsgPlayerInfo info = new MsgPlayerInfo();

            foreach (ServerPlayer peer in locals)
            {
                if (peer == player)
                {
                    continue;
                }

                player.SendMessage(true, BuildPlayerAdd(peer));
                info.PlayerUpdates.Add(GetPlayerInfo(peer));
            }
            player.SendMessage(true, info);

            TeamInfo[] teams = null;
            lock (Teams)
                teams = Teams.Values.ToArray();

            MsgTeamUpdate tUpd = new MsgTeamUpdate();

            foreach (var team in teams)
            {
                if (team.Team == player.ActualTeam) // the event already sent this
                {
                    continue;
                }

                MsgTeamUpdate.TeamUpdate u = new MsgTeamUpdate.TeamUpdate();
                u.TeamID = team.Team;
                u.Size   = team.Size();
                u.Wins   = team.Wins;
                u.Losses = team.Losses;
                tUpd.TeamUpdates.Add(u);
            }
            player.SendMessage(tUpd);

            // tell everyone they joined
            SendToAll(BuildPlayerAdd(player), false);

            // send info bits to everyone
            info = new MsgPlayerInfo();
            info.PlayerUpdates.Add(GetPlayerInfo(player));
            SendToAll(info, false);

            ServerHost.PostAddPlayer(player);

            if (player.ActualTeam == TeamColors.ObserverTeam)
            {
                Chat.SendChatToUser(null, player, Resources.ObserverModeNotificatioMessage, false);
            }

            return(true);
        }
예제 #16
0
    /// <summary>
    /// 登录成功,进入游戏界面
    /// </summary>
    /// <param name="msg"></param>
    private void RevcLoginSuc(MsgGlobal msg)
    {
        Debug.Log("UDP请求第一次登录成功");
        SDKManager.Instance.isWechatCallback = 0;
        GA.ProfileSignIn(PlayerInfo.Instance.mPlayerData.pid.ToString(), "wechat"); // 用户登录ID

        // TalkingData
        TDGAAccount tdAccount = TDGAAccount.SetAccount(PlayerInfo.Instance.mPlayerData.pid.ToString());

        tdAccount.SetAccountType(AccountType.TYPE1);
        tdAccount.SetAccountName(PlayerInfo.Instance.mPlayerData.name);
        if (PlayerInfo.Instance.mPlayerData.sex == 1)
        {
            tdAccount.SetGender(Gender.MALE);
        }
        else if (PlayerInfo.Instance.mPlayerData.sex == 2)
        {
            tdAccount.SetGender(Gender.FEMALE);
        }
        else
        {
            tdAccount.SetGender(Gender.UNKNOW);
        }

        MsgPlayerInfo data = msg.player_info;

        PlayerInfo.Instance.mPlayerData.ip = data.ip;

        PlayingGameInfo.Instance.mReconnectId = 3;
        if (RoomInfo.Instance.mRoomCode > 0) //断线重连
        {
            //UIManager.Instance.EnqueueTip("断线重连: " + RoomInfo.Instance.mRoomCode);
            if (data.roomCode == 1) //等待界面
            {
                PlayingGameInfo.Instance.mReconnectId = 1;
            }
            else if (data.roomCode == 2) //战斗
            {
                PlayingGameInfo.Instance.mReconnectId = 2;
            }
        }
        SavePlayerToken();
        ContextManager.Instance.PopAll();
        GameManager.Instance.SwitchGameStatus(EGameStatus.EHome);

        if (RoomInfo.Instance.mRoomCode <= 0)
        {
            //Android 可以直接进入不需要判断
            //#if UNITY_IPHONE && !UNITY_EDITOR
            Debug.Log(">>>>>>使用剪切板房间号信息登录");
            SDKManager.Instance.GetClipRoomCodeEnterRoom();
            //#endif
        }

        if (GameManager.Instance.mGameMode != EGameMode.EDebug)
        {
            SDKManager.Instance.yayaLogin();// 呀呀语音登录
        }

        // 高德初始化
        bool isIosSj = GameManager.Instance.mGameMode == EGameMode.EAppleOnLine && PlayerInfo.Instance.mUrlData.iosSj;

        if (!isIosSj)
        {
            SDKManager.Instance.doOpenLocationService();
        }
    }