示例#1
0
    public static void ExportLightEffect(bool autoBulid = true)
    {
        Clear();

        if (string.IsNullOrEmpty(configPath))
        {
            configPath = Application.dataPath + schemePath;
        }

        if (!Directory.Exists(configPath))
        {
            if (autoBulid)
            {
                EditorLog.LogError("光效配置根目录不存在!");
            }
            else
            {
                EditorUtility.DisplayDialog("配置导出", "光效配置根目录不存在,请检查!", "OK");
            }

            return;
        }

        string[] schemeArray = Directory.GetFiles(configPath, "*" + schemeExtension, SearchOption.AllDirectories);
        foreach (string strSchemePath in schemeArray)
        {
            if (string.IsNullOrEmpty(strSchemePath) || !strSchemePath.EndsWith(schemeExtension))
            {
                continue;
            }

            string strTempPath = strSchemePath.Replace(@"\", "/");
            strTempPath = strTempPath.Substring(strTempPath.IndexOf("Assets"));

            UnityEngine.Object schemeObj = AssetDatabase.LoadAssetAtPath(@strTempPath, typeof(UnityEngine.Object));
            if (schemeObj != null)
            {
                LightingEffect scheme = schemeObj as LightingEffect;
                if (scheme != null)
                {
                    LightingEffectConfigType type = scheme.GetEffectType();
                    if (!lightEffectConfigMap.ContainsKey(type))
                    {
                        lightEffectConfigMap.Add(type, new List <LightingEffect>());
                    }

                    lightEffectConfigMap[type].Add(scheme);
                }
            }
        }

        lightEffectConfigMap = lightEffectConfigMap.OrderBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value);

        InitStreamWriter();

        foreach (KeyValuePair <LightingEffectConfigType, List <LightingEffect> > kvp in lightEffectConfigMap)
        {
            WriteSchemeHead(kvp.Key);

            foreach (LightingEffect item in kvp.Value)
            {
                ExportScheme(kvp.Key, item);
            }

            FlushStreamWriter();
        }

        FreeStreamWriter();
        Clear();

        if (!autoBulid)
        {
            EditorUtility.DisplayDialog("配置导出", "光效配置导出完成!", "OK");
        }
    }
示例#2
0
    private static void ExportScheme(LightingEffectConfigType type, LightingEffect scheme)
    {
        switch (type)
        {
        case LightingEffectConfigType.Bind:
        {
            ExportScheme_Bind(scheme);
        }
        break;

        case LightingEffectConfigType.Fly:
        {
            ExportScheme_Fly(scheme);
        }
        break;

        case LightingEffectConfigType.AniReplace:
        {
            ExportScheme_AniReplace(scheme);
        }
        break;

        case LightingEffectConfigType.Area:
        {
            ExportScheme_Area(scheme);
        }
        break;

        case LightingEffectConfigType.Camera:
        {
            ExportScheme_Camera(scheme);
        }
        break;

        case LightingEffectConfigType.Shadow:
        {
            ExportScheme_Shadow(scheme);
        }
        break;

        case LightingEffectConfigType.Sound:
        {
            ExportScheme_Sound(scheme);
        }
        break;

        case LightingEffectConfigType.Speed:
        {
            ExportScheme_Speed(scheme);
        }
        break;

        case LightingEffectConfigType.Ward:
        {
            ExportScheme_Ward(scheme);
        }
        break;

        case LightingEffectConfigType.Invalid:
        default:
            break;
        }
    }
示例#3
0
    private static void WriteSchemeHead(LightingEffectConfigType cfgType)
    {
        if (streamWriter == null)
        {
            return;
        }

        StringBuilder nameBuilder = new StringBuilder();

        nameBuilder.Append("光效配置类型(1.Bind 2.Fly 3.AnimReplace 4.Area 5.Camera 6.Shadow 7.Sound 8.Speed 9.Ward)(int),");
        nameBuilder.Append("光效ID(int),");
        nameBuilder.Append("资源GUID(string),");
        nameBuilder.Append("光效描述(string),");
        nameBuilder.Append("是否全局光效(bool),");
        nameBuilder.Append("一个人物是否只能挂一个(bool),");
        nameBuilder.Append("是否覆盖旧参数(bool),");
        nameBuilder.Append("是否需要速度缩放(bool),");
        nameBuilder.Append("忽略单一光效优化(bool),");
        nameBuilder.Append("启用距离优化(bool),");
        nameBuilder.Append("施法者死亡关闭光效(bool),");
        nameBuilder.Append("光效类型(0.受击 1.普通)(int),");

        switch (cfgType)
        {
        case LightingEffectConfigType.Bind:
        {
            nameBuilder.Append("屏幕外仍创建(bool),");
            nameBuilder.Append("光效统一缩放比例(float),");
            nameBuilder.Append("光效开始播放时间(毫秒)(int),");
            nameBuilder.Append("光效存在时间(毫秒)(int),");
            nameBuilder.Append("光效消失时间(毫秒)(int),");
            nameBuilder.Append("光效位置绑定骨骼名字(string),");
            nameBuilder.Append("光效相对骨骼的偏移(vector3),");
            nameBuilder.Append("光效旋转绑定骨骼名字(string),");
            nameBuilder.Append("光效相对绑定骨骼的旋转(vector3),");
            nameBuilder.Append("光效面向镜头(bool),");
            nameBuilder.Append("光效向镜头偏移到物体外部(bool),");
            nameBuilder.Append("光效绑定类型(0.StayAlone 1.BindWithBone 2.StayInTargetPos)(int),");
            nameBuilder.Append("光效面向(bool),");
            nameBuilder.Append("光效贴地(bool),");
            nameBuilder.Append("光效根据移动方向旋转(bool),");
            nameBuilder.Append("光效不随人物旋转(bool),");
            nameBuilder.Append("将target绑定到source上(bool),");
            nameBuilder.Append("将target绑定到source上时target的骨骼名(string),");
            nameBuilder.Append("使用碰撞盒检测光效是否到达(bool),");
            nameBuilder.Append("音效ID(int)");
        }
        break;

        case LightingEffectConfigType.Fly:
        {
            nameBuilder.Append("光效统一缩放比例(float),");
            nameBuilder.Append("光效开始播放时间(毫秒)(int),");
            nameBuilder.Append("光效存在时间(毫秒)(int),");
            nameBuilder.Append("光效开始时原地滞留时间(毫秒)(int),");
            nameBuilder.Append("光效消失时间(毫秒)(int),");
            nameBuilder.Append("源点和目标点最大距离(float),");
            nameBuilder.Append("光效位置绑定骨骼名字(string),");
            nameBuilder.Append("光效旋转绑定骨骼名字(string),");
            nameBuilder.Append("光效相对骨骼的偏移(vector3),");
            nameBuilder.Append("光效开始时的偏移(vector3),");
            nameBuilder.Append("飞向光效目标对象骨骼(string),");
            nameBuilder.Append("目标点的偏移(vector3),");
            nameBuilder.Append("光效飞行类型(0.TargetObject 1.TargetPosition 2.TargetPositionToTargetObject)(int),");
            nameBuilder.Append("光效是否始终面向目标(bool),");
            nameBuilder.Append("光效相对地面最低高度(float),");
            nameBuilder.Append("光效相对地面最高高度(float),");
            nameBuilder.Append("光效飞行速度(float),");
            nameBuilder.Append("光效飞行时间(秒)(float),");
            nameBuilder.Append("光效到达目的地时是否消失(bool),");
            nameBuilder.Append("对手死亡时关闭光效(bool),");
            nameBuilder.Append("光效是否进行碰撞检测(bool),");
            nameBuilder.Append("光效产生碰撞时是否消失(bool),");
            nameBuilder.Append("反路径飞行(bool),");
            nameBuilder.Append("到达目的后返回(bool),");
            nameBuilder.Append("光效关闭时返回(bool),");
            nameBuilder.Append("光效返回时的飞行速度(float),");
            nameBuilder.Append("始终有srcObject指向targetObject(bool),");
            nameBuilder.Append("击中人时的后续光效(string),");
            nameBuilder.Append("击中怪物时的后续光效(string),");
            nameBuilder.Append("击中地面时的后续光效(string),");
            nameBuilder.Append("飞到最远处的后续光效(string),");
            nameBuilder.Append("使用碰撞盒检测光效是否到达(bool),");
            nameBuilder.Append("结束时后续动作(string),");
            nameBuilder.Append("是否做上抛运动(bool),");
            nameBuilder.Append("上抛运动的高度(float),");
            nameBuilder.Append("上抛最小偏转角(float),");
            nameBuilder.Append("上抛最大偏转角(float),");
            nameBuilder.Append("上抛运动最高点在路径上的百分比(float),");
            nameBuilder.Append("音效ID(int),");
            nameBuilder.Append("光效到达目标位置后延迟消失的时间(毫秒)(int),");
            nameBuilder.Append("光效延迟消失的时候隐藏美术指定部件时间(毫秒)(int),");
            nameBuilder.Append("光效延迟消失时吸附在目标上(bool),");
            nameBuilder.Append("光效是否会影响护盾(bool)");
        }
        break;

        case LightingEffectConfigType.AniReplace:
        {
            nameBuilder.Append("开始时刻(毫秒)(int),");
            nameBuilder.Append("结束时刻(毫秒)(int)");
        }
        break;

        case LightingEffectConfigType.Area:
        {
            nameBuilder.Append("光效开始播放时间(毫秒)(int),");
            nameBuilder.Append("诞生光效间隔时间(毫秒)(int),");
            nameBuilder.Append("诞生光效ID(int),");
            nameBuilder.Append("光效位置绑定骨骼名字(string),");
            nameBuilder.Append("光效指定相对落地点的位移(vector3),");
            nameBuilder.Append("光效范围是投影到地面的(bool),");
            nameBuilder.Append("光效距离一直延长到最大距离(bool),");
            nameBuilder.Append("光效数量(int),");
            nameBuilder.Append("光效最长生命时间(毫秒)(int),");
        }
        break;

        case LightingEffectConfigType.Camera:
        {
            nameBuilder.Append("动画镜头的原点取的对象(0.Hero 1.FollowHero 2.TargetPos 3.SourceObject)(int),");
            nameBuilder.Append("动画镜头的原点需要贴地(bool),");
            nameBuilder.Append("动画镜头强制取主摄像机(bool),");
            nameBuilder.Append("震屏光效需要附加到哪些人身上(0.Source 1.Target 2.SourceAndTarget 3.All)(int),");
            nameBuilder.Append("震屏光效影响范围(float),");
            nameBuilder.Append("光效存在时间(毫秒)(int),");
            nameBuilder.Append("光效延迟开始时间(毫秒)(int),");
            nameBuilder.Append("光效中断时摄像机恢复用的秒数(毫秒)(int),");
            nameBuilder.Append("结束时是否恢复一开始的摄像机(bool),");
        }
        break;

        case LightingEffectConfigType.Shadow:
        {
            nameBuilder.Append("开始时刻(毫秒)(int),");
            nameBuilder.Append("结束时刻(毫秒)(int),");
            nameBuilder.Append("每个残影开始的透明度(float),");
            nameBuilder.Append("每个残影存在的时间(毫秒)(int),");
            nameBuilder.Append("每个残影淡出的时间(毫秒)(int),");
            nameBuilder.Append("插入残影的时间间隔(毫秒)(int),");
            nameBuilder.Append("需要插入残影的关键帧(string),");
            nameBuilder.Append("替换为的材质的透明参数名字(string),");
            nameBuilder.Append("武器无残影(bool),");
            nameBuilder.Append("替换为的材质的透明参数类型(0.Color 1.Float 2.Int)(int),");
            nameBuilder.Append("残影与残影/人物间最短间隔距离(float),");
        }
        break;

        case LightingEffectConfigType.Sound:
        {
            nameBuilder.Append("光效声音ID(int),");
        }
        break;

        case LightingEffectConfigType.Speed:
        {
            nameBuilder.Append("开始时刻(毫秒)(int),");
            nameBuilder.Append("结束时刻(毫秒)(int),");
            nameBuilder.Append("全局时间速度(float),");
            nameBuilder.Append("个人动作速度(float),");
            nameBuilder.Append("效果有效范围(float),");
        }
        break;

        case LightingEffectConfigType.Ward:
        {
            nameBuilder.Append("开始时刻(毫秒)(int),");
            nameBuilder.Append("结束时刻(毫秒)(int),");
            nameBuilder.Append("无视阵营阻挡一切(bool),");
        }
        break;

        case LightingEffectConfigType.Invalid:
        default:
            break;
        }
        streamWriter.WriteLine(nameBuilder.ToString());

        FlushStreamWriter();
    }
    private LightingEffectBehavior CreateNewBehavior(int effectID, LightingEffectConfigType t)
    {
        if (!isValid)
        {
            return(null);
        }

        LightingEffectBehavior reslut = null;

        switch (t)
        {
        case LightingEffectConfigType.AniReplace:
            reslut = new LightingEffectBehavior_AnimationReplace();
            break;

        case LightingEffectConfigType.Area:
            reslut = new LightingEffectBehavior_Area();
            break;

        case LightingEffectConfigType.Bind:
            reslut = new LightingEffectBehavior_Bind();
            break;

        case LightingEffectConfigType.Camera:
            reslut = new LightingEffectBehavior_Camera();
            break;

        case LightingEffectConfigType.Fly:
            reslut = new LightingEffectBehavior_Fly();
            break;

        case LightingEffectConfigType.Invalid:
            break;

        //case LightingEffectConfigType.MatReplace:
        //    reslut = new LightingEffectBehavior_MaterialReplace();
        //    break;
        case LightingEffectConfigType.Shadow:
            reslut = new LightingEffectBehavior_Shadow();
            break;

        case LightingEffectConfigType.Sound:
            reslut = new LightingEffectBehavior_Sound();
            break;

        case LightingEffectConfigType.Speed:
            reslut = new LightingEffectBehavior_Speed();
            break;

        case LightingEffectConfigType.Ward:
            reslut = new LightingEffectBehavior_Ward();
            break;
        }
        if (null == reslut)
        {
            Debug.LogError("CreateNewBehavior faild,找不到配置类型:" + t);
        }
        else
        {
            LinkedList <LightingEffectBehavior> list = null;
            if (!m_allBehaviorTable.TryGetValue(effectID, out list))
            {
                list = new LinkedList <LightingEffectBehavior>();
                m_allBehaviorTable.Add(effectID, list);
            }
            list.AddLast(reslut);
        }
        return(reslut);
    }