public override void Build(AutoSkillParticleEmitterItem targetObj) { if (targetObj.emitterShapeType == Example.SkillShapeNew.ShapeType.CIRCLE) { offset = targetObj.emitterOffset; CircleSkillShape circle = (CircleSkillShape)targetObj.emitterShape; float angle = 360f / targetObj.emitterCount; Vector3 dir = Target.transform.forward; for (int j = 0; j < targetObj.waves; j++) { for (int i = 0; i < targetObj.emitterCount; i++) { Vector3 ndir = RotateRound(dir, new Vector3(0, 1, 0), i * angle); GameObject sub = new GameObject(); sub.name = "SubParticle_" + j + "_" + i; sub.transform.SetParent(targetObj.transform); SkillParticleActionItem sg = sub.AddComponent <SkillParticleActionItem>(); sg.export = true; sg.effect = targetObj.effectPrefab; //sg.effectName = targetObj.effectPrefab.name; sg.pathType = targetObj.particlePathType; sg.Firetime = targetObj.Firetime + targetObj.particleStartFrame / 1000f + targetObj.waveDelay * j / 1000f; sg.Duration = targetObj.particleDuration / 1000f; sg.hitshapeType = targetObj.particleHitShapeType; //sg.hitShape = targetObj.hitShape; AddShape(sg, targetObj.hitShape); if (targetObj.particlePathType == Example.SkillPath.PathType.LINE) { sg.path = sub.AddComponent <LineSkillPath>(); sg.path.pathType = Example.SkillPath.PathType.LINE; LineSkillPath line = (LineSkillPath)sg.path; line.startPos = GameObject.CreatePrimitive(PrimitiveType.Cube).transform; line.startPos.gameObject.name = "LineStart"; line.startPos.localScale = Vector3.one * 0.3f; line.startPos.parent = sg.transform; line.startPos.position = Target.transform.position + targetObj.emitterOffset; line.endPos = GameObject.CreatePrimitive(PrimitiveType.Cube).transform; line.endPos.parent = sg.transform; line.endPos.gameObject.name = "LineEnd"; line.endPos.localScale = Vector3.one * 0.3f; line.endPos.position = Target.transform.position + targetObj.emitterOffset + ndir * circle.radius; } } } } }
public void AddShape(SkillParticleActionItem sg, SkillShape shape) { GameObject targetObj = sg.gameObject; if (shape.shapeType == Example.SkillShapeNew.ShapeType.CIRCLE) { CircleSkillShape cskill = (CircleSkillShape)shape; CircleSkillShape shape0 = targetObj.AddComponent <CircleSkillShape>(); shape0.Target = targetObj.transform; shape0.offset = cskill.offset; shape0.radius = cskill.radius; sg.hitShape = shape0; } if (shape.shapeType == Example.SkillShapeNew.ShapeType.BOX) { BoxSkillShape cskill = (BoxSkillShape)shape; BoxSkillShape shape0 = targetObj.AddComponent <BoxSkillShape>(); shape0.Target = targetObj.transform; shape0.offset = cskill.offset; shape0.width = cskill.width; shape0.height = cskill.height; sg.hitShape = shape0; } if (shape.shapeType == Example.SkillShapeNew.ShapeType.SECTOR) { SectorSkillShape cskill = (SectorSkillShape)shape; SectorSkillShape shape0 = targetObj.AddComponent <SectorSkillShape>(); shape0.Target = targetObj.transform; shape0.offset = cskill.offset; shape0.angle = cskill.angle; shape0.radius = cskill.radius; sg.hitShape = shape0; } if (shape.shapeType == Example.SkillShapeNew.ShapeType.TRIANGLE) { TriangleSkillShape cskill = (TriangleSkillShape)shape; TriangleSkillShape shape0 = targetObj.AddComponent <TriangleSkillShape>(); shape0.Target = targetObj.transform; shape0.offset = cskill.offset; shape0.width = cskill.width; shape0.height = cskill.height; sg.hitShape = shape0; } }
SkillShape ReplaceShape(Example.SkillShapeNew.ShapeType oldShape, Example.SkillShapeNew.ShapeType newShape, GameObject targetObj, SkillShape shape, Transform actor, Vector3 offset) { if (oldShape != newShape) { if (shape != null) { DestroyImmediate(shape); } if (newShape == Example.SkillShapeNew.ShapeType.CIRCLE) { CircleSkillShape shape0 = targetObj.AddComponent <CircleSkillShape>(); shape0.Target = actor; shape0.offset = offset; return(shape0); } if (newShape == Example.SkillShapeNew.ShapeType.BOX) { BoxSkillShape shape0 = targetObj.AddComponent <BoxSkillShape>(); shape0.Target = actor; shape0.offset = offset; return(shape0); } if (newShape == Example.SkillShapeNew.ShapeType.SECTOR) { SectorSkillShape shape0 = targetObj.AddComponent <SectorSkillShape>(); shape0.Target = actor; shape0.offset = offset; return(shape0); } if (newShape == Example.SkillShapeNew.ShapeType.TRIANGLE) { TriangleSkillShape shape0 = targetObj.AddComponent <TriangleSkillShape>(); shape0.Target = actor; shape0.offset = offset; return(shape0); } if (newShape == Example.SkillShapeNew.ShapeType.NONE) { return(null); } } return(shape); }
void RandomEmitterFunc(AutoSkillParticleEmitterItem targetObj) { if (targetObj.emitterType == Example.SkillParticleEmitter.EmitterType.RANDOM) { SkillParticleActionItem[] children = targetObj.transform.GetComponentsInChildren <SkillParticleActionItem>(); for (int i = 0; i < children.Length; i++) { GameObject.DestroyImmediate(children[i].gameObject); } children = null; GameObject Actor = null; if (targetObj.TimelineTrack.TrackGroup is ActorTrackGroup) { ActorTrackGroup ag = (ActorTrackGroup)targetObj.TimelineTrack.TrackGroup; Actor = ag.Actor.gameObject; } if (targetObj.waves <= 0) { targetObj.waves = 1; } if (targetObj.emitterShapeType == Example.SkillShapeNew.ShapeType.CIRCLE) { CircleSkillShape circle = (CircleSkillShape)targetObj.emitterShape; if (targetObj.particlePathType == Example.SkillPath.PathType.FIXED_POSITION) { EmittRandomAreaCircleParticles(targetObj, Actor, circle); } } if (targetObj.emitterShapeType == Example.SkillShapeNew.ShapeType.BOX) { BoxSkillShape box = (BoxSkillShape)targetObj.emitterShape; if (targetObj.particlePathType == Example.SkillPath.PathType.FIXED_POSITION) { OnEmittRandomAreaBoxParticles(targetObj, Actor, box); } } } }
public void EmittRandomAreaCircleParticles(AutoSkillParticleEmitterItem targetObj, GameObject Actor, CircleSkillShape circle) { for (int j = 0; j < targetObj.waves; j++) { for (int i = 0; i < targetObj.emitterCount; i++) { long tick = System.DateTime.Now.Ticks; System.Random ran = new System.Random((int)(tick & 0xffffffffL) | (int)(tick >> 32)); int rc = (int)(circle.radius * 1000); float radius = (float)ran.Next(0, rc) / 1000f; float angle = ran.Next(0, 360); float x = radius * Mathf.Cos(Mathf.Deg2Rad * angle); float z = radius * Mathf.Sin(Mathf.Deg2Rad * angle); Vector3 paticleDir = new Vector3(x, 0, z); GameObject sub = new GameObject(); sub.name = "SubParticle_" + j + "_" + i; sub.transform.SetParent(targetObj.transform); SkillParticleActionItem sg = sub.AddComponent <SkillParticleActionItem>(); sg.export = false; sg.effect = targetObj.effectPrefab; //sg.effectName = effectPrefab.name; sg.pathType = Example.SkillPath.PathType.FIXED_POSITION; sg.Firetime = targetObj.Firetime + targetObj.particleStartFrame / 1000f + targetObj.waveDelay * j / 1000f; sg.Duration = targetObj.particleDuration / 1000f; sg.path = sub.AddComponent <FixedPositionSkillPath>(); FixedPositionSkillPath fpath = (FixedPositionSkillPath)sg.path; fpath.fixedPosition = new GameObject("fixedPosotion").transform; fpath.fixedPosition.SetParent(sub.transform); fpath.fixedPosition.position = Actor.transform.position + targetObj.emitterOffset + paticleDir; } } }