Example #1
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);
                    }
                }
            }
        }
Example #2
0
 public InvokeEx()
 {
     self = this;
 }