/// <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(StructurePlacement objectToMakeUnused, bool callDestroy)
 {
     if (callDestroy)
     {
         objectToMakeUnused.Destroy();
     }
 }
        public override ISimplePlacement GetPlacement(IPurchasable purchasable, IResourceContainer resources)
        {
            var placement = new StructurePlacement(() => resources.HasEnough(purchasable.Cost) ? null : "Not enough resources");

            placement.OnPlaced += OnPlaced;
            return(placement);
        }
        public static StructurePlacement CreateNew(Layer layer, float x = 0, float y = 0)
        {
            StructurePlacement instance = null;

            instance = new StructurePlacement(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 <StructurePlacement> )
                {
                    var index = (list as PositionedObjectList <StructurePlacement>).GetFirstAfter(x, Axis.X, 0, list.Count);
                    list.Insert(index, instance);
                }
                else if (SortAxis == FlatRedBall.Math.Axis.Y && list is PositionedObjectList <StructurePlacement> )
                {
                    var index = (list as PositionedObjectList <StructurePlacement>).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);
        }
Exemplo n.º 4
0
        public void DisplayForPlacement(StructurePlacement placement)
        {
            CurrentPlacement = placement;

            X = CurrentPlacement.X;
            Y = CurrentPlacement.Y;

            if (MoreThanFour)
            {
                CurrentCapacityState = Capacity.Seven;

                if (BuildButtonInstance6.AbsoluteY < 0 || X > 0.9f * Camera.Main.OrthogonalWidth / 2 || X < -0.9f * Camera.Main.OrthogonalWidth / 2)
                {
                    CurrentCapacityState = X < 0 ? Capacity.SevenRight : Capacity.SevenLeft;
                }
            }
            else
            {
                CurrentCapacityState = Capacity.Four;

                if (BuildButtonInstance3.AbsoluteY < 0 || X > 0.9f * Camera.Main.OrthogonalWidth / 2 || X < -0.9f * Camera.Main.OrthogonalWidth / 2)
                {
                    CurrentCapacityState = X < 0 ? Capacity.FourRight : Capacity.FourLeft;
                }
            }
            Visible = true;
        }
        private static void FactoryInitialize()
        {
            const int numberToPreAllocate = 20;

            for (int i = 0; i < numberToPreAllocate; i++)
            {
                StructurePlacement instance = new StructurePlacement(mContentManagerName, false);
                mPool.AddToPool(instance);
            }
        }
 /// <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(StructurePlacement objectToMakeUnused)
 {
     MakeUnused(objectToMakeUnused, true);
 }
Exemplo n.º 7
0
 public void Hide(bool didBuild = false)
 {
     HideRangePreview();
     CurrentPlacement = null;
     Visible          = false;
 }