コード例 #1
0
        public IEntity[] Generate()
        {
            int         amount = Rand.Next(1, 4);
            List <Bird> birds  = new List <Bird>();

            for (int i = 0; i < amount; i++)
            {
                int   height = Rand.Next((int)Bird.Size.Y, window.Height / 3);
                int   x      = (int)-Bird.Size.X;
                float angle  = MathHelper.ToRadians(0);
                if (Rand.Next(2) == 0)//Right side
                {
                    x     = window.Width + (int)Bird.Size.X;
                    angle = MathHelper.ToRadians(180);
                }
                Bird b = new Bird(level,
                                  yat,
                                  spriteSheet,
                                  null,//hawk.CreateInstance(),
                                  Bird.Size,
                                  new Vector2(x, height),
                                  angle,
                                  xpgen.New(),
                                  window);
                birds.Add(b);
            }
            return(birds.ToArray());
        }
コード例 #2
0
        public IEntity[] Generate()
        {
            List <Mushroom> mushrooms = new List <Mushroom>();

            Block[] collisions = level.Manager.GetAllBlocks(BlockFilter.Top, false);
            int     maximum    = Rand.Next(2, 5);

            for (int i = 0; i < collisions.Length; i++)
            {
                if (Rand.Next(2) == 0)
                {
                    Vector2  spawn   = new Vector2(collisions[i].X, collisions[i].Y - Mushroom.Size.Y);
                    Fireball fb      = new Fireball(fireballSheet, null, Fireball.Size, new Vector2(0), Rand.Next(1, 6));
                    Mushroom current = new Mushroom(spriteSheet,
                                                    Mushroom.Size,
                                                    spawn,
                                                    level,
                                                    yat,
                                                    fb,
                                                    null,//sound.CreateInstance(),
                                                    xpgen.New(),
                                                    window);
                    mushrooms.Add(current);
                    if (mushrooms.Count >= maximum)
                    {
                        break;
                    }
                }
            }
            return(mushrooms.ToArray());
        }