Beispiel #1
0
 private void GeneratePotentialProps(Vector3 direction)
 {
     for (int i = 0; i < _potentialItems.Count; i++)
     {
         UiItem prop = GenerateInPresentScene("Props" + _potentialItems[i].Index.ToString(), _potentialItems[i].PositionInScreen + direction, true);
     }
 }
Beispiel #2
0
 public override void MoveOut(UiItem focus = null)
 {
     _col.enabled = false;
     if (focus == this)
     {
         Transfer(_moveOutTo, true);
     }
 }
Beispiel #3
0
        // (What is "kindName" supposed to be?)
        // (Explain what this function is doing?)
        public UiItem GenerateItem(string sceneName, string objectPath, Vector3 position, string kindName,
                                   bool initialize)
        {
            if (!_sceneDict.ContainsKey(sceneName))
            {
                return(null);
            }
            GameObject newObject = Resources.Load <GameObject>(objectPath);

            if (newObject == null)
            {
                return(null);
            }

            // (Explain this chunk of code)
            Scene     theScene = _sceneDict[sceneName];
            BatchNode parentNode;

            if (theScene.DetectSceneBatch(kindName))
            {
                parentNode = theScene.GetSceneBatch(kindName);
            }
            else
            {
                parentNode = theScene.GetSceneBatch("Others");
            }

            newObject = Instantiate(newObject, parentNode.transform);
            newObject.transform.position = position;

            // Call parentNode.UpdatePosition here, if its leaves are likely to move from original position
            parentNode.AddLeaf(newObject.transform);

            UiItem returnValue = newObject.GetComponent <UiItem>();

            if (returnValue == null)
            {
                returnValue = newObject.AddComponent <UiItem>();
            }

            // (If what is initialized?)
            if (initialize)
            {
                returnValue.Initialize();
            }

            return(newObject.GetComponent <UiItem>());
        }
Beispiel #4
0
        private void MoveOutGroup(Transform parent, UiItem focus)
        {
            int numChildren = parent.childCount;

            for (int i = 0; i < numChildren; i++)
            {
                UiItem item = parent.GetChild(i).gameObject.GetComponent <UiItem>();
                if (item != null)
                {
                    item.MoveOut(focus);
                }
                else
                {
                    Debug.LogError("UiManager try to MoveOutkGroup a parent that has non-UiItem child");
                }
            }
        }
Beispiel #5
0
        // This function generates (instantiates) an object
        public UiItem GenerateItem(string sceneName, string objectPath, Vector3 position, string kindName,
                                   bool initialize)
        {
            if (!_sceneDict.ContainsKey(sceneName))
            {
                return(null);
            }
            GameObject newObject = Resources.Load <GameObject>(objectPath);

            if (newObject == null)
            {
                return(null);
            }
            Scene     theScene = _sceneDict[sceneName];
            BatchNode parentNode;

            if (theScene.DetectSceneBatch(kindName))
            {
                parentNode = theScene.GetSceneBatch(kindName);
            }
            else
            {
                parentNode = theScene.GetSceneBatch("Others");
            }

            newObject = Instantiate(newObject, parentNode.transform);
            newObject.transform.position = position;
            parentNode.AddLeaf(newObject.transform);

            UiItem returnValue = newObject.GetComponent <UiItem>();

            if (returnValue == null)
            {
                returnValue = newObject.AddComponent <UiItem>();
            }

            if (initialize)
            {
                returnValue.Initialize();
            }

            return(newObject.GetComponent <UiItem>());
        }
Beispiel #6
0
        private void MoveBackGroup(Transform parent, Transform switchToParent = null)
        {
            int numChildren = parent.childCount;

            for (int i = 0; i < numChildren; i++)
            {
                UiItem item = parent.GetChild(i).gameObject.GetComponent <UiItem>();
                if (item != null)
                {
                    item.MoveBack();
                    if (switchToParent != null)
                    {
                        item.transform.parent = switchToParent;
                    }
                }
                else
                {
                    Debug.LogError("UiManager try to MoveBackGroup a parent that has non-UiItem child");
                }
            }
        }
Beispiel #7
0
 public override void MoveOut(UiItem focus = null)
 {
     Transfer(_potentialPosition, true, true);
 }
Beispiel #8
0
 /// <summary>
 /// Not being used anymore? Because it is virtual it needs to be overridden by child classes.
 /// </summary>
 /// <param name="focus"></param>
 public virtual void MoveOut(UiItem focus = null)
 {
 }