// Internal handlnig of adding sprite private void addInternal(SpriteActor sprite) { sprites.Add(sprite); if (sprite is Bullet) { bullets.Add(sprite as Bullet); } else if (sprite is Enemy) { enemies.Add(sprite as Enemy); } else if (sprite is Pickup) { pickups.Add(sprite as Pickup); } else if (sprite is Player) { player = sprite as Player; } if (sprite is Enemy) { if (sprite is Boss) { boss = sprite as Boss; } } }
/// <summary> /// Create a basic bullet /// </summary> /// <param name="tex">bullet texture</param> /// <param name="position">initial position</param> /// <param name="velocity">inital velocity</param> /// <param name="src">source from which this button was spawned (e.g. player, enemy, etc.)</param> /// <param name="autoBB">automatically set BB</param> public Bullet(Texture2D tex, Vector2 position, Vector2 velocity, SpriteActor src, bool autoBB) : base(tex, position, velocity) { source = src; if (!autoBB) { sprite.setBB(spriteSize.X / 2 - (Resources.Bullet.Width / 2), spriteSize.Y / 2 - (Resources.Bullet.Height / 2), Resources.Bullet.Width, Resources.Bullet.Height); } sprite.boundingSphereRadius = 15; }
/// <summary> /// Add a sprite actor to the sprite manager to later be updated and drawn /// </summary> /// <param name="sprite">SpriteActor object to be added</param> public void addSpriteActor(SpriteActor sprite) { // If we're currently working on our list of sprites, add them to a temp if (updating) { tempList.Add(sprite); } else { addInternal(sprite); } }
// Checks if two sprites are colliding, uses internal RC_Framework collision handling private bool isColliding(SpriteActor s1, SpriteActor s2) { return(s1.sprite.collision(s2.sprite)); }