public static Bullet CreateNew(Layer layer, float x = 0, float y = 0)
        {
            Bullet instance = null;

            instance = new Bullet(mContentManagerName ?? FlatRedBall.Screens.ScreenManager.CurrentScreen.ContentManagerName, false);
            instance.AddToManagers(layer);
            instance.X = x;
            instance.Y = y;
            foreach (var list in ListsToAddTo)
            {
                if (SortAxis == FlatRedBall.Math.Axis.X && list is PositionedObjectList <Bullet> )
                {
                    var index = (list as PositionedObjectList <Bullet>).GetFirstAfter(x, Axis.X, 0, list.Count);
                    list.Insert(index, instance);
                }
                else if (SortAxis == FlatRedBall.Math.Axis.Y && list is PositionedObjectList <Bullet> )
                {
                    var index = (list as PositionedObjectList <Bullet>).GetFirstAfter(y, Axis.Y, 0, list.Count);
                    list.Insert(index, instance);
                }
                else
                {
                    // Sort Z not supported
                    list.Add(instance);
                }
            }
            if (EntitySpawned != null)
            {
                EntitySpawned(instance);
            }
            return(instance);
        }
        public static Bullet CreateNew(Layer layer)
        {
            if (string.IsNullOrEmpty(mContentManagerName))
            {
                throw new System.Exception("You must first initialize the factory to use it.");
            }
            Bullet instance = null;

            instance = new Bullet(mContentManagerName, false);
            instance.AddToManagers(layer);
            if (mScreenListReference != null)
            {
                mScreenListReference.Add(instance);
            }
            if (EntitySpawned != null)
            {
                EntitySpawned(instance);
            }
            return(instance);
        }
예제 #3
0
        public static Bullet CreateNew(Layer layer, float x = 0, float y = 0)
        {
            Bullet instance = null;

            if (string.IsNullOrEmpty(mContentManagerName))
            {
                throw new System.Exception("You must first initialize the factory for this type because it is pooled. You can either add PositionedObjectList of type Bullet (the most common solution) or call Initialize in custom code");
            }
            instance = mPool.GetNextAvailable();
            if (instance == null)
            {
                mPool.AddToPool(new Bullet(mContentManagerName, false));
                instance = mPool.GetNextAvailable();
            }
            instance.AddToManagers(layer);
            instance.X = x;
            instance.Y = y;
            foreach (var list in ListsToAddTo)
            {
                if (SortAxis == FlatRedBall.Math.Axis.X && list is PositionedObjectList <Bullet> )
                {
                    var index = (list as PositionedObjectList <Bullet>).GetFirstAfter(x, Axis.X, 0, list.Count);
                    list.Insert(index, instance);
                }
                else if (SortAxis == FlatRedBall.Math.Axis.Y && list is PositionedObjectList <Bullet> )
                {
                    var index = (list as PositionedObjectList <Bullet>).GetFirstAfter(y, Axis.Y, 0, list.Count);
                    list.Insert(index, instance);
                }
                else
                {
                    // Sort Z not supported
                    list.Add(instance);
                }
            }
            if (EntitySpawned != null)
            {
                EntitySpawned(instance);
            }
            return(instance);
        }
예제 #4
0
        public static Bullet CreateNew(Layer layer, float x = 0, float y = 0)
        {
            if (string.IsNullOrEmpty(mContentManagerName))
            {
                throw new System.Exception("You must first initialize the factory to use it. You can either add PositionedObjectList of type Bullet (the most common solution) or call Initialize in custom code");
            }
            Bullet instance = null;

            instance = mPool.GetNextAvailable();
            if (instance == null)
            {
                mPool.AddToPool(new Bullet(mContentManagerName, false));
                instance = mPool.GetNextAvailable();
            }
            instance.AddToManagers(layer);
            instance.X = x;
            instance.Y = y;
            if (mScreenListReference != null)
            {
                if (SortAxis == FlatRedBall.Math.Axis.X)
                {
                    var index = mScreenListReference.GetFirstAfter(x, Axis.X, 0, mScreenListReference.Count);
                    mScreenListReference.Insert(index, instance);
                }
                else if (SortAxis == FlatRedBall.Math.Axis.Y)
                {
                    var index = mScreenListReference.GetFirstAfter(y, Axis.Y, 0, mScreenListReference.Count);
                    mScreenListReference.Insert(index, instance);
                }
                else
                {
                    // Sort Z not supported
                    mScreenListReference.Add(instance);
                }
            }
            if (EntitySpawned != null)
            {
                EntitySpawned(instance);
            }
            return(instance);
        }