//Creates the next branches in the chain, if the conditions are right
        protected virtual void SpawnNext()
        {
            if (!hasBranched && currentLife > branchTime && positionInChain < repetitions)
            {
                Vector2 nextPos = new Vector2();
                float   rot;

                for (int i = 0; i < numBranches; i++)
                {
                    nextPos.X = position.X + (float)Math.Cos(rotation) * length;
                    nextPos.Y = position.Y + (float)Math.Sin(rotation) * length;
                    rot       = rotation + (float)((Game1.rand.NextDouble() - 0.5f) * 2) * (MathHelper.PiOver4 / 2);
                    Brancher b = new Brancher(nextPos, Vector2.Zero, tex, lifeTime, rot, positionInChain + 1, repetitions);
                    Player.AddGrower(b);
                }

                hasBranched = true;
            }
        }
示例#2
0
        private void HandleBranches(GamePadState gState)
        {
            if (gState.Buttons.RightShoulder == ButtonState.Pressed && Points >= POINTS_TO_BRANCH && !rbDown)
            {
                float rotation;

                if (gState.ThumbSticks.Right.Length() > 0)
                {
                    rotation = (float)Math.Atan2(-gState.ThumbSticks.Right.Y, gState.ThumbSticks.Right.X);
                }
                else
                {
                    rotation = (float)Math.Atan2(velocity.Y, velocity.X);
                }
                int      length = Math.Min((Math.Min(Points, 60) / POINTS_TO_BRANCH) + stats.BranchAmp, stats.MaxBranchLength);
                Brancher b      = new Brancher(position, Vector2.Zero, bTex3, BRANCH_SPEED, rotation, 0, length);
                growers.Add((Bullet)b);

                b = new Brancher(position, Vector2.Zero, bTex3, BRANCH_SPEED, rotation, 0, length);
                growers.Add((Bullet)b);
                b = new Brancher(position, Vector2.Zero, bTex3, BRANCH_SPEED, rotation, 0, length);
                growers.Add((Bullet)b);

                rbDown = true;
                if (Points <= 60)
                {
                    Points = 0;
                }
                else
                {
                    Points -= 60;
                }
            }
            if (gState.Buttons.RightShoulder == ButtonState.Released)
            {
                rbDown = false;
            }
        }
示例#3
0
 /// <summary>
 /// Adds a brancher bullet to the collidable bullets list
 /// </summary>
 /// <param name="b">The brancher to add</param>
 public static void AddGrower(Brancher b)
 {
     bullets.Add((Bullet)b);
 }