Exemplo n.º 1
0
        /// <summary>
        /// Returns true iff the specified child can be inserted</summary>
        /// <param name="child">Child to be inserted</param>
        /// <returns>True iff the specified child can be inserted as a child of this object</returns>
        /// <remarks>Unlike most other IHierarchical implementations, the specified objects
        /// are NOT inserted as children of this object but rather as children
        /// of the GameObjectFolder child (thus becoming grand children of Game)</remarks>
        public bool CanAddChild(object child)
        {
            if (child.Is <GameReference>())
            {
                return(true);
            }
            var gameObjFolder = RootGameObjectFolder.AsAll <IHierarchical>();

            foreach (var folder in gameObjFolder)
            {
                if (folder.CanAddChild(child))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Inserts the specified child</summary>
        /// <param name="child">Child to be inserted</param>
        /// <remarks>Unlike most other IHierarchical implementations, the specified objects
        /// are NOT inserted as children of this object but rather as children
        /// of the GameObjectFolder child (thus becoming grand children of Game).</remarks>
        public bool AddChild(object child)
        {
            GameReference gameref = child.As <GameReference>();

            if (gameref != null)
            {
                IList <GameReference> grefList = GetChildList <GameReference>(Schema.gameType.gameReferenceChild);
                grefList.Add(gameref);
                return(true);
            }

            var gameObjFolder = RootGameObjectFolder.AsAll <IHierarchical>();

            foreach (var folder in gameObjFolder)
            {
                if (folder.AddChild(child))
                {
                    return(true);
                }
            }

            return(false);
        }