Exemple #1
0
        void appendIn(utList <tListEntry> list, System.Object target, bool paused)
        {
            tListEntry listEntry = new tListEntry();

            listEntry.target            = target;
            listEntry.paused            = paused;
            listEntry.markedForDeletion = false;
            MethodInfo method = target.GetType().GetMethod(updateSelector);

            listEntry.impMethod = (TICK_IMP)Delegate.CreateDelegate(typeof(TICK_IMP), target, method);

            utNode <tListEntry> listElement = new utNode <tListEntry> ();

            listElement.next = listElement.prev = null;
            listElement.obj  = listEntry;

            list.DL_APPEND(listElement);

            tHashUpdateEntry hashElement = new tHashUpdateEntry();

            hashElement.target = target;
            hashElement.list   = list;
            hashElement.entry  = listElement;
            hashForUpdates.HASH_ADD_INT(target.GetHashCode(), hashElement);
        }
Exemple #2
0
        void priorityIn(utList <tListEntry> list, System.Object target, int priority, bool paused)
        {
            tListEntry listEntry = new tListEntry();

            listEntry.target   = target;
            listEntry.priority = priority;
            listEntry.paused   = paused;
            MethodInfo method = target.GetType().GetMethod(updateSelector);

            listEntry.impMethod         = (TICK_IMP)Delegate.CreateDelegate(typeof(TICK_IMP), target, method);
            listEntry.markedForDeletion = false;

            utNode <tListEntry> listElement = new utNode <tListEntry> ();

            listElement.next = listElement.prev = null;
            listElement.obj  = listEntry;


            if (list.head == null)
            {
                list.DL_APPEND(listElement);
            }
            else
            {
                bool added = false;
                for (utNode <tListEntry> elem = list.head; elem != null; elem = elem.next)
                {
                    if (priority < elem.obj.priority)
                    {
                        if (elem == list.head)
                        {
                            list.DL_PREPEND(listElement);
                        }
                        else
                        {
                            listElement.next = elem;
                            listElement.prev = elem.prev;

                            elem.prev.next = listElement;
                            elem.prev      = listElement;
                        }
                        added = true;
                        break;
                    }
                }

                if (!added)
                {
                    list.DL_APPEND(listElement);
                }
            }
            tHashUpdateEntry hashElement = new tHashUpdateEntry();

            hashElement.target = target;
            hashElement.list   = list;
            hashElement.entry  = listElement;
            hashForUpdates.HASH_ADD_INT(target.GetHashCode(), hashElement);
        }
		public bool removeDelegate<T>(System.Object aDelegate, utList<T> list) where T : tDelegateEntry
		{
			utNode<T> entry;
			for((entry)=(list.head); (entry !=null ); (entry) = entry.next){
				if(entry.obj.aDelegate == aDelegate){
					list.DL_DELETE(entry);
					return true;
				}
			}
			return false;
		}
		public CCEventDispatcher(){
			// events enabled by default
			_dispatchEvents = true;
			
			// delegates
			_keyboardDelegates = new utList<tListEntry>();
			_mouseDelegates = new utList<tListEntry>();
			
			_delegatesToBeAdded = new utList<tListAddedEntry>();
			_delegatesToBeRemoved = new utList<tListDeletedEntry>();
			
			_locked = false;
		}
 public CC3TileSprite(Texture2D texture)
 {
     this.nameInHierarchy = string.Concat(GetType().Name, "-", texture.name);
     _texture             = texture;
     _tiles     = new utList <Tile>();
     _meshDirty = false;
     this.meshRender.sharedMaterial = CCMaterialCache.sharedMaterialCache.getMaterial(texture);
     this.renderQueue = RenderQueue.Geometry;
     this.renderType  = "Opaque";
     ccUtils.SetRenderValue(this.meshRender, "_CullMode", (int)CullMode.Back);
     ccUtils.SetRenderValue(this.meshRender, "_ZWrite", 1);
     ccUtils.SetRenderColor(this.meshRender, Color.white, new Color32(0, 0, 0, 0));
 }
		public void removeAllDelegatesFromList(utList<tListEntry> list)
		{
			NSUtils.Assert( ! _locked, "BUG. Open a ticket. Can't call this function when processing events.");
			
			lock(this) {
				utNode<tListEntry> entry, tmp;
				entry = list.head;
				while(entry != null){
					tmp = entry.next;
					list.DL_DELETE(entry);
					entry = tmp;
					tmp = null;
				}
			}
		}
		public void addLaterDelegate(System.Object aDelegate, int priority, utList<tListEntry> list)
		{
			// XXX: Since, "remove" is "executed" after "add", it is not needed to check if the delegate was already added for removal.
			// In fact, if you remove it now, it could be a bug, since EventDispatcher doesn't support updated priority.
			// And the only way to update the priority is by deleting, re-adding the delegate with a new priority
			tListAddedEntry listEntry = new tListAddedEntry();
			
			listEntry.aDelegate = aDelegate;
			listEntry.priority = priority;
			listEntry.listToBeAdded = list;

			utNode<tListAddedEntry> listElement = new utNode<tListAddedEntry> ();
			listElement.next = listElement.prev = null;
			listElement.obj = listEntry;

			_delegatesToBeAdded.DL_APPEND(listElement);
		}
        public utList <Tile> getTilesAt(Vector2 positionInNodeSpace)
        {
            Vector2       uPositionInNodeSpace = positionInNodeSpace / UIWindow.PIXEL_PER_UNIT;
            utList <Tile> tiles = new utList <Tile>();

            for (var ent = _tiles.head; ent != null; ent = ent.next)
            {
                Vector2 sptSize = ent.obj.spriteFrame.originalSize / UIWindow.PIXEL_PER_UNIT;
                Rect    sptRect = new Rect(-sptSize / 2, sptSize);
                sptRect = CGAffineTransform.CGRectApplyAffineTransform(sptRect, ent.obj.transform);
                if (sptRect.Contains(uPositionInNodeSpace))
                {
                    tiles.DL_APPEND(ent.obj);
                }
            }
            return(tiles);
        }
		public void removeLaterDelegate(System.Object aDelegate, utList<tListEntry> list)
		{
			// Only add it if it was not already added for deletion
			if( ! removeDelegate<tListAddedEntry>(aDelegate, _delegatesToBeAdded)) {
				
				tListDeletedEntry listEntry = new tListDeletedEntry();
				
				listEntry.aDelegate = aDelegate;
				listEntry.listToBeDeleted = list;

				
				utNode<tListDeletedEntry> listElement = new utNode<tListDeletedEntry> ();
				listElement.next = listElement.prev = null;
				listElement.obj = listEntry;
				
				_delegatesToBeRemoved.DL_APPEND(listElement );
			}
		}
Exemple #10
0
        public utList <BBFlashMovie> getChildrenByClassName(string name)
        {
            if (name == null)
            {
                return(null);
            }
            utList <BBFlashMovie> children = new utList <BBFlashMovie>();

            for (int i = 0; i < _depthDisplays.Length; i++)
            {
                BBGamelib.flash.imp.Display child = _depthDisplays[i];
                if (child != null && !child.removed && child.define.className == name)
                {
                    children.DL_APPEND(child  as BBFlashMovie);
                }
            }
            return(children);
        }
        public void DL_CONTACT(utList <T> list2)
        {
            var head1 = _head;
            var head2 = list2.head;

            if (head2 != null)
            {
                if (head1 != null)
                {
                    var tmp = head2.prev;
                    head2.prev      = head1.prev;
                    head1.prev.next = head2;
                    head1.prev      = tmp;
                }
                else
                {
                    _head = head2;
                }
            }
        }
Exemple #12
0
        public void removeSpriteFramesFromTexture(Texture2D texture)
        {
            utList <string> keysToRemove = new utList <string> ();
            var             enumerator   = _spriteFrames.GetEnumerator();

            while (enumerator.MoveNext())
            {
                KeyValuePair <string, CCSpriteFrame> kv = enumerator.Current;
                string        spriteFrameKey            = kv.Key;
                CCSpriteFrame frame = kv.Value;
                if (frame.texture == texture)
                {
                    keysToRemove.DL_APPEND(spriteFrameKey);
                }
            }
            for (var ent = keysToRemove.head; ent != null; ent = ent.next)
            {
                _spriteFrames.Remove(ent.obj);
            }
        }
Exemple #13
0
        //----------init------------
        public CCScheduler()
        {
            _timeScale = 1.0f;

            // used to trigger CCTimer#update
            updateSelector = "update";
//			impMethod = (TICK_IMP) [CCTimerTargetSelector instanceMethodForSelector:updateSelector];

            // updates with priority
            updates0       = new utList <tListEntry>();
            updatesNeg     = new utList <tListEntry>();
            updatesPos     = new utList <tListEntry>();
            hashForUpdates = new utHash <int, tHashUpdateEntry>();

            // selectors with interval
            currentTarget         = null;
            currentTargetSalvaged = false;
            hashForTimers         = new utHash <int, tHashTimerEntry>();
            updateHashLocked      = false;
            _paused = false;
        }
		public void addDelegate(System.Object aDelegate, int priority, utList<tListEntry> list)
		{
			tListEntry listEntry = new tListEntry();
			
			listEntry.aDelegate = aDelegate;
			listEntry.priority = priority;

			utNode<tListEntry> listElement = new utNode<tListEntry> ();
			listElement.next = listElement.prev = null;
			listElement.obj = listEntry;

			bool added = false;
			
			for( utNode<tListEntry> elem = list.head; elem != null ; elem = elem.next ) {
				if( priority <= elem.obj.priority ) {
					
					if( elem == list.head )
						list.DL_PREPEND(listElement);
					else {
						listElement.next = elem;
						listElement.prev = elem.prev;
						
						elem.prev.next = listElement;
						elem.prev = listElement;
					}
					
					added = true;
					break;
				}
			}
			
			// Not added? priority has the higher value. Append it.
			if( !added )
				list.DL_APPEND(listElement);

		}