Exemplo n.º 1
0
        private void ShowNextPose(AnimationEnum animationType)
        {
            Console.ForegroundColor = MeemkiColor;

            MeemkiAnimation animationToPlay = animationList.Where(a => a.AnimationKind == animationType).First();

            //handle locking animations
            //LOCK
            if (animationToPlay.IsLockingAnimation)
            {
                Global.Variables.AnimationLock   = true;
                Global.Variables.LockedAnimation = animationType;
            }

            if (animationType == lastAnimationPlayed)
            {
                int poseIndex = lastPlayedPoseIndex + 1 < animationToPlay.NumberOfFrames ? lastPlayedPoseIndex + 1 : 0;

                MeemkiPose newPose = animationToPlay.AnimationPoses[poseIndex];

                //loop on the right edge
                if (meemkiPosition.X + newPose.XOffsetToPrevious + Global.Variables.MeemkiWidth > Console.BufferWidth) //+ Meemki's width, so the check is about whole Meemki and not just the position where the drawing starts...
                {
                    meemkiPosition.X = 0;
                }
                //loop on the left edge
                else if (meemkiPosition.X + newPose.XOffsetToPrevious < 0)
                {
                    meemkiPosition.X = Console.BufferWidth - Global.Variables.MeemkiWidth;
                }
                else
                {
                    meemkiPosition.X += newPose.XOffsetToPrevious;
                }

                meemkiPosition.Y += newPose.YOffsetToPrevious;

                foreach (Model.PositionedChar posChar in newPose.Pose)
                {
                    int xOffset = (int)posChar.Position.X + meemkiPosition.X;
                    int yOffset = (int)posChar.Position.Y + meemkiPosition.Y;
                    Console.SetCursorPosition(xOffset, yOffset);
                    if (posChar.Char != ' ')
                    {
                        Console.Write(posChar.Char);
                    }
                }
                System.Threading.Thread.Sleep(newPose.ShowInMilliseconds);
                lastPlayedPoseIndex = poseIndex;
                lastAnimationPlayed = animationType;
                lastMeemkiPosition  = meemkiPosition;
            }
            else
            {
                lastPlayedPoseIndex = -1;
                lastAnimationPlayed = animationType;
                ShowNextPose(animationType);
            }

            //UNLOCK
            if (lastPlayedPoseIndex == animationToPlay.NumberOfFrames - 1)
            {
                Global.Variables.AnimationLock = false;
            }
        }
Exemplo n.º 2
0
 public Meemki()
 {
     meemkiPosition = new MeemkiPosition();
     animationList  = new Logic.AnimationLoader().Load();
 }