少年修仙传客户端代码仓库
client_linchunjie
2018-08-21 a1e7374b1d3e6af8b8cf6bf6f59e3f9b101eb8be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
 
[CreateAssetMenu(menuName = "Config/WindowConfig")]
public class WindowConfig : ScriptableObject
{
 
    public WindowTable[] windows;
 
    static WindowConfig config;
    public static WindowConfig Get()
    {
        if (config == null)
        {
            config = Resources.Load<WindowConfig>("ScriptableObject/Config/WindowConfig");
        }
 
        return config;
    }
 
 
    public bool FindChildWindow(string _parent, int _order, out string _child)
    {
        for (int i = 0; i < windows.Length; i++)
        {
            var table = windows[i];
            if (table.parent == _parent)
            {
                for (int j = 0; j < table.orderTables.Length; j++)
                {
                    if (table.orderTables[j].order == _order)
                    {
                        _child = table.orderTables[j].window;
                        return true;
                    }
                }
            }
        }
 
        _child = string.Empty;
        return false;
    }
 
    public bool FindParentWindow(string _child, out string _parent)
    {
        for (int i = 0; i < windows.Length; i++)
        {
            var table = windows[i];
            for (int j = 0; j < table.orderTables.Length; j++)
            {
                var orderTable = table.orderTables[j];
                if (orderTable.window == _child)
                {
                    _parent = table.parent;
                    return true;
                }
            }
        }
 
        _parent = string.Empty;
        return false;
    }
 
    [Serializable]
    public struct WindowTable
    {
        public string parent;
        public OrderTable[] orderTables;
    }
 
    [Serializable]
    public struct OrderTable
    {
        public int order;
        public string window;
    }
 
}