public bool gotoParent(bool registerStack = false)
 {
     if (m_counter == NativeManagement.getContextCounter())
     {
         IntPtr nNode = node_getParent(m_nodeCpp);
         if (nNode != IntPtr.Zero)
         {
             // Push on navigation stack if needed.
             if (registerStack)
             {
                 m_navigation.Add(m_nodeCpp);
             }
             m_nodeCpp = nNode;
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         throw new CKLBExceptionTooOld();
     }
 }
 /// <summary>
 /// Try to find a Node designated by name in the subnode of the actual one.
 /// If the Node is found, the NodeIterator is updated.
 /// Else it keeps its reference to the current Node.
 /// </summary>
 /// <param name="name">Name of the node looked for.</param>
 /// <returns>true if succeeds, else returns false.</returns>
 public bool find(String name, bool registerStack = false)
 {
     if (m_counter == NativeManagement.getContextCounter())
     {
         if (m_nodeCpp != IntPtr.Zero)
         {
             IntPtr ptr = node_search(m_nodeCpp, __MarshallingUtils.NativeUtf8FromString(name));
             if (ptr != IntPtr.Zero)
             {
                 if (registerStack)
                 {
                     m_navigation.Add(m_nodeCpp);
                 }
                 m_nodeCpp = ptr;
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             throw new CKLBExceptionNullCppObject();
         }
     }
     else
     {
         throw new CKLBExceptionTooOld();
     }
 }
Beispiel #3
0
        /// <summary>
        /// Bind a GameObject to a C++ ObjectScriptable through its node name.
        /// </summary>
        /// <param name="nodeName">Name of the Node to bind.</param>
        public void bind(String nodeName)
        {
            if (nodeName == null)
            {
                throw new CKLBException("Impossible to bind with a null name.");
            }
            if (m_cppObject != IntPtr.Zero)
            {
                throw new CKLBException("This GameObject is already binded.");
            }

            NodeIterator nodeIterator = new NodeIterator(NativeManagement.getContextCounter(), NodeIterator.getRoot());

            if (nodeIterator.find(nodeName))
            {
                IntPtr cppObj       = nodeIterator.getAsUITask().CppObject;
                uint   nativeHandle = CKLBObjectScriptable_getScriptContext(cppObj);

                if (nativeHandle == NULLHANDLER)
                {
                    NativeManagement.registerWrapper(cppObj, m_handle);
                    m_cppObject = cppObj;
                    doSetupCallbacks();
                }
                else
                {
                    throw new CKLBException("This C++ object is already wrapped.");
                }
            }
            else
            {
                throw new CKLBException("There is not any Node with this name.");
            }
        }
Beispiel #4
0
        /// <summary>
        /// Get a node iterator, allowing to navigate through the scenegraph and manipulate nodes inside a task.
        /// Return the node passed as parameter.
        /// </summary>
        /// <param name="nodeIterator">Return a </param>
        /// <returns></returns>
        public NodeIterator getIterator(out NodeIterator nodeIterator)
        {
            uint   counter = NativeManagement.getContextCounter();
            IntPtr node    = NodeIterator.getNodeFromTask(this);

            nodeIterator = new NodeIterator(counter, node);
            return(nodeIterator);
        }
 public void setXY(float x, float y)
 {
     if (m_counter == NativeManagement.getContextCounter())
     {
         if (m_nodeCpp != IntPtr.Zero)
         {
             node_setTranslate(m_nodeCpp, x, y);
         }
         else
         {
             throw new CKLBExceptionNullCppObject();
         }
     }
     else
     {
         throw new CKLBExceptionTooOld();
     }
 }
 public AnimationNode getAsAnimationNode()
 {
     if (m_counter == NativeManagement.getContextCounter())
     {
         if (node_asAnimationNode(m_nodeCpp) != IntPtr.Zero)
         {
             return(new AnimationNode(m_counter, node_asElement(m_nodeCpp)));
         }
         else
         {
             return(null);
         }
     }
     else
     {
         throw new CKLBExceptionTooOld();
     }
 }
 public void setClickArea(int x, int y, int width, int height)
 {
     if (m_counter == NativeManagement.getContextCounter())
     {
         if (m_nodePtr != IntPtr.Zero)
         {
             selectable_setClick(m_nodePtr, x, y, width, height);
         }
         else
         {
             throw new CKLBExceptionNullCppObject();
         }
     }
     else
     {
         throw new CKLBExceptionTooOld();
     }
 }
 public bool setAudio(String assetName, uint mode, float volume)
 {
     if (m_counter == NativeManagement.getContextCounter())
     {
         if (m_nodePtr != IntPtr.Zero)
         {
             return(selectable_setAudio(m_nodePtr, __MarshallingUtils.NativeUtf8FromString(assetName), mode, volume));
         }
         else
         {
             throw new CKLBExceptionNullCppObject();
         }
     }
     else
     {
         throw new CKLBExceptionTooOld();
     }
 }
 /// <summary>
 /// Take the latest entry inside the navigation stack if any, and jump to the node, then the node is removed from the navigation stack.
 /// Returns true if the operation is sucessfull, false if the navigation stack is empty.
 /// </summary>
 /// <returns>
 /// True if successfull.
 /// False if the navigation stack is empty.
 /// </returns>
 public bool rollback()
 {
     if (m_counter == NativeManagement.getContextCounter())
     {
         if (m_navigation.Count != 0)
         {
             m_nodeCpp = m_navigation[m_navigation.Count - 1];
             // Pop from stack.
             m_navigation.RemoveAt(m_navigation.Count - 1);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         throw new CKLBExceptionTooOld();
     }
 }