Example #1
0
        public YAMLNode ExportYAML(IExportContainer container)
        {
            YAMLMappingNode node = new YAMLMappingNode();

            node.Add(NameName, Name);
            node.Add(NormalName, Normal.ExportYAML(container));
            node.Add(HoverName, Hover.ExportYAML(container));
            node.Add(ActiveName, Active.ExportYAML(container));
            node.Add(FocusedName, Focused.ExportYAML(container));
            node.Add(OnNormalName, OnNormal.ExportYAML(container));
            node.Add(OnHoverName, OnHover.ExportYAML(container));
            node.Add(OnActiveName, OnActive.ExportYAML(container));
            node.Add(OnFocusedName, OnFocused.ExportYAML(container));
            node.Add(BorderName, Border.ExportYAML(container));
            node.Add(MarginName, Margin.ExportYAML(container));
            node.Add(PaddingName, Padding.ExportYAML(container));
            node.Add(OverflowName, Overflow.ExportYAML(container));
            node.Add(FontName, Font.ExportYAML(container));
            node.Add(FontSizeName, FontSize);
            node.Add(FontStyleName, (int)FontStyle);
            node.Add(AlignmentName, (int)Alignment);
            node.Add(WordWrapName, WordWrap);
            node.Add(RichTextName, RichText);
            node.Add(TextClippingName, (int)TextClipping);
            node.Add(ImagePositionName, (int)ImagePosition);
            node.Add(ContentOffsetName, ContentOffset.ExportYAML(container));
            node.Add(FixedWidthName, FixedWidth);
            node.Add(FixedHeightName, FixedHeight);
            node.Add(StretchWidthName, StretchWidth);
            node.Add(StretchHeightName, StretchHeight);
            return(node);
        }
Example #2
0
        public YAMLNode ExportYAML(IExportContainer container)
        {
            YAMLMappingNode node = new YAMLMappingNode();

            node.Add("m_Name", Name);
            node.Add("m_Normal", Normal.ExportYAML(container));
            node.Add("m_Hover", Hover.ExportYAML(container));
            node.Add("m_Active", Active.ExportYAML(container));
            node.Add("m_Focused", Focused.ExportYAML(container));
            node.Add("m_OnNormal", OnNormal.ExportYAML(container));
            node.Add("m_OnHover", OnHover.ExportYAML(container));
            node.Add("m_OnActive", OnActive.ExportYAML(container));
            node.Add("m_OnFocused", OnFocused.ExportYAML(container));
            node.Add("m_Border", Border.ExportYAML(container));
            node.Add("m_Margin", Margin.ExportYAML(container));
            node.Add("m_Padding", Padding.ExportYAML(container));
            node.Add("m_Overflow", Overflow.ExportYAML(container));
            node.Add("m_Font", Font.ExportYAML(container));
            node.Add("m_FontSize", FontSize);
            node.Add("m_FontStyle", (int)FontStyle);
            node.Add("m_Alignment", (int)Alignment);
            node.Add("m_WordWrap", WordWrap);
            node.Add("m_RichText", RichText);
            node.Add("m_TextClipping", (int)TextClipping);
            node.Add("m_ImagePosition", (int)ImagePosition);
            node.Add("m_ContentOffset", ContentOffset.ExportYAML(container));
            node.Add("m_FixedWidth", FixedWidth);
            node.Add("m_FixedHeight", FixedHeight);
            node.Add("m_StretchWidth", StretchWidth);
            node.Add("m_StretchHeight", StretchHeight);
            return(node);
        }
        /// <summary>
        /// 执行组件的激活操作。
        /// </summary>
        public async Task Active()
        {
            IsActived = true;
            await OnActive.InvokeAsync(IsActived);

            StateHasChanged();
        }
Example #4
0
        public void Read(AssetStream stream)
        {
            StyleName = stream.ReadStringAligned();
            Normal.Read(stream);
            Hover.Read(stream);
            Active.Read(stream);
            Focused.Read(stream);
            OnNormal.Read(stream);
            OnHover.Read(stream);
            OnActive.Read(stream);
            OnFocused.Read(stream);
            Border.Read(stream);
            Margin.Read(stream);
            Padding.Read(stream);
            Overflow.Read(stream);
            Font.Read(stream);
            FontSize  = stream.ReadInt32();
            FontStyle = stream.ReadInt32();
            Alignment = stream.ReadInt32();
            WordWrap  = stream.ReadBoolean();
            RichText  = stream.ReadBoolean();
            stream.AlignStream(AlignType.Align4);

            TextClipping  = stream.ReadInt32();
            ImagePosition = stream.ReadInt32();
            ContentOffset.Read(stream);
            FixedWidth    = stream.ReadSingle();
            FixedHeight   = stream.ReadSingle();
            StretchWidth  = stream.ReadBoolean();
            StretchHeight = stream.ReadBoolean();
            stream.AlignStream(AlignType.Align4);
        }
Example #5
0
    public void ActivateTutorial(string _tutorialID)
    {
        TutorialObject _object = _tutorialObjects.Find(o => o.TutorialID == _tutorialID);

        if (_object != null)
        {
            _activeTutorial = _object;
            OnActive?.Invoke(_activeTutorial);
        }
        else
        {
            throw new ArgumentNullException("Tutorial Not Found");
        }
    }
Example #6
0
        protected void SetActive(bool active)
        {
            if (rb != null && !rb.isKinematic)
            {
                //we can't have disabled colliders with an active rb
                active = true;
            }

            if (rb != null)
            {
                rb.detectCollisions = active;
            }
            else
            {
                //get rid of collider.enabled wherever possible
                if (HasStates && States.CurrentState != null)
                {
                    if (States.CurrentState.StateCollider != null)
                    {
                        States.CurrentState.StateCollider.enabled = active;
                    }
                }
                else
                {
                    for (int i = 0; i < Colliders.Count; i++)
                    {
                        if (Colliders [i] != null)
                        {
                            Colliders [i].enabled = active;
                        }
                    }
                }
            }

            if (Is(WILoadState.Initialized | WILoadState.PreparingToUnload | WILoadState.Unloading))
            {
                try {
                    if (active)
                    {
                        OnActive.SafeInvoke();
                    }
                    else
                    {
                        OnInactive.SafeInvoke();
                    }
                } catch (Exception e) {
                    Debug.LogException(e);
                }
            }
        }
Example #7
0
        public async Task <string> Work(int fuelTankVolume, WriterDelegate writerDelegate)
        {
            try
            {
                int time = 3000;
                var step = time * Volume / 1000;
                for (int i = 0; i < fuelTankVolume; i += step)
                {
                    if (i == step)
                    {
                        OnActive?.Invoke(this, new EventArgs());
                    }
                    await Task.Delay(time);

                    writerDelegate($"{this.ToString()} Мощность = {Power} лс");
                }
                OnDeactivate?.Invoke(this, new EventArgs());
                return("ok");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Example #8
0
        public void Read(AssetReader reader)
        {
            StyleName = reader.ReadString();
            Normal.Read(reader);
            Hover.Read(reader);
            Active.Read(reader);
            Focused.Read(reader);
            OnNormal.Read(reader);
            OnHover.Read(reader);
            OnActive.Read(reader);
            OnFocused.Read(reader);
            Border.Read(reader);
            if (IsBuiltIn(reader.Version))
            {
                Margin.Read(reader);
                Padding.Read(reader);
            }
            else
            {
                Padding.Read(reader);
                Margin.Read(reader);
            }
            Overflow.Read(reader);
            Font.Read(reader);

            if (IsBuiltIn(reader.Version))
            {
                FontSize  = reader.ReadInt32();
                FontStyle = (FontStyle)reader.ReadInt32();
                Alignment = (TextAnchor)reader.ReadInt32();
                WordWrap  = reader.ReadBoolean();
                RichText  = reader.ReadBoolean();
                reader.AlignStream(AlignType.Align4);

                TextClipping  = (TextClipping)reader.ReadInt32();
                ImagePosition = (ImagePosition)reader.ReadInt32();
                ContentOffset.Read(reader);
                FixedWidth    = reader.ReadSingle();
                FixedHeight   = reader.ReadSingle();
                StretchWidth  = reader.ReadBoolean();
                StretchHeight = reader.ReadBoolean();
                reader.AlignStream(AlignType.Align4);
            }
            else
            {
                ImagePosition = (ImagePosition)reader.ReadInt32();
                Alignment     = (TextAnchor)reader.ReadInt32();
                WordWrap      = reader.ReadBoolean();
                reader.AlignStream(AlignType.Align4);

                TextClipping = (TextClipping)reader.ReadInt32();
                ContentOffset.Read(reader);
                ClipOffset.Read(reader);
                FixedWidth  = reader.ReadSingle();
                FixedHeight = reader.ReadSingle();
                if (IsReadFontSize(reader.Version))
                {
                    FontSize  = reader.ReadInt32();
                    FontStyle = (FontStyle)reader.ReadInt32();
                }
                StretchWidth = reader.ReadBoolean();
                reader.AlignStream(AlignType.Align4);
                StretchHeight = reader.ReadBoolean();
                reader.AlignStream(AlignType.Align4);
            }
        }
Example #9
0
        public void Write(AssetWriter writer)
        {
            writer.Write(Name);
            Normal.Write(writer);
            Hover.Write(writer);
            Active.Write(writer);
            Focused.Write(writer);
            OnNormal.Write(writer);
            OnHover.Write(writer);
            OnActive.Write(writer);
            OnFocused.Write(writer);
            Border.Write(writer);
            if (IsBuiltin(writer.Version))
            {
                Margin.Write(writer);
                Padding.Write(writer);
            }
            else
            {
                Padding.Write(writer);
                Margin.Write(writer);
            }
            Overflow.Write(writer);
            Font.Write(writer);

            if (IsBuiltin(writer.Version))
            {
                writer.Write(FontSize);
                writer.Write((int)FontStyle);
                writer.Write((int)Alignment);
                writer.Write(WordWrap);
                writer.Write(RichText);
                writer.AlignStream();

                writer.Write((int)TextClipping);
                writer.Write((int)ImagePosition);
                ContentOffset.Write(writer);
                writer.Write(FixedWidth);
                writer.Write(FixedHeight);
                writer.Write(StretchWidth);
                writer.Write(StretchHeight);
                writer.AlignStream();
            }
            else
            {
                writer.Write((int)ImagePosition);
                writer.Write((int)Alignment);
                writer.Write(WordWrap);
                writer.AlignStream();

                writer.Write((int)TextClipping);
                ContentOffset.Write(writer);
                ClipOffset.Write(writer);
                writer.Write(FixedWidth);
                writer.Write(FixedHeight);
                if (HasFontSize(writer.Version))
                {
                    writer.Write(FontSize);
                    writer.Write((int)FontStyle);
                }
                writer.Write(StretchWidth);
                writer.AlignStream();
                writer.Write(StretchHeight);
                writer.AlignStream();
            }
        }
 void OnEnable()
 {
     OnActive.Invoke();
 }
 public void SetOnActive(OnActive _activator)
 {
     ActiveTooltip = _activator;
 }
Example #12
0
        public void Read(AssetReader reader)
        {
            GUIStyleLayout layout = reader.Layout.Serialized.GUIStyle;

            Name = reader.ReadString();
            Normal.Read(reader);
            Hover.Read(reader);
            Active.Read(reader);
            Focused.Read(reader);
            OnNormal.Read(reader);
            OnHover.Read(reader);
            OnActive.Read(reader);
            OnFocused.Read(reader);
            Border.Read(reader);
            if (layout.IsBuiltinFormat)
            {
                Margin.Read(reader);
                Padding.Read(reader);
            }
            else
            {
                Padding.Read(reader);
                Margin.Read(reader);
            }

            Overflow.Read(reader);
            Font.Read(reader);
            if (layout.IsBuiltinFormat)
            {
                FontSize  = reader.ReadInt32();
                FontStyle = (FontStyle)reader.ReadInt32();
                Alignment = (TextAnchor)reader.ReadInt32();
                WordWrap  = reader.ReadBoolean();
                RichText  = reader.ReadBoolean();
                reader.AlignStream();

                TextClipping  = (TextClipping)reader.ReadInt32();
                ImagePosition = (ImagePosition)reader.ReadInt32();
                ContentOffset.Read(reader);
                FixedWidth    = reader.ReadSingle();
                FixedHeight   = reader.ReadSingle();
                StretchWidth  = reader.ReadBoolean();
                StretchHeight = reader.ReadBoolean();
                reader.AlignStream();
            }
            else
            {
                ImagePosition = (ImagePosition)reader.ReadInt32();
                Alignment     = (TextAnchor)reader.ReadInt32();
                WordWrap      = reader.ReadBoolean();
                reader.AlignStream();

                TextClipping = (TextClipping)reader.ReadInt32();
                ContentOffset.Read(reader);
                ClipOffset.Read(reader);
                FixedWidth  = reader.ReadSingle();
                FixedHeight = reader.ReadSingle();
                if (layout.HasFontSize)
                {
                    FontSize  = reader.ReadInt32();
                    FontStyle = (FontStyle)reader.ReadInt32();
                }
                StretchWidth = reader.ReadBoolean();
                reader.AlignStream();
                StretchHeight = reader.ReadBoolean();
                reader.AlignStream();
            }
        }
Example #13
0
        public YAMLNode ExportYAML(IExportContainer container)
        {
            YAMLMappingNode node   = new YAMLMappingNode();
            GUIStyleLayout  layout = container.ExportLayout.Serialized.GUIStyle;

            node.Add(layout.NameName, Name);
            node.Add(layout.NormalName, Normal.ExportYAML(container));
            node.Add(layout.HoverName, Hover.ExportYAML(container));
            node.Add(layout.ActiveName, Active.ExportYAML(container));
            node.Add(layout.FocusedName, Focused.ExportYAML(container));
            node.Add(layout.OnNormalName, OnNormal.ExportYAML(container));
            node.Add(layout.OnHoverName, OnHover.ExportYAML(container));
            node.Add(layout.OnActiveName, OnActive.ExportYAML(container));
            node.Add(layout.OnFocusedName, OnFocused.ExportYAML(container));
            node.Add(layout.BorderName, Border.ExportYAML(container));
            if (layout.IsBuiltinFormat)
            {
                node.Add(layout.MarginName, Margin.ExportYAML(container));
                node.Add(layout.PaddingName, Padding.ExportYAML(container));
            }
            else
            {
                node.Add(layout.PaddingName, Padding.ExportYAML(container));
                node.Add(layout.MarginName, Margin.ExportYAML(container));
            }

            node.Add(layout.OverflowName, Overflow.ExportYAML(container));
            node.Add(layout.FontName, Font.ExportYAML(container));
            if (layout.IsBuiltinFormat)
            {
                node.Add(layout.FontSizeName, FontSize);
                node.Add(layout.FontStyleName, (int)FontStyle);
                node.Add(layout.AlignmentName, (int)Alignment);
                node.Add(layout.WordWrapName, WordWrap);
                node.Add(layout.RichTextName, RichText);
                node.Add(layout.TextClippingName, (int)TextClipping);
                node.Add(layout.ImagePositionName, (int)ImagePosition);
                node.Add(layout.ContentOffsetName, ContentOffset.ExportYAML(container));
                node.Add(layout.FixedWidthName, FixedWidth);
                node.Add(layout.FixedHeightName, FixedHeight);
                node.Add(layout.StretchWidthName, StretchWidth);
                node.Add(layout.StretchHeightName, StretchHeight);
            }
            else
            {
                node.Add(layout.ImagePositionName, (int)ImagePosition);
                node.Add(layout.AlignmentName, (int)Alignment);
                node.Add(layout.WordWrapName, WordWrap);
                node.Add(layout.TextClippingName, (int)TextClipping);
                node.Add(layout.ContentOffsetName, ContentOffset.ExportYAML(container));
                node.Add(layout.ClipOffsetName, ClipOffset.ExportYAML(container));
                node.Add(layout.FixedWidthName, FixedWidth);
                node.Add(layout.FixedHeightName, FixedHeight);
                if (layout.HasFontSize)
                {
                    node.Add(layout.FontSizeName, FontSize);
                    node.Add(layout.FontStyleName, (int)FontStyle);
                }
                node.Add(layout.StretchWidthName, StretchWidth);
                node.Add(layout.StretchHeightName, StretchHeight);
            }
            return(node);
        }
Example #14
0
 override public void Interact()
 {
     base.Interact();
     OnActive?.Invoke();
 }
Example #15
0
 public override bool Active()
 {
     OnActive.Invoke();
     return(base.Active());
 }
Example #16
0
        private void CreateGateButtons(InputContainer componentMenu, GameMenu gameMenu)
        {
            List <TextureField> icons = new List <TextureField>();

            ButtonTexture bt = new ButtonTexture(
                InputController.DefaultTexture,
                new Color(50, 50, 50),
                new Color(100, 100, 100),
                new Color(75, 75, 75),
                new Color(95, 115, 255)
                );
            int buttonSize = (Width - (ButtonPrRow + 1) * BPadding) / ButtonPrRow;
            int offsetY    = 0;

            for (int i = 0; i < gateTypes.Count; i++)
            {
                Type gateType = gateTypes[i];
                int  offsetX  = (i % ButtonPrRow);
                offsetX = offsetX * buttonSize + offsetX * BPadding;
                offsetY = (i / ButtonPrRow);
                offsetY = offsetY * buttonSize + offsetY * BPadding;

                Rectangle bounds     = new Rectangle(X + BPadding + offsetX, Y + BPadding + offsetY, buttonSize, buttonSize);
                Rectangle iconBounds = bounds;
                iconBounds.Inflate(-4, -4);

                Texture2D texture;
                if (gameMenu.GateTextureMap.ContainsKey(gateType.FullName))
                {
                    texture = gameMenu.GateTextureMap[gateType.FullName];
                }
                else
                {
                    texture = InputController.DefaultTexture;
                }

                TextureField icon = new TextureField(iconBounds, texture, Color.White);
                Button       temp = new Button(bounds, bt, new Text("", Color.White));
                temp.ID = gateType.FullName;

                icons.Add(icon);
                group.Add(temp, false);
            }



            group.BeforeSelectedButtonChange += (object sender, ButtonEventArgs e) =>
            {
                if (group.SelectedButton != null)
                {
                    Containers[group.SelectedButton.ID].Active = false;
                    Containers[group.SelectedButton.ID].DeFocus();
                }

                if (!Selected)
                {
                    OnActive?.Invoke();
                }
            };

            group.AfterSelectedButtonChange += (object sender, ButtonEventArgs e) =>
            {
                Containers[e.Button.ID].Active = true;
                Containers[e.Button.ID].Focus();
            };

            componentMenu.Add(group);
            componentMenu.Add(icons);
            CurrentY = offsetY + buttonSize + BPadding;
        }