Ejemplo n.º 1
0
        public override void TakeHit(Sonic hitter, GameLevel level, out bool blocking)
        {
            blocking = true;
            hitter.Coins++;
            active = false;
            MovingAnchoredAnimation maa = new MovingAnchoredAnimation(3.0f, new Point[] { new Point((int)this.Location.X, (int)this.Location.Y+48), new Point((int)this.Location.X, (int)this.Location.Y + 144) }, 16, 0, 3, 0, 48, 48, Coin.SpinCoin, true);

            (XSonicGame.CurrentGame.Services.GetService(typeof(AnimationManager)) as AnimationManager).Add(maa);
            (XSonicGame.CurrentGame.Services.GetService(typeof(AudioManager)) as AudioManager).PlaySound("coins");
        }
Ejemplo n.º 2
0
        public BloodSplatter(Vector2 centerLocation, int splatterCount, int distance)
        {
            if(bloodSS == null) bloodSS = (XSonicGame.CurrentGame.Services.GetService(typeof(AnimationManager)) as AnimationManager).Content.Load<Texture2D>("Blood");

            Point[] targetPoints = XSonicGame.GetParabolic(centerLocation.X, centerLocation.Y, 800.0, 40.0, splatterCount);

            int minX = int.MaxValue, maxX = int.MinValue;
            for (int x = 0; x < targetPoints.Length; x++)
            {
                if (targetPoints[x].X > maxX)
                    maxX = targetPoints[x].X;
                if (targetPoints[x].X < minX)
                    minX = targetPoints[x].X;
            }
            for (int x = 0; x < targetPoints.Length; x++)
            {
                targetPoints[x].X += ((maxX - minX) / 2);

                double x1 = (double)targetPoints[x].X - centerLocation.X;
                double y1 = (double)targetPoints[x].Y - centerLocation.Y;

                double mag = Math.Sqrt(x1 * x1 + y1 * y1);

                x1 = x1 / mag;
                y1 = y1 / mag;

                x1 *= (double)distance;
                y1 *= (double)distance;

                targetPoints[x].X = (int)Math.Round(x1 + centerLocation.X);
                targetPoints[x].Y = (int)Math.Round(-y1 + centerLocation.Y);
            }
            Random r = new Random();
            for (int x = 0; x < targetPoints.Length; x++)
            {
                MovingAnchoredAnimation maa = new MovingAnchoredAnimation(6.0f + ((float)(r.Next(0, 601) - 300) / 100.0f), new Point[]{ new Point((int)centerLocation.X, (int)centerLocation.Y), targetPoints[x]}, 4, 0, 3, 0, 48, 48, bloodSS, false);
                (XSonicGame.CurrentGame.Services.GetService(typeof(AnimationManager)) as AnimationManager).Add(maa);
            }
        }
Ejemplo n.º 3
0
        public void Do(XSonicGame game, Sonic player, AudioManager audio, GameTime gameTime)
        {
            if (doing)
            {
                if (gameTime.TotalGameTime.TotalMilliseconds - doingAt >= 3000.0f && doingAt != -1.0f)
                {
                    doing = false;
                    doingAt = -1.0f;
                    player.IsAlive = true;

                    game.ResetLevel();
                }
                else
                {
                    //base.Update(gameTime);
                    return;
                }
            }

            if (!player.IsAlive)
            {
                BloodSplatter bs = new BloodSplatter(player.Location, 5000, 30);
                if (player.HasBonus)
                {
                    player.HasBonus = false;
                    doingBonus = false;

                    player.IsAlive = true;

                    game.ResetAfterBonus();
                }
                else if (!doing)
                {
                    doing = true;
                    Point[] deathAnimationPoints = XSonicGame.GetParabolic(player.Location.X, player.Location.Y, 17.25f, 0.8f, 17);//new Point[] { new Point((int)player.Location.X, (int)player.Location.Y), new Point((int)player.Location.X, (int)player.Location.Y + 144), new Point((int)player.Location.X - 96, (int)player.Location.Y + 96), new Point((int)player.Location.X - 96, (int)player.Location.Y - 96) };
                    MovingAnchoredAnimation maa = new MovingAnchoredAnimation(5.0f, deathAnimationPoints, 2, 3, 6, 6, 48, 48, player.SpriteSheet, false);
                    (XSonicGame.CurrentGame.Services.GetService(typeof(AnimationManager)) as AnimationManager).Add(maa);
                    player.Lives--;
                    if (player.Lives >= 0)
                    {
                        audio.PlaySound("1down");
                        doingAt = gameTime.TotalGameTime.TotalMilliseconds;
                    }
                    else
                    {
                        audio.PlaySpecialSong("gameover");
                    }
                }
            }

            if (player.HasWon)
            {
                if(!game.OnLastLevel())
                {
                    doingBonus = false;
                    player.HasBonus = false;
                    game.NextLevel();
                }
            }
            if (player.HasBonus && !doingBonus)
            {
                doingBonus = true;

                game.NextBonusLevel();
            }
        }