protected override IEnumerable <PropertyDescriptor> GetProperties()
        {
            var properties = new List <PropertyDescriptor>
            {
                PropertyDescriptorFactory.Create(EmitterType.GetProperty("Width"),
                                                 new CategoryAttribute("Box Emitter"),
                                                 new DisplayNameAttribute("Width"),
                                                 new DescriptionAttribute("Gets or sets the width of the box.")),

                PropertyDescriptorFactory.Create(EmitterType.GetProperty("Height"),
                                                 new CategoryAttribute("Box Emitter"),
                                                 new DisplayNameAttribute("Height"),
                                                 new DescriptionAttribute("Gets or sets the height of the box.")),

                PropertyDescriptorFactory.Create(EmitterType.GetProperty("Depth"),
                                                 new CategoryAttribute("Box Emitter"),
                                                 new DisplayNameAttribute("Depth"),
                                                 new DescriptionAttribute("Gets or sets the depth of the box.")),

                PropertyDescriptorFactory.Create(EmitterType.GetProperty("Rotation"),
                                                 new CategoryAttribute("Box Emitter"),
                                                 new DisplayNameAttribute("Rotation"),
                                                 new DescriptionAttribute("Gets or sets the rotation vector of the box.")),
            };

            return(base.GetProperties().Concat(properties));
        }
        protected override IEnumerable <PropertyDescriptor> GetProperties()
        {
            var properties = new List <PropertyDescriptor>
            {
                PropertyDescriptorFactory.Create(EmitterType.GetProperty("Radius"),
                                                 new CategoryAttribute("Cylinder Emitter"),
                                                 new DisplayNameAttribute("Radius"),
                                                 new DescriptionAttribute("Gets or sets the radius of the cylinder.")),

                PropertyDescriptorFactory.Create(EmitterType.GetProperty("Height"),
                                                 new CategoryAttribute("Cylinder Emitter"),
                                                 new DisplayNameAttribute("Height"),
                                                 new DescriptionAttribute("Gets or sets the height of the cylinder.")),

                PropertyDescriptorFactory.Create(EmitterType.GetProperty("Shell"),
                                                 new CategoryAttribute("Cylinder Emitter"),
                                                 new DisplayNameAttribute("Shell"),
                                                 new DescriptionAttribute("Gets or sets a value indicating whether particles should be released only on the edge of the cylinder.")),

                PropertyDescriptorFactory.Create(EmitterType.GetProperty("Radiate"),
                                                 new CategoryAttribute("Cylinder Emitter"),
                                                 new DisplayNameAttribute("Radiate"),
                                                 new DescriptionAttribute("Gets or sets a value indicating whether particles should radiate out from the centre column of the cylinder.")),
            };

            return(base.GetProperties().Concat(properties));
        }
Beispiel #3
0
        public EmitterController SpawnEmitter(GridElementController container, EmitterType type)
        {
            var prefab  = ItemsMap.Emitters.FirstOrDefault((p) => p.Type == type).Prefab;
            var emitter = Instantiate(prefab, container.transform, false);

            return(emitter);
        }
        public void CreateParticle(Texture2D texture, Rectangle sourceRect, ParticleInfo pInfo, EmitterType type)
        {
            if (sourceRect != Rectangle.Empty)
                this.Initialize(texture, sourceRect);
            else
                this.Initialize(texture);

            m_Type = type;

            m_CurrentLife = pInfo.m_Lifespan;
            m_Lifespan = pInfo.m_Lifespan;
            m_Position = pInfo.m_Pos;
            m_StartPos = pInfo.m_StartPos;
            m_Velocity = pInfo.m_Velocity;
            m_EmitterRadius = pInfo.m_EmitterRadius;
            m_EmitterRadiusDelta = pInfo.m_EmitterRadiusDelta;
            m_EmitterRotation = pInfo.m_EmitterRotation;
            m_EmitterRotationDelta = pInfo.m_EmitterRotationDelta;
            m_RadialAcceleration = pInfo.m_RadialAcceleration;
            m_TangentialAcceleration = pInfo.m_TangentialAcceleration;
            m_Scale = pInfo.m_Scale;
            m_ScaleDelta = pInfo.m_ScaleDelta;
            m_Color = pInfo.m_StartColor;
            m_StartColor = pInfo.m_StartColor;
            m_EndColor = pInfo.m_EndColor;
            m_ColorDelta = pInfo.m_ColorDelta;
            m_Rotation = pInfo.m_Rotation;
            m_RotationDelta = pInfo.m_RotationDelta;
            m_Depth = pInfo.m_Depth;
            m_DepthDelta = pInfo.m_DepthDelta;
            m_Speed = pInfo.m_Speed;
        }
    public void ChangeType()
    {
        System.Random random        = new System.Random();
        int           random_number = random.Next(0, 2);

        //Temporary, will change to switch if more EmitterType
        typeOfEmitter = random_number == 0 ? EmitterType.ENEMY : EmitterType.POWERUP;
    }
Beispiel #6
0
 public Emitter(EmitterType type, int priority, bool exclusive, IEnumerable <E164Number> numbers)
 {
     this.Type = type;
     if (numbers != null)
     {
         this.PhoneNumbers = new List <E164Number>(numbers);
     }
 }
Beispiel #7
0
        protected override IEnumerable <PropertyDescriptor> GetProperties()
        {
            var properties = new List <PropertyDescriptor>
            {
                PropertyDescriptorFactory.Create(EmitterType.GetProperty("ConstrainToPlane"),
                                                 new CategoryAttribute("Plane Emitter"),
                                                 new DisplayNameAttribute("Constrain To Plane"),
                                                 new DescriptionAttribute("Should random forces keep the particle in the XY plane or allow it to move in all 3. Can be used in 2d or 3d. In 2d this will keep particles in the same plane as the emitter. In 3d it keeps particles radiating in a planar fashion.")),
            };

            return(base.GetProperties().Concat(properties));
        }
Beispiel #8
0
        public static void ToggleEmitter(EmitterType emitterType)
        {
            StudioEventEmitter emitter = AudioManager.Instance.EventPaths.GetEmitter(emitterType);

            if (emitter.IsPlaying())
            {
                emitter.Stop();
                return;
            }

            emitter.Play();
        }
Beispiel #9
0
        private void RenderItemsManagmentMenu()
        {
            EditorGUILayout.BeginHorizontal();

            selectedAbsorberType  = (AbsorberType)EditorGUILayout.EnumPopup(selectedAbsorberType);
            selectedReflectorType = (ReflectorType)EditorGUILayout.EnumPopup(selectedReflectorType);
            selectedEmitterType   = (EmitterType)EditorGUILayout.EnumPopup(selectedEmitterType);

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            {
                SetEnabled(selectedAbsorberType != AbsorberType.None);
                if (GUILayout.Button("Spawn"))
                {
                    TrySetEntityToSpawn(new LevelEntity()
                    {
                        Type = EntityType.Absorber, AbsorberType = selectedAbsorberType
                    });
                }
                ResetEnabled();
            }

            {
                SetEnabled(selectedReflectorType != ReflectorType.None);
                if (GUILayout.Button("Spawn"))
                {
                    TrySetEntityToSpawn(new LevelEntity()
                    {
                        Type = EntityType.Reflector, ReflectorType = selectedReflectorType
                    });
                }
                ResetEnabled();
            }

            {
                SetEnabled(selectedEmitterType != EmitterType.None);
                if (GUILayout.Button("Spawn"))
                {
                    TrySetEntityToSpawn(new LevelEntity()
                    {
                        Type = EntityType.Emitter, EmitterType = selectedEmitterType
                    });
                }
                ResetEnabled();
            }

            EditorGUILayout.EndHorizontal();
        }
Beispiel #10
0
 /// <summary>
 /// Preleva un emitter del tipo fornito. Se non esiste lo crea.
 /// </summary>
 /// <param name="et">Tipo di emitter da ottenere</param>
 private AudioEmitter getEmitter(EmitterType et)
 {
     for (int i = 0; i < emittersList.Count - 1; i++)
     {
         if (emittersList[i].Type == et)
         {
             return(emittersList[i]);
         }
     }
     emittersList.Add(new AudioEmitter {
         Type = et, Source = new AudioSource()
     });
     return(emittersList[emittersList.Count - 1]);
 }
        public ParticleEmitter AddEmitter(EmitterType type, LinkedList<Texture2D> textures, Vector3 location, Vector3 speed, int particlesPerFrame, Vector2 particleMovementSpeed, float defaultScale, int lifetime, Color color)
        {
            ParticleEmitter emitter = null;

            switch (type)
            {
                case EmitterType.Point:
                    emitter = new PointEmitter(textures, location, speed, particlesPerFrame, particleMovementSpeed, defaultScale, lifetime, color);
                    emitters.AddLast(emitter);
                    break;

                default:
                    break;
            }

            return emitter;
        }
Beispiel #12
0
        private string Write13_EmitterType(EmitterType v)
        {
            string result;

            switch (v)
            {
            case EmitterType.Unknown:
                result = "Unknown";
                break;

            case EmitterType.TextMessaging:
                result = "TextMessaging";
                break;

            default:
                throw base.CreateInvalidEnumValueException(((long)v).ToString(CultureInfo.InvariantCulture), "Microsoft.Exchange.Data.Storage.VersionedXml.EmitterType");
            }
            return(result);
        }
        protected override IEnumerable <PropertyDescriptor> GetProperties()
        {
            var properties = new List <PropertyDescriptor>
            {
                PropertyDescriptorFactory.Create(EmitterType.GetProperty("Length"),
                                                 new CategoryAttribute("Line Emitter"),
                                                 new DisplayNameAttribute("Length"),
                                                 new DescriptionAttribute("Gets or sets the length of the line.")),

                PropertyDescriptorFactory.Create(EmitterType.GetField("Rectilinear"),
                                                 new CategoryAttribute("Line Emitter"),
                                                 new DisplayNameAttribute("Rectilinear"),
                                                 new DescriptionAttribute("If true, will emit particles perpendicular to the angle of the line.")),

                PropertyDescriptorFactory.Create(EmitterType.GetField("EmitBothWays"),
                                                 new CategoryAttribute("Line Emitter"),
                                                 new DisplayNameAttribute("EmitBothWays"),
                                                 new DescriptionAttribute("If true, will emit particles both ways. Only work when Rectilinear is enabled.")),
            };

            return(base.GetProperties().Concat(properties));
        }
        public ParticleEmitterInfo(DatLoader.FileTypes.ParticleEmitterInfo info)
        {
            _info            = info;
            EmitterType      = info.EmitterType;
            ParticleType     = info.ParticleType;
            GfxObjID         = info.GfxObjId;
            HWGfxObjID       = info.HwGfxObjId;
            Birthrate        = info.Birthrate;
            MaxParticles     = info.MaxParticles;
            InitialParticles = info.InitialParticles;
            TotalParticles   = info.TotalParticles;
            TotalSeconds     = info.TotalSeconds;
            LifeSpanRand     = info.LifespanRand;
            LifeSpan         = info.Lifespan;
            //SortingSphere?
            OffsetDir     = info.OffsetDir.Copy();
            MinOffset     = info.MinOffset;
            MaxOffset     = info.MaxOffset;
            A             = info.A.Copy();
            B             = info.B.Copy();
            C             = info.C.Copy();
            MinA          = info.MinA;
            MaxA          = info.MaxA;
            MinB          = info.MinB;
            MaxB          = info.MaxB;
            MinC          = info.MinC;
            MaxC          = info.MaxC;
            ScaleRand     = info.ScaleRand;
            StartScale    = info.StartScale;
            FinalScale    = info.FinalScale;
            TransRand     = info.TransRand;
            StartTrans    = info.StartTrans;
            FinalTrans    = info.FinalTrans;
            IsParentLocal = info.IsParentLocal != 0;

            InitEnd();
        }
Beispiel #15
0
 public StudioEventEmitter GetEmitter(EmitterType emitterType)
 {
     return(emitters[emitterType]);
 }
Beispiel #16
0
 public static void StopEmitter(EmitterType emitter)
 {
     AudioManager.Instance.EventPaths.GetEmitter(emitter).Stop();
 }
Beispiel #17
0
        public PRE2(BinaryReader br)
        {
            Size = br.ReadUInt32();
            Load(br);

            EmitterSize           = br.ReadInt32();
            EmitterType           = (EmitterType)br.ReadUInt32();
            Speed                 = br.ReadSingle();
            Variation             = br.ReadSingle();
            Latitude              = br.ReadSingle();
            Longitude             = br.ReadSingle();
            Gravity               = br.ReadSingle();
            ZSource               = br.ReadSingle();
            Lifespan              = br.ReadSingle();
            EmissionRate          = br.ReadSingle();
            Length                = br.ReadSingle();
            Width                 = br.ReadSingle();
            Rows                  = br.ReadInt32();
            Cols                  = br.ReadInt32();
            ParticleType          = (CellType)br.ReadUInt32();
            TailLength            = br.ReadSingle();
            MiddleTime            = br.ReadSingle();
            StartColor            = br.ReadStruct <CBGR>();
            MiddleColor           = br.ReadStruct <CBGR>();
            EndColor              = br.ReadStruct <CBGR>();
            StartAlpha            = br.ReadByte() / 255f;
            MiddleAlpha           = br.ReadByte() / 255f;
            EndAlpha              = br.ReadByte() / 255f;
            StartScale            = br.ReadSingle();
            MiddleScale           = br.ReadSingle();
            EndScale              = br.ReadSingle();
            LifespanUVAnimStart   = br.ReadUInt32();
            LifespanUVAnimEnd     = br.ReadUInt32();
            LifespanUVAnimRepeat  = br.ReadUInt32();
            DecayUVAnimStart      = br.ReadUInt32();
            DecayUVAnimEnd        = br.ReadUInt32();
            DecayUVAnimRepeat     = br.ReadUInt32();
            TailUVAnimStart       = br.ReadUInt32();
            TailUVAnimEnd         = br.ReadUInt32();
            TailUVAnimRepeat      = br.ReadUInt32();
            TailDecayUVAnimStart  = br.ReadUInt32();
            TailDecayUVAnimEnd    = br.ReadUInt32();
            TailDecayUVAnimRepeat = br.ReadUInt32();
            BlendMode             = (BlendMode)br.ReadUInt32();
            TextureId             = br.ReadUInt32();
            PriorityPlane         = br.ReadInt32();
            ReplaceableId         = br.ReadUInt32();
            GeometryModel         = br.ReadString(260).TrimEnd('\0');
            RecursionModel        = br.ReadString(260).TrimEnd('\0');
            TwinkleFPS            = br.ReadSingle();
            TwinkleOnOff          = br.ReadSingle();
            TwinkleScaleMin       = br.ReadSingle();
            TwinkleScaleMax       = br.ReadSingle();
            IvelScale             = br.ReadSingle();
            TumbleX               = br.ReadStruct <CRange>();
            TumbleY               = br.ReadStruct <CRange>();
            TumbleZ               = br.ReadStruct <CRange>();
            Drag                  = br.ReadSingle();
            Spin                  = br.ReadSingle();
            WindVector            = br.ReadStruct <C3Vector>();
            WindTime              = br.ReadSingle();
            FollowSpeed1          = br.ReadSingle();
            FollowScale1          = br.ReadSingle();
            FollowSpeed2          = br.ReadSingle();
            FollowScale2          = br.ReadSingle();
            Splines               = br.ReadStructArray <C3Vector>(br.ReadInt32());
            Squirts               = br.ReadUInt32() == 1; // for footsteps and impact spell effects

            while (true)
            {
                string token = br.ReadString(4);
                br.BaseStream.Position -= 4;
                switch (token)
                {
                case "KP2S": SpeedKeys = new MDXTrack <float>(br); break;

                case "KP2R": VariationKeys = new MDXTrack <float>(br); break;

                case "KP2G": GravityKeys = new MDXTrack <float>(br); break;

                case "KP2W": WidthKeys = new MDXTrack <float>(br); break;

                case "KP2N": LengthKeys = new MDXTrack <float>(br); break;

                case "KVIS": VisibilityKeys = new MDXTrack <float>(br); break;

                case "KP2E": EmissionRateKeys = new MDXTrack <float>(br); break;

                case "KP2L": LatitudeKeys = new MDXTrack <float>(br); break;

                case "KLIF": LifespanKeys = new MDXTrack <float>(br); break;

                case "KPLN": LongitudeKeys = new MDXTrack <float>(br); break;

                case "KP2Z": ZSourceKeys = new MDXTrack <float>(br); break;

                default: return;
                }
            }
        }
 public M2Particle(BinaryReader br, uint build)
 {
     ParticleId           = br.ReadInt32();
     Flags                = (Particle_Flags)br.ReadUInt32();
     Position             = br.ReadStruct <C3Vector>();
     BoneIndex            = br.ReadUInt16();
     TextureIndex         = br.ReadUInt16();
     GeometryMdl          = br.ReadM2Array <byte>(build)?.AsString();
     RecursionMdl         = br.ReadM2Array <byte>(build)?.AsString();
     BlendMode            = br.ReadUInt16();
     EmitterType          = br.ReadEnum <EmitterType>();
     ParticleType         = br.ReadEnum <ParticleType>();
     CellType             = br.ReadEnum <CellType>();
     PriorityPlane        = br.ReadInt16();
     Rows                 = br.ReadUInt16();
     Cols                 = br.ReadUInt16();
     SpeedTrack           = new M2Track <float>(br, build);
     VariationTrack       = new M2Track <float>(br, build);
     LatitudeTrack        = new M2Track <float>(br, build);
     LongitudeTrack       = new M2Track <float>(br, build);
     GravityTrack         = new M2Track <float>(br, build);
     LifeTrack            = new M2Track <float>(br, build);
     EmissionRateTrack    = new M2Track <float>(br, build);
     WidthTrack           = new M2Track <float>(br, build);
     LengthTrack          = new M2Track <float>(br, build);
     ZSourceTrack         = new M2Track <float>(br, build);
     MiddleTime           = br.ReadSingle();
     StartColor           = br.ReadStruct <CImVector>();
     MiddleColor          = br.ReadStruct <CImVector>();
     EndColor             = br.ReadStruct <CImVector>();
     StartScale           = br.ReadSingle();
     MiddleScale          = br.ReadSingle();
     EndScale             = br.ReadSingle();
     LifespanUVAnimStart  = br.ReadUInt16();
     LifespanUVAnimEnd    = br.ReadUInt16();
     LifespanUVAnimRepeat = br.ReadUInt16();
     DecayUVAnimStart     = br.ReadUInt16();
     DecayUVAnimEnd       = br.ReadUInt16();
     DecayUVAnimRepeat    = br.ReadUInt16();
     TailUVAnimStart      = br.ReadUInt16();
     TailUVAnimEnd        = br.ReadUInt16();
     TailDecayUVAnimStart = br.ReadUInt16();
     TailDecayUVAnimEnd   = br.ReadUInt16(); // unverified
     TailLength           = br.ReadSingle();
     TwinkleFPS           = br.ReadSingle();
     TwinklePercent       = br.ReadSingle();
     TwinkleScaleMin      = br.ReadSingle();
     TwinkleScaleMax      = br.ReadSingle();
     IvelScale            = br.ReadSingle();
     Drag                 = br.ReadSingle();
     Spin                 = br.ReadSingle();
     TumblexMin           = br.ReadSingle();
     TumblexMax           = br.ReadSingle();
     TumbleyMin           = br.ReadSingle();
     TumbleyMax           = br.ReadSingle();
     TumblezMin           = br.ReadSingle();
     TumblezMax           = br.ReadSingle();
     WindVector           = br.ReadStruct <C3Vector>();
     WindTime             = br.ReadSingle();
     FollowSpeed1         = br.ReadSingle();
     FollowScale1         = br.ReadSingle();
     FollowSpeed2         = br.ReadSingle();
     FollowScale2         = br.ReadSingle();
     Splines              = br.ReadM2Array <C3Vector>(build);
     EnabledIn            = new M2Track <bool>(br, build);
 }
Beispiel #19
0
 public static Emitter Emitter(string name = "", double radiantProportion = 0.0, double viewCoefficient = 0.0, double maximumOutsideTemperature = 0.0, double switchOffOutsideTemperature = 0.0, EmitterType type = EmitterType.Undefined)
 {
     return(new Emitter
     {
         Name = name,
         RadiantProportion = radiantProportion,
         ViewCoefficient = viewCoefficient,
         MaximumOutsideTemperature = maximumOutsideTemperature,
         SwitchOffOutsideTemperature = switchOffOutsideTemperature,
         Type = type,
     });
 }
        /*  Function:  public abstract void Initialize()
         *   Purpose:  This function is abstract and will be defined by a derived class
         ****************************************************************/
        protected virtual void Initialize()
        {
            // Misc
            m_Origin = new Vector2(m_Graphics.PreferredBackBufferWidth / 2, m_Graphics.PreferredBackBufferHeight / 2);
            m_EmitterDuration = 0;
            m_IsInfinite = true;
            m_IsOn = true;

            m_Type = EmitterType.GRAVITY;

            m_SortMode = SpriteSortMode.BackToFront;
            m_BlendType = BlendState.AlphaBlend;

            LoadContent(m_ContentManager);

            m_SourceRectangle = m_ParticleTexture.Bounds;

            // Color
            InitializeColorConfig();

            // Particles
            InitializeParticleConfig();

            // Gravity
            InitializeGravityConfig();

            // Radial
            InitializeRadialConfig();
        }
 public void CreateParticle(Texture2D texture, ParticleInfo pInfo, EmitterType type)
 {
     CreateParticle(texture, Rectangle.Empty, pInfo, type);
 }
Beispiel #22
0
        public ParticleEffect(string fileName)
        {
            Name = fileName;
            colorFade_ = new ObservableCollection<ParticleColorFade>();
            texAnim_ = new ObservableCollection<ParticleTexAnim>();
            type_ = EmitterType.Box;
            emissionRate_ = new MinMax();
            directionMax_ = new Vector3();
            directionMax_ = new Vector3();
            emitterSize_ = new Vector3();
            constantForce_ = new Vector3();
            interval_ = new MinMax();
            minSize_ = new Vector2();
            maxSize_ = new Vector2();
            timeToLive_ = new MinMax();
            velocity_ = new MinMax();
            rotation_ = new MinMax();
            rotation_ = new MinMax();
            sizeDelta_ = new Vector2() { X = 0, Y = 1 };
            color_ = new UColor { A = 1, B = 1, G = 1, R = 1 };

            string path = System.IO.Path.ChangeExtension(fileName, "xml");
            if (System.IO.File.Exists(path)) {
                    XmlDocument doc = new XmlDocument();
                doc.Load(path);

                foreach (XmlElement mat in doc.DocumentElement.GetElementsByTagName("material"))
                    Material = mat.GetAttribute("name");
                foreach (XmlElement num in doc.DocumentElement.GetElementsByTagName("numparticles"))

                foreach (XmlElement u in doc.DocumentElement.GetElementsByTagName("updateinvisible"))
                    UpdateInvisible = u.GetAttribute("enable").Equals("true");
                foreach (XmlElement rel in doc.DocumentElement.GetElementsByTagName("relative"))
                    Relative = rel.GetAttribute("enable").Equals("true");
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("scaled"))
                    Scaled = s.GetAttribute("enable").Equals("true");
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("sorted"))
                    Sorted = s.GetAttribute("enable").Equals("true");
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("animlodbias"))
                    AnimLodBias = float.Parse(s.GetAttribute("value"));
                foreach (XmlElement t in doc.DocumentElement.GetElementsByTagName("emittertype")) {
                    foreach (EmitterType type in Enum.GetValues(typeof(EmitterType))) {
                        if (type.ToString().ToLower().Equals(t.GetAttribute("value"))) {
                            Type = type;
                            break;
                        }
                    }
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("emittersize"))
                    EmitterSize = Vector3.FromString(s.GetAttribute("value"));
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("emitterradius"))
                    EmitterRadius = float.Parse(s.GetAttribute("value"));
                foreach (XmlElement d in doc.DocumentElement.GetElementsByTagName("direction")) {
                    DirectionMax = Vector3.FromString(d.GetAttribute("max"));
                    DirectionMin = Vector3.FromString(d.GetAttribute("min"));
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("constantforce"))
                    ConstantForce = Vector3.FromString(s.GetAttribute("value"));
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("dampingforce"))
                    DampingForce = float.Parse(s.GetAttribute("value"));
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("activetime"))
                    ActiveTime = float.Parse(s.GetAttribute("value"));
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("inactivetime"))
                    InActiveTime = float.Parse(s.GetAttribute("value"));
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("interval"))
                    Interval = MinMax.FromElement(s);
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("emissionrate"))
                    EmissionRate = MinMax.FromElement(s);
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("particlesize")) {
                    if (s.HasAttribute("min"))
                        MinSize = Vector2.FromString(s.GetAttribute("min"));
                    if (s.HasAttribute("max"))
                        MaxSize = Vector2.FromString(s.GetAttribute("max"));
                    if (s.HasAttribute("value")) {
                        MinSize = Vector2.FromString(s.GetAttribute("value"));
                        MaxSize = Vector2.FromString(s.GetAttribute("value"));
                    }
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("timetolive"))
                    TimeToLive = MinMax.FromElement(s);
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("velocity"))
                    Velocity = MinMax.FromElement(s);
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("rotation"))
                    Rotation = MinMax.FromElement(s);
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("rotationspeed"))
                    RotationSpeed = MinMax.FromElement(s);
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("sizedelta")) {
                    Vector2 sd = new Vector2();
                    if (s.HasAttribute("add"))
                        sd.X = float.Parse(s.GetAttribute("add"));
                    if (s.HasAttribute("mul"))
                        sd.Y = float.Parse(s.GetAttribute("mul"));
                    SizeDelta = sd;
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("color"))
                    Color = UColor.FromString(s.GetAttribute("color"));

                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("colorfade"))
                    ColorFade.Add(new ParticleColorFade(s));
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("texanim"))
                    TextureAnim.Add(new ParticleTexAnim(s));
            }
        }
Beispiel #23
0
        private string GetPathForEmitter(EmitterType emitterType)
        {
            EventType eventType = emitterEvents.First(item => item.Key == emitterType).Value;

            return(GetPath(eventType));
        }
Beispiel #24
0
        public ParticleEffect(string fileName)
        {
            Name       = fileName;
            colorFade_ = new ObservableCollection <ParticleColorFade>();
            texAnim_   = new ObservableCollection <ParticleTexAnim>();
            type_      = EmitterType.Box;

            string path = System.IO.Path.ChangeExtension(fileName, "xml");

            if (System.IO.File.Exists(path))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(path);

                foreach (XmlElement mat in doc.DocumentElement.GetElementsByTagName("material"))
                {
                    Material = mat.GetAttribute("name");
                }
                foreach (XmlElement num in doc.DocumentElement.GetElementsByTagName("numparticles"))
                {
                    foreach (XmlElement u in doc.DocumentElement.GetElementsByTagName("updateinvisible"))
                    {
                        UpdateInvisible = u.GetAttribute("enable").Equals("true");
                    }
                }
                foreach (XmlElement rel in doc.DocumentElement.GetElementsByTagName("relative"))
                {
                    Relative = rel.GetAttribute("enable").Equals("true");
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("scaled"))
                {
                    Scaled = s.GetAttribute("enable").Equals("true");
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("sorted"))
                {
                    Sorted = s.GetAttribute("enable").Equals("true");
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("animlodbias"))
                {
                    AnimLodBias = float.Parse(s.GetAttribute("value"));
                }
                foreach (XmlElement t in doc.DocumentElement.GetElementsByTagName("emittertype"))
                {
                    foreach (EmitterType type in Enum.GetValues(typeof(EmitterType)))
                    {
                        if (type.ToString().ToLower().Equals(t.GetAttribute("value")))
                        {
                            Type = type;
                            break;
                        }
                    }
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("emittersize"))
                {
                    EmitterSize = Vector3.FromString(s.GetAttribute("value"));
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("emitterradius"))
                {
                    EmitterRadius = float.Parse(s.GetAttribute("value"));
                }
                foreach (XmlElement d in doc.DocumentElement.GetElementsByTagName("direction"))
                {
                    DirectionMax = Vector3.FromString(d.GetAttribute("max"));
                    DirectionMin = Vector3.FromString(d.GetAttribute("min"));
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("constantforce"))
                {
                    ConstantForce = Vector3.FromString(s.GetAttribute("value"));
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("dampingforce"))
                {
                    DampingForce = float.Parse(s.GetAttribute("value"));
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("activetime"))
                {
                    ActiveTime = float.Parse(s.GetAttribute("value"));
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("inactivetime"))
                {
                    InActiveTime = float.Parse(s.GetAttribute("value"));
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("interval"))
                {
                    Interval = MinMax.FromElement(s);
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("emissionrate"))
                {
                    EmissionRate = MinMax.FromElement(s);
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("particlesize"))
                {
                    if (s.HasAttribute("min"))
                    {
                        MinSize = Vector2.FromString(s.GetAttribute("min"));
                    }
                    if (s.HasAttribute("max"))
                    {
                        MaxSize = Vector2.FromString(s.GetAttribute("max"));
                    }
                    if (s.HasAttribute("value"))
                    {
                        MinSize = Vector2.FromString(s.GetAttribute("value"));
                        MaxSize = Vector2.FromString(s.GetAttribute("value"));
                    }
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("timetolive"))
                {
                    TimeToLive = MinMax.FromElement(s);
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("velocity"))
                {
                    Velocity = MinMax.FromElement(s);
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("rotation"))
                {
                    Rotation = MinMax.FromElement(s);
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("rotationspeed"))
                {
                    RotationSpeed = MinMax.FromElement(s);
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("sizedelta"))
                {
                    Vector2 sd = new Vector2();
                    if (s.HasAttribute("add"))
                    {
                        sd.X = float.Parse(s.GetAttribute("add"));
                    }
                    if (s.HasAttribute("mul"))
                    {
                        sd.Y = float.Parse(s.GetAttribute("mul"));
                    }
                    SizeDelta = sd;
                }

                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("colorfade"))
                {
                    ColorFade.Add(new ParticleColorFade(s));
                }
                foreach (XmlElement s in doc.DocumentElement.GetElementsByTagName("texanim"))
                {
                    TextureAnim.Add(new ParticleTexAnim(s));
                }
            }
            else
            {
                // Add the initial color fade
                // ColorFade.Add(new ParticleColorFade() { Color = new UColor(1, 1, 1, 1), Time = 0 });
            }
        }
Beispiel #25
0
 public static void PlayEmitter(EmitterType emitter)
 {
     AudioManager.Instance.EventPaths.GetEmitter(emitter).Play();
 }