Beispiel #1
0
        private ObjectEmitCalculateResult OnCalculate(ObjectEmitCalculateParams args, ref ObjectEmitCalculateResult result)
        {
            switch (args.emitter.launchType)
            {
            //存在一次发射不同方向的可能
            case EObjectEmitLaunchType.Line:
            {
                float lAngle = args.emitter.launchLineAngle * Mathf.Deg2Rad;
                result.startMoveSpeed.x       = args.emitter.launchMoveSpeed * Mathf.Cos(lAngle);
                result.startMoveSpeed.y       = args.emitter.launchMoveSpeed * Mathf.Sin(lAngle);
                args.emitter.launchLineAngle += args.emitter.launchLineRPT;

                result.startPosition.x = args.emitter.launchLineDistance * Mathf.Cos(lAngle);
                result.startPosition.y = args.emitter.launchLineDistance * Mathf.Sin(lAngle);

                result.startEulerAngles.z = (lAngle * Mathf.Rad2Deg) - 90;
                result.startAngleSpeed.z  = args.emitter.launchAngleSpeed;
            }
            break;

            case EObjectEmitLaunchType.Sector:
            {
                float sectorAnglePerTimes = args.emitter.launchSectorSpreadAngle / args.emitter.launchNum;
                float sectorAngle         = (sectorAnglePerTimes * args.index + args.emitter.launchSectorStartAngle) * Mathf.Deg2Rad;

                result.startPosition.x = args.emitter.launchSectorRadius * Mathf.Cos(sectorAngle);
                result.startPosition.y = args.emitter.launchSectorRadius * Mathf.Sin(sectorAngle);

                result.startMoveSpeed.x = args.emitter.launchMoveSpeed * Mathf.Cos(sectorAngle);
                result.startMoveSpeed.y = args.emitter.launchMoveSpeed * Mathf.Sin(sectorAngle);

                result.startAngleSpeed.z  = args.emitter.launchAngleSpeed;
                result.startEulerAngles.z = (sectorAngle * Mathf.Rad2Deg) - 90;
            }
            break;

            case EObjectEmitLaunchType.Random:
            {
                //随机位置
                float minR  = args.emitter.launchRandomMinRadius;
                float maxR  = args.emitter.launchRandomMaxRadius;
                float r     = ObjectEmitManager.GetInstance().GetRandom().Next((int)(minR * 100), (int)((maxR * 100) + 1)) / 100f;
                float angle = ObjectEmitManager.GetInstance().GetRandom().Next(0, 361) * Mathf.Deg2Rad;
                float rX    = r * Mathf.Cos(angle);
                float rY    = r * Mathf.Sin(angle);
                result.startPosition.x = rX;
                result.startPosition.y = rY;

                result.startMoveSpeed.x = args.emitter.launchMoveSpeed * (float)Mathf.Cos(angle);
                result.startMoveSpeed.y = args.emitter.launchMoveSpeed * (float)Mathf.Sin(angle);

                result.startAngleSpeed.z  = args.emitter.launchAngleSpeed;
                result.startEulerAngles.z = (angle * Mathf.Rad2Deg) - 90;
            }
            break;

            case EObjectEmitLaunchType.FixedPoint:
            {
                //固定位置
                if (args.emitter.launchFixedPointPoints.Length > 0)
                {
                    var ponit = args.emitter.launchFixedPointPoints[(args.index + args.times) % args.emitter.launchFixedPointPoints.Length];
                    result.startPosition.x = ponit.x;
                    result.startPosition.y = ponit.y;
                    result.startPosition.z = ponit.z;
                }
            }
            break;

            case EObjectEmitLaunchType.Custom:
            {
                if (args.emitter.launchCustomCallback != null)
                {
                    result = args.emitter.launchCustomCallback.Calculate(args);
                }
            }
            break;
            }

            return(result);
        }
Beispiel #2
0
 public abstract ObjectEmitCalculateResult Calculate(ObjectEmitCalculateParams args);