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); }
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); } } }
void PlayceToNew(WsPlaceMark wpm) { if (mStaticThings.I == null) { return; } if (wpm.dname == "") { if (WsPlaceMarkDic.ContainsKey(wpm.id)) { if (WsPlaceMarkDic[wpm.id] != wpm.dname) { RemoveSingleDotPlayced(WsPlaceMarkDic[wpm.id]); WsPlaceMarkDic[wpm.id] = wpm.dname; } } else { WsPlaceMarkDic.Add(wpm.id, wpm.dname); } return; } Transform target = Playces.Find(wpm.dname); if (target == null) { int sort = mStaticThings.I.GetSortNumber(mStaticThings.I.mAvatarID); int maxnum = StartGroup.GetComponent <VRPlayceGroup>()._VRPlayceDots.Count - 1; int findnum = Mathf.Clamp(sort, 0, maxnum); target = StartGroup.GetComponent <VRPlayceGroup>()._VRPlayceDots[findnum].transform; } if (WsPlaceMarkDic.ContainsKey(wpm.id)) { if (WsPlaceMarkDic[wpm.id] != target.name) { RemoveSingleDotPlayced(WsPlaceMarkDic[wpm.id]); WsPlaceMarkDic[wpm.id] = target.name; } } else { WsPlaceMarkDic.Add(wpm.id, target.name); } VRPlayceDot vp = target.GetComponent <VRPlayceDot>(); if (vp == null) { return; } vp.isPlaced = true; vp.PlacedWSID = wpm.id; //Debug.LogWarning(wpm.id + " " + mStaticThings.I.mWsID); if (wpm.id == mStaticThings.I.mAvatarID) { if (mStaticThings.I.MainVRROOT == null) { return; } bool ccenabled = false; if (mStaticThings.I.MainVRROOT.GetComponent <CharacterController>()) { if (mStaticThings.I.MainVRROOT.GetComponent <CharacterController>().enabled) { ccenabled = true; mStaticThings.I.MainVRROOT.GetComponent <CharacterController>().enabled = false; } } PlayceDotKind dotkind = vp.dotkind; mStaticThings.I.MainVRROOT.position = target.position; if (dotkind == PlayceDotKind.direction) { mStaticThings.I.MainVRROOT.rotation = target.rotation; } else if (dotkind == PlayceDotKind.recenter) { mStaticThings.I.MainVRROOT.rotation = target.rotation; MessageDispatcher.SendMessage(CommonVREventType.VRrecenter.ToString()); } mStaticThings.I.MainVRROOT.localScale = target.lossyScale; foreach (var item in mStaticThings.I.VRCameras) { item.nearClipPlane = target.lossyScale.x * 0.1f; item.farClipPlane = target.lossyScale.x * 1000f; } if (ccenabled) { mStaticThings.I.MainVRROOT.GetComponent <CharacterController>().enabled = true; } MessageDispatcher.SendMessage(this, VrDispMessageType.SelfPlaceTo.ToString(), wpm.dname, 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); } }