static SkillShape CreateSkillShape(GameObject go, Example.SkillShapeNew.ShapeType type) { SkillShape shape = null; switch (type) { case Example.SkillShapeNew.ShapeType.BOX: shape = go.AddComponent <BoxSkillShape> (); break; case Example.SkillShapeNew.ShapeType.CIRCLE: var circle = go.AddComponent <CircleSkillShape> (); shape = circle; break; } shape.shapeType = type; return(shape); }
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); }
public static SkillParticle CreateSkillParticle(SkillParticleEmitter skillEmitter, GameObject effectPrefab, int startFrame, int duration, Example.SkillPath.PathType pathType, Example.SkillShapeNew.ShapeType shapeType) { var go = CreateGameObject(skillEmitter.transform, "Particle"); var path = CreateSkillPath(go, pathType); var shape = CreateSkillShape(go, shapeType); var skillParticle = go.AddComponent <SkillParticle> (); //var effect = InstantiateGameObject (go.transform,effectPrefab,"Effect"); skillParticle.path = path; skillParticle.hitShape = shape; skillParticle.startFrame = startFrame; skillParticle.duration = duration; skillParticle.effect = effectPrefab; skillParticle.effectName = effectPrefab != null?effectPrefab.name:""; return(skillParticle); }
public static AutoSkillParticleEmitter CreateSkillParticleEmitter(Skill skill, Example.SkillParticleEmitter.EmitterType emitterType, Example.SkillShapeNew.ShapeType shapeType, int count) { var go = CreateGameObject(skill.transform, "ParticleEmitter"); var shape = CreateSkillShape(go, shapeType); var particleEmitter = go.AddComponent <AutoSkillParticleEmitter> (); particleEmitter.emitterType = emitterType; particleEmitter.emitterShape = shape; particleEmitter.emitterCount = count; return(particleEmitter); }
public override void OnInspectorGUI() { Obj = new SerializedObject(this.target); this.firetime = Obj.FindProperty("firetime"); this.duration = Obj.FindProperty("duration"); this.emitterShapeType = Obj.FindProperty("emitterShapeType"); this.emitterType = Obj.FindProperty("emitterType"); this.emitterOffset = Obj.FindProperty("emitterOffset"); this.emitterCount = Obj.FindProperty("emitterCount"); this.emitterShape = Obj.FindProperty("emitterShape"); this.effectPrefab = Obj.FindProperty("effectPrefab"); this.particlePathType = Obj.FindProperty("particlePathType"); this.particleHitShapeType = Obj.FindProperty("particleHitShapeType"); this.particleStartFrame = Obj.FindProperty("particleStartFrame"); this.particleDuration = Obj.FindProperty("particleDuration"); this.waves = Obj.FindProperty("waves"); this.waveDelay = Obj.FindProperty("waveDelay"); EditorGUILayout.PropertyField(firetime); EditorGUILayout.PropertyField(duration); EditorGUILayout.PropertyField(emitterShape); EditorGUILayout.PropertyField(emitterType); EditorGUILayout.PropertyField(emitterShapeType); EditorGUILayout.PropertyField(emitterOffset); EditorGUILayout.PropertyField(emitterCount); EditorGUILayout.PropertyField(waves); EditorGUILayout.PropertyField(waveDelay); EditorGUILayout.PropertyField(effectPrefab); EditorGUILayout.PropertyField(particlePathType); EditorGUILayout.PropertyField(particleHitShapeType); EditorGUILayout.PropertyField(particleStartFrame); EditorGUILayout.PropertyField(particleDuration); AutoSkillParticleEmitterItem targetObj = this.target as AutoSkillParticleEmitterItem; // Example.SkillPath.PathType oldPath = targetObj.particlePathType; Example.SkillShapeNew.ShapeType oldShape = targetObj.emitterShapeType; Example.SkillShapeNew.ShapeType oldhitShape = targetObj.particleHitShapeType; Obj.ApplyModifiedProperties(); targetObj.emitterShape = ReplaceShape(oldShape, targetObj.emitterShapeType, targetObj.gameObject, targetObj.emitterShape, targetObj.Actor(), targetObj.emitterOffset); if (targetObj.emitterShape != null) { targetObj.emitterShape.shapeType = targetObj.emitterShapeType; } targetObj.hitShape = ReplaceShape(oldhitShape, targetObj.particleHitShapeType, targetObj.gameObject, targetObj.hitShape, targetObj.Actor(), Vector3.zero); if (targetObj.hitShape != null) { targetObj.hitShape.shapeType = targetObj.particleHitShapeType; } if (targetObj.emitterType == Example.SkillParticleEmitter.EmitterType.RANDOM) { if (targetObj.emitterShapeType != Example.SkillShapeNew.ShapeType.CIRCLE && targetObj.emitterShapeType != Example.SkillShapeNew.ShapeType.BOX) { EditorGUILayout.HelpBox("随机发射形状仅支持Circle和Box", MessageType.Error); } if (targetObj.particlePathType != Example.SkillPath.PathType.FIXED_POSITION) { EditorGUILayout.HelpBox("随机发射仅支持FIXED_POSITION粒子线路类型", MessageType.Error); } } else { if (targetObj.particlePathType != Example.SkillPath.PathType.LINE) { EditorGUILayout.HelpBox("不支持除直线以外的粒子线路类型", MessageType.Error); } } if (targetObj.emitterType == Example.SkillParticleEmitter.EmitterType.RANDOM) { if (GUILayout.Button("生成")) { RandomEmitterFunc(targetObj); } } if (targetObj.emitterType == Example.SkillParticleEmitter.EmitterType.FIXED) { if (GUILayout.Button("生成")) { 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; } targetObj.emitterShape.Build(targetObj); } } }
public override void OnInspectorGUI() { Obj = new SerializedObject(this.target); this.firetime = Obj.FindProperty("firetime"); this.duration = Obj.FindProperty("duration"); this.id = Obj.FindProperty("id"); this.effect = Obj.FindProperty("effect"); this.pathType = Obj.FindProperty("pathType"); this.hitshapeType = Obj.FindProperty("hitshapeType"); this.isBullet = Obj.FindProperty("isBullet"); export = Obj.FindProperty("export"); EditorGUILayout.PropertyField(firetime); EditorGUILayout.PropertyField(duration); EditorGUILayout.PropertyField(id); EditorGUILayout.PropertyField(effect); EditorGUILayout.PropertyField(pathType); EditorGUILayout.PropertyField(hitshapeType); EditorGUILayout.PropertyField(isBullet); EditorGUILayout.PropertyField(export); SkillParticleActionItem targetObj = this.target as SkillParticleActionItem; Example.SkillPath.PathType oldPath = targetObj.pathType; Example.SkillShapeNew.ShapeType oldShape = targetObj.hitshapeType; //targetObj.pathType = (Example.SkillPath.PathType)EditorGUILayout.EnumPopup("pathType", targetObj.pathType); Obj.ApplyModifiedProperties(); if (oldPath != targetObj.pathType) { if (targetObj.path != null) { if (targetObj.path is LineSkillPath) { LineSkillPath line = (LineSkillPath)targetObj.path; if (line.startPos.gameObject != null) { DestroyImmediate(line.startPos.gameObject); } if (line.endPos.gameObject != null) { DestroyImmediate(line.endPos.gameObject); } } DestroyImmediate(targetObj.path); } if (targetObj.pathType == Example.SkillPath.PathType.LINE) { targetObj.path = targetObj.gameObject.AddComponent <LineSkillPath>(); LineSkillPath line = (LineSkillPath)targetObj.path; line.startPos = GameObject.CreatePrimitive(PrimitiveType.Cube).transform; line.startPos.gameObject.name = "LineStart"; line.startPos.localScale = Vector3.one * 0.3f; line.startPos.parent = targetObj.gameObject.transform; line.endPos = GameObject.CreatePrimitive(PrimitiveType.Cube).transform; line.endPos.parent = targetObj.gameObject.transform; line.endPos.gameObject.name = "LineEnd"; line.endPos.localScale = Vector3.one * 0.3f; } if (targetObj.pathType == Example.SkillPath.PathType.FOLLOW) { targetObj.path = targetObj.gameObject.AddComponent <FollowSkillPath>(); //FollowSkillPath line = (FollowSkillPath)targetObj.path; } if (targetObj.pathType == Example.SkillPath.PathType.HELIX) { targetObj.path = targetObj.gameObject.AddComponent <HelixSkillPath>(); HelixSkillPath line = (HelixSkillPath)targetObj.path; line.StartPoint = GameObject.CreatePrimitive(PrimitiveType.Cube).transform; line.StartPoint.gameObject.name = "StartPoint"; line.StartPoint.localScale = Vector3.one * 0.3f; line.StartPoint.parent = targetObj.gameObject.transform; } if (targetObj.pathType == Example.SkillPath.PathType.SCALE) { targetObj.path = targetObj.gameObject.AddComponent <ScaleSkillPath>(); //ScaleSkillPath line = (ScaleSkillPath)targetObj.path; } if (targetObj.pathType == Example.SkillPath.PathType.FIXED_POSITION) { targetObj.path = targetObj.gameObject.AddComponent <FixedPositionSkillPath>(); FixedPositionSkillPath line = (FixedPositionSkillPath)targetObj.path; line.fixedPosition = GameObject.CreatePrimitive(PrimitiveType.Cube).transform; line.fixedPosition.gameObject.name = "fixedPosition"; line.fixedPosition.localScale = Vector3.one * 0.3f; line.fixedPosition.parent = targetObj.gameObject.transform; } if (targetObj.pathType == Example.SkillPath.PathType.NONE) { targetObj.path = targetObj.gameObject.AddComponent <NOPSkillPath>(); } } if (oldShape != targetObj.hitshapeType) { if (targetObj.hitShape != null) { // if (targetObj.hitShape is CircleSkillShape) { // CircleSkillShape line = (CircleSkillShape)targetObj.hitShape; } DestroyImmediate(targetObj.hitShape); } if (targetObj.hitshapeType == Example.SkillShapeNew.ShapeType.CIRCLE) { targetObj.hitShape = targetObj.gameObject.AddComponent <CircleSkillShape>(); } if (targetObj.hitshapeType == Example.SkillShapeNew.ShapeType.BOX) { targetObj.hitShape = targetObj.gameObject.AddComponent <BoxSkillShape>(); } if (targetObj.hitshapeType == Example.SkillShapeNew.ShapeType.SECTOR) { targetObj.hitShape = targetObj.gameObject.AddComponent <SectorSkillShape>(); } if (targetObj.hitshapeType == Example.SkillShapeNew.ShapeType.TRIANGLE) { targetObj.hitShape = targetObj.gameObject.AddComponent <TriangleSkillShape>(); } } if (GUILayout.Button("添加碰撞动作")) { GameObject hit = new GameObject(); hit.name = "HitAction"; SkillHitAction skillhit = hit.AddComponent <SkillHitAction>(); hit.transform.SetParent(targetObj.transform); targetObj.HitActions.Add(skillhit); } if (GUILayout.Button("整理碰撞动作")) { ClearBoom(targetObj); } if (GUILayout.Button("生成碰撞动作模拟")) { ClearBoom(targetObj); targetObj.Boom(); } }