/// <summary> /// Constructor for bullet class. /// </summary> /// <param name="position">Inital position of the bullet.</param> /// <param name="velocity">Inital velosity of the bullet.</param> /// <param name="drawDirection">Direction to draw the bullet.</param> /// <param name="bulletColour">Colour of the bullet</param> /// <param name="bulletType">Type of the bullet</param> /// <param name="owner">Owner of the bullet</param> public BulletEntity(Point2D position, Velocity2D velocity, double drawDirection, BulletColour bulletColour, BulletType bulletType, Entity owner) : base(position, InitaliseBounding(position, bulletColour, bulletType), 1, bulletType.ToString() + bulletColour.ToString()) { _owner = owner; _drawDirection = drawDirection; _bulletColour = bulletColour; _bulletType = bulletType; _movement = new VectorMovement(velocity); }
/// <summary> /// Constructs bullet entity. /// </summary> /// <param name="bulletColour">Colour of bullet.</param> /// <param name="bulletType">Type of bullet.</param> /// <param name="owner">Owner of bullet.</param> /// <param name="position">Spawn position of bullet.</param> /// <param name="trajectory">Trajectory of bullet.</param> public BulletEntity(BulletColour bulletColour, BulletType bulletType, Entity owner, Point position, Vector trajectory) : base(bulletType.ToString() + bulletColour.ToString(), InitBounding(bulletType, position, trajectory), 1) { _bulletColour = bulletColour; _bulletType = bulletType; _owner = owner; _trajectory = trajectory; _grazed = false; _movement = new Linear(trajectory); }
/// <summary> /// Grabs a deactivated bullet from the pool /// </summary> /// <returns> /// Not always there, check if it's null /// </returns> public GameObject GetBullet(BulletColour c) { foreach (GameObject b in bullets) { if (!b.activeSelf) { b.GetComponentInChildren <SpriteRenderer>().color = bulletColours[(int)c]; return(b); } } Debug.LogError("BulletPool Error: Ran out of Bullets!"); return(null); }
public static List <Bounding> InitaliseBounding(Point2D point, BulletColour bulletColour, BulletType bulletType) { List <Bounding> result = new List <Bounding>(); result.Add(new Bounding(new Point2D[] { new Point2D(point.X + (GameResources.GameImage(bulletType.ToString() + bulletColour.ToString()).Width / 2), point.Y - (GameResources.GameImage(bulletType.ToString() + bulletColour.ToString()).Height / 2)), new Point2D(point.X - (GameResources.GameImage(bulletType.ToString() + bulletColour.ToString()).Width / 2), point.Y - (GameResources.GameImage(bulletType.ToString() + bulletColour.ToString()).Height / 2)), new Point2D(point.X - (GameResources.GameImage(bulletType.ToString() + bulletColour.ToString()).Width / 2), point.Y + (GameResources.GameImage(bulletType.ToString() + bulletColour.ToString()).Height / 2)), new Point2D(point.X + (GameResources.GameImage(bulletType.ToString() + bulletColour.ToString()).Width / 2), point.Y + (GameResources.GameImage(bulletType.ToString() + bulletColour.ToString()).Height / 2)) })); return(result); }