public GameObjectFactory ShootDoggy(GameObjectFactory factory, CannonGroups cannonGroup) { List <int> temp = new List <int>(); //figure out which cannon to shoot from //replace once just pass which cannon //endreplace //dog int dog = factory.Create( (int)RaginRovers.GameObjectTypes.DOG, factory.Objects[cannonGroup.cannonKey].sprite.Location + new Vector2(30, 0), "spritesheet", Vector2.Zero, cannonGroup.Rotation, 0, 0); factory.Objects[dog].sprite.OnCollision += new OnCollisionEventHandler(CollisionEvents.dog_OnCollision); if (factory.Objects[cannonGroup.cannonKey].sprite.Location.X > 6000) { factory.Objects[dog].sprite.PlayerNumber = 2; } if (factory.Objects[cannonGroup.cannonKey].sprite.Location.X < 6000) { factory.Objects[dog].sprite.PlayerNumber = 1; } if (cannonGroup.isFlipped) { factory.Objects[dog].sprite.flipType = Sprite.FlipType.VERTICAL; } factory.Objects[dog].sprite.PhysicsBody.LinearVelocity = new Vector2( cannonPower * (float)Math.Cos((double)cannonGroup.Rotation), cannonPower * (float)Math.Sin((double)cannonGroup.Rotation)); //chaning magnitude depending on power bar factory.Objects[dog].sprite.PhysicsBody.LinearVelocity *= cannonGroup.Power; // ((factory.Objects[cannonGroup.tabKey].sprite.Location.X - factory.Objects[cannonGroup.barKey].sprite.Location.X) / factory.Objects[cannonGroup.barKey].sprite.BoundingBoxRect.Width) + 1; factory.Objects[cannonGroup.boomKey].sprite.Dead = false; cannonGroup.boomTime = 0f; factory.Objects[dog].sprite.PhysicsBody.Mass = 30; factory.Objects[dog].sprite.PhysicsBody.Restitution = 0.4f; //factory.Objects[cannonGroup.boomKey].sprite.Rotation = factory.Objects[cannonGroup.cannonKey].sprite.Rotation; factory.Objects[cannonGroup.boomKey].sprite.Location = factory.Objects[cannonGroup.cannonKey].sprite.Location - factory.Objects[cannonGroup.boomKey].sprite.Origin + new Vector2(0, -150) + factory.Objects[dog].sprite.PhysicsBody.LinearVelocity / factory.Objects[dog].sprite.PhysicsBody.LinearVelocity.Length() * 200; return(factory); }
private SunManager() { factory = GameObjectFactory.Instance; rand = new Random(System.Environment.TickCount); this.sun = factory.Create((int)GameObjectTypes.SUN, new Vector2(GameWorld.WorldWidth / 2, -800), "sun", Vector2.Zero, 0f, 0f, 0f, 256); factory.Objects[sun].sprite.Location -= new Vector2(factory.Objects[sun].sprite.BoundingBoxRect.Width / 2, 0); defaultLocation = factory.Objects[sun].sprite.Location; factory.Objects[sun].saveable = false; }
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 - 95, (int)location.Y - 80), "spritesheet", new Vector2(0, 0), 0, -MathHelper.PiOver2, 0, 32); } else { icannon = factory.Create((int)RaginRovers.GameObjectTypes.CANNON, new Vector2(location.X - 95, location.Y - 80), "spritesheet", new Vector2(0, 0), -MathHelper.Pi, -MathHelper.Pi, -MathHelper.PiOver2, 32); } //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 + 50), "background", new Vector2(0, 0), 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), "background", 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 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 GameObjectFactory ShootDoggy(GameObjectFactory factory, CannonGroups cannonGroup) { List<int> temp = new List<int>(); //figure out which cannon to shoot from //replace once just pass which cannon //endreplace //dog int dog = factory.Create( (int)RaginRovers.GameObjectTypes.DOG, factory.Objects[cannonGroup.cannonKey].sprite.Location + new Vector2(30, 0), "spritesheet", Vector2.Zero, cannonGroup.Rotation, 0, 0); factory.Objects[dog].sprite.OnCollision += new OnCollisionEventHandler(CollisionEvents.dog_OnCollision); if (factory.Objects[cannonGroup.cannonKey].sprite.Location.X > 6000) factory.Objects[dog].sprite.PlayerNumber = 2; if (factory.Objects[cannonGroup.cannonKey].sprite.Location.X < 6000) factory.Objects[dog].sprite.PlayerNumber = 1; if (cannonGroup.isFlipped) { factory.Objects[dog].sprite.flipType = Sprite.FlipType.VERTICAL; } factory.Objects[dog].sprite.PhysicsBody.LinearVelocity = new Vector2( cannonPower * (float)Math.Cos((double)cannonGroup.Rotation), cannonPower * (float)Math.Sin((double)cannonGroup.Rotation)); //chaning magnitude depending on power bar factory.Objects[dog].sprite.PhysicsBody.LinearVelocity *= cannonGroup.Power; // ((factory.Objects[cannonGroup.tabKey].sprite.Location.X - factory.Objects[cannonGroup.barKey].sprite.Location.X) / factory.Objects[cannonGroup.barKey].sprite.BoundingBoxRect.Width) + 1; factory.Objects[cannonGroup.boomKey].sprite.Dead = false; cannonGroup.boomTime = 0f; factory.Objects[dog].sprite.PhysicsBody.Mass = 30; factory.Objects[dog].sprite.PhysicsBody.Restitution = 0.4f; //factory.Objects[cannonGroup.boomKey].sprite.Rotation = factory.Objects[cannonGroup.cannonKey].sprite.Rotation; factory.Objects[cannonGroup.boomKey].sprite.Location = factory.Objects[cannonGroup.cannonKey].sprite.Location - factory.Objects[cannonGroup.boomKey].sprite.Origin + new Vector2(0, -150) + factory.Objects[dog].sprite.PhysicsBody.LinearVelocity / factory.Objects[dog].sprite.PhysicsBody.LinearVelocity.Length() * 200; return factory; }