/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here GameWorld.Initialize(0, 5700, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height, new Vector2(0, 9.8f)); GameWorld.ViewPortXOffset = 0; SpriteCreators.Load("Content\\spritesheet.txt"); // Create the texture manager textureManager = new TextureManager(Content); // Now load the sprite creator factory helper factory = GameObjectFactory.Instance; factory.Initialize(textureManager); cannonManager = new CannonManager(); cannonGroups = new List<CannonGroups>(); client = new ClientNetworking(); client.Connect(); client.ActionHandler["shoot"] = new EventHandler(this.HandleNetworkShoot); client.ActionHandler["create"] = new EventHandler(this.HandleNetworkCreate); // Add a few sprite creators factory.AddCreator((int)GameObjectTypes.CAT, SpriteCreators.CreateCat); factory.AddCreator((int)GameObjectTypes.DOG, SpriteCreators.CreateDog); factory.AddCreator((int)GameObjectTypes.BOOM, SpriteCreators.CreateBoom); factory.AddCreator((int)GameObjectTypes.WOOD1, SpriteCreators.CreateWood1); factory.AddCreator((int)GameObjectTypes.WOOD2, SpriteCreators.CreateWood2); factory.AddCreator((int)GameObjectTypes.WOOD3, SpriteCreators.CreateWood3); factory.AddCreator((int)GameObjectTypes.WOOD4, SpriteCreators.CreateWood4); factory.AddCreator((int)GameObjectTypes.PLATFORM_LEFT, SpriteCreators.CreatePlatformLeft); factory.AddCreator((int)GameObjectTypes.PLATFORM_MIDDLE, SpriteCreators.CreatePlatformMiddle); factory.AddCreator((int)GameObjectTypes.PLATFORM_RIGHT, SpriteCreators.CreatePlatformRight); factory.AddCreator((int)GameObjectTypes.CANNON, SpriteCreators.CreateCannon); factory.AddCreator((int)GameObjectTypes.CANNONWHEEL, SpriteCreators.CreateCannonWheel); factory.AddCreator((int)GameObjectTypes.POWERMETERBAR, SpriteCreators.CreatePowerMeterBar); factory.AddCreator((int)GameObjectTypes.POWERMETERTAB, SpriteCreators.CreatePowerMeterTab); mapEditor = new MapEditor(Window, client, cannonManager, cannonGroups); base.Initialize(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here GameWorld.Initialize(0, 12234 - ( 1080 * 2), this.Window.ClientBounds.Width, this.Window.ClientBounds.Height, new Vector2(0, 9.8f)); GameWorld.ViewPortXOffset = 0; SpriteCreators.Load("Content\\spritesheet.txt"); MapLoaded = false; // Create the texture manager textureManager = new TextureManager(Content); //Create the audio manager AudioManager.Instance.Initialize(Content); // Now load the sprite creator factory helper factory = GameObjectFactory.Instance; factory.Initialize(textureManager); cannonManager = new CannonManager(); cannonGroups = new List<CannonGroups>(); client = new ClientNetworking(); client.Connect(); client.ActionHandler["shoot"] = new EventHandler(this.HandleNetworkShoot); client.ActionHandler["create"] = new EventHandler(this.HandleNetworkCreate); client.ActionHandler["plane"] = new EventHandler(this.HandleNetworkPlane); client.ActionHandler["createother"] = new EventHandler(this.HandleNetworkCreateOtherStuff); client.ActionHandler["reset"] = new EventHandler(this.HandleReset); client.ActionHandler["endgame"] = new EventHandler(this.HandleEndGame); client.ActionHandler["sendpoints"] = new EventHandler(this.HandleSendPoints); // Add a few sprite creators factory.AddCreator((int)GameObjectTypes.CAT, SpriteCreators.CreateCat); factory.AddCreator((int)GameObjectTypes.DOG, SpriteCreators.CreateDog); factory.AddCreator((int)GameObjectTypes.SUN, SpriteCreators.CreateSun); factory.AddCreator((int)GameObjectTypes.BOOM, SpriteCreators.CreateBoom); factory.AddCreator((int)GameObjectTypes.PUFF, SpriteCreators.CreatePuff); factory.AddCreator((int)GameObjectTypes.DINO, SpriteCreators.CreateDino); factory.AddCreator((int)GameObjectTypes.CLOUD1, SpriteCreators.CreateCloud1); factory.AddCreator((int)GameObjectTypes.CLOUD2, SpriteCreators.CreateCloud2); factory.AddCreator((int)GameObjectTypes.CLOUD3, SpriteCreators.CreateCloud3); factory.AddCreator((int)GameObjectTypes.CLOUD4, SpriteCreators.CreateCloud4); factory.AddCreator((int)GameObjectTypes.CLOUD5, SpriteCreators.CreateCloud5); factory.AddCreator((int)GameObjectTypes.CLOUD6, SpriteCreators.CreateCloud6); factory.AddCreator((int)GameObjectTypes.WOOD1, SpriteCreators.CreateWood1); factory.AddCreator((int)GameObjectTypes.WOOD2, SpriteCreators.CreateWood2); factory.AddCreator((int)GameObjectTypes.WOOD3, SpriteCreators.CreateWood3); factory.AddCreator((int)GameObjectTypes.WOOD4, SpriteCreators.CreateWood4); factory.AddCreator((int)GameObjectTypes.PLATFORM_LEFT, SpriteCreators.CreatePlatformLeft); factory.AddCreator((int)GameObjectTypes.PLATFORM_MIDDLE, SpriteCreators.CreatePlatformMiddle); factory.AddCreator((int)GameObjectTypes.PLATFORM_RIGHT, SpriteCreators.CreatePlatformRight); factory.AddCreator((int)GameObjectTypes.CANNON, SpriteCreators.CreateCannon); factory.AddCreator((int)GameObjectTypes.CANNONWHEEL, SpriteCreators.CreateCannonWheel); factory.AddCreator((int)GameObjectTypes.POWERMETERBAR, SpriteCreators.CreatePowerMeterBar); factory.AddCreator((int)GameObjectTypes.POWERMETERTAB, SpriteCreators.CreatePowerMeterTab); factory.AddCreator((int)GameObjectTypes.EXPLOSION1, SpriteCreators.CreateExplosion1); factory.AddCreator((int)GameObjectTypes.EXPLOSION1, SpriteCreators.CreateExplosion2); factory.AddCreator((int)GameObjectTypes.PLANE, SpriteCreators.CreatePlane); factory.AddCreator((int)GameObjectTypes.CATSPLODE, SpriteCreators.CreateCatsplode); factory.AddCreator((int)GameObjectTypes.DUSTSPLODE, SpriteCreators.CreateDustsplode); factory.AddCreator((int)GameObjectTypes.YOULOSE, SpriteCreators.CreateYouLose); factory.AddCreator((int)GameObjectTypes.YOUWIN, SpriteCreators.CreateYouWin); factory.AddCreator((int)GameObjectTypes.SCOREPLUS50, SpriteCreators.CreatePlus50); factory.AddCreator((int)GameObjectTypes.SCOREPLUS100, SpriteCreators.CreatePlus100); factory.AddCreator((int)GameObjectTypes.SCOREPLUS250, SpriteCreators.CreatePlus250); //factory.AddCreator((int)GameObjectTypes.EAHSCSLOGO, SpriteCreators.CreateEAHSCSLogo); mapEditor = new MapEditor(Window, client, cannonManager, cannonGroups, ScreenConfiguration); base.Initialize(); }