}         //调起买票窗体

        private void InitListView()
        {
            if (type == 1)
            {
                int count = int.Parse(ExtraMsg.Split('\r')[0].Split('\n')[1]);
                //无需换乘,多种路线
                int id = 1;
                for (int i = 0; i < count; i++)
                {
                    string cache = ExtraMsg.Split('\r')[i + 3];
                    Info   info  = new Info();
                    info.Number = id;
                    info.Detail = ExtraMsg.Split('\r')[1].Split('\n')[1] + " -> " +
                                  cache.Split('\n')[0] + " -> " + ExtraMsg.Split('\r')[1].Split('\n')[3];
                    info._detail = ExtraMsg.Split('\r')[1].Split('\n')[0] + "\n"
                                   + ExtraMsg.Split('\r')[2].Split('\n')[i] + "\n"
                                   + ExtraMsg.Split('\r')[1].Split('\n')[2];
                    //station A id, line X id, station B id
                    info.ChangeTimes = 0;
                    info.TotalOrder  = int.Parse(cache.Split('\n')[1]);
                    info._totalTime  = DateTime.Parse(cache.Split('\n')[2]);
                    info.TotalTime   = (info._totalTime.Minute + info._totalTime.Hour * 60).ToString() + "min";
                    info.TotalPrice  = double.Parse(cache.Split('\n')[3]);
                    info.Note        = "";
                    id = id + 1;
                    allinfo.Add(info);
                }
            }
            else if (type == 2)
            {
                //一次换乘,多种路线
                int count = int.Parse(ExtraMsg.Split('\r')[0].Split('\n')[1]);
                int id    = 1;
                for (int i = 0; i < count; i++)
                {
                    string cache = ExtraMsg.Split('\r')[i + 2];
                    Info   info  = new Info();
                    info.Number = id;
                    info.Detail = ExtraMsg.Split('\r')[1].Split('\n')[1] + " -> " +
                                  cache.Split('\n')[1] + " -> " + cache.Split('\n')[3] + " -> " +
                                  cache.Split('\n')[5] + " -> " + ExtraMsg.Split('\r')[1].Split('\n')[3];
                    info._detail = ExtraMsg.Split('\r')[1].Split('\n')[0] + "\n" +
                                   cache.Split('\n')[0] + "\n" + cache.Split('\n')[2] + "\n" +
                                   cache.Split('\n')[4] + "\n" + ExtraMsg.Split('\r')[1].Split('\n')[2];
                    //station A id, line X id, station B id, line Y id, station C id
                    info.ChangeTimes = 1;
                    info.TotalOrder  = int.Parse(cache.Split('\n')[6]);
                    info._totalTime  = DateTime.Parse(cache.Split('\n')[7]);
                    info.TotalTime   = (info._totalTime.Minute + info._totalTime.Hour * 60).ToString() + "min";
                    info.TotalPrice  = double.Parse(cache.Split('\n')[8]);
                    info.Note        = "";
                    id = id + 1;
                    allinfo.Add(info);
                }
            }
            else if (type == 3)
            {
                //一次换乘,两次换乘

                string[] sep = ExtraMsg.Split('\\');

                ExtraMsg = sep[0];
                int count = int.Parse(ExtraMsg.Split('\r')[0].Split('\n')[1]);
                int id    = 1;
                for (int i = 0; i < count; i++)
                {
                    string cache = ExtraMsg.Split('\r')[i + 2];
                    Info   info  = new Info();
                    info.Number = id;
                    info.Detail = ExtraMsg.Split('\r')[1].Split('\n')[1] + " -> " +
                                  cache.Split('\n')[1] + " -> " + cache.Split('\n')[3] + " -> " +
                                  cache.Split('\n')[5] + " -> " + ExtraMsg.Split('\r')[1].Split('\n')[3];
                    info._detail = ExtraMsg.Split('\r')[1].Split('\n')[0] + "\n" +
                                   cache.Split('\n')[0] + "\n" + cache.Split('\n')[2] + "\n" +
                                   cache.Split('\n')[4] + "\n" + ExtraMsg.Split('\r')[1].Split('\n')[2];
                    //station A id, line X id, station B id, line Y id, station C id
                    info.ChangeTimes = 1;
                    info.TotalOrder  = int.Parse(cache.Split('\n')[6]);
                    info._totalTime  = DateTime.Parse(cache.Split('\n')[7]);
                    info.TotalTime   = (info._totalTime.Minute + info._totalTime.Hour * 60).ToString() + "min";
                    info.TotalPrice  = double.Parse(cache.Split('\n')[8]);
                    info.Note        = "";
                    id = id + 1;
                    allinfo.Add(info);
                }

                ExtraMsg = sep[1];
                count    = int.Parse(ExtraMsg.Split('\r')[0].Split('\n')[1]);
                for (int i = 0; i < count; i++)
                {
                    string cache = ExtraMsg.Split('\r')[i + 2];
                    Info   info  = new Info();
                    info.Number = id;
                    info.Detail = ExtraMsg.Split('\r')[1].Split('\n')[1] + " -> " +
                                  cache.Split('\n')[1] + " -> " + cache.Split('\n')[3] + " -> " +
                                  cache.Split('\n')[5] + " -> " + cache.Split('\n')[7] + " -> " +
                                  cache.Split('\n')[9] + " -> " + ExtraMsg.Split('\r')[1].Split('\n')[3];
                    info._detail = ExtraMsg.Split('\r')[1].Split('\n')[0] + "\n" +
                                   cache.Split('\n')[0] + "\n" + cache.Split('\n')[2] + "\n" +
                                   cache.Split('\n')[4] + "\n" + cache.Split('\n')[6] + "\n" +
                                   cache.Split('\n')[8] + "\n" + ExtraMsg.Split('\r')[1].Split('\n')[2];
                    //station A id, line X id, station B id, line Y id, station C id, line Z id, station D id
                    info.ChangeTimes = 2;
                    info.TotalOrder  = int.Parse(cache.Split('\n')[10]);
                    info._totalTime  = DateTime.Parse(cache.Split('\n')[11]);
                    info.TotalTime   = (info._totalTime.Minute + info._totalTime.Hour * 60).ToString() + "min";
                    info.TotalPrice  = double.Parse(cache.Split('\n')[12]);
                    info.Note        = "";
                    id = id + 1;
                    allinfo.Add(info);
                }
            }
            else if (type == 4)
            {
                //两次换乘
                int count = int.Parse(ExtraMsg.Split('\r')[0].Split('\n')[1]);
                int id    = 1;
                for (int i = 0; i < count; i++)
                {
                    string cache = ExtraMsg.Split('\r')[i + 2];
                    Info   info  = new Info();
                    info.Number = id;
                    info.Detail = ExtraMsg.Split('\r')[1].Split('\n')[1] + " -> " +
                                  cache.Split('\n')[1] + " -> " + cache.Split('\n')[3] + " -> " +
                                  cache.Split('\n')[5] + " -> " + cache.Split('\n')[7] + " -> " +
                                  cache.Split('\n')[9] + " -> " + ExtraMsg.Split('\r')[1].Split('\n')[3];
                    info._detail = ExtraMsg.Split('\r')[1].Split('\n')[0] + "\n" +
                                   cache.Split('\n')[0] + "\n" + cache.Split('\n')[2] + "\n" +
                                   cache.Split('\n')[4] + "\n" + cache.Split('\n')[6] + "\n" +
                                   cache.Split('\n')[8] + "\n" + ExtraMsg.Split('\r')[1].Split('\n')[2];
                    //station A id, line X id, station B id, line Y id, station C id, line Z id, station D id
                    info.ChangeTimes = 2;
                    info.TotalOrder  = int.Parse(cache.Split('\n')[10]);
                    info._totalTime  = DateTime.Parse(cache.Split('\n')[11]);
                    info.TotalTime   = (info._totalTime.Minute + info._totalTime.Hour * 60).ToString() + "min";
                    info.TotalPrice  = double.Parse(cache.Split('\n')[12]);
                    info.Note        = "";
                    id = id + 1;
                    allinfo.Add(info);
                }
            }
            if (allinfo.Count == 0)
            {
                MessageBox.Show("查询失败,可能是路线过于复杂");
            }

            int    minchangtimes = allinfo[0].ChangeTimes;
            double minpay        = allinfo[0].TotalPrice;
            double mintime       = allinfo[0]._totalTime.Ticks;
            int    minorder      = allinfo[0].TotalOrder;

            for (int i = 0; i < allinfo.Count; i++)
            {
                if (allinfo[i].ChangeTimes < minchangtimes)
                {
                    minchangtimes = allinfo[i].ChangeTimes;
                }
                if (allinfo[i].TotalPrice < minpay)
                {
                    minpay = allinfo[i].TotalPrice;
                }
                if (allinfo[i]._totalTime.Ticks < mintime)
                {
                    mintime = allinfo[i]._totalTime.Ticks;
                }
                if (allinfo[i].TotalOrder < minorder)
                {
                    minorder = allinfo[i].TotalOrder;
                }
            }
            for (int i = 0; i < allinfo.Count; i++)
            {
                if (allinfo[i].ChangeTimes == minchangtimes)
                {
                    Info info = allinfo[i];
                    info.Note  = info.Note + " 换乘次数最少 ";
                    allinfo[i] = info;
                }
                if (allinfo[i].TotalPrice == minpay)
                {
                    Info info = allinfo[i];
                    info.Note  = allinfo[i].Note + " 车票总价最少 ";
                    allinfo[i] = info;
                }
                if (allinfo[i]._totalTime.Ticks == mintime)
                {
                    Info info = allinfo[i];
                    info.Note  = allinfo[i].Note + " 乘坐耗时最少 ";
                    allinfo[i] = info;
                }
                if (allinfo[i].TotalOrder == minorder)
                {
                    Info info = allinfo[i];
                    info.Note  = allinfo[i].Note + " 经过站数最少 ";
                    allinfo[i] = info;
                }
            }
        }
示例#2
0
    public static void Calualation()
    {
        GameObject[]   gameObjects   = GameObject.FindObjectsOfType <GameObject> ();
        List <string>  materialnames = new List <string> ();
        List <string>  pngnames      = new List <string> ();
        List <AllInfo> calualation   = new List <AllInfo> ();

        for (int i = 0; i < gameObjects.Length; i++)
        {
            Renderer render = gameObjects[i].GetComponent <Renderer>();
            if (null != render)
            {
                Material   material  = render.sharedMaterial;
                Material[] materials = render.sharedMaterials;
                int        count     = materials.Length;
                for (int j = 0; j < count; j++)
                {
                    if (null != materials[j])
                    {
                        if (materialnames.Contains(materials[j].name))
                        {
                            ;
                        }
                        continue;
                    }
                    materialnames.Add(materials[j].name);
                    AllInfo allinfo = new AllInfo();
                    allinfo.Add(materials[j].name);
                    Shader shader = materials[j].shader;
                    if (null != shader)
                    {
                        int propertyNum = ShaderUtil.GetPropertyCount(shader);
                        for (int k = 0; k < propertyNum; k++)
                        {
                            if (ShaderUtil.GetPropertyType(shader, k) == ShaderUtil.ShaderPropertyType.TexEnv)
                            {
                                string  textureName = ShaderUtil.GetPropertyName(shader, k);
                                Texture texture     = materials[j].GetTexture(textureName);
                                if (null != texture)
                                {
                                    float  texturesize     = Profiler.GetRuntimeMemorySize(texture) / 2048.0f;
                                    string textureRealName = texture.name;
                                    if (!pngnames.Contains(textureRealName))
                                    {
                                        pngnames.Add(textureRealName);
                                        allinfo.Add(textureRealName, texturesize);
                                    }
                                }
                            }
                        }
                    }
                    allinfo.sort();
                    calualation.Add(allinfo);
                }
            }
        }
        AddByDescending(calualation);
        print(calualation);
        PrintToFile(calualation);
        UnityEngine.Debug.LogWarning("Material Number:" + materialnames.Count);
        UnityEngine.Debug.LogWarning("Textures Name:" + pngnames.Count);
        PrintResultes(materialnames, pngnames);
    }