コード例 #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;
         }
     }
 }
コード例 #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;
         }
     }
 }
コード例 #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();
        }
    }