Ejemplo n.º 1
0
        public override void Update()
        {
            //string pattern = "Arrowhead";
            //string trajectory = "Arc";
            //int numBullets = 10;
            //string bulletType = "BulletTypeA";
            int initialXPosition = Constants.K - (30 * ((Mobs.Count / 2) - 1));

            if (FrameCount == 0)
            {
                foreach (MobileEntity mob in Mobs)
                {
                    mob.Position = new Vector2((initialXPosition + 30 * Mobs.IndexOf(mob)), -30 * (Mobs.IndexOf(mob) + 1));
                    mob.Active   = true;
                }
            }
            foreach (MobileEntity mob in Mobs)
            {
                //mobs enter from top of screen for 5 seconds
                if (FrameCount < 5 * Constants.FPS)
                {
                    if (mob.Position.Y < Constants.F)
                    {
                        mob.UpdatePosition("down");
                    }
                    else if (mob.Position.Y < Constants.F + mob.MoveSpeed)
                    {
                        //fire(pattern, mob, bulletType, mob.Color, numBullets, trajectory);
                        if (this.willFire && mob.Active)
                        {
                            //List<MobileEntity>bullets = formation.SetFormation("BulletTypeA", mob.Position);
                            Formation formation = new Arrowhead(bulletMaker, mob.Position);
                            //List<MobileEntity> bulletFormation = BulletMaker.CreateBulletList("BulletTypeA", new Arrowhead(mob.Position));
                            Bullets.Add(MoveScriptMaker.CreateMoveScript("Arc", formation.SetFormation("BulletTypeA"), false));
                        }
                        mob.UpdatePosition("down");
                    }
                }
                else //mobs begin exiting one by one
                {
                    if (FrameCount > (5 + Mobs.IndexOf(mob)) * Constants.FPS)
                    {
                        mob.UpdatePosition("up");
                    }
                    if (mob.Position.Y < 0)
                    {
                        mob.Active = false;
                    }
                }
            }
            foreach (MoveScript formation in Bullets)
            {
                formation.Update();
            }
            FrameCount++;
        }
Ejemplo n.º 2
0
        public override void Update()
        {
            MobileEntity mob        = Mobs[0];
            string       bulletType = "BulletTypeB";

            if (FrameCount == 0)
            {
                mob.Position = new Vector2(Constants.P, -70);
                mob.Active   = true;
            }

            //ZigZag down for 4 seconds
            if (FrameCount <= 4 * Constants.FPS)
            {
                if (mob.Position.Y < Constants.A || mob.Position.Y >= Constants.D)
                {
                    mob.UpdatePosition("downRight");
                }
                else
                {
                    mob.UpdatePosition("downLeft");
                }
            }

            //zigzag left for 6 seconds
            else if (FrameCount <= 10 * Constants.FPS)
            {
                if (mob.Position.X >= 0 && mob.Position.X < Constants.C || mob.Position.X >= Constants.G && mob.Position.X < Constants.K || mob.Position.X >= Constants.O && mob.Position.X < Constants.S)
                {
                    mob.UpdatePosition("upLeft");
                }
                //the mobs move downLeft between C-G, K-O, S-V
                else if (mob.Position.X >= Constants.C && mob.Position.X < Constants.G || mob.Position.X >= Constants.K && mob.Position.X < Constants.O || mob.Position.X >= Constants.S && mob.Position.X < Constants.V)
                {
                    mob.UpdatePosition("downLeft");
                }
            }

            //zigzag right for 5 seconds
            else if (FrameCount <= 15 * Constants.FPS)
            {
                if (mob.Position.X >= 0 && mob.Position.X < Constants.C || mob.Position.X >= Constants.G && mob.Position.X < Constants.K || mob.Position.X >= Constants.O && mob.Position.X < Constants.S)
                {
                    mob.UpdatePosition("upRight");
                }
                //the mobs move downRight between C-G, K-O, S-V
                else if (mob.Position.X >= Constants.C && mob.Position.X < Constants.G || mob.Position.X >= Constants.K && mob.Position.X < Constants.O || mob.Position.X >= Constants.S && mob.Position.X < Constants.V)
                {
                    mob.UpdatePosition("downRight");
                }
            }
            //zigzag left for 7 seconds
            else if (FrameCount <= 22 * Constants.FPS)
            {
                if (mob.Position.X >= 0 && mob.Position.X < Constants.C || mob.Position.X >= Constants.G && mob.Position.X < Constants.K || mob.Position.X >= Constants.O && mob.Position.X < Constants.S)
                {
                    mob.UpdatePosition("upLeft");
                }
                //the mobs move downLeft between C-G, K-O, S-V
                else if (mob.Position.X >= Constants.C && mob.Position.X < Constants.G || mob.Position.X >= Constants.K && mob.Position.X < Constants.O || mob.Position.X >= Constants.S && mob.Position.X < Constants.V)
                {
                    mob.UpdatePosition("downLeft");
                }
            }

            //Sawtooth right
            else if (FrameCount <= 30 * Constants.FPS)
            {
                // mobs teleport down when on C,G,K,O, or S
                if ((FrameCount / Constants.FPS) >= 23 && (FrameCount / Constants.FPS) <= 23.5)
                {
                    mob.UpdatePosition("down");
                    mob.UpdatePosition("down");
                }
                else if ((FrameCount / Constants.FPS) >= 25 && (FrameCount / Constants.FPS) <= 25.5)
                {
                    mob.UpdatePosition("down");
                    mob.UpdatePosition("down");
                }
                else if ((FrameCount / Constants.FPS) >= 27 && (FrameCount / Constants.FPS) <= 27.5)
                {
                    mob.UpdatePosition("down");
                    mob.UpdatePosition("down");
                }
                else if ((FrameCount / Constants.FPS) >= 29 && (FrameCount / Constants.FPS) <= 29.5)
                {
                    mob.UpdatePosition("down");
                    mob.UpdatePosition("down");
                }

                //the mobs move upRight otherwise
                else
                {
                    mob.UpdatePosition("upRight");
                    mob.UpdatePosition("upRight");
                }
            }

            else if (FrameCount <= 38 * Constants.FPS)
            {
                // mobs teleport down when on C,G,K,O, or S
                if ((FrameCount / Constants.FPS) >= 31 && (FrameCount / Constants.FPS) <= 31.5)
                {
                    mob.UpdatePosition("down");
                    mob.UpdatePosition("down");
                }
                else if ((FrameCount / Constants.FPS) >= 33 && (FrameCount / Constants.FPS) <= 33.5)
                {
                    mob.UpdatePosition("down");
                    mob.UpdatePosition("down");
                }
                else if ((FrameCount / Constants.FPS) >= 35 && (FrameCount / Constants.FPS) <= 35.5)
                {
                    mob.UpdatePosition("down");
                    mob.UpdatePosition("down");
                }
                else if ((FrameCount / Constants.FPS) >= 37 && (FrameCount / Constants.FPS) <= 37.5)
                {
                    mob.UpdatePosition("down");
                    mob.UpdatePosition("down");
                }

                //the mobs move upRight otherwise
                else
                {
                    mob.UpdatePosition("upLeft");
                    mob.UpdatePosition("upLeft");
                }
            }

            //small arc arcoss screen to exit
            else if (FrameCount > 38 * Constants.FPS)
            {
                if (FrameCount % 1 == 0)
                {
                    mob.UpdatePosition("right");
                }

                if (FrameCount % 1 == 0)
                {
                    mob.Position = new Vector2(mob.Position.X, Constants.H - 40 + (-(float)Math.Sin(mob.Position.X / 200) * 100));
                }
            }

            //bullets shoot every second after 4 seconds have passed
            if (FrameCount % 60 == 0 && mob.Active && FrameCount > 4 * Constants.FPS && mob.Position.X < 670)
            {
                Formation formation = new ZigZagFormation(new BulletMaker(), mob.Position);
                Bullets.Add(MoveScriptMaker.CreateMoveScript("ZigZag", formation.SetFormation(bulletType), false));
            }

            //changed the dead area outside the window so it wouldn't kill mobs when they spawn just off screen
            if (mob.Position.X < -60 || mob.Position.X > 670)
            {
                mob.Color = Color.TransparentBlack;
                //this.Active = false;
            }

            //if(frameCount>45*Constants.FPS)
            //{
            //    this.Active = false;
            //}
            foreach (MoveScript formation in Bullets)
            {
                formation.Update();
            }
            FrameCount++;
        }
Ejemplo n.º 3
0
        public override void Update()
        {
            MobileEntity mob        = Mobs[0];
            string       bulletType = "BulletTypeB";

            if (FrameCount == 0)
            {
                mob.Position = new Vector2(Constants.P, -70);
                mob.Active   = true;
            }

            //start sin wave from top left
            if (FrameCount <= 11 * Constants.FPS)
            {
                if (FrameCount % 1 == 0)
                {
                    mob.UpdatePosition("right");
                }

                if (FrameCount % 1 == 0)
                {
                    mob.Position = new Vector2(mob.Position.X, Constants.E + (-(float)Math.Cos(mob.Position.X / 50) * 150));
                }
            }

            //sin wave back right
            else if (FrameCount <= 22 * Constants.FPS)
            {
                if (FrameCount % 1 == 0)
                {
                    mob.UpdatePosition("left");
                }

                if (FrameCount % 1 == 0)
                {
                    mob.Position = new Vector2(mob.Position.X, Constants.E + (-(float)Math.Cos(mob.Position.X / 50) * 150));
                }
            }

            //diagnal from top left
            else if (FrameCount <= 33 * Constants.FPS)
            {
                //mobs enter from top left corner of screen, move to center
                if (mob.Position.X <= 327)
                {
                    mob.UpdatePosition("downRight");
                }
                //after hitting center, mobs leave top right
                else if (mob.Position.X >= 327)
                {
                    mob.UpdatePosition("upRight");
                }
            }

            //diagnal from top right
            else if (FrameCount <= 43 * Constants.FPS)
            {
                //mobs enter from top right corner of screen, move to center
                if (mob.Position.X >= 327)
                {
                    mob.UpdatePosition("downLeft");
                }
                //after hitting center, mobs leave top left
                else if (mob.Position.X <= 327)
                {
                    mob.UpdatePosition("upLeft");
                }
            }

            //sin wave from left to offscreen right
            else if (FrameCount > 43 * Constants.FPS)
            {
                if (FrameCount % 1 == 0)
                {
                    mob.UpdatePosition("right");
                }

                if (FrameCount % 1 == 0)
                {
                    mob.Position = new Vector2(mob.Position.X, Constants.E + (-(float)Math.Sin(mob.Position.X / 10) * 150));
                }
            }

            //bullets shoot every second after 4 seconds have passed
            if (FrameCount % 60 == 0 && mob.Active && FrameCount > 4 * Constants.FPS)
            {
                Formation formation = new ZigZagFormation(new BulletMaker(), mob.Position);
                Bullets.Add(MoveScriptMaker.CreateMoveScript("ZigZag", formation.SetFormation(bulletType), false));
            }

            //changed the dead area outside the window so it wouldn't kill mobs when they spawn just off screen
            if (mob.Position.X < -60 || mob.Position.X > 670)
            {
                mob.Active = false;
            }
            if (mob.Position.X < -60 || mob.Position.X > 670)
            {
                mob.Color = Color.Red;
            }
            foreach (MoveScript formation in Bullets)
            {
                formation.Update();
            }
            FrameCount++;
        }