Exemple #1
0
    void MarkAllPlayce(WsPlaceMarkList wpmlist, bool ContainMyself = true)
    {
        VRPlayceDot[] vp = GetComponentsInChildren <VRPlayceDot>();
        foreach (var item in vp)
        {
            item.isPlaced   = false;
            item.PlacedWSID = "";
        }

        foreach (var item in wpmlist.marks)
        {
            if (item.id != mStaticThings.I.mAvatarID || ContainMyself)
            {
                if (mStaticThings.AllActiveAvatarList.Contains(item.id) && item.dname != null)
                {
                    Transform target = Playces.Find(item.dname);
                    if (target != null)
                    {
                        VRPlayceDot tvp = target.GetComponent <VRPlayceDot>();
                        if (tvp != null)
                        {
                            tvp.isPlaced   = true;
                            tvp.PlacedWSID = item.id;
                        }
                    }
                }
            }
        }
    }
Exemple #2
0
    void RecievePlaceMark(IMessage msg)
    {
        WsPlaceMarkList newwpmlist = (WsPlaceMarkList)msg.Data;

        //Debug.LogWarning("TELEPORT Sender:  " + JsonUtility.ToJson(newwpmlist));

        foreach (var item in newwpmlist.marks)
        {
            PlayceToNew(item);
            if (mStaticThings.AllActiveAvatarList.Contains(item.id))
            {
                if (WsPlaceMarkDic.ContainsKey(item.id))
                {
                    WsPlaceMarkDic[item.id] = item.dname;
                }
                else
                {
                    WsPlaceMarkDic.Add(item.id, item.dname);
                }
            }
        }

        if (newwpmlist.kind == WsPlaycePortKind.all)
        {
            MarkAllPlayce(newwpmlist);
            mStaticThings.I.nowGroupName = newwpmlist.gname;
        }
    }
Exemple #3
0
    void GoStartGroup()
    {
        int sort = 0;
        int max  = StartGroup.GetComponent <VRPlayceGroup>()._VRPlayceDots.Count - 1;

        if (mStaticThings.AllStaticAvatarsDic.Count > 1)
        {
            sort = mStaticThings.I.GetSortNumber(mStaticThings.I.mAvatarID);
        }
        int playcenum = Mathf.Clamp(sort, 0, max);

        WsPlaceMark newteleinfo = new WsPlaceMark
        {
            id    = mStaticThings.I.mAvatarID,
            dname = StartGroup.GetComponent <VRPlayceGroup>()._VRPlayceDots[playcenum].name
        };

        WsPlaceMarkList wmlist = new WsPlaceMarkList
        {
            kind  = WsPlaycePortKind.single,
            gname = StartGroup.name,
            id    = mStaticThings.I.mAvatarID,
            marks = new List <WsPlaceMark>()
        };

        mStaticThings.I.nowGroupName = StartGroup.name;
        wmlist.marks.Add(newteleinfo);
        PlayceToNew(newteleinfo);
        MessageDispatcher.SendMessage(this, WsMessageType.SendPlaceMark.ToString(), wmlist, 0);
    }
Exemple #4
0
        void RecievePlaceMark(IMessage msg)
        {
            WsPlaceMarkList newwpmlist = (WsPlaceMarkList)msg.Data;

            if (newwpmlist.kind == WsPlaycePortKind.all)
            {
                RecievedGroupName.Value = newwpmlist.gname;
                Fsm.Event(EventRecieveGroupName);
            }
        }
Exemple #5
0
    void VRPlaycePort(IMessage msg)
    {
        PlacePortObj ppo = (PlacePortObj)msg.Data;

        //Debug.LogWarning(JsonUtility.ToJson(ppo));
        if (ppo.isGroup)
        {
            MessageDispatcher.SendMessage(true, VrDispMessageType.AllPlaceTo.ToString(), ppo.nowselectobj == null ? "" : ppo.nowselectobj.name, 0);
        }
        else
        {
            if (ppo.telekind == WsTeleportKind.myself || ppo.telekind == WsTeleportKind.all)
            {
                WsPlaceMark newteleinfo = new WsPlaceMark
                {
                    id    = mStaticThings.I.mAvatarID,
                    dname = ppo.nowselectobj == null ? "" : ppo.nowselectobj.name
                };

                WsPlaceMarkList wmlist = new WsPlaceMarkList
                {
                    kind  = WsPlaycePortKind.single,
                    gname = mStaticThings.I.nowGroupName,
                    id    = mStaticThings.I.mAvatarID,
                    marks = new List <WsPlaceMark>()
                };
                wmlist.marks.Add(newteleinfo);

                PlayceToNew(newteleinfo);
                if (mStaticThings.I.SendAvatar)
                {
                    MessageDispatcher.SendMessage(this, WsMessageType.SendPlaceMark.ToString(), wmlist, 0);
                }
            }
            else if (ppo.telekind == WsTeleportKind.single)
            {
                WsPlaceMark newsingleinfo = new WsPlaceMark
                {
                    id    = mStaticThings.I.NowSelectedAvararid,
                    dname = ppo.nowselectobj == null ? "" : ppo.nowselectobj.name
                };
                WsPlaceMarkList wmlist = new WsPlaceMarkList
                {
                    kind  = WsPlaycePortKind.single,
                    gname = mStaticThings.I.nowGroupName,
                    id    = mStaticThings.I.mAvatarID,
                    marks = new List <WsPlaceMark>()
                };
                wmlist.marks.Add(newsingleinfo);
                PlayceToNew(newsingleinfo);
                MessageDispatcher.SendMessage(this, WsMessageType.SendPlaceMark.ToString(), wmlist, 0);
            }
        }
    }
Exemple #6
0
    IEnumerator SelfLoadScene()
    {
        if (mStaticThings.I.nowRoomServerGetUrl.Contains("127.0.0.1"))
        {
            PlayceToGroup(StartGroup.name, true);
        }
        else
        {
            string          url     = mStaticThings.I.nowRoomServerGetUrl + "/placemark?apitoken=" + mStaticThings.apitoken + "&socketid=" + mStaticThings.I.mWsID + "&room=" + mStaticThings.I.nowRoomChID;
            UnityWebRequest request = UnityWebRequest.Get(@url);
            yield return(request.SendWebRequest());

            if (request.error != null)
            {
                Debug.LogWarning(request.error);
                yield break;
            }
            string str = request.downloadHandler.text;
            //Debug.LogWarning("************************************" + str);
            WsPlaceMarkList nowwpm = JsonUtility.FromJson <WsPlaceMarkList>(str);
            InitConnectGroup(nowwpm);
        }
    }
Exemple #7
0
    void PlayceToGroup(string groupname, bool controlall)
    {
        Transform     Playcegroup = Playces.Find(groupname);
        VRPlayceGroup vrp;

        if (Playcegroup == null)
        {
            Debug.LogWarning("Can't Find a VRPlayceGroup : " + groupname);
            vrp = null;
        }
        else
        {
            vrp = Playcegroup.GetComponent <VRPlayceGroup>();
        }

        if (vrp != null && vrp._VRPlayceDots.Count < 1)
        {
            Debug.LogWarning("GroupDot : " + groupname + "Don't have any VRPlayceDot");
        }


        WsPlaceMarkList wmlist = new WsPlaceMarkList
        {
            kind  = WsPlaycePortKind.all,
            gname = groupname,
            id    = mStaticThings.I.mAvatarID,
            marks = new List <WsPlaceMark>()
        };

        int cnt = 0;

        List <string> nonactivelist = new List <string>();

        foreach (var item in mStaticThings.AllActiveAvatarList)
        {
            string temname;
            if (vrp != null)
            {
                if (vrp._VRPlayceDots.Count > cnt)
                {
                    temname = vrp._VRPlayceDots[cnt] != null?vrp._VRPlayceDots[cnt].gameObject.name : "";
                }
                else
                {
                    temname = vrp._VRPlayceDots[vrp._VRPlayceDots.Count - 1] != null ? vrp._VRPlayceDots[vrp._VRPlayceDots.Count - 1].gameObject.name:"";
                }
            }
            else
            {
                temname = "";
            }

            cnt++;

            WsPlaceMark newteleinfo = new WsPlaceMark
            {
                id    = item,
                dname = temname
            };
            if (item == mStaticThings.I.mAvatarID)
            {
                PlayceToNew(newteleinfo);
            }
            if (!controlall)
            {
                PlayceToNew(newteleinfo);
            }

            wmlist.marks.Add(newteleinfo);
        }

        foreach (var item in mStaticThings.AllStaticAvatarList)
        {
            if (!mStaticThings.AllActiveAvatarList.Contains(item))
            {
                string temname;
                if (vrp != null)
                {
                    if (vrp._VRPlayceDots.Count > cnt)
                    {
                        temname = vrp._VRPlayceDots[cnt] != null?vrp._VRPlayceDots[cnt].gameObject.name:"";
                    }
                    else
                    {
                        temname = vrp._VRPlayceDots[vrp._VRPlayceDots.Count - 1] != null ? vrp._VRPlayceDots[vrp._VRPlayceDots.Count - 1].gameObject.name :"";
                    }
                }
                else
                {
                    temname = "";
                }

                WsPlaceMark newteleinfo = new WsPlaceMark
                {
                    id    = item,
                    dname = temname
                };
                if (item == mStaticThings.I.mAvatarID)
                {
                    PlayceToNew(newteleinfo);
                }
                if (!controlall)
                {
                    PlayceToNew(newteleinfo);
                }
                wmlist.marks.Add(newteleinfo);
            }
        }

        // /Debug.LogWarning(JsonUtility.ToJson(wmlist));
        if (controlall)
        {
            MarkAllPlayce(wmlist);
            MessageDispatcher.SendMessage(this, WsMessageType.SendPlaceMark.ToString(), wmlist, 0);
        }
    }
Exemple #8
0
    void InitConnectGroup(WsPlaceMarkList nowwpm)
    {
        if (nowwpm.gname == null || nowwpm.gname == "")
        {
            GoStartGroup();
            return;
        }
        MarkAllPlayce(nowwpm, false);
        //Debug.LogWarning(JsonUtility.ToJson(nowwpm));
        Dictionary <string, string> temdic = new Dictionary <string, string>();

        foreach (var itemc in nowwpm.marks)
        {
            if (itemc.id != mStaticThings.I.mAvatarID)
            {
                temdic.Add(itemc.id, itemc.dname);
            }
        }
        Transform targetgroup = Playces.Find(nowwpm.gname);


        if (targetgroup == null)
        {
            targetgroup = Playces.Find(StartGroup.name);
        }
        if (targetgroup == null)
        {
            return;
        }
        mStaticThings.I.nowGroupName = targetgroup.name;
        VRPlayceGroup vrp = targetgroup.GetComponent <VRPlayceGroup>();

        if (vrp != null)
        {
            if (mStaticThings.I.SendAvatar)
            {
                foreach (var item in vrp._VRPlayceDots)
                {
                    if (item != null)
                    {
                        if (!temdic.ContainsValue(item.name))
                        {
                            PlacePortObj ppo = new PlacePortObj
                            {
                                nowselectobj = item.gameObject,
                                telekind     = WsTeleportKind.myself,
                                isGroup      = false
                            };
                            MessageDispatcher.SendMessage(this, VrDispMessageType.VRPlaycePort.ToString(), ppo, 0);
                            return;
                        }
                    }
                }
            }
            else
            {
                if (vrp._VRPlayceDots[vrp._VRPlayceDots.Count - 1] != null)
                {
                    PlacePortObj ppo = new PlacePortObj
                    {
                        nowselectobj = vrp._VRPlayceDots[vrp._VRPlayceDots.Count - 1].gameObject,
                        telekind     = WsTeleportKind.myself,
                        isGroup      = false
                    };
                    MessageDispatcher.SendMessage(this, VrDispMessageType.VRPlaycePort.ToString(), ppo, 0);
                }
                return;
            }
        }
    }