示例#1
0
 /// <summary>
 /// Loads letters dictionary with A to Z uppercase
 /// </summary>
 private void LoadLetters()
 {
     for (int i = 65; i <= 90; i++)
     {
         Letters.Add(Convert.ToChar(i), true);
     }
 }
示例#2
0
        public void AddLetter(int width, int height)
        {
            LetterCircle lc = new LetterCircle(random, width, height);

            Count[lc.Letter - 'A']++;
            Letters.Add(lc);
        }
示例#3
0
        /// <summary>
        /// Sends the letter.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="receiver">The receiver.</param>
        /// <param name="message">The message.</param>
        /// <param name="title">The title.</param>
        /// <param name="rotation">The rotation.</param>
        /// <param name="animation">The animation.</param>
        /// <param name="letterId">The client side letter id.</param>
        public void SendLetter(Player player, string receiver, string message, string title, byte rotation, byte animation, uint letterId)
        {
            using var loggerScope = player.Logger.BeginScope(this.GetType());
            var sendPrice = player.GameContext.Configuration.LetterSendPrice;

            if (player.Money < sendPrice)
            {
                player.ViewPlugIns.GetPlugIn <IShowMessagePlugIn>()?.ShowMessage("Not enough Zen to send a letter.", MessageType.BlueNormal);
                player.ViewPlugIns.GetPlugIn <ILetterSendResultPlugIn>()?.LetterSendResult(LetterSendSuccess.NotEnoughMoney, letterId);
                return;
            }

            if (player.SelectedCharacter is null)
            {
                player.ViewPlugIns.GetPlugIn <ILetterSendResultPlugIn>()?.LetterSendResult(LetterSendSuccess.TryAgain, letterId);
                return;
            }

            LetterHeader?letter;

            try
            {
                using (var context = player.GameContext.PersistenceContextProvider.CreateNewPlayerContext(player.GameContext.Configuration))
                {
                    letter = this.CreateLetter(context, player, receiver, message, title, rotation, animation);
                    if (!context.CanSaveLetter(letter))
                    {
                        player.ViewPlugIns.GetPlugIn <ILetterSendResultPlugIn>()?.LetterSendResult(LetterSendSuccess.ReceiverNotExists, letterId);
                        return;
                    }

                    context.SaveChanges();
                }

                player.ViewPlugIns.GetPlugIn <ILetterSendResultPlugIn>()?.LetterSendResult(LetterSendSuccess.Success, letterId);
                player.TryAddMoney(-sendPrice);
            }
            catch (Exception ex)
            {
                player.Logger.LogError(ex, "Unexpected error when trying to send a letter");
                player.ViewPlugIns.GetPlugIn <ILetterSendResultPlugIn>()?.LetterSendResult(LetterSendSuccess.TryAgain, letterId);
                player.ViewPlugIns.GetPlugIn <IShowMessagePlugIn>()?.ShowMessage("Oops, some error happened during sending the Letter.", MessageType.BlueNormal);
                return;
            }

            // Try to forward it to the player, if he is online
            var receiverPlayer = player.GameContext.GetPlayerByCharacterName(receiver);

            if (receiverPlayer != null)
            {
                receiverPlayer.PersistenceContext.Attach(letter);
                receiverPlayer.SelectedCharacter !.Letters.Add(letter);
                receiverPlayer.ViewPlugIns.GetPlugIn <IAddToLetterListPlugIn>()?.AddToLetterList(letter, (ushort)(receiverPlayer.SelectedCharacter.Letters.Count - 1), true);
            }
            else
            {
                (player.GameContext as IGameServerContext)?.FriendServer?.ForwardLetter(letter);
            }
        }
示例#4
0
    public void GenerateLetterList(string currentWord)
    {
        for (int i = 0; i < currentWord.Length; i++)

        {
            Letters.Add(new Letter(currentWord[i].ToString()));
        }
    }
        public Message()
        {
            Letter letter;


            Console.Write("Choose a letter for the logo (only M implemented): ");
            string letterString = Console.ReadLine().ToLower();

            switch (letterString)
            {
            case "m":
                letter = new LetterM();
                break;

            default:
                Console.WriteLine("The letter has not been implemented yet!");
                return;
            }

            Console.Write("Enter the size of the logo (letters count, e.g. 2 -> MM): ");
            lettersCountString = Console.ReadLine();
            lettersCount       = LettersCount;

            int thickness;

            Console.Write("Choose letter thickness (odd number between 3 and 9999 incl.): ");
            string thicknessString = Console.ReadLine();

            while (!int.TryParse(thicknessString, out thickness) || thickness % 2 == 0 || thickness < 3 || thickness > 9999)
            {
                Console.Write("Invalid value.\nChoose letter thickness (odd number between 3 and 9999 incl.): ");
                thicknessString = Console.ReadLine();
            }

            Console.Write("Choose a spacing string (recommended '-'): ");
            string spacingString = Console.ReadLine();

            char fillingCharacter;

            Console.Write("Choose a filling character (recommended '*'): ");
            string fillingCharacters = Console.ReadLine();

            while (!char.TryParse(fillingCharacters, out fillingCharacter))
            {
                Console.Write("Invalid value.\nChoose a filling character (recommended '*': ");
                fillingCharacters = Console.ReadLine();
            }

            letter.SetValues(thickness, spacingString, fillingCharacter);

            for (int i = 0; i < lettersCount; i++)
            {
                Letters.Add(letter);
            }
        }
示例#6
0
 public void GetLetters()
 {
     char[] chars = Input.ToCharArray();
     foreach (char character in chars)
     {
         Letters.Add(Char.ToLower(character));
     }
     foreach (char letter in Letters)
     {
         Letter newLetter = new Letter(letter);
         newLetter.SetPoint();
         Score = Score += newLetter.Points;
     }
 }
        public void AddLetter(Key key)
        {
            if (!CanType(key.ToString().ToLower()[0]))
            {
                return;
            }

            int xOffset = 0;

            Letters.ForEach(x => { xOffset += x.Width; });

            var gm = new GameMessage()
            {
                Skin     = GetASCII(key),
                PreciseX = this.PreciseX + xOffset,
                PreciseY = this.PreciseY
            };

            Letters.Add(gm);
            LetterSequence += key.ToString().ToLower();
            RecalculatePoints();
        }
        public void AddSpace()
        {
            if (!CanType(' '))
            {
                return;
            }

            int xOffset = 0;

            Letters.ForEach(x => { xOffset += x.Width; });

            var gm = new GameMessage()
            {
                Skin     = "   ",
                PreciseX = this.PreciseX + xOffset,
                PreciseY = this.PreciseY
            };

            Letters.Add(gm);
            LetterSequence += " ";
            RecalculatePoints();
        }
示例#9
0
 public void Add(char letter)
 {
     Letters.Add(new Letter(letter));
 }
示例#10
0
        /// <summary>
        /// Creates a complete font file and returns it as String
        /// </summary>
        /// <param name="firstChar">The character to start with</param>
        /// <param name="charCount">The number of characters to include by inc. the Chars Ordinal (ASCII 7bit only)</param>
        /// <param name="widthTarget">Width target setting</param>
        /// <returns>The created font file as String</returns>
        public override String FontFile(Char firstChar, int charCount, FontOptimizer.WidthTarget widthTarget)
        {
            String ret = "";

            // store args
            FirstChar = firstChar;
            CharCount = charCount;

            m_letters = new Letters(LetterFactory); // create font machine.. and submit the factory
            // create string
            int lastChar = Convert.ToChar(Convert.ToByte(FirstChar) + CharCount - 1);

            for (Char c = FirstChar; c <= lastChar; c++)
            {
                Size s = m_letters.Add(c, m_fo, widthTarget); // --> this will essentially capture all characters bits via Letter instance

                if (m_firstSize.Height == 0)
                {
                    m_firstSize = s;                        // collect size information - init in 1st round
                }
                Monospace = Monospace & (s == m_firstSize); // gets false if sizes are different
            }
            // final size from collected bit patterns
            Width  = m_letters.MaxSize.Width;
            Height = m_letters.MaxSize.Height;

            UInt16 totalSize = 6; // descriptor code size

            if (!Monospace)
            {
                totalSize += ( UInt16 )m_letters.SizeTable.Count;         // fixed fonts don't have a size table
            }
            totalSize += ( UInt16 )m_letters.CodeSize( );
            CodeSize   = totalSize;

            // start output
            FontNameCreated = ModName( );

            // create the file (collect all in one String)
            ret += Header( );
            // descriptor
            ret += Descriptor( );

            // code portion
            ret += CodeStart(totalSize);
            if (!Monospace)
            {
                ret += m_letters.SizeTable.GetBytes( );         // fixed fonts don't have a size table
            }
            // all font code now
            ret += m_letters.GetBytes( );
            // remove last comma from hex bytes
            int lc = ret.LastIndexOf(',');

            if (lc != -1)
            {
                ret = ret.Remove(lc, 1);
            }

            // write the code trailer
            ret += Trailer( );

            return(ret); // Done
        }