Exemple #1
0
        private string ConvertDirectionToString(PackmanDirection obj)
        {
            switch (obj)
            {
            case PackmanDirection.North:
                return("North");

            case PackmanDirection.South:
                return("South");

            case PackmanDirection.East:
                return("East");

            case PackmanDirection.West:
                return("West");
            }

            return(string.Empty);
        }
Exemple #2
0
        private async void PlacePackmanForReset(PackmanDirection direction, double positionX, double positionY)
        {
            CachedDirection           = direction;
            this.PackmanView.Rotation = 0; //Set thre Packman position to its default
            switch (direction)
            {
            case PackmanDirection.North:
                this.PackmanView.Rotation -= 90;
                break;

            case PackmanDirection.West:
                this.PackmanView.Rotation -= 180;
                break;

            case PackmanDirection.South:
                this.PackmanView.Rotation += 90;
                break;
            }

            if (positionX >= ScreenWidth) //Format Position X
            {
                positionX -= 45;
            }

            if (positionY >= ScreenHeight) //Format Position X
            {
                positionY -= 45;
            }

            //Prevent any Negative Values
            if (positionY < 0)
            {
                positionY = 0;
            }
            if (positionX < 0)
            {
                positionX = 0;
            }

            this.PackmanView.TranslationX = positionX;
            this.PackmanView.TranslationY = positionY;
        }
Exemple #3
0
        private async void NotifyViewModelOfDirectionalChange(bool isRight)
        {
            switch (CachedDirection)
            {
                #region Packman Rotations
            case PackmanDirection.East:

                if (isRight)
                {
                    CachedDirection            = PackmanDirection.South;
                    this.PackmanView.Rotation += 90;
                }
                else
                {
                    CachedDirection            = PackmanDirection.North;
                    this.PackmanView.Rotation -= 90;
                }
                break;

            case PackmanDirection.West:
                if (isRight)
                {
                    CachedDirection            = PackmanDirection.North;
                    this.PackmanView.Rotation += 90;
                }
                else
                {
                    CachedDirection            = PackmanDirection.South;
                    this.PackmanView.Rotation -= 90;
                }
                break;

            case PackmanDirection.South:
                if (isRight)
                {
                    CachedDirection            = PackmanDirection.West;
                    this.PackmanView.Rotation += 90;
                }
                else
                {
                    CachedDirection            = PackmanDirection.East;
                    this.PackmanView.Rotation -= 90;
                }
                break;

            case PackmanDirection.North:
                if (isRight)
                {
                    CachedDirection            = PackmanDirection.East;
                    this.PackmanView.Rotation += 90;
                }
                else
                {
                    CachedDirection            = PackmanDirection.West;
                    this.PackmanView.Rotation -= 90;
                }
                break;
                #endregion
            }

            await IoC.Get <IEventAggregator>()
            .PublishOnUIThreadAsync(new PackmanRotationDataHandler()
            {
                Direction = CachedDirection
            });                                   //Notify the Message Broker of changes to CachedDirection
        }