private void AddCloud() { var lTexture = this.Textures[this.Random.Next(this.Textures.Length)]; var lSize = new Vector2(lTexture.Width, lTexture.Height); var lSpeed = this.Random.Next(50, 200); var lScale = MathHelper.Lerp(0.2f, 1.0f, (float)Math.Pow((lSpeed - 50) / 200f, 2)); var lCloud = new SimpleGameEntity { Renderer = new BasicRenderer(lTexture, lScale), MovementBehavior = new StraightMovementBehavior { Position = new Vector2(this.ScreenSize.X, this.Random.Next((int)-lSize.Y, (int)(this.ScreenSize.Y + lSize.Y))), Velocity = Vector2.UnitX * -lSpeed, Acceleration = Vector2.Zero, }, }; this.Add(lCloud); }
private void Add(SimpleGameEntity cloud) { var lCurrentNode = this.Clouds.First; while ((lCurrentNode != null) && (lCurrentNode.Value.MovementBehavior.Velocity.X > cloud.MovementBehavior.Velocity.X)) lCurrentNode = lCurrentNode.Next; if (lCurrentNode == null) this.Clouds.AddLast(cloud); else this.Clouds.AddBefore(lCurrentNode, cloud); }
/// <summary> /// Removes the given coin from the collection of active coins. /// </summary> /// <param name="coin">The coin to remove.</param> public void Remove(SimpleGameEntity coin) { this.Coins.Remove(coin); }
/// <summary> /// When a bird dies, we need to spawn a new coin in its place. /// </summary> /// <param name="bird">The bird that died.</param> private void Bird_OnDeath(BirdEntity bird) { this.BirdsKilled++; var lCoin = new SimpleGameEntity { MovementBehavior = new GravityMovementBehavior { TargetEntity = this.BeeManager.Bee, Position = bird.Position, Velocity = Vector2.UnitX * -300, Acceleration = Vector2.UnitX * (40 * this.PlayerManager.Player.BeeHoneycombAttraction), }, }; this.CoinManager.Add(lCoin); }
/// <summary> /// Adds a new active coin. /// </summary> /// <param name="coin">The coin to add.</param> public void Add(SimpleGameEntity coin) { coin.Renderer = new BasicRenderer(this.Texture); this.Coins.Add(coin); }