Beispiel #1
0
 public static int getBytes2Int(object map, object key)
 {
     if (map == null || key == null)
     {
         return(0);
     }
     return(NumEx.bio2Int(getBytes(map, key)));
 }
Beispiel #2
0
        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());
        }
Beispiel #3
0
        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());
        }
Beispiel #4
0
        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);
                    }
                }
            }
        }