Пример #1
0
        private void Start()
        {
            // Create the root reel object.
            root      = new GameObject();
            root.name = "Root";
            gameObject.AddChild(root);

            // Get the reel settings and align all the symbol container game objects.
            settings = GetComponent <ReelSettings>();
            GetComponent <ReelLayout>().Layout(root, out symbolContainers);

            // Attach the symbol as a child objects of the symbol containers.
            for (int i = 0; i < settings.TotalSymbols; ++i)
            {
                var symbolObject = PoolManager.Obtain(symbolFactory.CreateSymbol("AA"));
                symbolContainers[i].AddChild(symbolObject);
                symbolObjects.Add(symbolObject);
            }
        }
Пример #2
0
        public void Layout(GameObject root, out List <GameObject> symbolContainers)
        {
            symbolContainers = new List <GameObject>();
            ReelSettings settings        = GetComponent <ReelSettings>();
            Vector3      initialPosition = root.transform.position;

            // Create the symbol containers.
            for (int i = 0; i < settings.TotalSymbols; ++i)
            {
                var symbolContainer = new GameObject();
                symbolContainer.name                    = "SymbolContainer";
                symbolContainer.transform.parent        = root.transform;
                symbolContainer.transform.localPosition = Vector3.zero;
                symbolContainers.Add(symbolContainer);
            }

            // Align the symbol containers.
            float reelHeight = (settings.TotalSymbols - 1) * settings.SymbolSpacing;

            AnimationCurveExtensions.AlignVerticalCenter(
                symbolContainers,
                initialPosition.y + reelHeight / 2,
                initialPosition.y - reelHeight / 2);
        }