public GameStateMars(ContentManager c, Game1 g)
        {
            Game = g;
            Content = c;

            rockMap = new RockMap(Content);

            windowRect = new Rectangle(0, 0, 1500, int.MaxValue);

            inputHandler = new InputHandler();

            drillSound = Content.Load<SoundEffect>("Drill");
            thrustSound = Content.Load<SoundEffect>("Thrust");
            drillSoundInstance = Content.Load<SoundEffect>("Drill").CreateInstance();
            drillSoundInstance.IsLooped = true;
            thrustSoundInstance = Content.Load<SoundEffect>("Thrust").CreateInstance();
            thrustSoundInstance.IsLooped = true;
            boomSound = Content.Load<SoundEffect>("Boom");

            sdSystem = new TextSystem("profont.png", Content);
            sdSystem.resetString(new Vector2(5, 725));
            sdSystem.addString("Out of energy. Press \\3ESC to self-destruct");

            bg = new Sprite("mars-bg.png", Content, new Vector2(0, 0), false);
            player = new Player("miner.png", Content, new Vector2(windowRect.Width/2, 25));
            shop = new Sprite("shop.png", Content, new Vector2(500, 25));
            deadOverlay = new Sprite("dead.png", Content, new Vector2(0, 0), false);

            otherPlayers = new Dictionary<string, Player>();

            mapOffset = new Vector2(0,-125);

            thrusters = false;
            transY = 0f;
            transX = 0f;

            drillTime = 0f;

            redTexture = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1);
            redTexture.SetData(new Color[] { Color.Red });
            blueTexture = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1);
            blueTexture.SetData(new Color[] { Color.Blue });
            greenTexture = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1);
            greenTexture.SetData(new Color[] { Color.Green });
            blackTexture = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1);
            blackTexture.SetData(new Color[] { Color.Black });
        }
Beispiel #2
0
        public GameManager()
        {
            //initalise the game
            gameState = gameState.programInit;
            menu = menus.main;

            hasJoy = false;

            messageBuffer = new string[50];
            for (int i = 0; i < 50; i++)
            {
                messageBuffer[i] = "";
            }

            cammoving = false;
            camAddX = 0;
            camAddY = 0;

            player = new Player(new Vector3(0, 0, 0), Quaternion.IDENTITY);
        }
Beispiel #3
0
        private void label2_Click(object sender, EventArgs e)
        {
            if (rbPlayerVsComputer.Checked)
                {
                    NewPlayer player = new NewPlayer();
                    player.Player2Name = "Computer";
                    player.ShowDialog();
                    if (player.DialogResult == DialogResult.OK)
                    {
                        Player p = new Player(player.Player1Name);
                        pbPlayer1.Location = TheGame.PlayerOneStarting;
                        p.CurrentLocation = TheGame.PlayerOneStarting;
                        pbPlayer1.Image = ilFigures.Images[player.Figure1];
                        TheGame.Players[0] = p;
                        p = new Player(player.Player2Name);
                        pbPlayer2.Location = TheGame.PlayerTwoStarting;
                        p.CurrentLocation = TheGame.PlayerTwoStarting;
                        pbPlayer2.Image = ilFigures.Images[player.Figure2];
                        TheGame.Players[1] = p;
                        TheGame.stopSound("starting");
                        lbPlayerOneName.Text = TheGame.Players[0].Name;
                        lbPlayerOnePosition.Text = TheGame.Players[0].CurrentPosition.ToString();
                        lbPlayerTwoName.Text = TheGame.Players[1].Name;
                        lbPlayerTwoPosition.Text = TheGame.Players[1].CurrentPosition.ToString();
                        pnStarting.Visible = false;
                    }

                }
                else
                {
                    NewPlayer player = new NewPlayer();
                    player.Player2Name = "Player";
                    player.ShowDialog();
                    if (player.DialogResult == DialogResult.OK)
                    {
                        Player p = new Player(player.Player1Name);
                        pbPlayer1.Location = TheGame.PlayerOneStarting;
                        p.CurrentLocation = TheGame.PlayerOneStarting;
                        pbPlayer1.Image = ilFigures.Images[player.Figure1];
                        TheGame.Players[0] = p;
                        p = new Player(player.Player2Name);
                        pbPlayer2.Location = TheGame.PlayerTwoStarting;
                        p.CurrentLocation = TheGame.PlayerTwoStarting;
                        pbPlayer2.Image = ilFigures.Images[player.Figure2];
                        TheGame.Players[1] = p;
                        TheGame.stopSound("starting");
                        lbPlayerOneName.Text = TheGame.Players[0].Name;
                        lbPlayerOnePosition.Text = TheGame.Players[0].CurrentPosition.ToString();
                        lbPlayerTwoName.Text = TheGame.Players[1].Name;
                        lbPlayerTwoPosition.Text = TheGame.Players[1].CurrentPosition.ToString();
                        pnStarting.Visible = false;
                    }
                }
        }
Beispiel #4
0
 public void newGame()
 {
     Edges = new LinkedList<int>();
     Edges.AddLast(5);
     Edges.AddLast(10);
     Edges.AddLast(15);
     Edges.AddLast(20);
     Up = new LinkedList<KeyValuePair<int, int>>();
     Up.AddLast(new KeyValuePair<int, int>(3, 15));
     Up.AddLast(new KeyValuePair<int, int>(12, 20));
     Up.AddLast(new KeyValuePair<int, int>(18, 24));
     Down = new LinkedList<KeyValuePair<int, int>>();
     Down.AddLast(new KeyValuePair<int, int>(9,1));
     Down.AddLast(new KeyValuePair<int, int>(14,8));
     Down.AddLast(new KeyValuePair<int, int>(17, 15));
     Down.AddLast(new KeyValuePair<int, int>(21, 13));
     Turn = 0;
     FinalPosition = 25;
     rand = new Random();
     Players = new Player[2];
     PlayerOneStarting = new Point(17, 457);
     PlayerTwoStarting = new Point(63, 503);
     playSound("starting", true);
 }
 public void sendLocationUpdate(Player p)
 {
     string m = 'm' + playerId;
     m += (int)p.position.X;
     m += "," + (int)p.position.Y;
     sendMessage(m);
 }