Exemplo n.º 1
0
        public override void Simulate(SpaceGame g)
        {
            this.upperLeft += this.moving;
            if (upperLeft.X < 0)
            {
                upperLeft.X = g.ScreenDim.X;
            }
            if (upperLeft.X > g.ScreenDim.X)
            {
                upperLeft.X = 0;
            }
            if (upperLeft.Y < 0)
            {
                upperLeft.Y = g.ScreenDim.Y;
            }
            if (upperLeft.Y > g.ScreenDim.Y)
            {
                upperLeft.Y = 0;
            }

            if (rand.Next() % 40 == 0)
            {
                moving = RandomVector(2.0);
            }
        }
Exemplo n.º 2
0
 public virtual void Blast(SpaceGame g)
 {
     g.RemoveFromLists(this);
     g.CreateDebris(upperLeft);
     Spawner.SpawnChildren(g, upperLeft);
     g.AddScore(ScorePayout);
 }
 public override void Simulate(SpaceGame g)
 {
     base.Simulate(g);
     count++;
     if (Thrusting)
     {
         moving += .6 * (new Vector(0, 1) * rotationMatrix);
     }
 }
        public void Shoot(SpaceGame g)
        {
            SpaceBullet b = new SpaceBullet(upperLeft + 34 * ((new Vector(0, 1)) * rotationMatrix), worldSize);

            b.SetMoving(this.moving + 17 * ((new Vector(0, 1)) * rotationMatrix));
            //MessageBox.Show("" + upperLeft);

            g.AddBullet(b);
        }
 public void Simulate(SpaceGame g)
 {
     timer--;
     loc += moving;
     if (timer <= 0)
     {
         g.Blast(this);
     }
 }
 public override void Blast(SpaceGame g)
 {
     g.LoseLife();
     g.TimeInPlayer(60);
     g.CreateDebris(upperLeft);
     g.CreateDebris(upperLeft);
     g.CreateDebris(upperLeft);
     g.CreateDebris(upperLeft);
 }
Exemplo n.º 7
0
        private void g_GameOver(object sender, EventArgs e)
        {
            int    sc   = g.Score;
            string name = g.NameGotten;

            MessageBox.Show("Your Score: " + sc);
            g.StopGame();
            g = null;
            g = new SpaceGameScoreScreen(SpaceCanvas, ScoreLabel, SpaceCanvas.Width, SpaceCanvas.Height, new SpaceScore(sc, name));
        }
Exemplo n.º 8
0
 private void NewGameItem_Click(object sender, RoutedEventArgs e)
 {
     g.StopGame();
     g = null;
     g = new Asteroids.SpaceGame(SpaceCanvas, ScoreLabel, SpaceCanvas.Width, SpaceCanvas.Height);
     //SpaceLine l;
     //this.DataContext = g.Score;
     //ScoreLabel.DataContext = g.Score;
     g.GameOver += g_GameOver;
 }
Exemplo n.º 9
0
 public void Shoot(SpaceGame g, Point PlayerLocation)
 {
     if (rand.Next() % ShootMod == 0)
     {
         Vector      v = RandomVector(16.0);
         SpaceBullet b = new SpaceBullet(upperLeft + (10 * v), g.ScreenDim);
         b.SetMoving(v);
         g.AddBullet(b);
     }
 }
Exemplo n.º 10
0
        public override void Blast(SpaceGame g)
        {
            //base.Blast(g);
            g.RemoveFromAliens(this);

            g.CreateDebris(upperLeft);
            g.CreateDebris(upperLeft + RandomVector(5.0));
            g.CreateDebris(upperLeft + RandomVector(5.0));
            g.CreateDebris(upperLeft + RandomVector(5.0));
            //Spawner.SpawnChildren(g, upperLeft);
            g.AddScore(ScorePayout);
        }
Exemplo n.º 11
0
        public MainWindow()
        {
            InitializeComponent();
            g = new SpaceGameScoreScreen(SpaceCanvas, ScoreLabel, SpaceCanvas.Width, SpaceCanvas.Height, new SpaceScore(30, "ASS"));
            //g = new Asteroids.SpaceGame(SpaceCanvas, ScoreLabel, SpaceCanvas.Width, SpaceCanvas.Height);
            //SpaceLine l;
            //this.DataContext = g.Score;
            //ScoreLabel.DataContext = g.Score;

            g.GameOver += g_GameOver;

            //MessageBox.Show("Got here");
        }
Exemplo n.º 12
0
        public override void Simulate(SpaceGame g)
        {
            prev.X = upperLeft.X;
            prev.Y = upperLeft.Y;
            // Had to grab this from the base class
            // because I want to do a check and cancel the way
            // I get the line from it for the current frame.
            // This prevents teleporting bullets from killing everything between teleportation spots.

            this.upperLeft += this.moving;
            if (upperLeft.X < 0)
            {
                upperLeft.X = g.ScreenDim.X;
                prev.X      = upperLeft.X;
                prev.Y      = upperLeft.Y;
            }
            if (upperLeft.X > g.ScreenDim.X)
            {
                upperLeft.X = 0;
                prev.X      = upperLeft.X;
                prev.Y      = upperLeft.Y;
            }
            if (upperLeft.Y < 0)
            {
                upperLeft.Y = g.ScreenDim.Y;
                prev.X      = upperLeft.X;
                prev.Y      = upperLeft.Y;
            }
            if (upperLeft.Y > g.ScreenDim.Y)
            {
                upperLeft.Y = 0;
                prev.X      = upperLeft.X;
                prev.Y      = upperLeft.Y;
            }
            timer--;
            if (timer <= 0)
            {
                g.Blast(this);
            }
            //MessageBox.Show("sim");
        }
Exemplo n.º 13
0
        public virtual void Simulate(SpaceGame g)
        {
            this.upperLeft += this.moving;
            if (upperLeft.X < 0)
            {
                upperLeft.X = g.ScreenDim.X;
            }
            if (upperLeft.X > g.ScreenDim.X)
            {
                upperLeft.X = 0;
            }
            if (upperLeft.Y < 0)
            {
                upperLeft.Y = g.ScreenDim.Y;
            }
            if (upperLeft.Y > g.ScreenDim.Y)
            {
                upperLeft.Y = 0;
            }

            rotationMatrix.Rotate(rotationSpeed);
        }
Exemplo n.º 14
0
 public override void Blast(SpaceGame g)
 {
     g.RemoveFromLists(this);
 }
 public void SpawnChildren(SpaceGame g, Point loc)
 {
     g.CreateDebris(loc);
     g.CreateDebris(loc);
 }
 public void SpawnChildren(SpaceGame g, Point loc)
 {
     g.SpawnMediums(loc);
 }
Exemplo n.º 17
0
 public SpaceFactory(SpaceGame sg)
 {
     rand    = new Random();
     this.sg = sg;
 }
 public void SpawnChildren(SpaceGame g, Point loc)
 {
     g.SpawnSmalls(loc);
 }
 public void Blast(SpaceGame g)
 {
     g.RemoveFromDebris(this);
 }