public GravityGrenade(Actor launcher, float weaponPower, Vector2 destination)
        {
            Scale = .7f;
            this.doNotSave = true;
            var player = (GameEngine.Singleton.GetPlayState())
                .ActiveMap.MainPlayer;
            Launcher = launcher;
            WeaponPower = weaponPower;
            PolyBody = new PolyBody(.1f, 3);
            PolyBody.Gravity = -9.8f * Vector2.UnitY;
            Load();
            PolyBody.Position = launcher.PolyBody.Position +
                (launcher.PolyBody.GetWidth() + (Sprite.BoundingBox().X/2)) * Math.Sign(destination.X - launcher.PolyBody.Position.X) *
                Vector2.UnitX;
            PolyBody.Velocity = computeTargetVelocity(destination);

            PolyBody.Collided += new PhysicsEventHandler(Detonate);
        }
Example #2
0
        public Map(string mapID, float pixelsPerMeter, Actor[] gameObjects)
        {
            GameObjects = gameObjects.ToList<Actor>();
            DynamicObjects = new List<Actor>();
            LinkedObjects = new Dictionary<string, Actor>();
            PixelsPerMeter = pixelsPerMeter;
            ID = mapID;

            foreach (Actor actor in GameObjects)
            {
                if (actor is Actors.IDynamic)
                    DynamicObjects.Add(actor);
                if (actor is Actors.ILinked)
                    LinkedObjects.Add(
                        ((Actors.ILinked)actor).ID,
                        actor);
            }
        }
 public InteractEventArgs(Actor selection)
 {
     Selection = selection;
 }
 private void FillPolygon(PolyBody body, Actor actor)
 {
     GraphicsEngine.FillPolygon(body, ((PolyBody)body).tex, actor.color);
 }
Example #5
0
 public Map(string mapID, Actor[] gameObjects)
 {
     GameObjects = gameObjects.ToList<Actor>();
     DynamicObjects = new List<Actor>();
     LinkedObjects = new Dictionary<string, Actor>();
     PixelsPerMeter = (float)Utilities.DefaultSettings.Settings["PixelsPerMeter"];
     ID = mapID;
     foreach (Actor actor in GameObjects)
     {
         if (actor is Actors.IDynamic)
             DynamicObjects.Add(actor);
         if (actor is Actors.ILinked)
             LinkedObjects.Add(
                 ((Actors.ILinked)actor).ID,
                 actor);
     }
 }
Example #6
0
 public void RemoveGameObject(Actor actor)
 {
     GameObjects.Remove(actor);
     if (actor is Actors.IDynamic)
         DynamicObjects.Remove(actor);
     if (actor is Actors.ILinked)
         LinkedObjects.Remove(((Actors.ILinked)actor).ID);
 }
Example #7
0
 public void AddGameObject(Actor actor)
 {
     GameObjects.Add(actor);
     if (actor is Actors.IDynamic)
         DynamicObjects.Add(actor);
     if (actor is Actors.ILinked)
         LinkedObjects.Add(((Actors.ILinked)actor).ID, actor);
 }
 private void DrawPolygon(Polygon body, Actor actor)
 {
     actor.color = Color.Gray;
     GraphicsEngine.FillPolygon(body, ((PolyBody)body).tex, actor.color);
 }
 private void DrawActor(Actor actor)
 {
     if (actor.PolyBody.tex != null)
         DrawPolygon((PolyBody)actor.PolyBody, actor);
     else
         CreateSprite(actor.GetType().ToString(),
             actor.State.Name,
             actor.Scale,
             actor.PolyBody.Position,
             actor.PolyBody.Rotation);
 }
        private void InitGame()
        {
            HardCodedMaps = new Dictionary<string, Actor[]>();

            /*var map1 =
                    new Actor[]
                {
                    new Floor(Size.Width, Color.Blue),
                    //new FromArtPlatform(Size.Width, Size.Width/2, 0),
                    new Block(12, .25f, 6, 5),
                    new PhysicsHat("GravityGrenade", Size.Width /4,
                        PhysicsHat.Radius),
                    new PhysicsHat("FrictionFlamethrower", Size.Width /3,
                        PhysicsHat.Radius),
                   // new Bouncer(1, Color.Red, Size.Width - 1, 1),

                    new Actors.IntraMapPortal("Entrance", String.Empty, 2, 10),
                   new Actors.InterMapPortal("Exit", "TestMap2.Entrance", Size.Width - Portal.Radius, Portal.Radius)
               };

            var map2 =
                    new Actor[]
                    {
                        new Platform(1, Color.Orange, 1, Size.Height / 2),
                        new Platform(1, Color.Purple, 2.5f, Size.Height / 2),
                        new MovablePlatform(5000, 1.1f, Color.Green, Platform.DefaultThickness, 4.5f, Size.Height / 2),
                        new MovablePlatform(200,     2, Color.HotPink, Platform.DefaultThickness, Size.Width - 4, 1),
                            new Platform(Portal.Radius, Color.Yellow, Size.Width - Portal.Radius, Size.Height / 2),
                        new Bouncer(1, Color.Red, Size.Width - Portal.Radius,
                           Size.Height / 2 + Portal.Radius),
                       new Actors.InterMapPortal("Entrance", "TestMap1.Exit", Portal.Radius,
                           Size.Height / 2 + Portal.Radius),
                       new Actors.IntraMapPortal("Bottom", ".Top", 2, 1),
                       new Actors.IntraMapPortal("Top", ".Bottom", Size.Width - 4, Size.Y / 2),
                       new Actors.InterMapPortal("Exit", String.Empty, Size.Width - Portal.Radius,
                           Size.Height / 2 + Portal.Radius)
                   };

            map2[2].PolyBody.Gravity = Vector2.Zero;
            map2[3].PolyBody.Gravity = Vector2.Zero;
            //map2.StaticActors[3].PolyBody.RotationEnabled = false;
            */

            //
            // sean's test map:

            var map1 =
                    new Actor[]
                {
                    new Floor(Size.Width, Color.Blue),
                    //new FromArtPlatform(Size.Width, Size.Width/2, 0),
                    new Block(12, .25f, 6, 5),
                    new PhysicsHat("GravityGrenade", Size.Width /4,
                        PhysicsHat.Radius),
                    new PhysicsHat("FrictionFlamethrower", Size.Width /3,
                        PhysicsHat.Radius),

                    new Actors.IntraMapPortal("Entrance", String.Empty, 2, 10),
                   new Actors.InterMapPortal("Exit", "TestMap2.Entrance", Size.Width - Portal.Radius, Portal.Radius)
               };

            var map2 =
                    new Actor[]
                    {
                        new Platform(1, Color.Orange, 1, Size.Height / 2),
                        new Platform(1, Color.Purple, 2.5f, Size.Height / 2),
                        new MovablePlatform(5000, 1.1f, Color.Green, Platform.DefaultThickness, 4.5f, Size.Height / 2),
                        new MovablePlatform(200,     2, Color.HotPink, Platform.DefaultThickness, Size.Width - 4, 1),
                            new Platform(Portal.Radius, Color.Yellow, Size.Width - Portal.Radius, Size.Height / 2),
                        new Bouncer(1, Color.Red, Size.Width - Portal.Radius,
                           Size.Height / 2 + Portal.Radius),
                       new Actors.InterMapPortal("Entrance", "TestMap1.Exit", Portal.Radius,
                           Size.Height / 2 + Portal.Radius),
                       new Actors.IntraMapPortal("Bottom", ".Top", 2, 1),
                       new Actors.IntraMapPortal("Top", ".Bottom", Size.Width - 4, Size.Y / 2),
                       new Actors.InterMapPortal("Exit", String.Empty, Size.Width - Portal.Radius,
                           Size.Height / 2 + Portal.Radius)
                   };

            map2[2].PolyBody.Gravity = Vector2.Zero;
            map2[3].PolyBody.Gravity = Vector2.Zero;
            //map2.StaticActors[3].PolyBody.RotationEnabled = false;

            //
            // sean's test map:

            var finalMap1 =
                new Actor[]
                {
                    new Actors.IntraMapPortal("Entrance", String.Empty, 2, 10),
                    new Actors.InterMapPortal("Exit", "finalMap2.Entrance", 15, 3),
                    new Platform(5, Color.Blue, 4, 3, 0f),
                    new Platform(5, Color.BurlyWood, 10, 3, 0f),
                    new Block(12, .25f, 10, 4),
                    new Block(12, .25f, 10, 5.25f),
                    new Block(12, .25f, 10, 6.5f),
                    new Block(12, .25f, 10, 7.75f),
                    new Block(12, .25f, 10, 9),
                    new Block(12, .25f, 10, 10.25f),
                    new Block(12, .25f, 9, 4),
                    new Block(12, .25f, 9, 5.25f),
                    new Block(12, .25f, 9, 6.5f),
                    new Block(12, .25f, 9, 7.75f),
                    new Block(12, .25f, 9, 9),
                    new Block(12, .25f, 9, 10.25f),
                    new Block(12, .25f, 11, 4),
                    new Block(12, .25f, 11, 5.25f),
                    new Block(12, .25f, 11, 6.5f),
                    new Block(12, .25f, 11, 7.75f),
                    new Block(12, .25f, 11, 9),
                    new Block(12, .25f, 11, 10.25f),
                    new PhysicsHat("FrictionFlamethrower",4,4),
                };

            var finalMap2 =
                new Actor[]
                {
                    new Actors.IntraMapPortal("Entrance", String.Empty, 2, 4),
                    new Actors.InterMapPortal("Exit", "finalMap3.Entrance", 16, 3),
                    new Platform(3,Color.Coral, 3, 2),
                    new Block(12, .25f, 4, 3),
                    new PhysicsHat("GravityGrenade", 4,4),
                    new Platform(12, Color.Blue, 7, 10, .785397f),
                    new Platform(2, Color.Blue, 14, 12)
                 };
            var finalMap3 =
                new Actor[]
                {
                    new Actors.IntraMapPortal("Entrance", String.Empty, 2, 15),
                    new Actors.InterMapPortal("Exit", "finalMap1.Entrance", 16, 3),
                    new Platform(4, Color.Blue, 1, 15, (float)Math.PI/2f),
                    new Platform(4, Color.Blue, 3, 15, (float)Math.PI/2f),
                    new Platform(5, Color.Blue, 2, 11, 2),
                    new Platform(5, Color.Blue, 4, 11, 2),
                    new PhysicsHat("FrictionFlamethrower", 2, 15 ),

                    //new Platform(4, .5f, Color.Red, 6, 4, -.55f), //4.3 | 6.4
                    Platform.GeneratePlatform(new Vector2(4.0f, 4.5f), new Vector2(7f, 3.0f), .5f, Color.Red, 0f),
                    Platform.GeneratePlatform(new Vector2(7f, 3.0f), new Vector2(10f, 3.0f), .5f, Color.Red, 0f),
                    Platform.GeneratePlatform(new Vector2(10f, 3.0f), new Vector2(12f, 3.5f), .5f, Color.Red, 0f),

                    new Block(.01f, .25f, 8, 4, 0.0f)
                 };
            //end test map listing
            //

            HardCodedMaps.Add("finalMap1", finalMap1);
            HardCodedMaps.Add("finalMap2", finalMap2);
            HardCodedMaps.Add("finalMap3", finalMap3);

            if (!ActiveProfile.IsSavedProfileNull()) ActiveProfile.Load();
            else ActiveProfile.SetCurrentMap("finalMap1", "Entrance", true);

            ActiveProfile.PhysicsWeaponInventory.WeaponPowerChanged += new PhysicsWeaponManagerEventHandler(RefreshWeaponPowerLabel);
            ActiveProfile.PhysicsWeaponInventory.WeaponSwitched += new PhysicsWeaponManagerEventHandler(RefreshWeaponPowerLabel);
        }