Пример #1
0
 protected override void initWithGear(CCFactoryGear gear)
 {
     base.initWithGear(gear);
     _rotationX            = 0;
     _rotationY            = 0;
     _rotationSortingOrder = kRotationSortingOrder.YXZ;
     _scaleZ    = 1;
     _positionZ = 0;
 }
        protected override void init()
        {
            CCFactoryGear gear = CCFactory.Instance.takeGear(CCFactory.KEY_SPRITE);

            initWithGear(gear);
            this.meshRender.shadowCastingMode = ShadowCastingMode.Off;
            this.meshRender.receiveShadows    = false;
            this.meshRender.motionVectors     = false;
        }
Пример #3
0
        /** creates a CCLabelTTF from a fontname, horizontal alignment, vertical alignment, dimension in points, line break mode, and font size in points.
         * Supported lineBreakModes:
         * - iOS: all UILineBreakMode supported modes
         * - Mac: Only NSLineBreakByWordWrapping is supported.
         * @since v1.0
         */

        protected override void initWithGear(CCFactoryGear gear)
        {
            base.initWithGear(gear);
            _gear.gameObject.name = "LabelTTF";
//			_gear.gameObject.transform.localScale = new Vector3 (1, 1, 1);
            _content = new CCLabelContent();
            _content.gameObject.transform.parent = gameObject.transform;
            //			_content.renderer.sortingOrder = 1;
            ccUtils.SetRenderColor(_content.renderer, Color.white, new Color32(0, 0, 0, 0));
        }
Пример #4
0
        protected virtual void initWithGear(CCFactoryGear gear)
        {
            _gear = gear;
            _gear.gameObject.name = "node";
            _gear.gameObject.transform.localPosition = Vector3.zero;
//			_gear.gameObject.transform.localScale = new Vector3 (1, 1, 1);
            _isRunning = false;

            //			_skewX = _skewY = 0.0f;
            _rotation            = 0.0f;
            _scaleX              = _scaleY = 1.0f;
            _position            = Vector2.zero;
            _contentSize         = Vector2.zero;
            _anchorPointInPixels = _anchorPoint = Vector2.zero;


            // "whole screen" objects. like Scenes and Layers, should set ignoreAnchorPointForPosition to YES
            _ignoreAnchorPointForPosition = false;

            _isUpdateTransformDirty = _isTransformDirty = _isInverseDirty = true;

            //			_vertexZ = 0;

            //			_grid = nil;

            _visible = true;

            _userTag = null;

            _zOrder = 0;

            // lazy alloc
            //			_camera = nil;

            // children (lazy allocs)
            _children = null;

            // userData is always inited as nil
            _userObject = null;

            //initialize parent to nil
            _parent = null;

            //			_shaderProgram = nil;

            _orderOfArrival = 0;

            //			_glServerState = 0;

            // set default scheduler and actionManager
            CCDirector director = CCDirector.sharedDirector;

            this.actionManager = director.actionManager;
            this.scheduler     = director.scheduler;
        }
Пример #5
0
 public CCLabelContent()
 {
     gear = CCFactory.Instance.takeGear(CCFactory.KEY_LABEL);
     gear.gameObject.name = "content";
     //			gear.gameObject.transform.localScale = new Vector3 (1, 1, 1);
     this.mesh.color                = Color.white;
     mesh.characterSize             = 0.05f;
     mesh.anchor                    = TextAnchor.MiddleCenter;
     mesh.alignment                 = TextAlignment.Center;
     this.renderer.sortingLayerName = CCFactory.LAYER_DEFAULT;
     this.defaultMaterial           = this.renderer.material;
 }
Пример #6
0
        // ------------------------------------------------------------------------------
        //  private
        // ------------------------------------------------------------------------------
        CCFactoryGear buildGear(Type[] componentTypes)
        {
            CCFactoryGear gear = new CCFactoryGear();

            GameObject obj = new GameObject();

            gear.gameObject = obj;

            Component[] coms = new Component[componentTypes.Length];
            for (int j = 0; j < componentTypes.Length; j++)
            {
                coms[j] = obj.AddComponent(componentTypes[j]);
            }
            gear.components = coms;

            return(gear);
        }
        protected override void init()
        {
            CCFactoryGear gear = CCFactory.Instance.takeGear(CCFactory.KEY_SPRITE);

            initWithGear(gear);
            this.meshRender.sortingOrder      = 0;
            this.meshRender.shadowCastingMode = ShadowCastingMode.Off;
            this.meshRender.receiveShadows    = true;
            this.meshRender.motionVectors     = true;
            _squareVertices = new Vector3[4];

            _texture = new Texture2D(64, 64, TextureFormat.ARGB32, false, false);
            Material mat = new Material(Shader.Find("BBGamelib/CCTexture"));

            mat.name        = "CCMaterial-New";
            mat.mainTexture = _texture;
            this.meshRender.sharedMaterial = mat;
            init(new Color(0, 0, 0, 0));
        }
Пример #8
0
        // ------------------------------------------------------------------------------
        //  public runtime metod
        // ------------------------------------------------------------------------------
        public CCFactoryGear takeGear(string category)
        {
            Storage storage = getStorage(category, false);

            if (storage != null)
            {
                while (storage.gears.Count > 0)
                {
                    CCFactoryGear gear = storage.gears[0];
                    storage.gears.RemoveAt(0);
                    gear.gameObject.hideFlags = HideFlags.None;
                    gear.gameObject.SetActive(true);
                    if (gear.gameObject.transform.childCount != 0)
                    {
                        CCDebug.Warning("CCFactory try to take a not empty gear: {0}-{1}.", gear.gameObject, gear.gameObject.transform.GetChild(0));
                        DestroyObject(gear.gameObject);
                    }
                    else
                    {
                        return(gear);
                    }
                }
                //no gear caches
                {
                    Type[] componentTypes = new Type[storage.componentTypeNames.Length];
                    for (int i = 0; i < componentTypes.Length; i++)
                    {
                        componentTypes[i] = Type.GetType(storage.componentTypeNames[i]);
                    }
                    CCFactoryGear gear = buildGear(componentTypes);
                    gear.gameObject.hideFlags = HideFlags.None;
                    gear.gameObject.SetActive(true);
                    return(gear);
                }
            }
            return(null);
        }
Пример #9
0
        protected virtual void init()
        {
            CCFactoryGear gear = CCFactory.Instance.takeGear(CCFactory.KEY_NODE);

            initWithGear(gear);
        }
Пример #10
0
        public bool recycleGear(string category, CCFactoryGear gear, bool constraint = false)
        {
            if (gear.gameObject.transform.childCount != 0)
            {
                CCDebug.Warning("CCFactory try to recyle a not empty gear: {0}-{1}.", gear.gameObject, gear.gameObject.transform.GetChild(0));
                DestroyObject(gear.gameObject);
                return(false);
            }


            Storage storage = getStorage(category, true);

            if (storage.componentTypeNames == null)
            {
                string[] componentTypeNames = new string[gear.components.Length];
                for (int i = 0; i < componentTypeNames.Length; i++)
                {
                    componentTypeNames [i] = gear.components [i].GetType().FullName;
                }
                storage.componentTypeNames = componentTypeNames;
            }
            else if (constraint)
            {
                if (storage.componentTypeNames.Length != gear.components.Length)
                {
                    return(false);
                }
                else
                {
                    HashSet <string> typeSet = new HashSet <string>(storage.componentTypeNames);

                    int count = gear.components.Length;
                    for (int i = 0; i < count; i++)
                    {
                        Component com   = gear.components[i];
                        string    tName = com.GetType().FullName;
                        if (!typeSet.Remove(tName))
                        {
                            return(false);
                        }
                    }
                }
            }

            gear.gameObject.layer = LayerMask.NameToLayer("Default");
            gear.gameObject.transform.SetParent(this.transform);
            gear.gameObject.transform.localEulerAngles = Vector3.zero;
            gear.gameObject.transform.localScale       = new Vector3(1, 1, 1);
            gear.gameObject.transform.localPosition    = Vector3.zero;
            gear.gameObject.name      = string.Format("{0}-{1}", category, storage.gears.Count);
            gear.gameObject.hideFlags = HideFlags.HideInHierarchy;
            gear.gameObject.SetActive(false);
            storage.gears.Add(gear);

            if (gear.gameObject.transform.parent == null)
            {
                NSUtils.Assert(gear.gameObject.transform.parent != null, "Recyle# set parent fail!");
            }

            return(true);
        }