Esempio n. 1
0
        public override void Activate(bool instancePreserved)
        {
            IsoTileMap world;
            Camera camera;

            if (!instancePreserved)
            {
                Color myColor = Color.FromNonPremultiplied(255, 10, 10, 128);
                Console.WriteLine(myColor);
                ContentManager content = ScreenManager.Game.Content;
                manager = GameManager.Instance;
                manager.InMultiplayer = false;

                escapePressed = new InputAction(null, new Keys[] { Keys.Escape }, true);
                uPressed = new InputAction(null, new Keys[] { Keys.U }, true);

                // Called when the screen is first activated.. can initialize here
                camera = new Camera(ScreenManager.Game);
                camera.Autonomous = false;
                manager.Camera = camera;

                world = new IsoTileMap(camera);
                world.Cursor.Active = true;
                world.Cursor.Colour = Color.Blue;
                world.LoadFromFile(content, "Content/Maps/MPMap.map");
                scorebg = content.Load<Texture2D>("UITextures/scorebg");
                scoreFont = content.Load<SpriteFont>("Fonts/GUIFont");
                gameOverFont = content.Load<SpriteFont>("Fonts/GameOverFont");
                world.SetCameraToWorldBounds();
                manager.TileMap = world;

                                // Set up a fresh game state
                GameManager.Instance.GameState = new GameState(GameManager.Instance);

                manager.GameState.Characters = new Character[26];

                Character playerChar = new Character(manager);
                manager.GameState.Characters[0] = playerChar;
                playerChar.Initialize(1, new Vector2(350, 350));
                playerChar.IsPlayer = true;
                player = playerChar;
                characters.Add(playerChar);
                actionBar = new ActionBar(player);
                playerFrame = new PlayerFrame(player);
                playerChar.Team = Team.BLUE;
                player.CurrentFocus = 25;
                player.CurrentHealth = 100;
                player.CrystalCount = 500;

                manager.MyID = 0;

                for (int i = 1; i < 26; i++)
                {
                    NPC c = new NPC(manager);
                    manager.GameState.Characters[i] = c;
                    bool canPlace = false;
                    Vector2 pos = Vector2.Zero;
                    while (!canPlace)
                    {
                        int xPos = randomizer.Next(32, manager.TileMap.GetWidthInPixels() - 32);
                        int yPos = randomizer.Next(32, manager.TileMap.GetHeightInPixels() - 32);
                        pos = new Vector2(xPos, yPos);
                        if ((pos - manager.GameState.Characters[0].WorldPosition).Length() > 1000)
                        {
                            canPlace = true;
                        }
                    }
                    c.Initialize(randomizer.Next(0, 4), pos);
                }

                /*
                NPC char1 = new NPC(manager);
                char1.Initialize(0, new Vector2(450, 350));
                characters.Add(char1);
                char1.Name = "Player1";

                NPC char2 = new NPC(manager);
                char2.Initialize(1, new Vector2(550, 350));
                characters.Add(char2);
                char2.Name = "Player2";
                char2.Team = Team.RED;
                char2.CurrentHealth = char2.MaxHealth / 2;

                NPC char3 = new NPC(manager);
                char3.Initialize(2, new Vector2(650, 350));
                characters.Add(char3);
                char3.Name = "Player3";

                NPC char4 = new NPC(manager);
                char4.Initialize(3, new Vector2(750, 350));
                characters.Add(char4);
                char4.Name = "Player4";
                char4.Team = Team.RED;
                char4.CurrentHealth = char2.MaxHealth / 2;
                */
                /*
                Random randomizer = new Random();
                for (int i = 0; i < 20; i++)
                {

                    Character chari = new Character(manager);
                    chari.Initialize(3, new Vector2(randomizer.Next(0,4000),randomizer.Next(0, 4000)));
                    characters.Add(chari);
                    chari.Name = "Player4";
                    chari.Team = Team.RED;
                    chari.CurrentHealth = char2.MaxHealth;
                    Console.WriteLine("ok");
                }
                */

                //manager.GameState.Characters = new[] { playerChar, char1, char2, char3, char4 };
                namePlates = new List<NamePlate>();
                radar = new Radar(playerChar);
                radar.Scale = 0.5f;
                radar.Alpha = 0.8f;
                radar.SnapToCorner(Radar.Corner.TopRight);

                foreach (Character c in manager.GameState.Characters)
                {
                    if (c != player)
                    {
                        NamePlate np = new NamePlate(c);
                        namePlates.Add(np);
                    }
                }

                for (int i = 0; i < 120; i++)
                {
                    PickUp pu = new PickUp(manager);
                    pickUps.Add(pu);
                    pu.Initialize(0);
                }

                bgMusic = ScreenManager.Game.Content.Load<Song>("Audio/Demo_FinalFight");
                MediaPlayer.IsRepeating = true;
                MediaPlayer.Play( bgMusic );
                MediaPlayer.Volume = 0.4f;
                cPress = new InputAction(null, new Keys[] { Keys.C }, true);
                bPress = new InputAction(null, new Keys[] { Keys.B }, true);
            }
        }
Esempio n. 2
0
        public override void Activate( bool instancePreserved )
        {
            if ( !instancePreserved )
            {
                ContentManager content = ScreenManager.Game.Content;

                // The escape button handler to open the pause menu
                escapePressed = new InputAction( null, new Keys[] { Keys.Escape }, true );

                // The u button handler to open the upgrades screen
                uPressed = new InputAction( null, new Keys[] { Keys.U }, true );

                // Create world/camera
                Camera camera = new Camera( ScreenManager.Game );
                camera.Autonomous = false;
                GameManager.Instance.Camera = camera;
                IsoTileMap world = new IsoTileMap( camera );
                //world.Cursor.Active = true;
                //world.Cursor.Colour = Color.Blue;
                world.LoadFromFile( content, "Content/Maps/MPMap.map" );
                world.SetCameraToWorldBounds();
                GameManager.Instance.TileMap = world;

                // Set up the game UI
                playerChar = GameManager.Instance.GameState.Characters[GameManager.Instance.MyID];
                playerChar.IsPlayer = true;
                playerFrame = new PlayerFrame( playerChar );
                actionBar = new ActionBar( playerChar );
                radar = new Radar( playerChar );
                radar.Scale = 0.6f;
                radar.Alpha = 0.8f;
                radar.SnapToCorner( Radar.Corner.TopRight );

                // NamePlates
                namePlates = new NamePlate[GameManager.Instance.GameState.Characters.Length];
                for ( int i = 0; i < namePlates.Length; ++i )
                {
                    namePlates[i] = new NamePlate( GameManager.Instance.GameState.Characters[i] );
                }

                // Load fonts
                scoreBoardFont = content.Load<SpriteFont>( "Fonts/ScoreBoardFont" );
                msgFont = content.Load<SpriteFont>( "Fonts/ScoreBoardFont" );

                // Start listening for packets from the server
                GameManager.Instance.RegisterForPackets( this );
            }
        }