public void insertList(object data) { ArrayList _list = null; _list = wrapList(data); UIWidget uiw = null; int newDataCount = _list.Count; int _startIndex = 0; if (itemList != null && itemList.Count > 0) { _startIndex = NumEx.stringToInt(itemList [0].name); for (int i = 0; i < itemList.Count; i++) { uiw = itemList [i]; if (uiw == null) { continue; } uiw.name = NumEx.nStrForLen(newDataCount + _startIndex + i, 6); } } if (list != null) { _list.AddRange(list); } list = _list; refreshContentOnly(); }
public void _show(object callback, List <string> list) { NGUITools.SetActive(gameObject, true); List <string> tmplist = defautSpriteNameList; if (list != null && list.Count > 0) { tmplist = list; } if (tmplist != null && tmplist.Count > 0) { int index = NumEx.NextInt(0, tmplist.Count); CLUIUtl.setSpriteFit(sprite, tmplist [index]); } finishCallback = callback; // NGUITools.SetActive (label.gameObject, false); tweenAlpha.Play(true); CLPanelBase p = CLPanelManager.topPanel; panel.depth = p == null ? 3000 : p.panel.depth + CLPanelManager.depthOffset + 100; panel.renderQueue = UIPanel.RenderQueue.StartAt; // 设置startingRenderQueue是为了可以在ui中使用粒子效果,注意在粒子中要绑定CLUIParticle角本 panel.startingRenderQueue = CLPanelManager.Const_RenderQueue + this.panel.depth; }
public static void readFully4BLength(Stream ns) { int len = NumEx.readInt(ns); byte[] b = new byte[len]; readFully(ns, b); }
public static void writeDouble(Stream os, double val) { long v = NumEx.DoubleToInt64Bits(val); //long v = Double.doubleToLongBits(var); if (v == 0) { WriteByte(os, B2Type.DOUBLE_0); // } else if (v >= Byte.MIN_VALUE && v <= Byte.MAX_VALUE) { // WriteByte(os, B2Type.DOUBLE_8B); // WriteByte(os, (int) v); // } else if (v >= Short.MIN_VALUE && v <= Short.MAX_VALUE) { // WriteByte(os, B2Type.DOUBLE_16B); // WriteByte(os, (byte) ((v >> 8) & 0xff)); // WriteByte(os, (byte) ((v >> 0) & 0xff)); // } else if (v >= Integer.MIN_VALUE && v <= Integer.MAX_VALUE) { // WriteByte(os, B2Type.DOUBLE_32B); // WriteByte(os, (byte) ((v >> 24) & 0xff)); // WriteByte(os, (byte) ((v >> 16) & 0xff)); // WriteByte(os, (byte) ((v >> 8) & 0xff)); // WriteByte(os, (byte) ((v >> 0) & 0xff)); } else { WriteByte(os, B2Type.DOUBLE_64B); WriteByte(os, (byte)((v >> 56) & 0xff)); WriteByte(os, (byte)((v >> 48) & 0xff)); WriteByte(os, (byte)((v >> 40) & 0xff)); WriteByte(os, (byte)((v >> 32) & 0xff)); WriteByte(os, (byte)((v >> 24) & 0xff)); WriteByte(os, (byte)((v >> 16) & 0xff)); WriteByte(os, (byte)((v >> 8) & 0xff)); WriteByte(os, (byte)((v >> 0) & 0xff)); } }
void _appendList(ArrayList list) { if (list.Count == 0) { return; } int dataIndex = 0; int tmpIndex = itemList.Count; UIWidget uiw = null; Transform t = null; for (int i = 0; i < cachedTransform.childCount; i++) { if (dataIndex >= list.Count) { break; } t = cachedTransform.GetChild(i); if (t.gameObject.activeSelf) { continue; } uiw = t.GetComponent <UIWidget> (); if (uiw == null) { continue; } uiw.name = NumEx.nStrForLen(tmpIndex + dataIndex, 6); NGUITools.SetActive(t.gameObject, true); Utl.doCallback(this.initCellCallback, t.GetComponent <CLCellBase> (), list [dataIndex]); NGUITools.updateAll(t); // itemList.Add (uiw); dataIndex++; } }
public void insertList(object data, bool isNeedRePosition, bool isCalculatePosition) { ArrayList _list = null; if (data is LuaTable) { _list = CLUtlLua.luaTableVals2List((LuaTable)data); } else if (data is ArrayList) { _list = (ArrayList)data; } else if (data is object[]) { _list = new ArrayList(); _list.AddRange((object[])data); } times = (int)(_list.Count / RealCellCount); //------------------------------------------------ CLUILoopTableCell uiw = null; CLUILoopTableCell targetUIW = null; int newDataCount = _list.Count; Transform t = null; int _startIndex = 0; if (itemList != null && itemList.Count > 0) { _startIndex = NumEx.stringToInt(itemList [0].name); for (int i = 0; i < itemList.Count; i++) { uiw = itemList [i]; if (uiw == null) { continue; } uiw.name = NumEx.nStrForLen(newDataCount + _startIndex + i, 6); } } //------------------------------------------------ if (RealCellCount > itemList.Count) { Debug.Log("说明之前加载的数据没有占用完所有单元"); //说明之前加载的数据没有占用完所有单元 _insertList(_list, isCalculatePosition); if (isNeedRePosition) { table.Reposition(); } } //------------------------------------------------ if (list != null) { _list.AddRange(list); } list = _list; }
public void effectStart(int to, object back, float delayTime = 0) { string vStr = labSelf.text; int from = NumEx.toInt(vStr); effectStart(from, to, back, delayTime); }
public static int getBytes2Int(object map, object key) { if (map == null || key == null) { return(0); } return(NumEx.bio2Int(getBytes(map, key))); }
/// <summary> /// Encoder the specified str and scrtkey.加密 /// </summary> /// <param name='str'>要加密的串 /// String. /// </param> /// <param name='scrtkey'>密钥secretkey /// Scrtkey. /// </param> public static string encoder(string str, string scrtkey) { if (string.IsNullOrEmpty(str)) { return(""); } string unicodestr = ""; string posstr = ""; string tmpstr = ""; string uniscrtkey = ""; string ret = ""; int i; int[] poslist = new int[str.Length]; for (i = 0; i < str.Length; i++) { unicodestr = unicodestr + (int)(str [i]); poslist [i] = unicodestr.Length; } for (i = 0; i < str.Length; i++) { tmpstr = StrEx.Mid(unicodestr, poslist [i] - 1, 1); unicodestr = tmpstr + StrEx.Left(unicodestr, poslist [i] - 1) + StrEx.Mid(unicodestr, poslist [i]); posstr = posstr + NumEx.nStrForLen(poslist [i], 4); //每4位表示一个位置 } for (i = 0; i < scrtkey.Length; i++) { uniscrtkey = uniscrtkey + (int)(scrtkey [i]); } string flag = "+"; posstr = trimIntZero(posstr); string sub = bgnusub(uniscrtkey, posstr); if (!string.IsNullOrEmpty(sub) && sub.Length > 0 && sub [0] == '-') { sub = StrEx.Mid(sub, 1); flag = "-"; } //每四位中把前面为0的用+号代表 string enSub = ""; int tmpN = 0; for (i = sub.Length - 4; i >= 0; i = i - 4) { tmpN = NumEx.stringToInt(StrEx.Mid(sub, i, 4)); enSub = (tmpN.ToString().Length < 4 ? "+" : "") + tmpN + enSub; } if (i != -4) { tmpN = NumEx.stringToInt(StrEx.Left(sub, i + 4)); enSub = (tmpN.ToString().Length < 4 ? "+" : "") + tmpN + enSub; } ret = unicodestr + flag + enSub; return(ret); }
public void init() { if (isFinishInit) { return; } cachedTransform = this.transform; grid = this.GetComponent <UIGrid> (); grid.sorting = UIGrid.Sorting.Alphabetic; grid.hideInactive = true; oldGridPosition = grid.transform.localPosition; _scrollView = scrollView; Transform prefab = cachedTransform.GetChild(0); if (cachedTransform.childCount < cellCount) { for (int i = cachedTransform.childCount; i < cellCount; i++) { NGUITools.AddChild(gameObject, prefab.gameObject); } } float cellWidth = grid.cellWidth; float cellHeight = grid.cellHeight; posParam = new Vector4(cellWidth, cellHeight, grid.arrangement == UIGrid.Arrangement.Horizontal ? -1 : 0, grid.arrangement == UIGrid.Arrangement.Vertical ? 1 : 0); wrapLineNum = grid.maxPerLine; if (wrapLineNum > 0) { posParam.z = -1; posParam.w = 1; } for (int i = 0; i < cachedTransform.childCount; ++i) { Transform t = cachedTransform.GetChild(i); UIWidget uiw = t.GetComponent <UIWidget> (); // uiw.name = string.Format("{0:D5}", itemList.Count); uiw.name = NumEx.nStrForLen(itemList.Count, 6); itemList.Add(uiw); } RealCellCount = itemList.Count; grid.Reposition(); isFinishInit = true; if (itemList.Count < 3) { Debug.Log("The childCount < 3"); } }
public bool checkNeedDownload(string path) { if (string.IsNullOrEmpty(path)) { return(false); } bool ret = false; if (localPriorityVer[path] != null) { //在优先资源里有 ret = false; } else { //则可能在others里 object obj1 = otherResVerOld[path]; object obj2 = otherResVerNew[path]; if (obj1 == null && obj2 != null) { //本地没有,最新有 ret = true; } else if (obj1 != null && obj2 != null) { if (NumEx.stringToInt(obj1.ToString()) >= NumEx.stringToInt(obj2.ToString())) {//本地是最新的 ret = false; } else { //本地不是最新的 ret = true; } } else if (obj1 != null && obj2 == null) {//本地有,最新没有 ret = false; } else { //都没有找到 // NAlertTxt.add("Cannot Found the res. Path= \n"+ path, Color.red, 1); Debug.LogError("Cannot Found the res. Path= \n" + path); ret = true; } } // if (ret) { // if (!Utl.netIsActived ()) { // NAlertTxt.add (Localization.Get ("MsgNetWorkCannotReached"), Color.red, 1); // reLoadGame (); // } // } return(ret); }
public static void setInt2Bytes(object map, object key, int val) { if (map == null || key == null) { return; } if (map is LuaTable) { ((LuaTable)map) [key] = NumEx.int2Bio(val); } else { ((Hashtable)map) [key] = NumEx.int2Bio(val); } }
/// <summary> /// Sets the action. /// </summary> /// <param name="actionValue">Action value.动作对应的value</param> /// <param name="callbackInfor">Callback infor. 是一个key:value的键值对 /// key:是0~100的整数,表示动作播放到百分之多少时执行回调, /// 而回调方法就是该key所对应的value /// </param> public void doSetActionWithCallback(int actionValue, ArrayList progressCallbackInfor) { // if (currActionValue == actionValue) { // return; // } ////////////////////////////////////////////////////////////////// progressPoints.Clear(); progressCallback.Clear(); callbackMap.Clear(); if (progressCallbackInfor != null) { int count = progressCallbackInfor.Count; for (int i = 0; i < count; i++) { if (i % 2 == 0) { progressPoints.Add(NumEx.stringToInt(progressCallbackInfor [i].ToString()) / 100.0f); } else { progressCallback.Add(progressCallbackInfor [i]); } } progressCallbackInfor.Clear(); progressCallbackInfor = null; } ////////////////////////////////////////////////////////////////// currActionValue = actionValue; currAction = (Action)(Enum.ToObject(typeof(Action), actionValue)); if (!animator.isInitialized) { return; } animator.SetInteger("Action", actionValue); if (progressPoints.Count > 0) { progressIndex = 0; isCheckProgress = true; // place the code after setAction, beacuse in setAction function ,set isCheckProgress = false; } else { isCheckProgress = false; } }
public static void appendList(UIGrid parent, GameObject prefabChild, ArrayList list, System.Type itype, int beforCount, GameObject nextPage, object initCallback, float offset = 0) { if (list == null) { return; } if (parent == null) { return; } parent.sorted = true; Transform go = null; string childName = ""; for (int i = 0; i < list.Count; i++) { childName = NumEx.nStrForLen(beforCount + i, 5); #if UNITY_5_6_OR_NEWER go = parent.transform.Find(childName); #else go = parent.transform.FindChild(childName); #endif if (go == null) { go = NGUITools.AddChild(parent.gameObject, prefabChild).transform; go.name = childName; } go.transform.localPosition = new Vector3(0, -(beforCount + i) * parent.cellHeight + offset, 0); NGUITools.SetActive(go.gameObject, true); Utl.doCallback(initCallback, go.GetComponent <CLCellBase> (), list [i]); } if (nextPage != null && go != null) { nextPage.transform.localPosition = Vector3.zero; nextPage.transform.parent = go; nextPage.transform.localPosition = new Vector3(0, -parent.cellHeight, 0); } }
public static byte[] post2(string host, int port, string path, byte[] buf, int timeout) { TcpClient client = new TcpClient(); client.SendTimeout = timeout; client.ReceiveTimeout = timeout; client.Connect(host, port); // create request post data //const string POST_HEAD = "POST /{0} HTTP/1.1\r\nHost: {1}:{2}\r\nContent-Type: text/html;\r\nContent-Length: {3:G} \r\n\r\n"; string str = string.Format(POST_HEAD, path, host, port, buf.Length); byte[] headBytes = System.Text.Encoding.Default.GetBytes(str); // send request data NetworkStream ns = client.GetStream(); ns.Write(headBytes, 0, headBytes.Length); ns.Write(buf, 0, buf.Length); ns.Flush(); // read http header int length = 0; for (int n = 0; n < 100; n++) { string line = readLine(ns); bool isLen = line.StartsWith("Content-Length"); if (isLen) { string sub = line.Substring(line.IndexOf(":") + 1); length = NumEx.stringToInt(sub); } if (line == null || line.Length <= 1) { break; } } // read response body byte[] r2 = new byte[length]; ns.Read(r2, 0, length); ns.Close(); client.Close(); return(r2); }
public static void MapToString(Hashtable map, StringBuilder outstr, int spacecount = 0) { // ICollection keslist = map.Keys; // IEnumerator e = keslist.GetEnumerator(); StringBuilder space = new StringBuilder(); for (int i = 0; i < spacecount; i++) { space.Append(" "); } outstr.Append("\n" + space.ToString()).Append("{"); foreach (DictionaryEntry cell in map) { object key = cell.Key; object val = cell.Value; if (val == null) { continue; } outstr.Append(space.ToString()).Append(key).Append("(").Append(key.GetType().ToString()).Append(")").Append("="); if (val is Hashtable) { MapToString((Hashtable)val, outstr, spacecount++); } else if (val is ArrayList) { ArrayListToString((ArrayList)val, outstr, spacecount++); } else if (val is LuaTable) { LuaTableToString((LuaTable)val, outstr, spacecount++); } else if (val is byte[]) { outstr.Append(NumEx.bio2Int((byte[])val)).Append("(").Append(val.GetType().ToString()).Append(")").Append("\n"); } else { outstr.Append(val).Append("(").Append(val.GetType().ToString()).Append(")").Append("\n"); } } outstr.Append("}\n"); //Debug.Log(outstr.ToString()); }
public void init() { if (isFinishInit) { return; } cachedTransform = this.transform; table = this.GetComponent <UITable> (); table.hideInactive = true; table.sorting = UITable.Sorting.Alphabetic; oldGridPosition = table.transform.localPosition; _scrollView = scrollView; Transform prefab = cachedTransform.GetChild(0); CLUILoopTableCell prefabCell = prefab.GetComponent <CLUILoopTableCell> (); table.cellAlignment = prefabCell.widget.pivot; if (cachedTransform.childCount < cellCount) { for (int i = cachedTransform.childCount; i < cellCount; i++) { NGUITools.AddChild(gameObject, prefab.gameObject); } } for (int i = 0; i < cachedTransform.childCount; ++i) { Transform t = cachedTransform.GetChild(i); CLUILoopTableCell uiw = t.GetComponent <CLUILoopTableCell> (); // uiw.name = string.Format ("{0:D5}", itemList.Count); uiw.name = NumEx.nStrForLen(itemList.Count, 6); itemList.Add(uiw); } RealCellCount = itemList.Count; table.Reposition(); isFinishInit = true; if (itemList.Count < 3) { Debug.LogError("The childCount < 3"); } }
public static void onGetSprite(params object[] paras) { UISprite sprite = (UISprite)(paras [0]); if (sprite == null || sprite.atlas == null) { return; } string sprName = paras [1].ToString(); sprite.spriteName = sprName; UISpriteData sd = sprite.atlas.getSpriteBorrowMode(sprite.spriteName); if (sd == null) { return; } int maxSize = NumEx.stringToInt(paras [2].ToString()); if (maxSize > 0) { if (sd == null) { return; } float x = (float)(sd.width); float y = (float)(sd.height); float size = x > y ? x : y; float rate = 1; if (size > maxSize) { rate = maxSize / size; } // sprite.MakePixelPerfect(); sprite.SetDimensions((int)(sd.width * rate), (int)(sd.height * rate)); } else { sprite.SetDimensions(sd.width, sd.height); } }
public static int[] ipv4(string ipv4) { int[] r2 = new int[4]; if (ipv4 == null || ipv4.Length < 7 || ipv4.Length > 17) { return(r2); } // 127.0.0.1 int p1 = ipv4.IndexOf('.'); if (p1 < 1) { return(r2); } int p2 = ipv4.IndexOf('.', p1 + 1); if (p2 < 1) { return(r2); } int p3 = ipv4.IndexOf('.', p2 + 1); if (p3 < 1) { return(r2); } string s1 = Mid(ipv4, 0, p1); string s2 = Mid(ipv4, p1 + 1, p2); string s3 = Mid(ipv4, p2 + 1, p3); string s4 = Mid(ipv4, p3 + 1, ipv4.Length); r2 [0] = NumEx.stringToInt(s1); r2 [1] = NumEx.stringToInt(s2); r2 [2] = NumEx.stringToInt(s3); r2 [3] = NumEx.stringToInt(s4); return(r2); }
public static void ArrayListToString(ArrayList list, StringBuilder outstr, int spacecount = 0) { StringBuilder space = new StringBuilder(); for (int i = 0; i < spacecount; i++) { space.Append(" "); } outstr.Append("\n" + space.ToString()).Append("["); foreach (object item in list) { if (item == null) { continue; } if (item is Hashtable) { MapToString((Hashtable)item, outstr, spacecount++); } else if (item is ArrayList) { ArrayListToString((ArrayList)item, outstr, spacecount++); } else if (item is byte[]) { outstr.Append(NumEx.bio2Int((byte[])item)).Append(","); } else { outstr.Append(item).Append(","); } } outstr.Append("]\n"); //Debug.Log(outstr.ToString()); }
public static Object readObject(Stream s) { int tag = ReadByte(s); switch (tag) { case B2Type.NULL: { return(null); } case B2Type.HASHTABLE_0: { return(new NewMap()); } case B2Type.HASHTABLE_1: { return(readMap(s, 1)); } case B2Type.HASHTABLE_2: { return(readMap(s, 2)); } case B2Type.HASHTABLE_3: { return(readMap(s, 3)); } case B2Type.HASHTABLE_4: { return(readMap(s, 4)); } case B2Type.HASHTABLE_5: { return(readMap(s, 5)); } case B2Type.HASHTABLE_6: { return(readMap(s, 6)); } case B2Type.HASHTABLE_7: { return(readMap(s, 7)); } case B2Type.HASHTABLE_8: { return(readMap(s, 8)); } case B2Type.HASHTABLE_9: { return(readMap(s, 9)); } case B2Type.HASHTABLE_10: { return(readMap(s, 10)); } case B2Type.HASHTABLE_11: { return(readMap(s, 11)); } case B2Type.HASHTABLE_12: { return(readMap(s, 12)); } case B2Type.HASHTABLE_13: { return(readMap(s, 13)); } case B2Type.HASHTABLE_14: { return(readMap(s, 14)); } case B2Type.HASHTABLE_15: { return(readMap(s, 15)); } case B2Type.HASHTABLE: { int len = readInt(s); return(readMap(s, len)); } case B2Type.INT_N1: { return((int)-1); } case B2Type.INT_0: { return((int)0); } case B2Type.INT_1: { return((int)1); } case B2Type.INT_2: { return((int)2); } case B2Type.INT_3: { return((int)3); } case B2Type.INT_4: { return((int)4); } case B2Type.INT_5: { return((int)5); } case B2Type.INT_6: { return((int)6); } case B2Type.INT_7: { return((int)7); } case B2Type.INT_8: { return((int)8); } case B2Type.INT_9: { return((int)9); } case B2Type.INT_10: { return((int)10); } case B2Type.INT_11: { return((int)11); } case B2Type.INT_12: { return((int)12); } case B2Type.INT_13: { return((int)13); } case B2Type.INT_14: { return((int)14); } case B2Type.INT_15: { return((int)15); } case B2Type.INT_16: { return((int)16); } case B2Type.INT_17: { return((int)17); } case B2Type.INT_18: { return((int)18); } case B2Type.INT_19: { return((int)19); } case B2Type.INT_20: { return((int)20); } case B2Type.INT_21: { return((int)21); } case B2Type.INT_22: { return((int)22); } case B2Type.INT_23: { return((int)23); } case B2Type.INT_24: { return((int)24); } case B2Type.INT_25: { return((int)25); } case B2Type.INT_26: { return((int)26); } case B2Type.INT_27: { return((int)27); } case B2Type.INT_28: { return((int)28); } case B2Type.INT_29: { return((int)29); } case B2Type.INT_30: { return((int)30); } case B2Type.INT_31: { return((int)31); } case B2Type.INT_32: { return((int)32); } case B2Type.INT_8B: { sbyte v = (sbyte)ReadByte(s); return((int)v); } case B2Type.INT_16B: { short v = (short)(((ReadByte(s) & 0xff) << 8) + ((ReadByte(s) & 0xff) << 0)); return((int)v); } case B2Type.INT_32B: { int v1 = ReadByte(s); int v2 = ReadByte(s); int v3 = ReadByte(s); int v4 = ReadByte(s); int v = ((v1 & 0xff) << 24) + ((v2 & 0xff) << 16) + ((v3 & 0xff) << 8) + ((v4 & 0xff) << 0); return((int)v); } case B2Type.STR_0: { return(""); } case B2Type.STR_1: { return(readStringImpl(s, 1)); } case B2Type.STR_2: { return(readStringImpl(s, 2)); } case B2Type.STR_3: { return(readStringImpl(s, 3)); } case B2Type.STR_4: { return(readStringImpl(s, 4)); } case B2Type.STR_5: { return(readStringImpl(s, 5)); } case B2Type.STR_6: { return(readStringImpl(s, 6)); } case B2Type.STR_7: { return(readStringImpl(s, 7)); } case B2Type.STR_8: { return(readStringImpl(s, 8)); } case B2Type.STR_9: { return(readStringImpl(s, 9)); } case B2Type.STR_10: { return(readStringImpl(s, 10)); } case B2Type.STR_11: { return(readStringImpl(s, 11)); } case B2Type.STR_12: { return(readStringImpl(s, 12)); } case B2Type.STR_13: { return(readStringImpl(s, 13)); } case B2Type.STR_14: { return(readStringImpl(s, 14)); } case B2Type.STR_15: { return(readStringImpl(s, 15)); } case B2Type.STR_16: { return(readStringImpl(s, 16)); } case B2Type.STR_17: { return(readStringImpl(s, 17)); } case B2Type.STR_18: { return(readStringImpl(s, 18)); } case B2Type.STR_19: { return(readStringImpl(s, 19)); } case B2Type.STR_20: { return(readStringImpl(s, 20)); } case B2Type.STR_21: { return(readStringImpl(s, 21)); } case B2Type.STR_22: { return(readStringImpl(s, 22)); } case B2Type.STR_23: { return(readStringImpl(s, 23)); } case B2Type.STR_24: { return(readStringImpl(s, 24)); } case B2Type.STR_25: { return(readStringImpl(s, 25)); } case B2Type.STR_26: { return(readStringImpl(s, 26)); } case B2Type.STR: { int len = readInt(s); return(readStringImpl(s, len)); } case B2Type.BOOLEAN_TRUE: { return(true); } case B2Type.BOOLEAN_FALSE: { return(false); } case B2Type.BYTE_0: { byte v = 0; return(v); } case B2Type.BYTE: { byte v = (byte)ReadByte(s); return(v); } case B2Type.BYTES_0: { return(new byte[0]); } case B2Type.BYTES: { int len = readInt(s); byte[] b = new byte[len]; s.Read(b, 0, len); return(b); } case B2Type.VECTOR_0: { return(new NewList()); } case B2Type.VECTOR_1: { return(readList(s, 1)); } case B2Type.VECTOR_2: { return(readList(s, 2)); } case B2Type.VECTOR_3: { return(readList(s, 3)); } case B2Type.VECTOR_4: { return(readList(s, 4)); } case B2Type.VECTOR_5: { return(readList(s, 5)); } case B2Type.VECTOR_6: { return(readList(s, 6)); } case B2Type.VECTOR_7: { return(readList(s, 7)); } case B2Type.VECTOR_8: { return(readList(s, 8)); } case B2Type.VECTOR_9: { return(readList(s, 9)); } case B2Type.VECTOR_10: { return(readList(s, 10)); } case B2Type.VECTOR_11: { return(readList(s, 11)); } case B2Type.VECTOR_12: { return(readList(s, 12)); } case B2Type.VECTOR_13: { return(readList(s, 13)); } case B2Type.VECTOR_14: { return(readList(s, 14)); } case B2Type.VECTOR_15: { return(readList(s, 15)); } case B2Type.VECTOR_16: { return(readList(s, 16)); } case B2Type.VECTOR_17: { return(readList(s, 17)); } case B2Type.VECTOR_18: { return(readList(s, 18)); } case B2Type.VECTOR_19: { return(readList(s, 19)); } case B2Type.VECTOR_20: { return(readList(s, 20)); } case B2Type.VECTOR_21: { return(readList(s, 21)); } case B2Type.VECTOR_22: { return(readList(s, 22)); } case B2Type.VECTOR_23: { return(readList(s, 23)); } case B2Type.VECTOR_24: { return(readList(s, 24)); } case B2Type.VECTOR: { int len = readInt(s); return(readList(s, len)); } case B2Type.SHORT_0: { short v = 0; return(v); } case B2Type.SHORT_8B: { short v = (short)ReadByte(s); return(v); } case B2Type.SHORT_16B: { short v = (short)(((ReadByte(s) & 0xff) << 8) + ((ReadByte(s) & 0xff) << 0)); return(v); } case B2Type.LONG_0: { int v = 0; return((long)v); } case B2Type.LONG_8B: { int v = ReadByte(s); return((long)v); } case B2Type.LONG_16B: { int v = (((ReadByte(s) & 0xff) << 8) + ((ReadByte(s) & 0xff) << 0)); if (v > 32767) { v = v - 65536; } return((long)(v)); } case B2Type.LONG_32B: { int v1 = ReadByte(s); int v2 = ReadByte(s); int v3 = ReadByte(s); int v4 = ReadByte(s); long v = ((v1 & 0xff) << 24) + ((v2 & 0xff) << 16) + ((v3 & 0xff) << 8) + ((v4 & 0xff) << 0); if (v > 2147483647) { v = v - 4294967296; } return((long)(v)); } case B2Type.LONG_64B: { byte[] b = new byte[8]; for (int i = 0; i < 8; i++) { b [i] = (byte)ReadByte(s); } long high = ((b [0] & 0xff) << 24) + ((b [1] & 0xff) << 16) + ((b [2] & 0xff) << 8) + ((b [3] & 0xff) << 0); long low = ((b [4] & 0xff) << 24) + ((b [5] & 0xff) << 16) + ((b [6] & 0xff) << 8) + ((b [7] & 0xff) << 0); long v = (high << 32) + (0xffffffffL & low); return((long)(v)); } case B2Type.DOUBLE_0: { // int v = 0; // double ret = Double.longBitsToDouble(v); return((double)(0)); // }case B2Type.DOUBLE_8B: { // int v = is.read(); // double ret = Double.longBitsToDouble(v); // return new Double(ret); // }case B2Type.DOUBLE_16B: { // int v = (((is.read() & 0xff) << 8) + ((is.read() & 0xff) << 0)); // double ret = Double.longBitsToDouble(v); // return new Double(ret); // }case B2Type.DOUBLE_32B: { // int v1 = is.read(); // int v2 = is.read(); // int v3 = is.read(); // int v4 = is.read(); // // int v = ((v1 & 0xff) << 24) + ((v2 & 0xff) << 16) // + ((v3 & 0xff) << 8) + ((v4 & 0xff) << 0); // double ret = Double.longBitsToDouble(v); // return new Double(ret); } case B2Type.DOUBLE_64B: { byte[] b = new byte[8]; for (int i = 0; i < 8; i++) { b [i] = (byte)ReadByte(s); } long high = ((b [0] & 0xff) << 24) + ((b [1] & 0xff) << 16) + ((b [2] & 0xff) << 8) + ((b [3] & 0xff) << 0); long low = ((b [4] & 0xff) << 24) + ((b [5] & 0xff) << 16) + ((b [6] & 0xff) << 8) + ((b [7] & 0xff) << 0); long v = (high << 32) + (0xffffffffL & low); double ret = NumEx.Int64BitsToDouble(v); return((double)(ret)); } case B2Type.INT_ARRAY_0: { return(new int[0]); } case B2Type.INT_ARRAY_1: { return(readIntArray(s, 1)); } case B2Type.INT_ARRAY_2: { return(readIntArray(s, 2)); } case B2Type.INT_ARRAY_3: { return(readIntArray(s, 3)); } case B2Type.INT_ARRAY_4: { return(readIntArray(s, 4)); } case B2Type.INT_ARRAY_5: { return(readIntArray(s, 5)); } case B2Type.INT_ARRAY_6: { return(readIntArray(s, 6)); } case B2Type.INT_ARRAY_7: { return(readIntArray(s, 7)); } case B2Type.INT_ARRAY_8: { return(readIntArray(s, 8)); } case B2Type.INT_ARRAY_9: { return(readIntArray(s, 9)); } case B2Type.INT_ARRAY_10: { return(readIntArray(s, 10)); } case B2Type.INT_ARRAY_11: { return(readIntArray(s, 11)); } case B2Type.INT_ARRAY_12: { return(readIntArray(s, 12)); } case B2Type.INT_ARRAY_13: { return(readIntArray(s, 13)); } case B2Type.INT_ARRAY_14: { return(readIntArray(s, 14)); } case B2Type.INT_ARRAY_15: { return(readIntArray(s, 15)); } case B2Type.INT_ARRAY_16: { return(readIntArray(s, 16)); } case B2Type.INT_ARRAY: { int len = readInt(s); return(readIntArray(s, len)); //}case B2Type.INT_2D_ARRAY_0: { // return new int[0][0]; //}case B2Type.INT_2D_ARRAY: { // int len = readInt(s); // return readInt2DArray(s, len); } case B2Type.INT_B2: { return(readInt(s)); } default: //throw new IOException("unknow tag error:" + tag); UnityEngine.Debug.LogError("bio2 unknon type:" + tag); break; } return(0); }
public float initRandomFactor3() { RandomFactor3 = NumEx.NextInt(0, 1001) / 1000.0f; return(RandomFactor3); }
/// <summary> /// Bignumberadditive the specified nu1 and nu2. /// 大数相加,以4位长的数字分段计算两个参数是不代符号的 /// </summary> /// <param name='nu1'> /// Nu1. /// </param> /// <param name='nu2'> /// Nu2. /// </param> static string bignumberadditive(string nu1, string nu2) { string result = ""; string a = ""; string b = ""; int sizea = 0; int sizeb = 0; string tmpstr; int i = 0; a = nu1; b = nu2; if (a.Length < b.Length) { tmpstr = a; a = b; b = tmpstr; } if (a.Length % 4 == 0) { sizea = a.Length / 4; } else { sizea = a.Length / 4 + 1; } if (b.Length % 4 == 0) { sizeb = b.Length / 4; } else { sizeb = b.Length / 4 + 1; } string[] lista = new string[sizea]; string[] tmpresult = new string[sizea]; string[] listb = new string[sizeb]; for (i = 0; i < sizea; i++) { if (a.Length > 4) { lista[i] = StrEx.Right(a, 4); a = StrEx.Left(a, a.Length - 4); } else { lista[i] = StrEx.Right(a, a.Length); a = StrEx.Left(a, a.Length); } } for (i = 0; i < sizeb; i++) { if (b.Length > 4) { listb[i] = StrEx.Right(b, 4); b = StrEx.Left(b, b.Length - 4); } else { listb[i] = StrEx.Right(b, b.Length); b = StrEx.Left(b, b.Length); } } for (i = 0; i < sizea; i++) { if (i < sizeb) { tmpresult[i] = (NumEx.stringToInt(lista[i]) + NumEx.stringToInt(listb[i])).ToString(); } else { tmpresult[i] = lista[i]; } if (i != 0) { if ((tmpresult[i - 1]).Length == 5) { tmpresult[i] = (NumEx.stringToInt(tmpresult[i]) + 1).ToString(); } } if (i != sizea - 1) { int tmpN = 0; if (tmpresult[i].Length >= 4) { tmpN = NumEx.stringToInt(StrEx.Right(tmpresult[i], 4)); } else { tmpN = NumEx.stringToInt(tmpresult[i]); } result = NumEx.nStrForLen(tmpN, 4) + result; } else { result = tmpresult[i] + result; } } return(result); }
/// <summary> /// Bignumbersubduct the specified nu1 and nu2. /// 大数相减,以4位长的数字分段计算 /// 两个参数是不代符号的 /// </summary> /// <param name='nu1'> /// Nu1. /// </param> /// <param name='nu2'> /// Nu2. /// </param> static string bignumbersubduct(string nu1, string nu2) { string result = ""; string a; string b; string tmpstr; int sizea = 0; int sizeb = 0; int i = 0; string flag = ""; a = nu1; b = nu2; if (a.Length < b.Length) { tmpstr = a; a = b; b = tmpstr; flag = "-"; } else if (a.Length == b.Length) { if (a.CompareTo(b) == -1) { tmpstr = a; a = b; b = tmpstr; flag = "-"; } } if (a.Length % 4 == 0) { sizea = a.Length / 4; } else { sizea = a.Length / 4 + 1; } if (b.Length % 4 == 0) { sizeb = b.Length / 4; } else { sizeb = b.Length / 4 + 1; } string[] lista = new string[sizea]; string[] tmpresult = new string[sizea]; string[] listb = new string[sizeb]; for (i = 0; i < sizea; i++) { if (a.Length > 4) { lista[i] = StrEx.Right(a, 4); a = StrEx.Left(a, a.Length - 4); } else { lista[i] = StrEx.Right(a, a.Length); a = StrEx.Left(a, a.Length); } } for (i = 0; i < sizeb; i++) { if (b.Length > 4) { listb[i] = StrEx.Right(b, 4); b = StrEx.Left(b, b.Length - 4); } else { listb[i] = StrEx.Right(b, b.Length); b = StrEx.Left(b, b.Length); } } for (i = 0; i < sizea; i++) { if (i < sizeb) { if (i != sizea - 1) { tmpresult[i] = (NumEx.stringToInt("1" + lista[i]) - NumEx.stringToInt(listb[i])).ToString(); } else { tmpresult[i] = (NumEx.stringToInt(lista[i]) - NumEx.stringToInt(listb[i])).ToString(); } } else { if (i != sizea - 1) { tmpresult[i] = "1" + lista[i]; } else { tmpresult[i] = lista[i]; } } if (i != 0) { if (tmpresult[i - 1].Length < 5) { tmpresult[i] = (NumEx.stringToInt(tmpresult[i]) - 1).ToString(); } } if (i != sizea - 1) { int tempN = 0; if (tmpresult[i].Length >= 4) { tempN = NumEx.stringToInt(StrEx.Right(tmpresult[i], 4)); } else { tempN = NumEx.stringToInt(tmpresult[i]); } result = NumEx.nStrForLen(tempN, 4) + result; } else { result = tmpresult[i] + result; } } result = flag + result; return(result); }
// void LateUpdate () public void Update() { if (!isFinishInit || itemList.Count < 3) { return; } sourceIndex = -1; targetIndex = -1; sign = 0; head = itemList [0]; tail = itemList [itemList.Count - 1]; checkHead = itemList [wrapLineNum * checkLineSize]; if (list.Count > 0 && int.Parse(tail.name) > list.Count) { tail = transform.Find(NumEx.nStrForLen(list.Count - 1, 6)).GetComponent <UIWidget> (); // itemList [list.Count - 1]; tmpIndex = itemList.IndexOf(tail) - (wrapLineNum * checkLineSize); tmpIndex = tmpIndex < 0 ? 0 : tmpIndex; checkTail = itemList [tmpIndex]; } else { tail = itemList [itemList.Count - 1]; checkTail = itemList [itemList.Count - 1 - (wrapLineNum * checkLineSize)]; } firstVislable = checkHead.isVisible; lastVisiable = checkTail.isVisible; // if first and last both visiable or invisiable then return // if (firstVislable == lastVisiable) { // return; // } // Debug.Log (int.Parse (head.name) + "=11===" + (list.Count - 1) + "===" + firstVislable); // Debug.Log (int.Parse (tail.name) + "=22===" + (list.Count - 1) + "===" + lastVisiable); if (firstVislable && int.Parse(head.name) > 0) { isCanCallOnEndList = true; isCanCallOnHeadList = true; times--; // move last to first one sourceIndex = itemList.Count - 1; targetIndex = 0; sign = 1; } else if (lastVisiable && int.Parse(tail.name) < list.Count - 1) { isCanCallOnEndList = true; isCanCallOnHeadList = true; times++; // move first to last one sourceIndex = 0; targetIndex = itemList.Count - 1; sign = -1; } else { if (firstVislable && int.Parse(head.name) == 0) { if (isCanCallOnHeadList) { isCanCallOnHeadList = false; Utl.doCallback(this.onHeadListCallback); } } else { isCanCallOnHeadList = true; } if (lastVisiable && int.Parse(tail.name) == list.Count - 1) { //说明已经到最后了 if (isCanCallOnEndList) { isCanCallOnEndList = false; Utl.doCallback(this.onEndListCallback); } } else { isCanCallOnEndList = true; } } if (sourceIndex > -1) { int lineNum = wrapLineNum <= 0 ? 1 : wrapLineNum; for (int j = 0; j < lineNum; j++) { UIWidget movedWidget = itemList [sourceIndex]; int oldIndex = int.Parse(movedWidget.name); int newIndex = 0; if (sign < 0) { newIndex = oldIndex + RealCellCount; } else { newIndex = oldIndex - RealCellCount; } movedWidget.name = NumEx.nStrForLen(newIndex, 6); moveCellPos(movedWidget, itemList [targetIndex], newIndex, newIndex + sign); itemList.RemoveAt(sourceIndex); itemList.Insert(targetIndex, movedWidget); if (newIndex >= list.Count) { NGUITools.SetActive(movedWidget.gameObject, false); } else { NGUITools.SetActive(movedWidget.gameObject, true); Utl.doCallback(this.initCellCallback, movedWidget.GetComponent <CLCellBase> (), this.list [newIndex]); } } } }
void _setList(object data, object initCellCallback, object onHeadListCallback, object onEndListCallback, bool isNeedRePosition, bool isPlayTween, float tweenSpeed, float twDuration, UITweener.Method twMethod, TweenType twType) { try { this.data = data; this.list = wrapList(data); this.initCellCallback = initCellCallback; this.onEndListCallback = onEndListCallback; this.onHeadListCallback = onHeadListCallback; if (!isFinishInit) { init(); } else { for (int i = 0; i < itemList.Count; i++) { itemList [i].name = NumEx.nStrForLen(i, 6); } } int tmpIndex = 0; times = 0; // itemList.Clear (); for (int i = 0; i < itemList.Count; i++) { // Transform t = cachedTransform.GetChild (i); UIWidget uiw = itemList [i]; tmpIndex = i; uiw.name = NumEx.nStrForLen(tmpIndex, 6); if (tmpIndex >= 0 && tmpIndex < this.list.Count) { NGUITools.SetActive(uiw.gameObject, true); Utl.doCallback(this.initCellCallback, uiw.GetComponent <CLCellBase> (), list [tmpIndex]); NGUITools.updateAll(uiw.transform); // itemList.Add (uiw); } else { NGUITools.SetActive(uiw.gameObject, false); } } if (isNeedRePosition) { resetClip(); if (!isPlayTween || twType == TweenType.alpha || twType == TweenType.scale) { grid.Reposition(); // scrollView.ResetPosition(); } if (isPlayTween) { for (int i = 0; i < itemList.Count; i++) { CLUIUtl.resetCellTween(i, grid, itemList [i].gameObject, tweenSpeed, twDuration, twMethod, twType); } } } isCanCallOnEndList = true; isCanCallOnHeadList = true; } catch (System.Exception e) { Debug.LogError(e); } }
// void LateUpdate () void Update() { if (itemList.Count < 3) { return; } sourceIndex = -1; targetIndex = -1; // sign = 0; head = itemList [0]; tail = itemList [itemList.Count - 1]; checkHead = itemList [1]; checkTail = itemList [itemList.Count - 2]; firstVislable = checkHead.widget.isVisible; lastVisiable = checkTail.widget.isVisible; // if first and last both visiable or invisiable then return if (firstVislable == lastVisiable) { return; } if (firstVislable && int.Parse(head.name) > 0) { isCanCallOnEndList = true; times--; // move last to first one sourceIndex = itemList.Count - 1; targetIndex = 0; forward = false; } else if (lastVisiable && int.Parse(tail.name) < list.Count - 1) { isCanCallOnEndList = true; times++; // move first to last one sourceIndex = 0; targetIndex = itemList.Count - 1; forward = true; } else if (lastVisiable && int.Parse(tail.name) == list.Count - 1) { //说明已经到最后了 if (isCanCallOnEndList) { isCanCallOnEndList = false; #if UNITY_EDITOR Debug.Log("说明已经到最后了"); #endif Utl.doCallback(this.onEndListCallback); } } else { isCanCallOnEndList = true; } if (sourceIndex > -1) { movedWidget = itemList [sourceIndex]; if (forward) { // movedWidget.name = string.Format ("{0:D5}",); movedWidget.name = NumEx.nStrForLen(NumEx.stringToInt(tail.name) + 1, 6); // movedWidget.name = NumEx.nStrForLen( ((times - 1) / RealCellCount + 1) * RealCellCount + int.Parse (movedWidget.name) % RealCellCount, 6); } else { movedWidget.name = NumEx.nStrForLen(NumEx.stringToInt(head.name) - 1, 6); // movedWidget.name = string.Format ("{0:D5}", ((times) / RealCellCount) * RealCellCount + int.Parse (movedWidget.name) % RealCellCount); // movedWidget.name = NumEx.nStrForLen(((times) / RealCellCount) * RealCellCount + int.Parse (movedWidget.name) % RealCellCount, 6); } int index = int.Parse(movedWidget.name); Utl.doCallback(this.initCellCallback, movedWidget.GetComponent <CLCellBase> (), this.list [index]); // ***after init call, then set the position*** if (movedWidget.isSetWidgetSize) { _boxCollidr = movedWidget.GetComponent <BoxCollider> (); if (_boxCollidr != null) { _boxCollidr.size = Vector2.zero; } movedWidget.widget.SetDimensions(0, 0); } NGUITools.updateAll(movedWidget.transform); if (movedWidget.isSetWidgetSize) { _bound = NGUIMath.CalculateRelativeWidgetBounds(movedWidget.transform, false); movedWidget.widget.SetDimensions((int)(_bound.size.x), (int)(_bound.size.y)); } targetWidget = itemList [targetIndex]; if (forward) { setPosition(movedWidget, targetWidget, table.direction); } else { UITable.Direction dir = table.direction; if (table.direction == UITable.Direction.Up) { dir = UITable.Direction.Down; } else { dir = UITable.Direction.Up; } setPosition(movedWidget, targetWidget, dir); } // change item index itemList.RemoveAt(sourceIndex); itemList.Insert(targetIndex, movedWidget); } }
public static void resetList(object parent, GameObject prefabChild, object data, System.Type itype, GameObject nextPage, bool isShowNoneContent, object initCallback, bool isReposition, bool isPlayTween, float tweenSpeed = 0.2f) { object[] list = null; if (data is LuaTable) { ArrayList _list = CLUtlLua.luaTableVals2List((LuaTable)data); list = _list.ToArray(); _list.Clear(); _list = null; } else if (data is ArrayList) { list = ((ArrayList)data).ToArray(); } if ((list == null || list.Length == 0) && isShowNoneContent) { //mtoast = NGUIPublic.toast (mtoast, USWarnMsg.warnMsgNoContent ()); } if (parent == null) { return; } bool isTable = false; if (typeof(UIGrid) == parent.GetType()) { isTable = false; } else if (typeof(UITable) == parent.GetType()) { isTable = true; } else { return; } Transform parentTf = null; if (isTable) { //((UITable)parent).sorting = UITable.Sorting.Alphabetic; parentTf = ((UITable)parent).transform; } else { ((UIGrid)parent).sorted = true; parentTf = ((UIGrid)parent).transform; } Transform go; int i = 0, j = 0; // bool isNeedReposition = false; string childName = ""; for (i = 0; i < parentTf.childCount && list != null && j < list.Length; i++) { childName = NumEx.nStrForLen(i, 5); #if UNITY_5_6_OR_NEWER go = parentTf.Find(childName); #else go = parentTf.FindChild(childName); #endif if (go != null) { if (go.GetComponent(itype) != null) { NGUITools.SetActive(go.gameObject, true); Utl.doCallback(initCallback, go.GetComponent <CLCellBase> (), list [j]); NGUITools.updateAll(go.transform); if (isPlayTween) { resetCellTween(i, parent, go.gameObject, tweenSpeed); } if ((j + 1) == list.Length && nextPage != null) { nextPage.transform.localPosition = Vector3.zero; nextPage.transform.parent = go; if (!isTable) { nextPage.transform.localPosition = new Vector3(0, -((UIGrid)parent).cellHeight, 0); } } j++; } } } while (i < parentTf.childCount) { childName = NumEx.nStrForLen(i, 5); #if UNITY_5_6_OR_NEWER go = parentTf.Find(childName); #else go = parentTf.FindChild(childName); #endif if (go != null && go.gameObject.activeSelf) { if (go.GetComponent(itype) != null) { NGUITools.SetActive(go.gameObject, false); // isNeedReposition = true; } } i++; } while (list != null && j < list.Length) { go = NGUITools.AddChild(parentTf.gameObject, prefabChild).transform; // isNeedReposition = true; childName = NumEx.nStrForLen(j, 5); go.name = childName; Utl.doCallback(initCallback, go.GetComponent <CLCellBase> (), list [j]); NGUITools.updateAll(go.transform); if (isPlayTween) { resetCellTween(j, parent, go.gameObject, tweenSpeed); } if ((j + 1) == list.Length && nextPage != null) { nextPage.transform.localPosition = Vector3.zero; nextPage.transform.parent = go; if (!isTable) { nextPage.transform.localPosition = new Vector3(0, -((UIGrid)parent).cellHeight, 0); } } j++; } if (!isPlayTween) { if (isReposition) { if (!isTable) { ((UIGrid)parent).enabled = true; ((UIGrid)parent).Start(); ((UIGrid)parent).Reposition(); ((UIGrid)parent).repositionNow = true; UIScrollView sv = ((UIGrid)parent).transform.parent.GetComponent <UIScrollView> (); if (sv != null) { sv.ResetPosition(); } } else { ((UITable)parent).enabled = true; ((UITable)parent).Start(); ((UITable)parent).Reposition(); ((UITable)parent).repositionNow = true; UIScrollView sv = ((UITable)parent).transform.parent.GetComponent <UIScrollView> (); if (sv != null) { sv.ResetPosition(); } } } } }
public void refreshContentOnly(object data, bool UpdatePosition) { list = wrapList(data); UIWidget t = null; int tmpIndex = 0; CLCellBase cell = null; int maxIndex = -1; bool isActivedAllItems = true; bool needScrollReposiont = false; for (int i = 0; i < itemList.Count; ++i) { t = itemList [i]; if (!t.gameObject.activeSelf) { isActivedAllItems = false; continue; } tmpIndex = int.Parse(t.name); maxIndex = (maxIndex < tmpIndex) ? tmpIndex : maxIndex; cell = t.GetComponent <CLCellBase> (); if (cell != null) { if (tmpIndex >= list.Count) { NGUITools.SetActive(cell.gameObject, false); needScrollReposiont = true; } else { NGUITools.SetActive(cell.gameObject, true); Utl.doCallback(this.initCellCallback, cell, list [tmpIndex]); } } } if (maxIndex < list.Count && !isActivedAllItems) { tmpIndex = maxIndex; for (int i = 0; i < itemList.Count; ++i) { t = itemList [i]; if (!t.gameObject.activeSelf) { tmpIndex++; if (tmpIndex < list.Count) { cell = t.GetComponent <CLCellBase> (); if (cell != null) { cell.name = NumEx.nStrForLen(tmpIndex, 6); NGUITools.SetActive(cell.gameObject, true); Utl.doCallback(this.initCellCallback, cell, list [tmpIndex]); } } } } // grid.Reposition (); // // if (scrollView != null) { // scrollView.ResetPosition (); // } } if (UpdatePosition && scrollView != null) { scrollView.RestrictWithinBounds(true); scrollView.UpdateScrollbars(); scrollView.UpdatePosition(); } // if (needScrollReposiont && scrollView != null) { // grid.Reposition (); // scrollView.ResetPosition (); // } }
public void fire(int firePointIndex, int numPoints, int numEach, float angle, float offsetTime, CLUnit attacker, CLUnit target, object attr, object data, object callbak) { if (attacker == null || attr == null) { return; } //#if UNITY_EDITOR // CLTest cltest = GetComponent<CLTest>(); // if(cltest == null) { // cltest = gameObject.AddComponent<CLTest>(); // } // cltest.fire ( numPoints, numEach, angle, attacker); //#endif Transform firePoint = null; if (firePointIndex < 0 || firePoints == null || firePoints.Length <= firePointIndex) { firePoint = transform; } else { firePoint = firePoints[firePointIndex]; } int h = NumEx.bio2Int(MapEx.getBytes(attr, "High")); bool isZeroY = h > 0 ? true : false; if (numPoints > 0) { // get fire point bool needFireMid = false; //是否需要在中间发射(是奇数时需要) int half = numPoints / 2; if (numPoints % 2 == 0) { needFireMid = false; } else { needFireMid = true; } Vector3 pos2 = Vector3.zero; Vector3 dir = Vector3.zero; for (int i = 0; i < numEach; i++) { if (needFireMid) { dir = attacker.mbody.forward; if (isZeroY) { dir.y = 0; } // StartCoroutine (createBullet (attacker, target, firePoint.position, dir, attr, data, callbak, i * 0.1f)); object[] list = { attacker, target, firePoint.position, dir, attr, data, callbak }; InvokeEx.invokeByFixedUpdate((Callback)createBullet2, list, i * offsetTime); } for (int j = 1; j <= half; j++) { pos2 = AngleEx.getCirclePointStartWithYV3(firePoint.position, 2, attacker.mbody.eulerAngles.y - j * angle); if (isZeroY) { pos2.y = 0; } dir = pos2 - firePoint.position; // StartCoroutine (createBullet (attacker, target, firePoint.position, dir, attr, data, callbak, i * 0.1f)); object[] list = { attacker, target, firePoint.position, dir, attr, data, callbak }; InvokeEx.invokeByFixedUpdate((Callback)createBullet2, list, i * offsetTime); pos2 = AngleEx.getCirclePointStartWithYV3(firePoint.position, 2, attacker.mbody.eulerAngles.y + j * angle); if (isZeroY) { pos2.y = 0; } dir = pos2 - firePoint.position; // StartCoroutine (createBullet (attacker, target, firePoint.position, dir, attr, data, callbak, i * 0.1f)); object[] list2 = { attacker, target, firePoint.position, dir, attr, data, callbak }; InvokeEx.invokeByFixedUpdate((Callback)createBullet2, list2, i * offsetTime); } } } }