コード例 #1
0
        public static void Update(float dt, Player p)
        {
            arrowTimer += (dt / 1000) * speed;
            wave = (float)Math.Sin(arrowTimer) * amplitude;

            if (counter == 0)
            {
                p.Baby = null;
                p.HoldingBaby = false;
            }
            if (counter < 4)
            {
                p.BabyLife = p.MaxBabyLife / 2;
            }

            if (done)
            {
                doneTimer += dt / 1000;
            }

            if (doneTimer > 2.2f)
            {
                Config.tutorial = false;
            }

            if (cueCounter)
            {
                timer += dt;
                if (timer >= cueTime)
                {
                    if (counter == 0)
                    {
                        destination.X = Config.screenW / 17;
                        destination.Y = (Config.screenH / 4) + (Config.screenH / 10);
                        text = "welcome to glow, baby, glow!";
                    }
                    else if (counter == 1)
                    {
                        Enemy e = new Enemy(new Point(
                        Config.screenW / 3, (Config.screenH / 2) - Tile.Size), w);
                        w.EnemyManager.Add(e);
                        text = "shoot that nasty looking thing over there";
                        text2 = "using ";
                        if (Input.keys)
                        {
                            text2 += "shift";
                        }
                        else
                        {
                            text2 += "#";
                        }
                    }
                    else if (counter == 2)
                    {
                        destination.X = Config.screenW / 2 - (Config.screenW / 30);
                        destination.Y = Config.screenH - (Config.screenH / 5);
                        text = "so far so good";
                        text2 = "hey, go stand over there";

                    }
                    else if (counter == 3)
                    {
                        for (int i = 0; i < 50; i++)
                        {
                            Vector2 pos = new Vector2(Config.screenW / 2, Config.screenH / 5);
                            pos.X += (float)(Config.rand.NextDouble() * Config.screenW / 10) - Config.screenW / 20;
                            GooParticle gp = new GooParticle(pos);
                            w.ParticleManager.AddParticle(gp);
                        }
                        Baby b = new Baby(new Vector2(
                            Config.screenW / 2, Config.screenH / 5),
                            0, p.Index, w);
                        b.Velocity = new Vector2(0, 0);
                        p.Baby = b;
                        text = "catch the baby!";
                        text2 = "";
                    }
                    else if (counter == 4)
                    {
                        text = "keep the baby alive by rocking it";
                        if (Input.keys)
                        {
                            text2 = "hold shift, mash left and right";
                        }
                        else
                        {
                            text2 = "hold #, spin the control stick $";
                        }
                    }
                    else if (counter == 5)
                    {
                        destination.X = Config.screenW / 2;
                        destination.Y = (Config.screenH / 4) + (Config.screenH / 10);
                        text = "oh yeah, whatever you do-";
                        text2 = "dont drop the baby!!!";
                    }
                    else if (counter == 6)
                    {
                        destination.X = Config.screenW / 17;
                        destination.Y = (Config.screenH / 4) + (Config.screenH / 10);
                        text = "you can give the baby a little toss-";
                        if (Input.keys)
                        {
                            text2 = "hold " + "space" + ", aim, and release!";
                        }
                        else
                        {
                            text2 = "hold " + "@" + ", aim, and release!";
                        }
                    }
                    else if (counter == 7)
                    {
                        for (int i = 0; i < 5; i++)
                        {
                            w.EnemyManager.Spawn();
                        }
                        text = "take care of these guys";
                        text2 = "coins will give you points!";
                    }
                    else if (counter == 8)
                    {
                        text = "good job, man";
                        text2 = "you can figure the rest out yourself";
                        destination.X =  (Config.screenW / 20);
                        destination.Y = Config.screenH - (Config.screenH / 5);
                    }

                    counter++;
                    timer = 0;
                    cueCounter = false;

                    return;
                }
            }
            else
            {
                if (counter == 1)
                {
                    if (p.HitRect.Intersects(destination))
                    {
                        cueCounter = true;
                    }
                }
                else if (counter == 2)
                {
                    if (w.EnemyManager.Enemies.Count == 0)
                    {
                        cueCounter = true;
                    }
                }
                else if (counter == 3)
                {
                    if (p.HitRect.Intersects(destination))
                    {
                        cueCounter = true;
                    }
                }
                else if (counter == 4)
                {
                    if (p.HoldingBaby)
                    {
                        cueCounter = true;
                    }
                }
                else if (counter == 5)
                {
                    if (p.BabyLife >= p.MaxBabyLife - 1)
                    {
                        cueCounter = true;
                    }
                }
                else if (counter == 6)
                {
                    if (p.HitRect.Intersects(destination))
                    {
                        cueCounter = true;
                    }
                }
                else if (counter == 7)
                {
                    if (p.HitRect.Intersects(destination))
                    {
                        cueCounter = true;
                    }
                }
                else if (counter == 8)
                {
                    if (w.EnemyManager.Enemies.Count == 0)
                    {
                        cueCounter = true;
                    }
                }
                else if (counter == 9)
                {
                    if (p.HitRect.Intersects(destination))
                    {
                        cueCounter = true;
                        done = true;
                    }
                }
            }
        }
        public void Spawn()
        {
            while (true)
            {
                int index = Config.rand.Next(world.Tiles.Count());
                bool colliding = false;

                foreach (Tile t in world.Tiles)
                {
                    if (t != world.Tiles[index])
                    {
                        Rectangle testRect = new Rectangle(world.Tiles[index].Rect.X + 5,
                            world.Tiles[index].Rect.Y + 5 - Tile.Size,
                            world.Tiles[index].Rect.Width - 10,
                            world.Tiles[index].Rect.Height - 10);
                        Rectangle testRect2 = testRect;
                        Rectangle testRect3 = testRect;
                        testRect2.X -= Tile.Size;
                        testRect3.X += Tile.Size;

                        if (t.Rect.Intersects(testRect) ||
                            t.Rect.Intersects(testRect2) ||
                            t.Rect.Intersects(testRect3))
                        {
                            colliding = true;
                        }
                    }
                }

                if (!colliding)
                {
                    bool tooClose = false;
                    foreach (Player p in world.Players)
                    {
                        Vector2 v = new Vector2(world.Tiles[index].Rect.Center.X, world.Tiles[index].Rect.Center.Y);
                        float dist = Vector2.Distance(v, p.Position);
                        if (dist < spawnDistance)
                        {
                            tooClose = true;
                            break;
                        }
                    }
                    if (tooClose)
                    { break; }
                    else
                    {
                        Enemy e = null;
                        int enemyPorb = Config.rand.Next(100);

                        if (Config.tutorial)
                        {
                            enemyPorb = 100;
                        }

                        if (enemyPorb < 3)
                        {
                            e = new BossEnemy(new Point(world.Tiles[index].Rect.Center.X,
                                world.Tiles[index].Rect.Y), world);
                        }
                        else if (enemyPorb < 15)
                        {
                            e = new SpeedEnemy(new Point(world.Tiles[index].Rect.Center.X,
                                world.Tiles[index].Rect.Y), world);
                        }
                        else if (enemyPorb < 22)
                        {
                            e = new FatEnemy(new Point(world.Tiles[index].Rect.Center.X,
                                world.Tiles[index].Rect.Y), world);
                        }
                        else
                        {
                            e = new Enemy(new Point(world.Tiles[index].Rect.Center.X,
                                world.Tiles[index].Rect.Y), world);
                        }

                        e.MoveUp();
                        enemies.Add(e);
                        return;
                    }
                }
            }
        }
 public void Add(Enemy e)
 {
     toAdd.Add(e);
 }
 public void Remove(Enemy e)
 {
     toRemove.Add(e);
 }