Esempio n. 1
0
        /// <summary>
        /// Makes the argument objectToMakeUnused marked as unused.  This method is generated to be used
        /// by generated code.  Use Destroy instead when writing custom code so that your code will behave
        /// the same whether your Entity is pooled or not.
        /// </summary>
        public static void MakeUnused(Sheep1Enemy objectToMakeUnused, bool callDestroy)
        {
            mPool.MakeUnused(objectToMakeUnused);

            if (callDestroy)
            {
                objectToMakeUnused.Destroy();
            }
        }
Esempio n. 2
0
        private static void FactoryInitialize()
        {
            const int numberToPreAllocate = 20;

            for (int i = 0; i < numberToPreAllocate; i++)
            {
                Sheep1Enemy instance = new Sheep1Enemy(mContentManagerName, false);
                mPool.AddToPool(instance);
            }
        }
Esempio n. 3
0
        public static Sheep1Enemy CreateNew(Layer layer, float x = 0, float y = 0)
        {
            Sheep1Enemy 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 Sheep1Enemy (the most common solution) or call Initialize in custom code");
            }
            instance = mPool.GetNextAvailable();
            if (instance == null)
            {
                mPool.AddToPool(new Sheep1Enemy(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 <Sheep1Enemy> )
                {
                    var index = (list as PositionedObjectList <Sheep1Enemy>).GetFirstAfter(x, Axis.X, 0, list.Count);
                    list.Insert(index, instance);
                }
                else if (SortAxis == FlatRedBall.Math.Axis.Y && list is PositionedObjectList <Sheep1Enemy> )
                {
                    var index = (list as PositionedObjectList <Sheep1Enemy>).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);
        }
Esempio n. 4
0
 /// <summary>
 /// Makes the argument objectToMakeUnused marked as unused.  This method is generated to be used
 /// by generated code.  Use Destroy instead when writing custom code so that your code will behave
 /// the same whether your Entity is pooled or not.
 /// </summary>
 public static void MakeUnused(Sheep1Enemy objectToMakeUnused)
 {
     MakeUnused(objectToMakeUnused, true);
 }