コード例 #1
0
ファイル: SpriteManager.cs プロジェクト: xdegtyarev/ld23
	/// <summary>
	/// Returns whether the sprite is already managed by this
	/// manager.
	/// </summary>
	/// <param name="sprite">Sprite for which to look.</param>
	/// <returns>True when the sprite is already being managed by this manager.</returns>
	public bool AlreadyAdded(SpriteRoot sprite)
	{
		if(activeBlocks.Rewind())
		{
			do
			{
				if (activeBlocks.Current.sprite == sprite)
					return true;
			} while (activeBlocks.MoveNext());
		}

		return false;
	}
コード例 #2
0
    public void RemoveChild(GameObject go)
    {
        IUIObject obj = (IUIObject)go.GetComponent("IUIObject");

        if (obj != null)
        {
            if (uiObjs.Rewind())
            {
                do
                {
                    if (uiObjs.Current.val == obj)
                    {
                        uiObjs.Remove(uiObjs.Current);
                        break;
                    }
                } while (uiObjs.MoveNext());
            }

            if (obj.Container == (IUIContainer)this)
            {
                obj.Container = null;
            }
        }
        else
        {
            UIPanelBase panel = (UIPanelBase)go.GetComponent(typeof(UIPanelBase));
            if (panel != null)
            {
                if (childPanels.Rewind())
                {
                    do
                    {
                        if (childPanels.Current.val == panel)
                        {
                            childPanels.Remove(childPanels.Current);
                            break;
                        }
                    } while (childPanels.MoveNext());
                }

                if (panel.Container == (IUIContainer)this)
                {
                    panel.Container = null;
                }
            }
        }

        RemoveSubject(go);
    }
コード例 #3
0
    // Sets up the subjects of our transitions:
    protected virtual void SetupTransitionSubjects()
    {
        GameObject go;
        int        hash;

        // Only register the callback for the BringIn/Dismiss transitions:
        for (int i = 0; i < 4; ++i)
        {
            Transitions.list[i].AddTransitionEndDelegate(TransitionCompleted);
        }

        if (uiObjs.Rewind())
        {
            do
            {
                go   = ((Component)uiObjs.Current.val).gameObject;
                hash = go.GetHashCode();

                for (int i = 0; i < Transitions.list.Length; ++i)
                {
                    Transitions.list[i].AddSubSubject(go);
                }

                if (!subjects.ContainsKey(hash))
                {
                    subjects.Add(hash, go);
                }
            } while (uiObjs.MoveNext());
        }

        // Now find any sprites, since that's a common object type
        // we'll want to transition:
        Component[] sprites = transform.GetComponentsInChildren(typeof(SpriteRoot), true);

        for (int i = 0; i < sprites.Length; ++i)
        {
            // Don't add ourselves as we are the main subject:
            if (sprites[i].gameObject == gameObject)
            {
                continue;
            }

            go   = sprites[i].gameObject;
            hash = go.GetHashCode();

            // Only add new objects:
            if (subjects.ContainsKey(hash))
            {
                continue;
            }

            for (int j = 0; j < Transitions.list.Length; ++j)
            {
                Transitions.list[j].AddSubSubject(go);
            }

            subjects.Add(hash, go);
        }

        // Now find any SpriteText, since that's another common object type
        // we'll want to transition:
        Component[] texts = transform.GetComponentsInChildren(typeof(SpriteText), true);

        for (int i = 0; i < texts.Length; ++i)
        {
            // Don't add ourselves as we are the main subject:
            if (texts[i].gameObject == gameObject)
            {
                continue;
            }

            go   = texts[i].gameObject;
            hash = go.GetHashCode();

            // Only add new objects:
            if (subjects.ContainsKey(hash))
            {
                continue;
            }

            for (int j = 0; j < Transitions.list.Length; ++j)
            {
                Transitions.list[j].AddSubSubject(go);
            }

            subjects.Add(hash, go);
        }

        // Now find any other renderables:
        Component[] renderers = transform.GetComponentsInChildren(typeof(Renderer), true);

        for (int i = 0; i < renderers.Length; ++i)
        {
            // Don't add ourselves as we are the main subject:
            if (renderers[i].gameObject == gameObject)
            {
                continue;
            }

            go   = renderers[i].gameObject;
            hash = go.GetHashCode();

            // Only add new objects:
            if (subjects.ContainsKey(hash))
            {
                continue;
            }

            for (int j = 0; j < Transitions.list.Length; ++j)
            {
                Transitions.list[j].AddSubSubject(go);
            }

            subjects.Add(hash, go);
        }


        // Add our children IUIObjects to the list, and then
        // see if we have any additional GameObjects to add:

/*
 *              Dictionary<int, GameObject> objs = new Dictionary<int, GameObject>();
 *              if (uiObjs.Rewind())
 *              {
 *                      do
 *                      {
 *                              go = ((Component)uiObjs.Current.val).gameObject;
 *                              objs.Add(go.GetHashCode(), go);
 *                      } while (uiObjs.MoveNext());
 *              }
 *
 *              // Add first-tier children if they aren't the same
 *              // as our IUIObjects:
 *              foreach (Transform child in transform)
 *              {
 *                      go = child.gameObject;
 *                      int hash = go.GetHashCode();
 *                      if (objs.ContainsKey(hash))
 *                              continue;
 *                      objs.Add(hash, go);
 *              }
 *
 *              // Now add all of these as subjects:
 *              for(int i=0; i<applyToChildren.Length; ++i)
 *              {
 *                      if (!applyToChildren[i])
 *                              continue;
 *
 *                      Dictionary<int, GameObject>.ValueCollection coll = objs.Values;
 *
 *                      foreach(GameObject g in coll)
 *                      {
 *                              Transitions.list[i].AddSubSubject(g);
 *                      }
 *              }
 */
    }