Example #1
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;
         }
     }
 }
Example #2
0
    public override void OnInspectorGUI()
    {
        Obj           = new SerializedObject(this.target);
        this.firetime = Obj.FindProperty("firetime");
        this.duration = Obj.FindProperty("duration");

        EditorGUILayout.PropertyField(firetime);
        EditorGUILayout.PropertyField(duration);


        ManualSkillParticleEmitterItem targetObj = this.target as ManualSkillParticleEmitterItem;

        //
        Obj.ApplyModifiedProperties();

        if (GUILayout.Button("添加技能粒子"))
        {
            GameObject sub = new GameObject();
            sub.name = "SubParticle";
            sub.transform.SetParent(targetObj.transform);
            SkillParticleActionItem sg = sub.AddComponent <SkillParticleActionItem>();
            sg.Duration = 1;
            sg.export   = true;
        }
    }
Example #3
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;
         }
     }
 }
    public override void ResizeControlPosition(DirectorControlState state, Rect trackPosition)
    {
        CinemaActionWrapper wrapper = base.Wrapper as CinemaActionWrapper;

        if (wrapper == null)
        {
            return;
        }
        if (base.isRenaming)
        {
            return;
        }
        float num  = (wrapper.Firetime * state.Scale.x) + state.Translation.x;
        float num2 = ((wrapper.Firetime + wrapper.Duration) * state.Scale.x) + state.Translation.x;

        this.controlPosition = new Rect(num, 0f, num2 - num, trackPosition.height);
        SkillParticleActionItem action = Wrapper.Behaviour as SkillParticleActionItem;

        if (action == null)
        {
            return;
        }
        if (ParentEmitter != null)
        {
            int level = ParentEmitter.GetLevel();
            controlPosition = new Rect(controlPosition.x, trackPosition.height - trackPosition.height / level, controlPosition.width, trackPosition.height / level);
        }
    }
Example #5
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;
                    }
                }
            }
        }
    }
Example #6
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;
                    }
                }
            }
        }
    }
Example #7
0
    private void ClearBoom(SkillParticleActionItem targetObj)
    {
        List <SkillHitAction> clearlist = new List <SkillHitAction>();

        foreach (SkillHitAction shit in targetObj.HitActions)
        {
            if (shit == null)
            {
                clearlist.Add(shit);
            }
        }
        foreach (SkillHitAction shit in clearlist)
        {
            targetObj.HitActions.Remove(shit);
        }
    }
Example #8
0
    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;
        }
    }
    public override void Draw(DirectorControlState state)
    {
        SkillParticleActionItem action = Wrapper.Behaviour as SkillParticleActionItem;

        if (action == null)
        {
            return;
        }
        if (IsSelected)
        {
            GUI.Box(controlPosition, GUIContent.none, TimelineTrackControl.styles.ActorTrackItemSelectedStyle);
        }
        else
        {
            GUI.Box(controlPosition, GUIContent.none, TimelineTrackControl.styles.ActorTrackItemStyle);
        }

        DrawRenameLabel(action.name, controlPosition);
    }
Example #10
0
    private static Example.SkillParticle ExportSkillParticle(SkillParticleActionItem particle, List <Example.SkillParticle> particles)
    {
        if (!particle.export)
        {
            return(null);
        }
        Example.SkillParticle      skillParticle = new Example.SkillParticle();
        List <Example.SkillAction> skillActions  = new List <Example.SkillAction>();


        foreach (var action in particle.HitActions)
        {
            ExportSkillAction(action, skillActions);
        }
        var actions = particle.GetComponentsInChildren <SkillActionItem>();

        foreach (var action in actions)
        {
            ExportSkillAction(action, skillActions);
        }

        Example.SkillPath skillPath = new Example.SkillPath();
        skillPath.pathType = particle.path.pathType;
        skillPath.Args     = ArrayToList(particle.path.arguments);

        Example.SkillShapeNew skillShape = ExportSkillShape(particle.hitShape);
        Debug.Log("particle.hitShape " + particle.hitShape.Radius + " skillShape " + skillShape.Radius);
        skillParticle.IsBullet  = particle.isBullet;
        skillParticle.Id        = particles.Count;
        skillParticle.StartTime = Mathf.FloorToInt(particle.Firetime * 1000);
        skillParticle.Duration  = Mathf.FloorToInt(particle.Duration * 1000);
        skillParticle.Effect    = particle.EffectName;
        skillParticle.HitShape  = skillShape;
        skillParticle.Path      = skillPath;
        skillParticle.Actions   = skillActions;
        particles.Add(skillParticle);
        return(skillParticle);
    }
Example #11
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();
        }
    }