Пример #1
0
 /// <summary>
 /// Gets an initialized cannon ball from the resource pool.
 /// </summary>
 /// <param name="manager">Manager of the new cannonball.</param>
 /// <param name="space">Space to which the cannon ball belongs.</param>
 /// <param name="position">Position at which to spawn the cannon ball.</param>
 /// <param name="initialVelocity">Initial velocity of the cannon ball.</param>
 /// <returns>Newly initialized cannon ball.</returns>
 public static EnemyCannonBall Create(EnemyCannonBallManager manager, Space space, Vector3 position, Vector3 initialVelocity)
 {
     EnemyCannonBall toReturn = CannonBallPool.Take();
     toReturn.Initialize(manager, space, position, initialVelocity);
     return toReturn;
 }
Пример #2
0
 /// <summary>
 /// Initializes this cannon ball.
 /// </summary>
 /// <param name="manager">Manager of this cannonball.</param>
 /// <param name="space">Space that the physical form of this cannon ball resides in.</param>
 /// <param name="position">Point to put the cannon ball.</param>
 /// <param name="initialVelocity">Initial velocity of the cannon ball.</param>
 public void Initialize(EnemyCannonBallManager manager, Space space, Vector3 position, Vector3 initialVelocity)
 {
     Manager = manager;
     body.CollisionRules.Group = EnemyCannonBallCollisionGroup;
     Space = space;
     Body.CenterPosition = position;
     Body.LinearVelocity = initialVelocity;
     Space.Add(Body);
       //  Body.AngularVelocity = new Vector3(2, -3, 1); //random-looking angular velocity.
     shouldDraw = false;
     numFramesSinceInitialized = 0;
     IsActive = true;
 }