Esempio n. 1
0
 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;
         }
     }
 }
Esempio n. 2
0
 public void OnEmittRandomAreaBoxParticles(AutoSkillParticleEmitterItem targetObj, GameObject Actor, BoxSkillShape box)
 {
     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           w          = (int)(box.width * 1000);
             float         ww         = (float)ran.Next(0, w) / 1000f;
             int           h          = (int)(box.height * 1000);
             float         hh         = (float)ran.Next(0, h) / 1000f;
             float         x          = ww - box.width / 2;
             float         z          = hh - box.height / 2;
             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;
         }
     }
 }
Esempio n. 3
0
    private static Example.SkillParticleEmitter ExportParticleEmitter(SkillParticleEmitterItem emitter, List <Example.SkillParticleEmitter> emitters)
    {
        Example.SkillParticleEmitter particleEmitter = new Example.SkillParticleEmitter();
        List <Example.SkillParticle> skillParticles  = new List <Example.SkillParticle>();
        var particles = emitter.GetComponentsInChildren <SkillParticleActionItem>();

        foreach (var particle in particles)
        {
            ExportSkillParticle(particle, skillParticles);
        }
        if (emitter is AutoSkillParticleEmitterItem)
        {
            AutoSkillParticleEmitterItem autoEmitter = (AutoSkillParticleEmitterItem)emitter;
            particleEmitter.emitterType      = autoEmitter.emitterType;
            particleEmitter.StartTime        = Mathf.FloorToInt(autoEmitter.Firetime * 1000);
            particleEmitter.Duration         = Mathf.FloorToInt(autoEmitter.Duration * 1000);
            particleEmitter.EmitterShape     = ExportSkillShape(autoEmitter.emitterShape);
            particleEmitter.EmitterPosition  = MathUtil.ToVector3f(autoEmitter.emitterOffset);
            particleEmitter.ParticleTemplate = skillParticles.Count > 0 ? skillParticles[0] : null;
            particleEmitter.Particles        = skillParticles;
        }
        else if (emitter is ManualSkillParticleEmitterItem)
        {
            ManualSkillParticleEmitterItem autoEmitter = (ManualSkillParticleEmitterItem)emitter;
            particleEmitter.emitterType = autoEmitter.emitterType;
            particleEmitter.StartTime   = Mathf.FloorToInt(autoEmitter.Firetime * 1000);
            particleEmitter.Duration    = Mathf.FloorToInt(autoEmitter.Duration * 1000);
            particleEmitter.Particles   = skillParticles;
        }
        emitters.Add(particleEmitter);
        return(particleEmitter);
    }
Esempio n. 4
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;
                    }
                }
            }
        }
    }
Esempio n. 5
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;
                    }
                }
            }
        }
    }
Esempio n. 6
0
    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);
                }
            }
        }
    }
Esempio n. 7
0
    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);
            }
        }
    }
Esempio n. 8
0
 public virtual void Build(AutoSkillParticleEmitterItem targetObj)
 {
     throw new Exception(GetType().Name + ".Build(AutoSkillParticleEmitterItem) not impl");
 }