Esempio n. 1
0
 public void SetToSpell(SpellObject Spell)
 {
     buttonType    = ActionButtonType.Spell;
     name          = Spell.Name;
     Data          = Spell;
     numOfSameName = 0;
 }
Esempio n. 2
0
        public override int ReadFrom(byte[] Buffer, int StartIndex = 0)
        {
            int cursor = StartIndex;

            cursor += base.ReadFrom(Buffer, cursor);

            NewSpellObject = new SpellObject(Buffer, cursor);
            cursor += NewSpellObject.ByteLength;

            return cursor - StartIndex;
        }
Esempio n. 3
0
        public void SetToSpell(SpellObject Spell)
        {
            if (Spell == null)
            {
                return;
            }

            // remove attached listener
            RemoveListener();

            buttonType    = ActionButtonType.Spell;
            name          = Spell.Name;
            numOfSameName = 0;

            Data = Spell;
            Spell.PropertyChanged += OnObjectPropertyChanged;
        }
Esempio n. 4
0
        public override int ReadFrom(byte[] Buffer, int StartIndex = 0)
        {
            int cursor = StartIndex;

            cursor += base.ReadFrom(Buffer, cursor);

            ushort len = BitConverter.ToUInt16(Buffer, cursor);
            cursor += TypeSizes.SHORT;

            SpellObjects = new SpellObject[len];
            for (int i = 0; i < len; i++)
            {
                SpellObjects[i] = new SpellObject(Buffer, cursor);
                cursor += SpellObjects[i].ByteLength;
            }

            return cursor - StartIndex;
        }
Esempio n. 5
0
 public SpellAddMessage(SpellObject spellObject) 
     : base(MessageTypeGameMode.SpellAdd)
 {         
     this.NewSpellObject = spellObject;          
 }
Esempio n. 6
0
 public override unsafe void ReadFrom(ref byte* Buffer)
 {
     base.ReadFrom(ref Buffer);
     NewSpellObject = new SpellObject(ref Buffer);
 }
Esempio n. 7
0
 public ChatCommandCast(SpellObject Spell)
 {
     this.Spell = Spell;
 }
Esempio n. 8
0
 public ChatCommandCast()
 {
     Spell = new SpellObject();
 }
Esempio n. 9
0
        /// <summary>
        /// Almost exactly like ParseGoPlayer
        /// </summary>
        /// <param name="Words"></param>
        /// <param name="Text"></param>
        /// <param name="Data"></param>
        /// <returns></returns>
        protected static ChatCommandCast ParseCast(string[] Words, string Text, DataController Data)
        {
            Tuple <int, int, string> quote   = null;
            ChatCommandCast          command = null;
            SpellObject        spell         = null;
            string             prefix        = null;
            List <SpellObject> list          = null;
            int num = 0;

            if (Words == null || Words.Length < 2)
            {
                return(null);
            }

            // extract quoted name if second word starts with "
            // this is necessary to not care about quoted text (t someone "yes yes")
            // but only for quoted names (t "mister x" hello!)
            if (Words[1].Length > 0 && Words[1][0] == QUOTECHAR)
            {
                quote = Text.GetQuote();
            }

            /********* QUOTED NAME *********/
            if (quote != null)
            {
                // try get exact match for quoted name
                spell = Data.SpellObjects.GetItemByName(quote.Item3, false);

                if (spell != null)
                {
                    command = new ChatCommandCast(spell);
                }

                // no player with that name
                else
                {
                    Data.ChatMessages.Add(ServerString.GetServerStringForString(
                                              "No spell with name: " + quote.Item3));
                }
            }

            /********* UNQUOTED NAME *********/
            else
            {
                prefix = Words[1];
                list   = Data.SpellObjects.GetItemsByNamePrefix(prefix);

                // extend prefix with more words
                // until there is only one or zero matches found
                // or until there is only one more word left (supposed minimal text)
                num = 2;
                while (list.Count > 1 && num < Words.Length)
                {
                    prefix += DELIMITER + Words[num];
                    list    = Data.SpellObjects.GetItemsByNamePrefix(prefix);
                    num++;
                }

                if (list.Count == 1)
                {
                    command = new ChatCommandCast(list[0]);
                }

                // still more than one player with max. prefix
                else if (list.Count > 1)
                {
                    Data.ChatMessages.Add(ServerString.GetServerStringForString(
                                              "More than one spell with prefix: " + prefix));
                }

                // no spell with that prefix
                else
                {
                    Data.ChatMessages.Add(ServerString.GetServerStringForString(
                                              "No spell with prefix: " + prefix));
                }
            }

            return(command);
        }
Esempio n. 10
0
 public ChatCommandCast(SpellObject Spell)
 {
     this.Spell = Spell;
 }
Esempio n. 11
0
 public ChatCommandCast()
 {
     Spell = new SpellObject();
 }
Esempio n. 12
0
        public override unsafe void ReadFrom(ref byte* Buffer)
        {
            base.ReadFrom(ref Buffer);

            ushort len = *((ushort*)Buffer);
            Buffer += TypeSizes.SHORT;

            SpellObjects = new SpellObject[len];
            for (int i = 0; i < len; i++)
                SpellObjects[i] = new SpellObject(ref Buffer);

        }
Esempio n. 13
0
 public SpellsMessage(SpellObject[] SpellObjects) 
     : base(MessageTypeGameMode.Spells)
 {           
     this.SpellObjects = SpellObjects;
 }
Esempio n. 14
0
 public SpellObjectEventArgs(SpellObject Spell)
 {
     this.Spell = Spell;
 }
 public void SetToSpell(SpellObject Spell)
 {
     buttonType = ActionButtonType.Spell;
     name = Spell.Name;
     Data = Spell;
     numOfSameName = 0;
 }