public GameObjectFactory CreateCannonStuff(GameObjectFactory factory, Vector2 location, Camera camera, bool isReversed, ref List<CannonGroups> cannonGroups) { int icannon; if (!isReversed) { icannon = factory.Create( (int)RaginRovers.GameObjectTypes.CANNON, new Vector2((int)location.X, (int)location.Y), "spritesheet", new Vector2(0, 0), 0, -MathHelper.PiOver2, 0, 32); } else { icannon = factory.Create((int)RaginRovers.GameObjectTypes.CANNON, new Vector2(location.X - 20, location.Y - 20), "spritesheet", new Vector2(0, 0), -MathHelper.Pi, -MathHelper.Pi, -MathHelper.PiOver2, 32); } factory.Objects[icannon].sprite.Location -= new Vector2(0, factory.Objects[icannon].sprite.BoundingBoxRect.Height); //factory.Objects[icannon].sprite.Origin = new Vector2(120, 103); factory.Objects[icannon].sprite.Origin = new Vector2((factory.Objects[icannon].sprite.BoundingBoxRect.Width / 2) - 40, factory.Objects[icannon].sprite.BoundingBoxRect.Height / 2); int iwheel = factory.Create( (int)RaginRovers.GameObjectTypes.CANNONWHEEL, //new Vector2((int)location.X - 30, (int)location.Y - 120), factory.Objects[icannon].sprite.Origin, "spritesheet", new Vector2(0, 0), 0, 0f, 0f, 31); int ibar = factory.Create( (int)RaginRovers.GameObjectTypes.POWERMETERBAR, new Vector2( factory.Objects[icannon].sprite.Location.X, factory.Objects[icannon].sprite.Location.Y + factory.Objects[icannon].sprite.BoundingBoxRect.Height + 20), "spritesheet", new Vector2(0, 0), isReversed ? -MathHelper.Pi: 0, 0f, 0f, 30); int itab = factory.Create( (int)RaginRovers.GameObjectTypes.POWERMETERTAB, new Vector2( factory.Objects[ibar].sprite.Location.X, factory.Objects[ibar].sprite.Location.Y + factory.Objects[ibar].sprite.Origin.Y), "spritesheet", new Vector2(0, 0), 0, 0f, 0f, 30); //had to put after because cant access origin before sprite is created factory.Objects[itab].sprite.Location -= new Vector2(0, factory.Objects[itab].sprite.Origin.Y); //putting them all in a group //factory.Objects[icannon].sprite.groupNumber = groupNumber; //factory.Objects[iwheel].sprite.groupNumber = groupNumber; //factory.Objects[ibar].sprite.groupNumber = groupNumber; //factory.Objects[itab].sprite.groupNumber = groupNumber; //Sprite cannon = factory.Objects[icannon].sprite; //Sprite wheel = factory.Objects[iwheel].sprite;//boom int boom = factory.Create( (int)RaginRovers.GameObjectTypes.BOOM, factory.Objects[icannon].sprite.Location, "boom", Vector2.Zero, factory.Objects[icannon].sprite.Rotation, 0, 0, 5); factory.Objects[icannon].saveable = false; factory.Objects[iwheel].saveable = false; factory.Objects[itab].saveable = false; factory.Objects[ibar].saveable = false; factory.Objects[boom].saveable = false; //changing location so that origins equal factory.Objects[boom].sprite.Location += factory.Objects[icannon].sprite.Origin - factory.Objects[boom].sprite.Origin; factory.Objects[boom].sprite.Scale = 2.0f; if (isReversed) factory.Objects[boom].sprite.flipType = Sprite.FlipType.BOTH; factory.Objects[boom].sprite.Dead = true; cannonGroups.Add(new CannonGroups(icannon, iwheel, ibar, itab, boom, isReversed)); factory.Objects[iwheel].sprite.Location = factory.Objects[icannon].sprite.Location + factory.Objects[icannon].sprite.Origin - new Vector2(109-20, 113); // factory.Objects[iwheel].sprite.Origin; //groupNumber++; return factory; }
public void Update(GameTime gameTime, Camera camera) { KeyboardState kb = Keyboard.GetState(); MouseState msState = Mouse.GetState(); Vector2 ms = Vector2.Transform(new Vector2(msState.X, msState.Y), Matrix.Invert(camera.GetViewMatrix(Vector2.One))); window.Title = "Local Mouse> X: " + msState.X + " Y: " + msState.Y + ", World Mouse> X: " + ms.X + " Y: " + ms.Y; DetectKeyPress(kb, Keys.OemTilde); DetectKeyPress(kb, Keys.D1); // Record if this key is pressed DetectKeyPress(kb, Keys.D2); // Record if this key is pressed DetectKeyPress(kb, Keys.D3); DetectKeyPress(kb, Keys.D4); DetectKeyPress(kb, Keys.D5); DetectKeyPress(kb, Keys.D6); DetectKeyPress(kb, Keys.D7); DetectKeyPress(kb, Keys.D8); DetectKeyPress(kb, Keys.D9); DetectKeyPress(kb, Keys.D0); DetectKeyPress(kb, Keys.P); DetectKeyPress(kb, Keys.R); DetectKeyPress(kb, Keys.B); DetectKeyPress(kb, Keys.Delete); DetectKeyPress(kb, Keys.M); DetectKeyPress(kb, Keys.L); DetectKeyPress(kb, Keys.Enter); DetectKeyPress(kb, Keys.Space); DetectKeyPress(kb, Keys.N); DetectKeyPress(kb, Keys.J); if (KeyDown) { if (kb.IsKeyUp(Key)) { switch (Key) { case Keys.Enter: foreach (int i in factory.Objects.Keys) { if (factory.Objects[i].typeid == (int)GameObjectTypes.DOG) factory.Objects[i].sprite.PhysicsBody.ApplyLinearImpulse(new Vector2(60, 40)); } break; //////////////////////////////////////////////////// case Keys.Space: if (!EditMode) { cannonManager.ChangeCannonState(cannonGroups[0]); if (cannonGroups[0].cannonState == CannonState.WAITING) { client.SendMessage("action=shoot;cannonGroup=0;rotation=" + cannonGroups[0].Rotation + ";power=" + cannonGroups[0].Power); } } break; case Keys.N: if (!EditMode) { cannonManager.ChangeCannonState(cannonGroups[1]); if (cannonGroups[1].cannonState == CannonState.WAITING) { client.SendMessage("action=shoot;cannonGroup=1;rotation=" + cannonGroups[1].Rotation + ";power=" + cannonGroups[1].Power); } } break; case Keys.OemTilde: EditMode = !EditMode; //camera.Zoom = 1f; window.Title = "Ragin Rovers " + (EditMode ? " | EDITING MODE" : ""); break; case Keys.D1: if (EditMode) { int dog = factory.Create((int)GameObjectTypes.DOG, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); factory.Objects[dog].sprite.PhysicsBody.Mass = 30; factory.Objects[dog].sprite.PhysicsBody.Restitution = 0.4f; } break; case Keys.D2: if (EditMode) { int cat = factory.Create((int)GameObjectTypes.CAT, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); factory.Objects[cat].sprite.PhysicsBody.Mass = 30; factory.Objects[cat].sprite.PhysicsBody.Restitution = 0.8f; } break; case Keys.D3: if (EditMode) { int board = factory.Create((int)GameObjectTypes.WOOD1, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); } break; case Keys.D4: if (EditMode) { int board = factory.Create((int)GameObjectTypes.WOOD2, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); } break; case Keys.D5: if (EditMode) { int board = factory.Create((int)GameObjectTypes.WOOD3, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); } break; case Keys.D6: if (EditMode) { int board = factory.Create((int)GameObjectTypes.WOOD4, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); } break; case Keys.D7: if (EditMode) { factory.Create((int)GameObjectTypes.PLATFORM_LEFT, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); } break; case Keys.D8: if (EditMode) { factory.Create((int)GameObjectTypes.PLATFORM_MIDDLE, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); } break; case Keys.D9: if (EditMode) { factory.Create((int)GameObjectTypes.PLATFORM_RIGHT, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); } break; case Keys.D0: if (EditMode) { factory = cannonManager.CreateCannonStuff(factory, new Vector2(ms.X /*+ camera.Position.X*/ - 95, ms.Y - 80), camera, false, ref cannonGroups); } break; case Keys.P: if (EditMode) { factory = cannonManager.CreateCannonStuff(factory, new Vector2(ms.X, ms.Y), camera, true, ref cannonGroups); } break; case Keys.J: cannonManager.CreateCannonStuff(factory, new Vector2(0, 500), camera, true, ref cannonGroups); //need how to figure out location cannonManager.CreateCannonStuff(factory, new Vector2(500, 500), camera, false, ref cannonGroups); //need how to figure out location break; case Keys.B: int boom = factory.Create((int)GameObjectTypes.BOOM, new Vector2((int)ms.X + camera.Position.X - 95, (int)ms.Y - 80), "boom", new Vector2(0, 0), 0, 0f, 0f); break; case Keys.R: if (EditMode && MouseDown && DragSprite != -1) { if (factory.Objects[DragSprite].sprite.Rotation == 0) factory.Objects[DragSprite].sprite.Rotation = MathHelper.PiOver2; else factory.Objects[DragSprite].sprite.Rotation = 0; } break; case Keys.Delete: if (EditMode && MouseDown && DragSprite != -1) { factory.Remove(DragSprite); DragSprite = -1; } break; case Keys.L: using (StreamReader infile = new StreamReader("map.txt")) { string objs = infile.ReadToEnd(); string[] lines = objs.Split('\n'); for (int i = 0; i < lines.Length; i++) { if (lines[i].Length > 0) { string[] fields = lines[i].Split('\t'); client.SendMessage("action=create;gotype=" + Convert.ToInt32(fields[1]) + ";textureassetname=" + fields[4] + ";location.x=" + (float)Convert.ToDouble(fields[2]) + ";location.y=" + (float)Convert.ToDouble(fields[3]) + ";rotation=" + (float)Convert.ToDouble(fields[5]) + ";upperBounds=" + 0f + ";lowerBounds=" + 0f); /* factory.Create(Convert.ToInt32(fields[1]), new Vector2((float)Convert.ToDouble(fields[2]), (float)Convert.ToDouble(fields[3])), fields[4], Vector2.Zero, (float)Convert.ToDouble(fields[5]), 0f, 0f); */ } } } break; case Keys.M: string objlist = factory.Serialize(); using (StreamWriter outfile = new StreamWriter(@"map.txt")) { outfile.Write(objlist); } break; } KeyDown = false; Key = Keys.None; } } if (!EditMode) { for (int i = 0; i < cannonGroups.Count; i++) { factory = cannonManager.ManipulateCannons(factory, cannonGroups[i]); } } cannonManager.Update(gameTime, factory, cannonGroups); if (EditMode) { if (msState.LeftButton == ButtonState.Pressed && !MouseDown) { MouseDown = true; foreach (int key in factory.Objects.Keys) { Sprite sprite = factory.Objects[key].sprite; if (sprite.IsBoxColliding(new Rectangle((int)ms.X /*+ (int)camera.Position.X*/, (int)ms.Y, 1, 1))) { DragSprite = key; DragOffset = new Vector2(ms.X, ms.Y) - sprite.Location; } } } if (MouseDown && DragSprite != -1) { factory.Objects[DragSprite].sprite.Location = new Vector2(ms.X, ms.Y) - DragOffset; } if (msState.LeftButton == ButtonState.Released) { MouseDown = false; DragSprite = -1; } } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); camera = new Camera(new Viewport(GameWorld.ViewPortXOffset, 0, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height)); camera.Origin = new Vector2(camera.ViewPort.Width / 2.0f, camera.ViewPort.Height); camera.Zoom = .47f; camera.Position = new Vector2((12234/3) * (ScreenConfiguration-1), camera.Position.Y); // Load all the textures we're going to need for this game textureManager.LoadTexture("background"); textureManager.LoadTexture("spritesheet"); textureManager.LoadTexture("boom"); textureManager.LoadTexture("cursor"); textureManager.LoadTexture("sun"); textureManager.LoadTexture("explosion1"); textureManager.LoadTexture("plane_with_banner"); textureManager.LoadTexture("clouds"); textureManager.LoadTexture("catsplode"); textureManager.LoadTexture("dustsplode"); textureManager.LoadTexture("eahs_cs_logo"); textureManager.LoadTexture("wood-sign-hi"); textureManager.LoadTexture("scoresheet"); if (ScreenConfiguration == 2) { drumline = Content.Load<Song>("Audio/drumline"); funnymusic = Content.Load<Song>("Audio/funnymusic"); } spriteFont = Content.Load<SpriteFont>("spriteFont"); AudioManager.Instance.LoadSoundEffect("airplane"); AudioManager.Instance.LoadSoundEffect("cat1"); AudioManager.Instance.LoadSoundEffect("cat2"); AudioManager.Instance.LoadSoundEffect("cat3"); AudioManager.Instance.LoadSoundEffect("cat4"); AudioManager.Instance.LoadSoundEffect("dog1"); AudioManager.Instance.LoadSoundEffect("meat_hit"); AudioManager.Instance.LoadSoundEffect("cat_aaagh"); AudioManager.Instance.LoadSoundEffect("cat_gibberish"); AudioManager.Instance.LoadSoundEffect("cat_moan"); AudioManager.Instance.LoadSoundEffect("cat_myschool"); AudioManager.Instance.LoadSoundEffect("cat_pburgrules"); AudioManager.Instance.LoadSoundEffect("cat_soclose"); AudioManager.Instance.LoadSoundEffect("cat_taunt"); AudioManager.Instance.LoadSoundEffect("dog_bark"); AudioManager.Instance.LoadSoundEffect("dog_impact"); AudioManager.Instance.LoadSoundEffect("dog_oof"); AudioManager.Instance.LoadSoundEffect("dog_launch"); AudioManager.Instance.LoadSoundEffect("cannon_boom"); //AudioManager.Instance.LoadSoundEffect("Drum_Line"); /* int cat = factory.Create((int)GameObjectTypes.CAT, Vector2.Zero, "spritesheet", Vector2.Zero, 0); int dog = factory.Create((int)GameObjectTypes.DOG, new Vector2(500, 50), "spritesheet", new Vector2(30, 0), 0); int boom2 = factory.Create((int)GameObjectTypes.BOOM, new Vector2(500, 50), "boom", new Vector2(30, 0), 0); factory.Objects[dog].sprite.PhysicsBody.Mass = 30; factory.Objects[dog].sprite.PhysicsBody.Restitution = 0.4f; factory.Objects[cat].sprite.PhysicsBody.Restitution = 0.8f; */ Body body = BodyFactory.CreateBody(GameWorld.world); body.BodyType = BodyType.Static; body.Position = ConvertUnits.ToSimUnits(new Vector2(0, GameWorld.HeightofGround)); //hardcode workaround, can't figure out what to multiply the proportion by // * GameWorld.ProportionGroundtoScreen)); body.UserData = new GameObject(-1, (int)GameObjectTypes.GROUND); //FixtureFactory.AttachRectangle((float)GameWorld.WorldWidth, 10, 1, new Vector2(0, ConvertUnits.ToDisplayUnits(this.Window.ClientBounds.Height-30)), body); Fixture ground = FixtureFactory.AttachRectangle(ConvertUnits.ToSimUnits(GameWorld.WorldWidth)*10, ConvertUnits.ToSimUnits(10), 10, Vector2.Zero, body, "ground"); ground.Restitution = .1f; ground.Friction = 1f; if (ScreenConfiguration == 2) { MediaPlayer.Play(funnymusic); MediaPlayer.IsRepeating = true; MediaPlayer.Volume /= 5; } //AudioManager.Instance.SoundEffect("Drum_Line").Play(); ; CollisionEvents.Instance.TransferClientInfo(client); SpriteHelper.Instance.InitializeFunnySong(funnymusic); SetupLevel(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); camera = new Camera(new Viewport(GameWorld.ViewPortXOffset, 0, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height)); camera.Origin = new Vector2(camera.ViewPort.Width / 2.0f, camera.ViewPort.Height); camera.Position = new Vector2(GameWorld.WorldWidth * (ScreenConfiguration-1), camera.Position.Y); // Load all the textures we're going to need for this game textureManager.LoadTexture("background"); textureManager.LoadTexture("spritesheet"); textureManager.LoadTexture("boom"); textureManager.LoadTexture("cursor"); /* int cat = factory.Create((int)GameObjectTypes.CAT, Vector2.Zero, "spritesheet", Vector2.Zero, 0); int dog = factory.Create((int)GameObjectTypes.DOG, new Vector2(500, 50), "spritesheet", new Vector2(30, 0), 0); int boom2 = factory.Create((int)GameObjectTypes.BOOM, new Vector2(500, 50), "boom", new Vector2(30, 0), 0); factory.Objects[dog].sprite.PhysicsBody.Mass = 30; factory.Objects[dog].sprite.PhysicsBody.Restitution = 0.4f; factory.Objects[cat].sprite.PhysicsBody.Restitution = 0.8f; */ Body body = BodyFactory.CreateBody(GameWorld.world); body.BodyType = BodyType.Static; body.Position = ConvertUnits.ToSimUnits(new Vector2(0, this.Window.ClientBounds.Height-105)); //FixtureFactory.AttachRectangle((float)GameWorld.WorldWidth, 10, 1, new Vector2(0, ConvertUnits.ToDisplayUnits(this.Window.ClientBounds.Height-30)), body); FixtureFactory.AttachRectangle(ConvertUnits.ToSimUnits(GameWorld.WorldWidth)*10, ConvertUnits.ToSimUnits(10), 1, Vector2.Zero, body); //create cannons cannonManager.CreateCannonStuff(factory, new Vector2(0, 500), camera, true, ref cannonGroups); //need how to figure out location cannonManager.CreateCannonStuff(factory, new Vector2(500, 500), camera, false, ref cannonGroups); //need how to figure out location }
public void Update(GameTime gameTime, Camera camera) { KeyboardState kb = Keyboard.GetState(); MouseState msState = Mouse.GetState(); Vector2 ms = Vector2.Transform(new Vector2(msState.X, msState.Y), Matrix.Invert(camera.GetViewMatrix(Vector2.One))); window.Title = "Local Mouse> X: " + msState.X + " Y: " + msState.Y + ", World Mouse> X: " + ms.X + ", Y: " + ms.Y + ", Zoom: " + camera.Zoom; DetectKeyPress(kb, Keys.OemTilde); DetectKeyPress(kb, Keys.D1); // Record if this key is pressed DetectKeyPress(kb, Keys.D2); // Record if this key is pressed DetectKeyPress(kb, Keys.D3); DetectKeyPress(kb, Keys.D4); DetectKeyPress(kb, Keys.D5); DetectKeyPress(kb, Keys.D6); DetectKeyPress(kb, Keys.D7); DetectKeyPress(kb, Keys.D8); DetectKeyPress(kb, Keys.D9); DetectKeyPress(kb, Keys.D0); DetectKeyPress(kb, Keys.P); DetectKeyPress(kb, Keys.R); DetectKeyPress(kb, Keys.B); DetectKeyPress(kb, Keys.Delete); DetectKeyPress(kb, Keys.M); DetectKeyPress(kb, Keys.L); DetectKeyPress(kb, Keys.U); DetectKeyPress(kb, Keys.Enter); DetectKeyPress(kb, Keys.Space); DetectKeyPress(kb, Keys.N); DetectKeyPress(kb, Keys.J); DetectKeyPress(kb, Keys.Q); if (KeyDown) { if (kb.IsKeyUp(Key)) { switch (Key) { //////////////////////////////////////////////////// case Keys.Space: if (!EditMode) { //probably will get annoying when working on project and testing bugs if (screenconfiguration == 1) // put in "|| screenconfiguration == 2" to test stuff { cannonManager.ChangeCannonState(cannonGroups[1]); if (cannonGroups[1].cannonState == CannonState.WAITING) { client.SendMessage("action=shoot;cannonGroup=1;rotation=" + cannonGroups[1].Rotation + ";power=" + cannonGroups[1].Power + ";Screen=" + Game1.ScreenConfiguration); SunManager.Instance.Mood = SunMood.OPENSMILE; camera.Shake(10, 1); } } if (screenconfiguration == 3) { cannonManager.ChangeCannonState(cannonGroups[0]); if (cannonGroups[0].cannonState == CannonState.WAITING) { client.SendMessage("action=shoot;cannonGroup=0;rotation=" + cannonGroups[0].Rotation + ";power=" + cannonGroups[0].Power + ";Screen=" + Game1.ScreenConfiguration); SunManager.Instance.Mood = SunMood.OPENSMILE; camera.Shake(10, 1); } } } break; /* case Keys.OemTilde: if (screenconfiguration == 2) EditMode = !EditMode; //camera.Zoom = 1f; //window.Title = "Ragin Rovers " + (EditMode ? " | EDITING MODE" : ""); break; case Keys.Q: if (EditMode && screenconfiguration == 2) { int puff = factory.Create((int)GameObjectTypes.PUFF, new Vector2((int)ms.X /*+ camera.Position.X*/// - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); /* factory.Objects[puff].sprite.PhysicsBody.Mass = 30; factory.Objects[puff].sprite.PhysicsBody.Restitution = 0.4f; factory.Objects[puff].saveable = false; } break;*/ case Keys.D1: if (screenconfiguration != 2 && EditMode) { int dog = factory.Create((int)GameObjectTypes.DOG, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); factory.Objects[dog].sprite.PhysicsBody.Mass = 30; factory.Objects[dog].sprite.PhysicsBody.Restitution = 0.4f; } if (screenconfiguration == 2) { client.SendMessage("action=reset;map=" + 1); LoadPlanesandClouds(); } break; case Keys.D2: if (screenconfiguration != 2 && EditMode) { int cat = factory.Create((int)GameObjectTypes.CAT, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); factory.Objects[cat].sprite.PhysicsBody.Mass = 30; factory.Objects[cat].sprite.PhysicsBody.Restitution = 0.8f; } if (screenconfiguration == 2) { client.SendMessage("action=reset;map=" + 2); LoadPlanesandClouds(); } break; case Keys.D3: if (screenconfiguration != 2 && EditMode) { int board = factory.Create((int)GameObjectTypes.WOOD1, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); factory.Objects[board].sprite.OnCollision += new OnCollisionEventHandler(CollisionEvents.wood_OnCollision); } if (screenconfiguration == 2) { client.SendMessage("action=reset;map=" + 3); LoadPlanesandClouds(); } break; case Keys.D4: if (screenconfiguration != 2 && EditMode) { int board = factory.Create((int)GameObjectTypes.WOOD2, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); factory.Objects[board].sprite.OnCollision += new OnCollisionEventHandler(CollisionEvents.wood_OnCollision); } if (screenconfiguration == 2) { client.SendMessage("action=reset;map=" + 4); LoadPlanesandClouds(); } break; case Keys.D5: if (screenconfiguration != 2 && EditMode) { int board = factory.Create((int)GameObjectTypes.WOOD3, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); factory.Objects[board].sprite.OnCollision += new OnCollisionEventHandler(CollisionEvents.wood_OnCollision); } if (screenconfiguration == 2) { client.SendMessage("action=reset;map=" + 5); LoadPlanesandClouds(); } break; case Keys.D6: if (screenconfiguration != 2 && EditMode) { int board = factory.Create((int)GameObjectTypes.WOOD4, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); factory.Objects[board].sprite.OnCollision += new OnCollisionEventHandler(CollisionEvents.wood_OnCollision); } if (screenconfiguration == 2) { client.SendMessage("action=reset;map=" + 6); LoadPlanesandClouds(); } break; case Keys.D7: if (screenconfiguration != 2 && EditMode) { factory.Create((int)GameObjectTypes.PLATFORM_LEFT, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); } if (screenconfiguration == 2) { client.SendMessage("action=reset;map=" + 7); LoadPlanesandClouds(); } break; case Keys.D8: if (screenconfiguration != 2 && EditMode) { factory.Create((int)GameObjectTypes.PLATFORM_MIDDLE, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); } if (screenconfiguration == 2) { client.SendMessage("action=reset;map=" + 8); LoadPlanesandClouds(); } break; case Keys.D9: if (screenconfiguration != 2 && EditMode) { factory.Create((int)GameObjectTypes.PLATFORM_RIGHT, new Vector2((int)ms.X /*+ camera.Position.X*/ - 95, (int)ms.Y - 80), "spritesheet", new Vector2(0, 0), 0, 0f, 0f); } if (screenconfiguration == 2) { client.SendMessage("action=reset;map=" + 0); LoadPlanesandClouds(); } break; case Keys.D0: if (screenconfiguration != 2 && EditMode) { factory = cannonManager.CreateCannonStuff(factory, new Vector2(ms.X /*+ camera.Position.X*/ - 95, ms.Y - 80), camera, false, ref cannonGroups); } if (screenconfiguration == 2) { client.SendMessage("action=reset;map=" + 0); LoadPlanesandClouds(); } break; /*case Keys.P: if (EditMode && screenconfiguration == 2) { factory = cannonManager.CreateCannonStuff(factory, new Vector2(ms.X, ms.Y), camera, true, ref cannonGroups); } break; case Keys.J: if (screenconfiguration == 2) { cannonManager.CreateCannonStuff(factory, new Vector2(0, 500), camera, true, ref cannonGroups); //need how to figure out location cannonManager.CreateCannonStuff(factory, new Vector2(500, 500), camera, false, ref cannonGroups); //need how to figure out location } break; case Keys.B: int boom = factory.Create((int)GameObjectTypes.BOOM, new Vector2((int)ms.X + camera.Position.X - 95, (int)ms.Y - 80), "boom", new Vector2(0, 0), 0, 0f, 0f); break; case Keys.R: if (EditMode && MouseDown && DragSprite != -1) { if (factory.Objects[DragSprite].sprite.Rotation == 0) factory.Objects[DragSprite].sprite.Rotation = MathHelper.PiOver2; else factory.Objects[DragSprite].sprite.Rotation = 0; } break; case Keys.Delete: if (EditMode && MouseDown && DragSprite != -1) { factory.Remove(DragSprite); DragSprite = -1; } break; case Keys.L: if (screenconfiguration == 2) { } break; */ //done with saving maps for now /*case Keys.M: string objlist = factory.Serialize(); using (StreamWriter outfile = new StreamWriter(@"map.txt")) { outfile.Write(objlist); } break;*/ } KeyDown = false; Key = Keys.None; } } if (!EditMode) { for (int i = 0; i < cannonGroups.Count; i++) { factory = cannonManager.ManipulateCannons(factory, cannonGroups[i]); } } cannonManager.Update(gameTime, factory, cannonGroups); if (EditMode) { if (msState.LeftButton == ButtonState.Pressed && !MouseDown) { MouseDown = true; foreach (int key in factory.Objects.Keys) { Sprite sprite = factory.Objects[key].sprite; if (sprite.IsBoxColliding(new Rectangle((int)ms.X /*+ (int)camera.Position.X*/, (int)ms.Y, 1, 1))) { DragSprite = key; DragOffset = new Vector2(ms.X, ms.Y) - sprite.Location; } } } if (MouseDown && DragSprite != -1) { factory.Objects[DragSprite].sprite.Location = new Vector2(ms.X, ms.Y) - DragOffset; } if (msState.LeftButton == ButtonState.Released) { MouseDown = false; DragSprite = -1; } } }