/// <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(ElectricProjectile objectToMakeUnused, bool callDestroy)
 {
     if (callDestroy)
     {
         objectToMakeUnused.Destroy();
     }
 }
        public static ElectricProjectile CreateNew(Layer layer, float x = 0, float y = 0)
        {
            ElectricProjectile instance = null;

            instance = new ElectricProjectile(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 <ElectricProjectile> )
                {
                    var index = (list as PositionedObjectList <ElectricProjectile>).GetFirstAfter(x, Axis.X, 0, list.Count);
                    list.Insert(index, instance);
                }
                else if (SortAxis == FlatRedBall.Math.Axis.Y && list is PositionedObjectList <ElectricProjectile> )
                {
                    var index = (list as PositionedObjectList <ElectricProjectile>).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);
        }
        private static void FactoryInitialize()
        {
            const int numberToPreAllocate = 20;

            for (int i = 0; i < numberToPreAllocate; i++)
            {
                ElectricProjectile instance = new ElectricProjectile(mContentManagerName, false);
                mPool.AddToPool(instance);
            }
        }
コード例 #4
0
ファイル: ElectricGun.cs プロジェクト: jramell/Choice
    protected override void Start()
    {
        base.Start();
        shootSpawnHorizontalDistance = Mathf.Abs(projectileSpawn.transform.position.x - player.position.x);
        shootSpawnVerticalDistance   = Mathf.Abs(projectileSpawn.transform.position.y - player.position.y);
        ElectricProjectile projectileComponent = projectilePrefab.GetComponent <ElectricProjectile>();

        projectileComponent.shockStrength = shockStrength;
        projectileComponent.speed         = projectileSpeed;
        if (player == null)
        {
            player = GameObject.FindGameObjectWithTag("Player").transform;
        }
    }
 /// <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(ElectricProjectile objectToMakeUnused)
 {
     MakeUnused(objectToMakeUnused, true);
 }