Ejemplo n.º 1
0
        /// <summary>
        /// Denotes that the bee has been hit by smoke.
        /// </summary>
        /// <param name="smokePuff">The smoke puff which the be was hit by.</param>
        public void HitBySmoke(SmokePuff smokePuff)
        {
            if (!isHitBySmoke)
            {
                // Causes the bee to fly away from the smoke puff
                Vector2 escapeVector = Bounds.Center.GetVector() - smokePuff.Bounds.Center.GetVector();
                escapeVector.Normalize();
                escapeVector *= random.Next(3, 6);

                velocity = escapeVector;

                isHitBySmoke = true;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handle the interaction of the bees with other game components.
        /// </summary>
        /// <param name="gameTime">Game time information.</param>
        /// <param name="isBeeKeeperCollideWithVat">Whether the beekeeper is currently touching the vat.</param>
        /// <param name="isBeeKeeperCollideWithBeehive">Whether the beekeeper is currently touching a beehive.</param>
        private void HandleBeeInteractions(GameTime gameTime, bool isBeeKeeperCollideWithVat,
                                           bool isBeeKeeperCollideWithBeehive)
        {
            // Goes over all the bees
            foreach (Bee bee in bees)
            {
                // Check for smoke collisions
                SmokePuff intersectingPuff = beeKeeper.CheckSmokeCollision(bee.Bounds);

                if (intersectingPuff != null)
                {
                    bee.HitBySmoke(intersectingPuff);
                }

                // Check for vat collision
                if (vat.Bounds.HasCollision(bee.Bounds))
                {
                    bee.Collide(vat.Bounds);
                }
                // Check for beekeeper collision
                if (beeKeeper.Bounds.HasCollision(bee.Bounds))
                {
                    if (!bee.IsBeeHit && !isBeeKeeperCollideWithVat && !beeKeeper.IsStung && !beeKeeper.IsFlashing &&
                        !isBeeKeeperCollideWithBeehive)
                    {
                        jar.DecreaseHoneyByPercent(20);
                        beeKeeper.Stung(gameTime.TotalGameTime);
                        AudioManager.PlaySound("HoneyPotBreak");
                        AudioManager.PlaySound("Stung");
                    }

                    bee.Collide(beeKeeper.Bounds);
                }
                // Soldier bee chase logic
                if (bee is SoldierBee)
                {
                    SoldierBee SoldierBee = bee as SoldierBee;
                    SoldierBee.DistanceFromBeeKeeper =
                        (Vector2.Distance(beeKeeper.Bounds.GetVector(), SoldierBee.Bounds.GetVector()));

                    SoldierBee.BeeKeeperVector = beeKeeper.Bounds.GetVector() - SoldierBee.Bounds.GetVector();
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Denotes that the bee has been hit by smoke.
        /// </summary>
        /// <param name="smokePuff">The smoke puff which the be was hit by.</param>
        public void HitBySmoke(SmokePuff smokePuff)
        {
            if (!isHitBySmoke)
            {
                // Causes the bee to fly away from the smoke puff
                Vector2 escapeVector = Bounds.Center.GetVector() - smokePuff.Bounds.Center.GetVector();
                escapeVector.Normalize();
                escapeVector *= random.Next(3, 6);

                velocity = escapeVector;
                
                isHitBySmoke = true;
            }
        }