public override void Build(AutoSkillParticleEmitterItem targetObj) { ///TRIANGLE if (targetObj.emitterShapeType == Example.SkillShapeNew.ShapeType.TRIANGLE) { TriangleSkillShape Triangle = (TriangleSkillShape)targetObj.emitterShape; Vector3 dir = Target.forward; Vector3 beginPos = Vector3.zero; Vector3 launchPos = Vector3.zero; Vector3 pdir = Vector3.zero; Vector3 ndir = RotateRound(dir, new Vector3(0, 1, 0), 90); beginPos = -ndir * Triangle.width / 2f; if (targetObj.emitterCount > 1) { ndir = ndir * (Triangle.width / (targetObj.emitterCount - 1)); } for (int j = 0; j < targetObj.waves; j++) { for (int i = 0; i < targetObj.emitterCount; i++) { GameObject sub = new GameObject(); sub.name = "SubParticle_" + j + "_" + i; sub.transform.SetParent(targetObj.transform); launchPos = beginPos + i * ndir; SkillParticleActionItem sg = sub.AddComponent <SkillParticleActionItem>(); sg.export = true; sg.effect = targetObj.effectPrefab; // sg.effectName = targetObj.effectPrefab.name; sg.pathType = targetObj.particlePathType; sg.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.parent = sg.transform; line.startPos.position = Target.position + targetObj.emitterOffset + launchPos; line.startPos.localScale = Vector3.one * 0.3f; line.endPos = GameObject.CreatePrimitive(PrimitiveType.Cube).transform; line.endPos.parent = sg.transform; line.endPos.gameObject.name = "LineEnd"; line.endPos.position = Target.position + targetObj.emitterOffset + dir * Triangle.height; line.endPos.localScale = Vector3.one * 0.3f; } } } } }
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); }