Ejemplo n.º 1
0
    /// <summary>
    /// 预加载光效
    /// </summary>
    /// <param name="nMapID"></param>
    /// <param name="nType"></param>
    /// <param name="objs"></param>
    public static void LoadPreLights(int nMapID, ASpeedGame.Data.Scheme.LightType nType, System.Collections.Generic.IEnumerable <int> objs, CachePriority mask)
    {
        if (objs == null)
        {
            return;
        }

        List <Pre_Load_Light_Info> ls = new List <Pre_Load_Light_Info>();

        foreach (int id in objs)
        {
            // 加载必须要加载的光效
            ASpeedGame.Data.Scheme.ObjectLightNode light = ASpeedGame.Data.Scheme.SchemePreLoadLight.Instance.get(nMapID, nType, id);
            if (light == null)
            {
                continue;
            }

            Pre_Load_Light_Info info = new Pre_Load_Light_Info();
            info.nLightType   = nType;      //光效类型
            info.nMask       |= (int)mask;  //标志位
            info.effectIDList = light.Collection;

            ls.Add(info);
        }

        if (ls.Count > 0)
        {
            LightingEffectFactory.Instance.RecvPreLoadLinghtEffectInfo(ls);
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 预加载某一类光效
    /// </summary>
    /// <param name="nMapID"></param>
    /// <param name="nType"></param>
    public static void LoadTypePreLight(int nMapID, ASpeedGame.Data.Scheme.LightType nType, CachePriority mask)
    {
        // 加载必须要加载的光效
        ASpeedGame.Data.Scheme.TypeLightNode typeLight = ASpeedGame.Data.Scheme.SchemePreLoadLight.Instance.get(nMapID, nType);
        if (typeLight == null || typeLight.Collection == null || typeLight.Collection.Count == 0)
        {
            return;
        }

        List <Pre_Load_Light_Info> ls = new List <Pre_Load_Light_Info>();

        foreach (var item in typeLight.Collection)
        {
            ASpeedGame.Data.Scheme.ObjectLightNode node = item.Value;

            Pre_Load_Light_Info info = new Pre_Load_Light_Info();
            info.nLightType   = nType;      //光效类型
            info.nMask       |= (int)mask;  //标志位
            info.effectIDList = node.Collection;

            ls.Add(info);
        }

        LightingEffectFactory.Instance.RecvPreLoadLinghtEffectInfo(ls);
    }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加目标对象节点
        /// </summary>
        /// <param name="node"></param>
        public void Add(ObjectLightNode node)
        {
            if (m_objectList.ContainsKey(node.ObjID))
            {
                return;
            }

            m_objectList[node.ObjID] = node;
        }
Ejemplo n.º 4
0
    /// <summary>
    /// 卸载已加载好的预加载光效
    /// </summary>
    /// <param name="nMapID"></param>
    /// <param name="nType"></param>
    /// <param name="nObjID"></param>
    public static void UnloadPreLight(int nMapID, ASpeedGame.Data.Scheme.LightType nType, int nObjID)
    {
        ASpeedGame.Data.Scheme.ObjectLightNode light = ASpeedGame.Data.Scheme.SchemePreLoadLight.Instance.get(nMapID, nType, nObjID);
        if (light == null || light.Collection.Count == 0)
        {
            return;
        }

        LightingEffectFactory.Instance.ClearCache(light.Collection);
    }
Ejemplo n.º 5
0
        /// <summary>
        /// 增加某类型下的目标对象数据
        /// </summary>
        /// <param name="nType"></param>
        /// <param name="node"></param>
        public void Add(int nType, ref ObjectLightNode node)
        {
            if (dictTypeLightList.ContainsKey(nType))
            {
                dictTypeLightList[nType].Add(node);
            }
            else
            {
                TypeLightNode current = new TypeLightNode(nType);
                current.Add(node);

                dictTypeLightList.Add(nType, current);
            }
        }
Ejemplo n.º 6
0
    /// <summary>
    /// 预加载光效
    /// </summary>
    /// <param name="nMapID"></param>
    /// <param name="nType"></param>
    /// <param name="nObjID"></param>
    public static void LoadPreLight(int nMapID, ASpeedGame.Data.Scheme.LightType nType, int nObjID, CachePriority mask)
    {
        // 加载必须要加载的光效
        ASpeedGame.Data.Scheme.ObjectLightNode light = ASpeedGame.Data.Scheme.SchemePreLoadLight.Instance.get(nMapID, nType, nObjID);
        if (light == null)
        {
            return;
        }
        Pre_Load_Light_Info info = new Pre_Load_Light_Info();

        info.nLightType   = nType;              //光效类型
        info.nMask       |= (int)mask;          //标志位
        info.effectIDList = light.Collection;

        List <Pre_Load_Light_Info> ls = new List <Pre_Load_Light_Info>();

        ls.Add(info);

        LightingEffectFactory.Instance.RecvPreLoadLinghtEffectInfo(ls);
    }
Ejemplo n.º 7
0
        /// <summary>
        /// 加载配置文件
        /// </summary>
        /// <param name="stPath"></param>
        public void Load(string strFilePath)
        {
            ScpReader reader = new ScpReader(strFilePath, true, 2);

            if (reader == null)
            {
                Trace.LogError("read sheme fail! file=" + strFilePath);
                return;
            }
            m_dictMapLightList.Clear();

            char [] splitChars = new char[] { ';' };

            int nRecordCount = reader.GetRecordCount();

            for (int row = 0; row < nRecordCount; row++)
            {
                // 是否启用(1启用)
                int nOpen = reader.GetInt(row, (int)Column.COL_OPEN, 0);
                if (nOpen == 0)
                {
                    continue;
                }
                // 光效类型LightType
                int nType = reader.GetInt(row, (int)Column.COL_TYPE, 0);
                if (nType < (int)LightType.Unknown || nType >= (int)LightType.Max)
                {
                    continue;
                }
                // 地图ID
                int nMapID = reader.GetInt(row, (int)Column.COL_MAP, 0);


                // 对象ID
                string strObjIDList = reader.GetString(row, (int)Column.COL_OBJECT_ID, "").TrimEnd(splitChars).TrimStart(splitChars);
                if (string.IsNullOrEmpty(strObjIDList))
                {
                    continue;
                }

                try
                {
                    var objIDs = new List <int>(Array.ConvertAll(strObjIDList.Split(';'), int.Parse));
                    foreach (int nObjID in objIDs)
                    {
                        ObjectLightNode node = new ObjectLightNode(nObjID);

                        // 光效ID列共多列
                        for (Column i = Column.COL_LIGHT_ID1; i < Column.COL_OPEN; ++i)
                        {
                            string strLightIDList = reader.GetString(row, (int)i, "").TrimEnd(splitChars).TrimStart(splitChars);
                            if (string.IsNullOrEmpty(strLightIDList))
                            {
                                continue;
                            }

                            var lights = new List <int>(Array.ConvertAll(strLightIDList.Split(';'), int.Parse));
                            node.Add(lights);
                        }
                        // 标识
                        node.Flag = reader.GetInt(row, (int)Column.COL_FLAG, 0);

                        if (!m_dictMapLightList.ContainsKey(nMapID))
                        {
                            MapLightNode map = new MapLightNode();
                            map.nMapID = nMapID;

                            m_dictMapLightList.Add(nMapID, map);
                        }

                        m_dictMapLightList[nMapID].Add(nType, ref node);
                    }
                }
                catch (Exception ex)
                {
                    UnityEngine.Debug.LogError("Row=" + (row + 1).ToString() + ", error=" + ex.ToString());
                }
            }
        }