示例#1
0
    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;
                    }
                }
            }
        }
    }
示例#2
0
    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;
                    }
                }
            }
        }
    }
示例#3
0
    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();
        }
    }