Example #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);


            SetContentView(Resource.Layout.ScaleImage);

            // Register our sensor listener
            _sensorManager = (SensorManager) GetSystemService(SensorService);
            _sensorListener = new CustomListener(_sensorManager);
            _sensorListener.AccelerationProcessor.OnValueChanged += AccelerationProcessorOnValueChanged;
            _sensorListener.RotationProcessor.OnValueChanged += RotationProcessorOnValueChanged;

            // Class that will handle drawing of the map
            _mapMaker = new MapMaker();
            _mapMaker.Initialize(Resources);

            var graphAsset = Assets.Open("dcsGroundFloor.xml");
            var graphInstance = Graph.Load(graphAsset);

            _mapMaker.PathfindingGraph = graphInstance;

            _collision = new Collision(graphInstance, new StepDetector());
            _collision.SetLocation(707.0f, 677.0f);
            _collision.PassHeading(90);
            
            _collision.PositionChanged += CollisionOnPositionChanged;
            _collision.StepDetector.OnStep += StepDetectorOnStep;

            collisionMap = BitmapFactory.DecodeResource(Resources,Resource.Drawable.dcsFloor);

            _walCol = new WallCollision((x,y)=>collisionMap.GetPixel(x,y));
            _collision.WallCol = _walCol;


            pf = new Pathfinding.Pathfinding(new Dictionary<int, Stream>()
            {
                {0,Assets.Open("dcsGroundFloor.xml") },
                {1,Assets.Open("dcsFloor1.xml") }
            },Assets.Open("Rooms.xml") );
            pf.CurrentFloor = 0;


            while (true)
            {
                if (pf.Ready)
                    break;
                Thread.Sleep(500);
            }

            var result = pf.FindPath(new GraphLocatable(609, 457, 1), new GraphLocatable(1256, 80, 0));


            setUpUITabs();
        }