示例#1
0
 public Weapon(GraphicsContext g, Collision c, Texture2D t)
 {
     graphics = g;
     collisions = c;
     s = new Sprite (g, t);
     s.Center = new Vector2(0.5f, 0.8f);
 }
示例#2
0
 public static bool Colliding(Sprite s1, Sprite s2)
 {
     if(Vector3.DistanceSquared(s1.Position, s2.Position) < Math.Pow((s1.Height + s2.Height)/2, 2))
     {
         return true;
     }
     return false;
 }
示例#3
0
 public GameObj(GraphicsContext g, Texture2D t, Vector3 p)
 {
     sprite= new Sprite(g,t);
     pos=p;
     sprite.Position=pos;
     vel= Vector3.One;
     alive = true;
 }
示例#4
0
 public Item3(GraphicsContext g, Collision c, Vector3 pos, Item3.Type i)
 {
     type = i;
     s = new Sprite(g, new Texture2D("/Application/Assets/weapon3.png", false));
     s.Position = pos;
     graphics = g;
     col = c;
     IsAlive = true;
 }
示例#5
0
 public Enemy(GraphicsContext g, Collision c, Texture2D t, Vector3 pos)
 {
     graphics = g;
     collisions = c;
     s = new Sprite(g,t);
     s.Center = new Vector2(0.5f, 0.5f);
     s.Position = pos;
     s.Width = 40;
     isAlive = true;
 }
示例#6
0
 public Item(GraphicsContext g, Collision c, Vector3 pos, Item.Type i, Vector4 uc)
 {
     type = i;
     s = new Sprite(g, new Texture2D("/Application/Assets/weaponbase.png", false));
     s.Position = pos;
     s.SetColor(uc);
     graphics = g;
     col = c;
     IsAlive = true;
 }
示例#7
0
 public Bullet(GraphicsContext g, Collision c, float rot, Vector3 pos)
 {
     graphics = g;
     collisions = c;
     Texture2D t = new Texture2D("/Application/Assets/bullet.png",false);
     s = new Sprite (g, t);
     s.SetColor(new Vector4(1,1,1,1));
     isAlive = true;
     velocity = 10;
     s.Position = pos;
     s.Rotation = rot;
     s.Center = new Vector2(0.5f, 0.5f);
 }
示例#8
0
 public Player(GraphicsContext g, Collision c)
 {
     graphics = g;
     collisions = c;
     Texture2D tex = new Texture2D("/Application/Assets/player.png", false);
     s = new Sprite(g,tex);
     isAlive = true;
     movementSpeed = 5;
     rotSpeed = .05f;
     s.Position= new Vector3(25,25,0);
     duration = 50;
     size = 40;
     frames = 8;
     s.Width = size;
     s.Center= new Vector2(0.5f, 0.5f);
     s.Rotation = (float)Math.PI/2f;
     wlist = new List<Weapon>();
     health = 5;
 }
示例#9
0
        public static void RenderMenu()
        {
            // Clear the screen
            graphics.SetClearColor (0.6f, 0.1f, 0.1f, 0.0f);
            graphics.Clear ();

            elf1 = new Sprite(graphics, elf1Tex);
            elf1.Position = new Vector3(600, 100, 0);

            elf2 = new Sprite(graphics, elf2Tex);
            elf2.Position = new Vector3(50, 100, 0);

            elf2.Render ();
            elf1.Render ();

            menuDisplay.Announcement = "Destructive Santa!";
            menuDisplay.Announcement2 = "Press Enter to play the game.";
            menuDisplay.Announcement3 = "Press Select to See the High Score.";
            menuDisplay.Announcement4 = "Press Back to quit the game.";
            menuDisplay.Render();

            // Present the screen
            graphics.SwapBuffers ();
        }
示例#10
0
        public static void RenderHighScoreView()
        {
            graphics.SetClearColor (0.3f, 0.5f, 0.7f, 0.0f);
            graphics.Clear ();

            tree = new Sprite(graphics, treeTex);
            tree.Position = new Vector3(50, 200, 0);
            tree.Render ();

            menuDisplay.Announcement = null;
            menuDisplay.Announcement2 = holder + ": " + highscore;
            menuDisplay.Announcement3 = null;
            menuDisplay.Announcement4 = "Press Enter to restart or Back to quit.";
            menuDisplay.Render();

            // Present the screen
            graphics.SwapBuffers ();
        }
示例#11
0
        public static void NewGame(int sc)
        {
            gameOver = false;
            newLevel = true;
            score = sc;

            elf1Tex = new Texture2D("/Application/assets/elf1.png", false);
            elf2Tex = new Texture2D("/Application/assets/elf2.png", false);
            treeTex = new Texture2D("/Application/assets/tree.png", false);
            Texture2D bgTex = new Texture2D ("/Application/assets/snow.png", false);
            Texture2D catTex = new Texture2D ("/Application/assets/santa.png", false);
            Texture2D starTex= new Texture2D ("/Application/assets/house.png", false);
            Texture2D meteorTex= new Texture2D ("/Application/assets/car.png", false);
            Texture2D saucerTex= new Texture2D ("/Application/assets/police.png", false);
            Texture2D clawTex= new Texture2D ("/Application/assets/up_present.png", false);
            Texture2D meowTex = new Texture2D("/Application/assets/left_present.png", false);
            Texture2D hairballTex = new Texture2D("/Application/assets/right_present.png", false);
            gameOverTex = new Texture2D("/Application/assets/game_over.png", false);
            alphabetTex = new Texture2D("/Application/assets/alphabet.png", false);
            selectorTex = new Texture2D("/Application/assets/selector.png", false);

            alpha = new Sprite(graphics, alphabetTex);
            alpha.Position = new Vector3((graphics.Screen.Rectangle.Width / 2 - alpha.Width / 2)+340,
                                      graphics.Screen.Rectangle.Height / 2 - alpha.Height / 2, 0);
            selector = new Sprite(graphics, selectorTex);
            selector.Position = new Vector3((graphics.Screen.Rectangle.Width / 2 - selector.Width / 2) - 175,
                                      graphics.Screen.Rectangle.Height / 2 - selector.Height / 2, 0);

            go = new Sprite (graphics, gameOverTex);
            bg = new Sprite (graphics, bgTex);
            pieces = new List<GameObj> ();
            waiting = new List<Weapon> (); //weapons waiting to be rendered
            p = new Player (graphics, catTex, new Vector3 (30, 450, 0));
            pieces.Add (p);

            //add the enemies
            for( int i=0; i<3;i++){
                pieces.Add (new Star (graphics, starTex, new Vector3 (gen.Next(200,900),gen.Next(200,400),0), p));
                pieces.Add (new Star (graphics, starTex, new Vector3 (gen.Next(200,900),gen.Next(200,400),0), p));
                pieces.Add (new Meteor (graphics, meteorTex, new Vector3(gen.Next(200,900),gen.Next(200,400),0), p));
            }
            pieces.Add (new Saucer (graphics, saucerTex, new Vector3(gen.Next(200,900),gen.Next(200,400),0), p));

            //add weapons to the screne
            cl = new Claw(graphics, clawTex, new Vector3(gen.Next(200,900),gen.Next(200,400),0));
            cl.isActive = false;
            pieces.Add (cl);

            m = new SonicMeow(graphics, meowTex, new Vector3(gen.Next(200,900),gen.Next(200,400),0), new Vector3(0,0,0));
            m.isActive = false;
            pieces.Add (m);

            hb = new HairBall(graphics, hairballTex, new Vector3(gen.Next(200,900),gen.Next(200,400),0));
            hb.isActive = false;
            pieces.Add (hb);

            //to display the score
            UISystem.Initialize (graphics);
            Scene scene = new Scene ();

            scoreLabel = new Label (); //current score
            scoreLabel.X = 320;
            scoreLabel.Y = 10;
            scoreLabel.Width = 300;
            scoreLabel.Text = "Score: " + score;
            scene.RootWidget.AddChildLast (scoreLabel);

            LoadHighScore ();
            hsLabel = new Label (); //high score
            hsLabel.X = 620;
            hsLabel.Y = 10;
            hsLabel.Width = 300;
            hsLabel.Text = "High Score: " + highscore;
            scene.RootWidget.AddChildLast (hsLabel);

            UISystem.SetScene (scene, null);
        }