Exemple #1
0
        protected virtual CCNode ParsePropTypeCcbFile(CCNode node, CCNode parent, CCBReader reader)
        {
            string ccbFileName = reader.ReadCachedString();

            /* Change path extension to .ccbi. */
            string ccbFileWithoutPathExtension = CCBReader.DeletePathExtension(ccbFileName);

            ccbFileName = ccbFileWithoutPathExtension + ".ccbi";

            // Load sub file
            string path      = CCFileUtils.FullPathFromRelativePath(ccbFileName);
            var    ccbReader = new CCBReader(reader);

            byte[] pBytes = CCFileUtils.GetFileBytes(path);
            ccbReader.InitWithData(pBytes, reader.Owner);
            ccbReader.AnimationManager.RootContainerSize = parent.ContentSize;

            CCNode ccbFileNode = ccbReader.ReadFileWithCleanUp(false);

            if (ccbFileNode != null && ccbReader.AnimationManager.AutoPlaySequenceId != -1)
            {
                // Auto play animations
                ccbReader.AnimationManager.RunAnimations(ccbReader.AnimationManager.AutoPlaySequenceId, 0);
            }

            return(ccbFileNode);
        }
Exemple #2
0
        protected virtual CCNode ParsePropTypeCcbFile(CCNode node, CCNode parent, CCBReader pCCBReader)
        {
            string ccbFileName = pCCBReader.ReadCachedString();

            /* Change path extension to .ccbi. */
            string ccbFileWithoutPathExtension = CCBReader.DeletePathExtension(ccbFileName);
            ccbFileName = ccbFileWithoutPathExtension + ".ccbi";

            // Load sub file
            string path = CCFileUtils.FullPathFromRelativePath(ccbFileName);
            //long size = 0;
            byte[] pBytes = CCFileUtils.GetFileBytes(path);
            var reader = new CCBReader(pCCBReader);

            reader.AnimationManager.RootContainerSize = parent.ContentSize;

            reader._bytes = pBytes;
            reader._currentByte = 0;
            reader._currentBit = 0;
            reader._owner = pCCBReader._owner;

            reader.AnimationManager._owner = reader._owner;

            CCNode ccbFileNode = reader.ReadFileWithCleanUp(false, pCCBReader.AnimationManagers);

            if (ccbFileNode != null && reader.AnimationManager.AutoPlaySequenceId != -1)
            {
                // Auto play animations
                reader.AnimationManager.RunAnimationsForSequenceIdTweenDuration(reader.AnimationManager.AutoPlaySequenceId, 0);
            }

            if (reader.IsJSControlled() && pCCBReader.IsJSControlled() && null != reader._owner)
            {
                //set variables and callback to owner
                //set callback
                var ownerCallbackNames = reader.OwnerCallbackNames;
                var ownerCallbackNodes = reader.OwnerCallbackNodes;
                if (null != ownerCallbackNames && ownerCallbackNames.Count > 0 &&
                    null != ownerCallbackNodes && ownerCallbackNodes.Count > 0)
                {
                    Debug.Assert(ownerCallbackNames.Count == ownerCallbackNodes.Count);
                    int nCount = ownerCallbackNames.Count;
                    for (int i = 0; i < nCount; i++)
                    {
                        pCCBReader.AddOwnerCallbackName(ownerCallbackNames[i]);
                        pCCBReader.AddOwnerCallbackNode(ownerCallbackNodes[i]);
                    }
                }
                //set variables
                var ownerOutletNames = reader.OwnerOutletNames;
                var ownerOutletNodes = reader.OwnerOutletNodes;
                if (null != ownerOutletNames && ownerOutletNames.Count > 0 &&
                    null != ownerOutletNodes && ownerOutletNodes.Count > 0)
                {
                    Debug.Assert(ownerOutletNames.Count == ownerOutletNodes.Count);
                    int nCount = ownerOutletNames.Count;
                    for (int i = 0; i < nCount; i++)
                    {
                        pCCBReader.AddOwnerOutletName(ownerOutletNames[i]);
                        pCCBReader.AddOwnerOutletNode(ownerOutletNodes[i]);
                    }
                }
            }

            return ccbFileNode;
        }
        protected virtual CCNode ParsePropTypeCcbFile(CCNode node, CCNode parent, CCBReader reader)
        {
            string ccbFileName = reader.ReadCachedString();

            /* Change path extension to .ccbi. */
            string ccbFileWithoutPathExtension = CCBReader.DeletePathExtension(ccbFileName);
            ccbFileName = ccbFileWithoutPathExtension + ".ccbi";

            // Load sub file
            string path = CCFileUtils.FullPathFromRelativePath(ccbFileName);
            var ccbReader = new CCBReader(reader);

            byte[] pBytes = CCFileUtils.GetFileBytes(path);
            ccbReader.InitWithData(pBytes, reader.Owner);
            ccbReader.AnimationManager.RootContainerSize = parent.ContentSize;

            CCNode ccbFileNode = ccbReader.ReadFileWithCleanUp(false);

            if (ccbFileNode != null && ccbReader.AnimationManager.AutoPlaySequenceId != -1)
            {
                // Auto play animations
                ccbReader.AnimationManager.RunAnimations(ccbReader.AnimationManager.AutoPlaySequenceId, 0);
            }

            return ccbFileNode;
        }