Ejemplo n.º 1
0
        // ----------------------------------------------------------------
        //  Initialize
        // ----------------------------------------------------------------
        public void Initialize(ClustSelController clustSelController, Transform tf_parent, int worldIndex, Vector2 myPos)
        {
            this.clustSelController = clustSelController;
            this.WorldIndex         = worldIndex;

            // Parent jazz!
            GameUtils.ParentAndReset(this.gameObject, tf_parent);
            this.gameObject.name             = "World " + worldIndex;
            myRectTransform.anchoredPosition = myPos;

            // Look right!
            t_worldName.text = "World " + worldIndex;

            MakeClustRows();
            UpdateYouAreHereIconPos();

            // Start with last-played cluster selected.
            {
                int      clustIndex = GameManagers.Instance.DataManager.LastPlayedClustIndex(worldIndex);
                ClustRow clustRow   = GetClustRow(clustIndex);
                if (clustRow != null)
                {
                    UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject(clustRow.gameObject);
                }
            }
        }
Ejemplo n.º 2
0
        // ----------------------------------------------------------------
        //  Initialize
        // ----------------------------------------------------------------
        public void Initialize(ClustSelController clustSelController, WorldView myWorldView, RoomClusterData myClustData, Vector2 pos)
        {
            this.clustSelController = clustSelController;
            this.myClustData        = myClustData;
            worldHue = ((150 + myClustData.WorldIndex * 40) / 360f) % 1;

            // Parent jazz!
            GameUtils.ParentAndReset(this.gameObject, myWorldView.transform);
            transform.SetAsFirstSibling(); // put behind other stuff.
            this.gameObject.name             = "ClustRow " + myClustData.ClustIndex;
            myRectTransform.anchoredPosition = pos;

            t_clustName.text = (myClustData.ClustIndex + 1).ToString();

            // Add i_snacks!
            {
                int numEaten = myClustData.SnackCount.Eaten_All;
                int numTotal = myClustData.SnackCount.Total_All;
                i_snacks = new Image[numTotal];
                GameObject prefabGO        = ResourcesHandler.Instance.ClustSelListClustRowSnack;
                float      spacingX        = 26;
                float      snackIconsWidth = i_snacks.Length * spacingX;
                for (int i = 0; i < i_snacks.Length; i++)
                {
                    float posX = -2 - snackIconsWidth + (i * 26);
                    Image img  = Instantiate(prefabGO).GetComponent <Image>();
                    img.name = "Snack " + i;
                    GameUtils.ParentAndReset(img.gameObject, this.transform);
                    img.rectTransform.anchoredPosition = new Vector2(posX, 0);
                    // Not eaten? Darker img!
                    if (i >= numEaten)
                    {
                        img.color = new Color(0, 0, 0, 0.8f);
                    }
                    i_snacks[i] = img;
                }
            }

            RefreshVisuals();
        }