//---------------------------------------------------------------------- static bool GrabExtra(ref Types.XStringSeg word, out String result) { if (word != null) { XString type = new XString(); { while (word && ((word[0] != ',') && (word[0] != ')'))) { if (word[0] == ')') { break; } type.Append(word.Clone()); word = word.Next; } } if (type) { type.Originate(); result = type.ToString(); } else { result = null; } } else { result = null; } return(true); }
//---------------------------------------------------------------------- static bool GrabType(ref Types.XStringSeg word, out String result) { if (word != null) { //int quote = 0; //int escape = 0; XString type = new XString(); XStringSeg first_word; type.Append(first_word = word.Clone()); first_word.Originate(); word = word.Next; if (word && word[0] == '(') { while (word && word[0] != ')') { type.Append(word.Clone()); word = word.Next; } type.Append(word.Clone()); word = word.Next; } result = type.ToString(); return(true); } else { result = null; } return(false); }
/// <summary> /// Get transition type from XString /// </summary> /// <param name="xString"></param> /// <returns></returns> public static TransitionType GetTransitionType(this XString xString) { try { return((TransitionType)Enum.Parse(typeof(TransitionType), xString.ToString())); } catch { return(default);
/// <summary> /// 接受到生成物体的命令 /// </summary> /// <param name="msg"></param> private void OnSpawnCommandsRecive(NetworkInMessage msg) { long userID = msg.ReadInt64(); XString xs = msg.ReadString(); Vector3 pos = CustomMessages.Instance.ReadVector3(msg); string ss = xs.ToString(); string[] meg = ss.Split('/'); string name = meg[0]; string id = meg[1]; AddobjectToWorld(name, id, pos); }
//---------------------------------------------------------------------- static bool GrabName(ref Types.XStringSeg word, out String result, out bool bQuoted) { String name = null; //PTEXT start = word; //printf( "word is %s", GetText( *word ) ); if (TextLike(word, "`")) { XString phrase = new XString(); //Types.XStringSeg phrase = null; bQuoted = true; word = word.Next; while (word != null && word.ToString()[0] != '`') { phrase.Append(word.Clone()); word = word.Next; } // skip one more - end after the last ` word = word.Next; name = phrase.ToString(); } else { // don't know... String next; bQuoted = false; next = word.Next; if (next != null && next[0] == '.') { // database and table name... word = word.Next; word = word.Next; name = (String)word; word = word.Next; } else { if (word.Text == "(") { result = null; bQuoted = false; return(true); } name = (String)word; word = word.Next; } } result = name; return((result != null) ? true : false); }
/// <summary> /// 接受到操作命令 /// </summary> /// <param name="msg"></param> private void OnCommandsRecive(NetworkInMessage msg) { bool turnon = true; long userID = msg.ReadInt64(); XString xs = msg.ReadString(); string[] ss = xs.ToString().Split('/'); Debug.Log("<color=yellow>收到消息::::" + xs.ToString() + "</color>"); string id = ss[0]; if (ss.Length == 1) { //控制命令 if (acts.ContainsKey(id)) { acts[id](); } else { Debug.Log("未注册该命令!!!!!!!!!!"); } } }
/// <summary> /// 接受到颜色更改消息 /// </summary> /// <param name="msg"></param> private void OnColorReceive(NetworkInMessage msg) { Debug.Log("接收到color消息"); long userID = msg.ReadInt64(); XString xs = msg.ReadString(); string id = xs.ToString(); if (maps.ContainsKey(id) && maps[id] != null) { Vector3 col = CustomMessages.Instance.ReadVector3(msg); Color c = new Color(col.x, col.y, col.z); maps[id].GetComponentInChildren <MeshRenderer>().material.color = c; } }
/// <summary> /// 接受到位置更新消息 /// </summary> /// <param name="msg"></param> private void OnUpdatePosReceive(NetworkInMessage msg) { long userID = msg.ReadInt64(); XString str = msg.ReadString(); string id = str.ToString(); if (maps.ContainsKey(id)) { maps[id].localPosition = CustomMessages.Instance.ReadVector3(msg); maps[id].localRotation = CustomMessages.Instance.ReadQuaternion(msg); } else { Debug.Log("<color=red>不包含该ID::" + id + "</color>"); } }
/// <summary> /// 接受到删除命令 /// </summary> /// <param name="msg"></param> private void OnDeletRecive(NetworkInMessage msg) { long userID = msg.ReadInt64(); XString str = msg.ReadString(); string id = str.ToString(); if (maps.ContainsKey(id)) { Destroy(maps[id].gameObject); maps.Remove(id); } else { Debug.Log("<color=red>删除物体错误,不包含该ID::" + id + "</color>"); } }
String ConcatPath(string root, string relative) { String result = root + "\\" + relative; XString xresult = new XString(result, "/\\", null, false, false); for (int n = 0; n < xresult.Count; n++) { if ((string)(xresult[n]) == "..") { xresult.RemoveAt(n - 2); xresult.RemoveAt(n - 2); xresult.RemoveAt(n - 2); xresult.RemoveAt(n - 2); n -= 3; } } return(xresult.ToString()); }
/// <summary> /// To upper first char of XString /// </summary> /// <param name="xString"></param> /// <returns></returns> public static XString ToUpperFirstString(this XString xString) { var str = xString.ToString(); return($"{str[0].ToString().ToUpper()}{str.Substring(1, str.Length - 1)}"); }