Exemple #1
0
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            _physicsController = LayoutRoot.GetValue(PhysicsControllerMain.PhysicsControllerProperty) as PhysicsControllerMain;
            BoundaryCache.ReadBoundaryCache(_physicsController);

            _physicsController.Collision += new PhysicsControllerMain.CollisionHandler(_physicsController_Collision);
        }
Exemple #2
0
        private void GamePageLoaded(object sender, RoutedEventArgs e)
        {
            //get reference to physics controller
            _physicsController =
                LayoutRoot.GetValue(PhysicsControllerMain.PhysicsControllerProperty) as PhysicsControllerMain;


            //hook up initilized event
            _physicsController.Initialized += PhysicsControllerInitialized;


            //setup finger
            _finger = new Ellipse
            {
                Name            = "finger",
                Height          = 50,
                Width           = 50,
                StrokeThickness = 3,
                Stroke          = new SolidColorBrush(Colors.Red)
            };

            // Spawn initial branches
            for (int i = 0; i < (random.Next(2) + 4); i++)
            {
                spawnBranch((Side)random.Next(2), random.Next(500));
            }
        }
Exemple #3
0
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            _physicsController            = cnvGame.GetValue(PhysicsControllerMain.PhysicsControllerProperty) as PhysicsControllerMain;
            _physicsController.TimerLoop += new PhysicsControllerMain.TimerLoopHandler(_physicsController_TimerLoop);

            _accelerometer = new AccelerometerWrapper(cnvGame);
            _accelerometer.ReadingChanged += new AccelerometerWrapper.ReadingChangedHandler(_accelerometer_ReadingChanged);
        }
Exemple #4
0
        void AssociatedObject_Loaded(object sender, RoutedEventArgs e)
        {
            _controller = PhysicsControllerMain.FindController(this.AssociatedObject);
            if (_controller == null)
            {
                throw new Exception("You must add a PhysicsController Behavior to the Canvas representing the main Container.");
            }

            _controller.Initialized += new PhysicsControllerMain.InitializedHandler(controller_Initialized);
        }
        protected override void OnAttached()
        {
            base.OnAttached();

            this.AssociatedObject.Loaded += new RoutedEventHandler(AssociatedObject_Loaded);

            _physicsControllerMain.AutoAddCanvasObjects = false;

            PhysicsControllerMain.SetPhysicsController(this.AssociatedObject, _physicsControllerMain);
        }
Exemple #6
0
        public MainPage()
        {
            InitializeComponent();

            // note that we can use the Physics Controller to manipulate objects
            // in the simulation...
            _physicsController              = LayoutRoot.GetValue(PhysicsControllerMain.PhysicsControllerProperty) as PhysicsControllerMain;
            _physicsController.Initialized += new PhysicsControllerMain.InitializedHandler(_physicsController_Initialized);
            _physicsController.TimerLoop   += new PhysicsControllerMain.TimerLoopHandler(_physicsController_TimerLoop);
        }
        void AssociatedObject_Loaded(object sender, RoutedEventArgs e)
        {
            // also check for a physics controller behavior
            _physicsController = PhysicsControllerMain.FindController(this.AssociatedObject);
            if (_physicsController == null)
            {
                return;
            }

            _physicsController.Initialized += new PhysicsControllerMain.InitializedHandler(physicsController_Initialized);
        }
 void ucAstronaut_Loaded(object sender, RoutedEventArgs e)
 {
     _physicsController = LayoutRoot.GetValue(PhysicsControllerMain.PhysicsControllerProperty) as PhysicsControllerMain;
 }
Exemple #9
0
 void MainPage_Loaded(object sender, RoutedEventArgs e)
 {
     _physicsController = cnvGame.GetValue(PhysicsControllerMain.PhysicsControllerProperty) as PhysicsControllerMain;
 }
Exemple #10
0
        private void GamePageLoaded(object sender, RoutedEventArgs e)
        {
            //get reference to physics controller
            _physicsController =
                LayoutRoot.GetValue(PhysicsControllerMain.PhysicsControllerProperty) as PhysicsControllerMain;

            //hook up initilized event
            _physicsController.Initialized += PhysicsControllerInitialized;

            //setup finger
            _finger = new Ellipse
                          {
                              Name = "finger",
                              Height = 50,
                              Width = 50,
                              StrokeThickness = 3,
                              Stroke = new SolidColorBrush(Colors.Red)
                          };

            // Spawn initial branches
            for (int i = 0; i < (random.Next(2) + 4); i++)
            {
                spawnBranch((Side)random.Next(2), random.Next(500));
            }
        }
Exemple #11
0
        private void SetupReleaseTarget(object sender, PhysicsControllerMain physMain, ManipulationCompletedEventArgs e)
        {
            //remove old joints
            if (_joints.Count > 0)
            {
                foreach (DistanceJoint jnt in _joints)
                {
                    physMain.DeleteObject(jnt);
                }
            }

            const float breakpoint = 1000f;

            //translate coordinates relative to screen
            var touchedObject = sender as PhysicsSprite;
            //var list = BoundaryHelper.GetPointsForElement(touchedObject.uiElement, e.ManipulationContainer, false);

            //get reference to player
            PhysicsSprite player = physMain.PhysicsObjects["player"];

            var letgopoint = new Point((int) e.ManipulationOrigin.X + (int) e.TotalManipulation.Translation.X,
                                       (int) e.ManipulationOrigin.Y + (int) e.TotalManipulation.Translation.Y);

            Body testBody = BodyFactory.CreateCircle(physMain.Simulator, 25, 1, physMain.ScreenToWorld(letgopoint));

            //create distance joint between the two
            DistanceJoint joint = JointFactory.CreateDistanceJoint(physMain.Simulator, player.BodyObject,
                                                                   testBody, Vector2.Zero, Vector2.Zero);

            joint.Frequency = 4.0f;
            joint.DampingRatio = .5f;
            joint.Breakpoint = breakpoint;
            joint.CollideConnected = true;
            joint.Broke += joint_Broke;
            _joints.Add(joint);

            //create tounge

            //timer
            var timer = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(33)};

            timer.Tick += delegate
                              {
                                  //joint broke
                                  if (!joint.Enabled)
                                  {
                                      timer.Stop();
                                      physMain.DeleteObject(joint);
                                      return;
                                  }

                                  //reduce distance
                                  if (joint.Length <= 0f)
                                  {
                                      timer.Stop();
                                  }
                                  joint.Length -= .1f;
                              };
            timer.Start();
        }
Exemple #12
0
        private void SetupReleaseTarget(object sender, PhysicsControllerMain physMain, ManipulationCompletedEventArgs e)
        {
            //remove old joints
            if (_joints.Count > 0)
            {
                foreach (DistanceJoint jnt in _joints)
                {
                    physMain.DeleteObject(jnt);
                }
            }

            const float breakpoint = 1000f;

            //translate coordinates relative to screen
            var touchedObject = sender as PhysicsSprite;
            //var list = BoundaryHelper.GetPointsForElement(touchedObject.uiElement, e.ManipulationContainer, false);

            //get reference to player
            PhysicsSprite player = physMain.PhysicsObjects["player"];


            var letgopoint = new Point((int)e.ManipulationOrigin.X + (int)e.TotalManipulation.Translation.X,
                                       (int)e.ManipulationOrigin.Y + (int)e.TotalManipulation.Translation.Y);

            Body testBody = BodyFactory.CreateCircle(physMain.Simulator, 25, 1, physMain.ScreenToWorld(letgopoint));

            //create distance joint between the two
            DistanceJoint joint = JointFactory.CreateDistanceJoint(physMain.Simulator, player.BodyObject,
                                                                   testBody, Vector2.Zero, Vector2.Zero);

            joint.Frequency        = 4.0f;
            joint.DampingRatio     = .5f;
            joint.Breakpoint       = breakpoint;
            joint.CollideConnected = true;
            joint.Broke           += joint_Broke;
            _joints.Add(joint);

            //create tounge


            //timer
            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(33)
            };

            timer.Tick += delegate
            {
                //joint broke
                if (!joint.Enabled)
                {
                    timer.Stop();
                    physMain.DeleteObject(joint);
                    return;
                }

                //reduce distance
                if (joint.Length <= 0f)
                {
                    timer.Stop();
                }
                joint.Length -= .1f;
            };
            timer.Start();
        }