Exemple #1
0
 public GlyphDataAttribute(int index, int spellid, int effectid, string name, GlyphType type, string description)
 {
     _index = index;
     _spellid = spellid;
     _effectid = effectid;
     _name = name;
     _type = type;
     _description = description;
 }
Exemple #2
0
        public override void HandlePacket(BinaryReader reader, int whoAmI)
        {
            MessageType id = (MessageType)reader.ReadByte();
            byte        player;

            switch (id)
            {
            case MessageType.ProjectileData:
                gProj.ReceiveProjectileData(reader, whoAmI);
                break;

            case MessageType.Dodge:
                player = reader.ReadByte();
                byte type = reader.ReadByte();
                if (Main.netMode == 2)
                {
                    ModPacket packet = GetPacket(MessageType.Dodge, 2);
                    packet.Write(player);
                    packet.Write(type);
                    packet.Send(-1, whoAmI);
                }
                if (type == 1)
                {
                    Items.Glyphs.VeilGlyph.Block(Main.player[player]);
                }
                else
                {
                    ErrorLogger.Log("SpiritMod: Unknown message (2:" + type + ")");
                }
                break;

            case MessageType.Dash:
                player = reader.ReadByte();
                DashType dash = (DashType)reader.ReadByte();
                sbyte    dir  = reader.ReadSByte();
                if (Main.netMode == 2)
                {
                    ModPacket packet = GetPacket(MessageType.Dash, 3);
                    packet.Write(player);
                    packet.Write((byte)dash);
                    packet.Write(dir);
                    packet.Send(-1, whoAmI);
                }
                Main.player[player].GetModPlayer <MyPlayer>().PerformDash(dash, dir, false);
                break;

            case MessageType.PlayerGlyph:
                player = reader.ReadByte();
                GlyphType glyph = (GlyphType)reader.ReadByte();
                if (Main.netMode == 2)
                {
                    ModPacket packet = GetPacket(MessageType.PlayerGlyph, 2);
                    packet.Write(player);
                    packet.Write((byte)glyph);
                    packet.Send(-1, whoAmI);
                }
                if (player == Main.myPlayer)
                {
                    break;
                }
                Main.player[player].GetModPlayer <MyPlayer>().glyph = glyph;
                break;

            default:
                ErrorLogger.Log("SpiritMod: Unknown message (" + id + ")");
                break;
            }
        }
Exemple #3
0
        void AddTagGlyph(List <Glyph> glyphList, string tagText)
        {
            if (tagText.Length < 3 ||
                tagText.Substring(0, 1) != "{" ||
                tagText.Substring(tagText.Length - 1, 1) != "}")
            {
                return;
            }

            string tag = tagText.Substring(1, tagText.Length - 2);

            GlyphType type      = GlyphType.Character;
            string    paramText = "";

            if (tag == "b")
            {
                type = GlyphType.BoldStart;
            }
            else if (tag == "/b")
            {
                type = GlyphType.BoldEnd;
            }
            else if (tag == "i")
            {
                type = GlyphType.ItalicStart;
            }
            else if (tag == "/i")
            {
                type = GlyphType.ItalicEnd;
            }
            else if (tag.StartsWith("color="))
            {
                type      = GlyphType.ColorStart;
                paramText = tag.Substring(6, tag.Length - 6);
            }
            else if (tag == "/color")
            {
                type = GlyphType.ColorEnd;
            }
            else if (tag == "wi")
            {
                type = GlyphType.WaitForInputNoClear;
            }
            if (tag == "wc")
            {
                type = GlyphType.WaitForInputAndClear;
            }
            else if (tag.StartsWith("wp="))
            {
                type      = GlyphType.WaitOnPunctuation;
                paramText = tag.Substring(3, tag.Length - 3);
            }
            else if (tag == "wp")
            {
                type = GlyphType.WaitOnPunctuation;
            }
            else if (tag.StartsWith("w="))
            {
                type      = GlyphType.Wait;
                paramText = tag.Substring(2, tag.Length - 2);
            }
            else if (tag == "w")
            {
                type = GlyphType.Wait;
            }
            else if (tag == "c")
            {
                type = GlyphType.Clear;
            }
            else if (tag.StartsWith("s="))
            {
                type      = GlyphType.Speed;
                paramText = tag.Substring(2, tag.Length - 2);
            }
            else if (tag == "s")
            {
                type = GlyphType.Speed;
            }
            else if (tag == "x")
            {
                type = GlyphType.Exit;
            }

            Glyph glyph = new Glyph();

            glyph.type  = type;
            glyph.param = paramText.Trim();

            glyphList.Add(glyph);
        }
Exemple #4
0
        protected IEnumerator WriteText(string text, Action onWritingComplete, Action onExitTag)
        {
            storyText.text          = "";
            boldActive              = false;
            italicActive            = false;
            colorActive             = false;
            colorText               = "";
            currentSpeed            = writingSpeed;
            currentPunctuationPause = punctuationPause;

            List <Glyph> glyphs = MakeGlyphList(text);

            if (glyphs.Count == 0)
            {
                if (onWritingComplete != null)
                {
                    onWritingComplete();
                }
                yield break;
            }

            // Zero speed means write instantly
            // Also write instantly if text contains rich text markup tags
            if (currentSpeed == 0 ||
                text.Contains("<"))
            {
                foreach (Glyph glyph in glyphs)
                {
                    if (glyph.type == GlyphType.Character)
                    {
                        storyText.text += glyph.param;
                    }
                }

                if (onWritingComplete != null)
                {
                    onWritingComplete();
                }
                yield break;
            }

            GameObject typingAudio = null;

            if (writingSound != null)
            {
                typingAudio = new GameObject("WritingSound");
                typingAudio.AddComponent <AudioSource>();
                typingAudio.audio.clip = writingSound;
                typingAudio.audio.loop = loopWritingSound;
                typingAudio.audio.Play();
            }

            float writeDelay = 0f;

            if (currentSpeed > 0)
            {
                writeDelay = (1f / (float)currentSpeed);
            }

            float timeAccumulator = 0f;

            int i = 0;

            while (i < glyphs.Count)
            {
                timeAccumulator += Time.deltaTime;

                bool skipWriting = false;

                /*
                 * if (Input.GetMouseButtonDown(0))
                 * {
                 *      skipWriting = true;
                 * }
                 */

                while (skipWriting ||
                       timeAccumulator > writeDelay)
                {
                    timeAccumulator -= writeDelay;

                    Glyph glyph = glyphs[i];

                    switch (glyph.type)
                    {
                    case GlyphType.Character:

                        if (storyText.text.Length == 0 && glyph.param == "\n")
                        {
                            // Ignore leading newlines
                        }
                        else
                        {
                            // Wrap each individual character in rich text markup tags if required
                            // This must be done at the character level to support writing out the story text over time.
                            string start = "";
                            string end   = "";
                            if (boldActive)
                            {
                                start += "<b>";
                                end   += "</b>";
                            }
                            if (italicActive)
                            {
                                start += "<i>";
                                end    = "</i>" + end;                              // Have to nest tags correctly
                            }
                            if (colorActive)
                            {
                                start += "<color=" + colorText + ">";
                                end   += "</color>";
                            }

                            storyText.text += start + glyph.param + end;
                        }

                        // Add a wait glyph on punctuation marks
                        bool doPause = punctuationPause > 0 && IsPunctuation(glyph.param);
                        if (i == glyphs.Count - 1)
                        {
                            doPause = false;                             // No pause on last character
                        }
                        else
                        {
                            // No pause if next glyph is a pause
                            GlyphType nextType = glyphs[i + 1].type;
                            if (nextType == GlyphType.Wait ||
                                nextType == GlyphType.WaitForInputAndClear ||
                                nextType == GlyphType.WaitForInputNoClear)
                            {
                                doPause = false;
                            }
                        }

                        if (doPause)
                        {
                            // Ignore if next glyph is also punctuation, or if punctuation is the last character.
                            bool skipCharacter = (i < glyphs.Count - 1 &&
                                                  glyphs[i + 1].type == GlyphType.Character &&
                                                  IsPunctuation(glyphs[i + 1].param));

                            if (!skipCharacter &&
                                !skipWriting)
                            {
                                yield return(new WaitForSeconds(currentPunctuationPause));
                            }
                        }

                        break;

                    case GlyphType.BoldStart:
                        boldActive = true;
                        break;

                    case GlyphType.BoldEnd:
                        boldActive = false;
                        break;

                    case GlyphType.ItalicStart:
                        italicActive = true;
                        break;

                    case GlyphType.ItalicEnd:
                        italicActive = false;
                        break;

                    case GlyphType.ColorStart:
                        colorActive = true;
                        colorText   = glyph.param;
                        break;

                    case GlyphType.ColorEnd:
                        colorActive = false;
                        break;

                    case GlyphType.Wait:
                        float duration = 1f;
                        if (!Single.TryParse(glyph.param, out duration))
                        {
                            duration = 1f;
                        }
                        if (!skipWriting)
                        {
                            yield return(new WaitForSeconds(duration));

                            timeAccumulator = 0f;
                        }
                        break;

                    case GlyphType.WaitForInputNoClear:
                        OnWaitForInputTag(true);
                        yield return(StartCoroutine(WaitForInput(null)));

                        OnWaitForInputTag(false);
                        break;

                    case GlyphType.WaitForInputAndClear:
                        OnWaitForInputTag(true);
                        yield return(StartCoroutine(WaitForInput(null)));

                        OnWaitForInputTag(false);
                        storyText.text = "";
                        break;

                    case GlyphType.Clear:
                        storyText.text = "";
                        break;

                    case GlyphType.Speed:
                        if (!Single.TryParse(glyph.param, out currentSpeed))
                        {
                            currentSpeed = 0f;
                        }
                        writeDelay = 0;
                        if (currentSpeed > 0)
                        {
                            writeDelay = (1f / (float)currentSpeed);
                        }
                        break;

                    case GlyphType.Exit:

                        if (typingAudio != null)
                        {
                            Destroy(typingAudio);
                        }

                        if (onExitTag != null)
                        {
                            onExitTag();
                        }

                        yield break;

                    case GlyphType.WaitOnPunctuation:
                        if (!Single.TryParse(glyph.param, out currentPunctuationPause))
                        {
                            currentPunctuationPause = 0f;
                        }
                        break;
                    }

                    if (++i >= glyphs.Count)
                    {
                        break;
                    }
                }

                yield return(null);
            }

            if (typingAudio != null)
            {
                Destroy(typingAudio);
            }

            if (onWritingComplete != null)
            {
                onWritingComplete();
            }

            yield break;
        }
Exemple #5
0
 private void AddBonder(ref Vector2 position, int xOffset, int yOffset, int direction, GlyphType type)
 {
     position.X += xOffset;
     position.Y += yOffset;
     m_bonders.Add(new Glyph(this, position, direction, type));
 }
 private string GetClass(GlyphType type)
 {
     return("glyphicon-" + type.ToString().UnCamel(ch => char.IsUpper(ch) || char.IsDigit(ch)));
 }
 public BootstrapGlyph(GlyphType type)
 {
     Classes.Add("glyphicon");
     Classes.Add(GetClass(type));
     this.type = type;
 }
Exemple #8
0
 public Glyph(GameObject parent, Vector2 position, int rotation, GlyphType type)
     : base(parent, position, rotation)
 {
     Type = type;
 }
Exemple #9
0
 public static GlyphBase FromType(GlyphType type) => _lookup[(byte)type];
Exemple #10
0
        public void InitItem(IDBTableView view, bool show, GlyphType glyph, Color glyphColor)
        {
            if (view == null)
            {
                return;
            }
            TableItemNode node = null;

            if (show)
            {
                view.CollectionChanged   += OnCollectionChanged;
                view.ItemPropertyChanged += OnItemPropertyChanged;
                views.Add(view);
                if (ShowListNode)
                {
                    node            = InitItem((IDBTableContent)view);
                    node.Glyph      = glyph;
                    node.GlyphColor = glyphColor;
                    node.CheckNodes = true;
                    node.Localize();
                }
                IEnumerable enumer = view;
                if (view.Table.GroupKey != null)
                {
                    enumer = view.Table.SelectItems(view.Table.GroupKey, CompareType.Is, null);
                }

                foreach (DBItem item in enumer)
                {
                    if ((!Current ||
                         ((DBStatus.Actual | DBStatus.Edit | DBStatus.New | DBStatus.Error) & item.Status) != DBStatus.Empty) &&
                        (!Access || item.Access.GetFlag(AccessType.Read, GuiEnvironment.User)))
                    {
                        var element = InitItem(item);
                        if (ShowListNode)
                        {
                            element.Group = node;
                        }
                        else
                        {
                            Nodes.Add(element);
                        }
                    }
                }
                if (ShowListNode)
                {
                    Nodes.Add(node);
                }
            }
            else
            {
                view.CollectionChanged   -= OnCollectionChanged;
                view.ItemPropertyChanged -= OnItemPropertyChanged;
                views.Remove(view);
                node = (TableItemNode)Nodes.Find(GetName(view));
                if (node != null)
                {
                    node.Hide();
                }
            }
        }
Exemple #11
0
        internal GlyphInstance(FontInstance font, GlyphVector vector, ushort advanceWidth, short leftSideBearing, ushort sizeOfEm, ushort index, GlyphType glyphType = GlyphType.Standard, GlyphColor?glyphColor = null)
        {
            this.Font     = font;
            this.SizeOfEm = sizeOfEm;
            this.vector   = vector;

            this.AdvanceWidth    = advanceWidth;
            this.Index           = index;
            this.Height          = sizeOfEm - this.Bounds.Min.Y;
            this.GlyphType       = glyphType;
            this.LeftSideBearing = leftSideBearing;
            this.ScaleFactor     = this.SizeOfEm * 72F;
            this.GlyphColor      = glyphColor;
        }
Exemple #12
0
 public bool IsMatch(Point location, GlyphType glyphType)
 {
     return(sm_referenceImages[glyphType].IsMatch(Capture.Bitmap, location));
 }
Exemple #13
0
 public GlyphView(GlyphType glyph)
 {
     Glyph = glyph;
 }
Exemple #14
0
 public GlyphSlot(Func <Vector2> position, Func <float> scale, GlyphType type)
 {
     this.type     = type;
     this.position = position;
     this.scale    = scale;
 }
Exemple #15
0
 public static GlyphType GetGlyph(Type category, string name, GlyphType def = GlyphType.None)
 {
     return(GetGlyph(GetTypeCategory(category), name, def));
 }