Пример #1
0
    void Awake()
    {
        if (m_Instance)
        {
            Debug.LogError("There id two " + gameObject.name + " in the scene");
            Debug.Break();
        }
        m_Instance = this;
        PoolBall[] balls = GameObject.FindObjectsOfType <PoolBall>();
        if (balls != null)
        {
            m_Balls = new Dictionary <int, PoolBall>();
            for (int i = 0, length = balls.Length; i < length; i++)
            {
                m_Balls.Add(balls[i].GetBallID(), balls[i]);
            }
        }
        else
        {
            Debug.LogError("the balls number is not explicit in the scene, please debug the code");
        }
        m_CustomBalls = new Dictionary <int, PoolBall>();
        PoolCue[] cues = GameObject.FindObjectsOfType <PoolCue>();
        if (cues == null || cues.Length != 1)
        {
            Debug.LogError("the number of the cue is not explicit in the scene, please debug the code");
        }
        else
        {
            m_Cue = cues[0];
        }

        m_SceneCamera = Camera.main;

        m_BallStorageRack = FindObjectOfType <BallStorageRack>();

        m_BallIcons = new Sprite[15];
        for (int i = 1; i <= 15; i++)
        {
            m_BallIcons[i - 1] = Resources.Load <Sprite>("BallsIcon/" + i);
        }

        m_PocketTriggers.AddRange(FindObjectsOfType <PocketTrigger>());
        m_PocketTriggers.Sort((PocketTrigger left, PocketTrigger right) =>
        {
            if (left.PocketIndex < right.PocketIndex)
            {
                return(-1);
            }
            else if (left.PocketIndex > right.PocketIndex)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        });
    }
Пример #2
0
    void Awake()
    {
        if (m_Instance)
        {
            Debug.LogError("There id two " + gameObject.name + " in the scene");
            Debug.Break();
        }
        m_Instance = this;
        PoolBall[] balls = GameObject.FindObjectsOfType<PoolBall>();
        if (balls != null)
        {
            m_Balls = new Dictionary<int, PoolBall>();
            for (int i = 0, length = balls.Length; i < length; i++)
            {
                m_Balls.Add(balls[i].GetBallID(), balls[i]);
            }
        }
        else
        {
            Debug.LogError("the balls number is not explicit in the scene, please debug the code");
        }
        m_CustomBalls = new Dictionary<int, PoolBall>();
        PoolCue[] cues = GameObject.FindObjectsOfType<PoolCue>();
        if (cues == null || cues.Length != 1)
        {
            Debug.LogError("the number of the cue is not explicit in the scene, please debug the code");
        }
        else
        {
            m_Cue = cues[0];
        }

        m_SceneCamera = Camera.main;

        m_BallStorageRack = FindObjectOfType<BallStorageRack>();

        m_BallIcons = new Sprite[15];
        for (int i = 1; i <= 15; i++)
        {
            m_BallIcons[i - 1] = Resources.Load<Sprite>("BallsIcon/" + i);
        }

        m_PocketTriggers.AddRange(FindObjectsOfType<PocketTrigger>());
        m_PocketTriggers.Sort((PocketTrigger left, PocketTrigger right) =>
            {
                if (left.PocketIndex < right.PocketIndex)
                    return -1;
                else if (left.PocketIndex > right.PocketIndex)
                    return 1;
                else
                    return 0;
            });
    }