Пример #1
0
        public Attack(XElement element)
        {
            try
            {
                DamageType = (DamageType)Enum.Parse(typeof(DamageType), ToolBox.GetAttributeString(element, "damagetype", "None"), true);
            }
            catch
            {
                DamageType = DamageType.None;
            }


            damage          = ToolBox.GetAttributeFloat(element, "damage", 0.0f);
            structureDamage = ToolBox.GetAttributeFloat(element, "structuredamage", 0.0f);
            bleedingDamage  = ToolBox.GetAttributeFloat(element, "bleedingdamage", 0.0f);

            Force       = ToolBox.GetAttributeFloat(element, "force", 0.0f);
            TargetForce = ToolBox.GetAttributeFloat(element, "targetforce", 0.0f);

            Torque = ToolBox.GetAttributeFloat(element, "torque", 0.0f);

            Stun = ToolBox.GetAttributeFloat(element, "stun", 0.0f);

            string soundPath = ToolBox.GetAttributeString(element, "sound", "");

            if (!string.IsNullOrWhiteSpace(soundPath))
            {
                sound = Sound.Load(soundPath);
            }

            Range = ToolBox.GetAttributeFloat(element, "range", 0.0f);

            Duration = ToolBox.GetAttributeFloat(element, "duration", 0.0f);

            priority = ToolBox.GetAttributeFloat(element, "priority", 1.0f);

            foreach (XElement subElement in element.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "particleemitter":
                    particleEmitterPrefab = new ParticleEmitterPrefab(subElement);
                    break;

                case "statuseffect":
                    if (statusEffects == null)
                    {
                        statusEffects = new List <StatusEffect>();
                    }
                    statusEffects.Add(StatusEffect.Load(subElement));
                    break;
                }
            }
        }
Пример #2
0
        partial void InitProjSpecific(XElement element)
        {
            string soundPath = ToolBox.GetAttributeString(element, "sound", "");

            if (!string.IsNullOrWhiteSpace(soundPath))
            {
                sound = Sound.Load(soundPath);
            }

            foreach (XElement subElement in element.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "particleemitter":
                    particleEmitterPrefab = new ParticleEmitterPrefab(subElement);
                    break;
                }
            }
        }
Пример #3
0
        private void CreateUI()
        {
            Frame.ClearChildren();

            leftPanel = new GUIFrame(new RectTransform(new Vector2(0.125f, 1.0f), Frame.RectTransform)
            {
                MinSize = new Point(150, 0)
            },
                                     style: "GUIFrameLeft");
            var paddedLeftPanel = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.95f), leftPanel.RectTransform, Anchor.CenterLeft)
            {
                RelativeOffset = new Vector2(0.02f, 0.0f)
            })
            {
                RelativeSpacing = 0.01f,
                Stretch         = true
            };

            rightPanel = new GUIFrame(new RectTransform(new Vector2(0.25f, 1.0f), Frame.RectTransform, Anchor.TopRight)
            {
                MinSize = new Point(350, 0)
            },
                                      style: "GUIFrameRight");
            var paddedRightPanel = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), rightPanel.RectTransform, Anchor.Center)
            {
                RelativeOffset = new Vector2(0.02f, 0.0f)
            })
            {
                RelativeSpacing = 0.01f,
                Stretch         = true
            };

            var saveAllButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.03f), paddedRightPanel.RectTransform),
                                              TextManager.Get("editor.saveall"))
            {
                OnClicked = (btn, obj) =>
                {
                    SerializeAll();
                    return(true);
                }
            };

            new GUIButton(new RectTransform(new Vector2(1.0f, 0.03f), paddedRightPanel.RectTransform),
                          TextManager.Get("ParticleEditor.CopyPrefabToClipboard"))
            {
                OnClicked = (btn, obj) =>
                {
                    SerializeToClipboard(selectedPrefab);
                    return(true);
                }
            };

            new GUIButton(new RectTransform(new Vector2(1.0f, 0.03f), paddedRightPanel.RectTransform),
                          TextManager.Get("ParticleEditor.CopyEmitterToClipboard"))
            {
                OnClicked = (btn, obj) =>
                {
                    SerializeEmitterToClipboard();
                    return(true);
                }
            };

            var emitterListBox = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.25f), paddedRightPanel.RectTransform));

            new SerializableEntityEditor(emitterListBox.Content.RectTransform, emitterProperties, false, true, elementHeight: 20, titleFont: GUI.SubHeadingFont);

            var listBox = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.6f), paddedRightPanel.RectTransform));

            var filterArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.03f), paddedLeftPanel.RectTransform)
            {
                MinSize = new Point(0, 20)
            }, isHorizontal: true)
            {
                Stretch  = true,
                UserData = "filterarea"
            };

            filterLabel = new GUITextBlock(new RectTransform(Vector2.One, filterArea.RectTransform), TextManager.Get("serverlog.filter"), font: GUI.Font)
            {
                IgnoreLayoutGroups = true
            };
            filterBox = new GUITextBox(new RectTransform(new Vector2(0.8f, 1.0f), filterArea.RectTransform), font: GUI.Font);
            filterBox.OnTextChanged += (textBox, text) => { FilterEmitters(text); return(true); };
            new GUIButton(new RectTransform(new Vector2(0.05f, 1.0f), filterArea.RectTransform, scaleBasis: ScaleBasis.BothHeight), style: "GUICancelButton")
            {
                OnClicked = (btn, userdata) => { FilterEmitters(""); filterBox.Text = ""; filterBox.Flash(Color.White); return(true); }
            };

            prefabList             = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.8f), paddedLeftPanel.RectTransform));
            prefabList.OnSelected += (GUIComponent component, object obj) =>
            {
                cam.Position   = Vector2.Zero;
                selectedPrefab = obj as ParticlePrefab;
                emitterPrefab  = new ParticleEmitterPrefab(selectedPrefab, emitterProperties);
                emitter        = new ParticleEmitter(emitterPrefab);
                listBox.ClearChildren();
                new SerializableEntityEditor(listBox.Content.RectTransform, selectedPrefab, false, true, elementHeight: 20, titleFont: GUI.SubHeadingFont);
                //listBox.Content.RectTransform.NonScaledSize = particlePrefabEditor.RectTransform.NonScaledSize;
                //listBox.UpdateScrollBarSize();
                return(true);
            };

            if (GameMain.ParticleManager != null)
            {
                RefreshPrefabList();
            }
        }