private void CreateAnimations()
        {
            for (int i = CurrentInstructionIndex; i < CurrentProgram.Instructions.Count; i++)
            {
                Instruction instruction = CurrentProgram.Instructions[i];
                switch (instruction.InstructionType)
                {
                case Instruction.Type.Forward:
                    animations.Add(GetMoveAnimation(instruction.Repeat));
                    UpdatePosition();
                    break;

                case Instruction.Type.TurnLeft:
                    animations.Add(GetTurnAnimation(-90));
                    CurrentOrientation.TurnLeft();
                    break;

                case Instruction.Type.TurnRight:
                    animations.Add(GetTurnAnimation(90));
                    CurrentOrientation.TurnRight();
                    break;

                case Instruction.Type.ReadSensor:
                    animations.Add(GetSensorAnimation());
                    break;
                }
            }
            CurrentPosition    = new Position(InitialPosition.X, InitialPosition.Y);
            CurrentOrientation = new Compass(InitialOrientation.Orientation);
        }
Exemple #2
0
 private void RestoreOrientation()
 {
     if (OrientationLocked)
     {
         bool portrait = CurrentOrientation.IsPortrait();
         if (portrait)
         {
             SupportedOrientations = SupportedPageOrientation.Portrait;
         }
         else
         {
             SupportedOrientations = SupportedPageOrientation.Landscape;
         }
     }
 }
Exemple #3
0
        private void MainPage_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            // this computes the current orientation and spanned status
            QueryOrientation();

            Debug.WriteLine("Width of Window is {0}", Window.Current.Bounds.Width);
            Debug.WriteLine("Height of Window is {0}", Window.Current.Bounds.Height);

            Debug.WriteLine("Actual Width of MainView is {0}", MainView.ActualWidth);
            Debug.WriteLine("Actual Height of MainView is {0}", MainView.ActualHeight);

            Debug.WriteLine(string.Format("CurrentOrientation is {0}", CurrentOrientation.ToString()));
            Debug.WriteLine(string.Format("ApplicationIsSpanned = {0}", ApplicationIsSpanned.ToString()));

            Debug.WriteLine("------------------------------------------------");
        }
Exemple #4
0
        void UpdateScreenSize()
        {
            _scalingFactor = UIScreen.MainScreen.Scale;

            var boundsWidth  = UIScreen.MainScreen.Bounds.Width;
            var boundsHeight = UIScreen.MainScreen.Bounds.Height;

            // We can't rely directly on the MainScreen bounds because they may not have been updated yet
            // But CurrentOrientation is up-to-date, so we can use it to work out the dimensions
            var width = CurrentOrientation.IsLandscape()
                                ? Math.Max(boundsHeight, boundsWidth)
                                : Math.Min(boundsHeight, boundsWidth);

            var height = CurrentOrientation.IsPortrait()
                                ? Math.Max(boundsHeight, boundsWidth)
                                : Math.Min(boundsHeight, boundsWidth);

            _scaledScreenSize = new Size(width, height);
            _pixelScreenSize  = new Size(_scaledScreenSize.Width * _scalingFactor, _scaledScreenSize.Height * _scalingFactor);
        }
Exemple #5
0
        private void CreateAnimations()
        {
            for (int i = CurrentInstructionIndex; i < CurrentProgram.Instructions.Count; i++)
            {
                Instruction instruction = CurrentProgram.Instructions[i];
                switch (instruction.InstructionType)
                {
                case Instruction.Type.Forward:
                    animations.Add(GetMoveAnimation(instruction.Repeat));
                    break;

                case Instruction.Type.TurnLeft:
                    animations.Add(GetTurnAnimation(-90));
                    CurrentOrientation.TurnLeft();
                    break;

                case Instruction.Type.TurnRight:
                    animations.Add(GetTurnAnimation(90));
                    CurrentOrientation.TurnRight();
                    break;
                }
            }
        }
 private void TurnRightAnimation_Completed(object sender, EventArgs e)
 {
     CurrentOrientation.TurnRight();
 }
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return(Constants.ABREVIATION_AVENTURER + Constants.SEPERATOR + Name + Constants.SEPERATOR + AdventurerPosition?.AxeHorizontal + Constants.SEPERATOR + AdventurerPosition?.AxeVertical +
            Constants.SEPERATOR + CurrentOrientation.ToString() + Constants.SEPERATOR + NumberTreasureFound);
 }