Ejemplo n.º 1
0
        protected override void Update(GameTime gameTime)
        {
            width = GraphicsDevice.Viewport.Width;
            height = GraphicsDevice.Viewport.Height;

            if (explosion > 0)
            {
                explosion--;
                if (explosion == 0)
                {
                    ship_pos.X = new Random().Next(1, 300);
                    if (ship_dir.X < 0)
                        ship_dir.X = ship_dir.X - 1;
                    else
                        ship_dir.X = -ship_dir.X - 1;
                }
                base.Update(gameTime);
                return;
            }

            ship_pos -= ship_dir;
            if (ship_pos.X <= 0 || ship_pos.X > width - (texture.Width*0.25))
            {
                ship_dir = -ship_dir;
            }

            var tc = TouchPanel.GetState();
            if (waiting > 0)
                {
                    waiting--;
                }
            else
                if (tc.Count() > 0)
                    {
                        rockets g = new rockets();
                        g.tex = rocket;
                        g.pos.X = tc[0].Position.X;
                        g.pos.Y = height - 10;
                        roke.Add(g);
                        waiting = 30;
                    }

                foreach (rockets ro in roke)
                {
                    ro.pos += new Vector2(0, -7);
                    if (ro.pos.Y <= 80 + (texture.Height*0.25) && ro.pos.Y >= texture.Height*0.25 && ro.pos.X >= ship_pos.X && ro.pos.X <= ship_pos.X + (texture.Width*0.25))
                    {
                        explosion = 30;

                        kill++;
                        explode_pos = new Vector2(ro.pos.X - (explode.Width) / 2, ship_pos.Y + 25);
                        score += kill;
                        roke.Clear();
                        break;
                    }
                    if (ro.pos.Y <= 0)
                    {
                        roke.Remove(ro);
                        life -= 1;
                        if (life == 0)
                        {
                            if (score > highscore)
                                highscore = score;
                            kill = 0;
                            score = 0;
                            ship_dir.X = -3;
                            life = 3;
                        }

                        break;
                    }

                }

            base.Update(gameTime);
        }
Ejemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     thing = GameObject.Find("f");
     rocketa = thing.GetComponent<rockets>();
 }
Ejemplo n.º 3
0
        protected override void Update(GameTime gameTime)
        {
            width  = GraphicsDevice.Viewport.Width;
            height = GraphicsDevice.Viewport.Height;

            if (explosion > 0)
            {
                explosion--;
                if (explosion == 0)
                {
                    ship_pos.X = new Random().Next(1, 300);
                    if (ship_dir.X < 0)
                    {
                        ship_dir.X = ship_dir.X - 1;
                    }
                    else
                    {
                        ship_dir.X = -ship_dir.X - 1;
                    }
                }
                base.Update(gameTime);
                return;
            }

            ship_pos -= ship_dir;
            if (ship_pos.X <= 0 || ship_pos.X > width - (texture.Width * 0.25))
            {
                ship_dir = -ship_dir;
            }

            var tc = TouchPanel.GetState();

            if (waiting > 0)
            {
                waiting--;
            }
            else
            if (tc.Count() > 0)
            {
                rockets g = new rockets();
                g.tex   = rocket;
                g.pos.X = tc[0].Position.X;
                g.pos.Y = height - 10;
                roke.Add(g);
                waiting = 30;
            }

            foreach (rockets ro in roke)
            {
                ro.pos += new Vector2(0, -7);
                if (ro.pos.Y <= 80 + (texture.Height * 0.25) && ro.pos.Y >= texture.Height * 0.25 && ro.pos.X >= ship_pos.X && ro.pos.X <= ship_pos.X + (texture.Width * 0.25))
                {
                    explosion = 30;

                    kill++;
                    explode_pos = new Vector2(ro.pos.X - (explode.Width) / 2, ship_pos.Y + 25);
                    score      += kill;
                    roke.Clear();
                    break;
                }
                if (ro.pos.Y <= 0)
                {
                    roke.Remove(ro);
                    life -= 1;
                    if (life == 0)
                    {
                        if (score > highscore)
                        {
                            highscore = score;
                        }
                        kill       = 0;
                        score      = 0;
                        ship_dir.X = -3;
                        life       = 3;
                    }

                    break;
                }
            }

            base.Update(gameTime);
        }