예제 #1
0
        void btnRemoveClick(SelectionDock sender)
        {
            if (sender.Index == 0)
            {
                maxRow   = startingRow;
                maxOrder = 0;
            }
            else
            {
                int prevIdx = sender.Index;
                prevIdx--;

                SelectionDock prev = (from d in docks
                                      where d.Index == prevIdx
                                      select d).First();

                maxRow   = prev.MaxRow;
                maxOrder = prev.Index;
            }

            info = Info;

            if (info.Attachments.Length > 0)
            {
                int idx = sender.Index;
                idx -= 3;

                info.Attachments = ArrayHelper.RemoveAt <ParameterCollection>(idx, info.Attachments);
            }
            else
            {
                info.Attachments = new ParameterCollection[0];
            }

            if (docks.Count > 0)
            {
                for (int i = sender.Index; i < docks.Count; i++)
                {
                    docks[i].Destroy();
                }

                int count = 0;
                count = docks.Count - sender.Index;

                docks.RemoveRange(sender.Index, count);
                sender.Destroy();

                int idx = maxOrder++;
                idx -= 2;

                for (int i = idx; i < info.Attachments.Length; i++)
                {
                    DisplayAttachment(info.Attachments[i]);
                }
            }

            ReAddEnding();
        }
예제 #2
0
        void btnAdd_Click(object sender, EventArgs e)
        {
            ParticleEmitterInfo emitter = new ParticleEmitterInfo();

            string id = "Emitter" + lstEmitters.Items.Count;

            lstEmitters.Items.Add(id);

            emitters.Add(new EmitterDock(table, emitter, id));
        }
예제 #3
0
        public ParticleEmitter2D(string id, ParticleEmitterInfo info,
                                 int drawLayer, bool postDraw)
            : base(id)
        {
            this.drawLayer = drawLayer;

            if (postDraw)
            {
                PostRenderManager.Add(this);
            }
            else
            {
                DrawingManager.Add(this);
            }

            attachments = new AttachmentPool(info.Attachments);

            if (info.CycleType != null)
            {
                object obj = AssemblyManager.CreateInstance(info.CycleType);

                if (obj != null)
                {
                    spawnCycle              = obj as IntervalCycle;
                    spawnCycle.OnSpawn     += new OnSpawnEvent(GenerateParticles);
                    spawnCycle.OnCompleted += new OnSpawningCompleteEvent(OnCompletedSpawning);
                }
            }

            if (info.EmittionType != null)
            {
                object obj = AssemblyManager.CreateInstance(info.EmittionType);

                if (obj != null)
                {
                    emittionType = obj as IEmitter2D;
                }
            }

            if (info.RenderType != null)
            {
                object obj = AssemblyManager.CreateInstance(info.RenderType);

                if (obj != null)
                {
                    renderMethod = obj as IRenderer2D;
                }
            }

            lifeTime = new FloatRange(info.MinLifeTime, info.MaxLifeTime);
            mass     = new FloatRange(info.MinMass, info.MaxMass);
        }
예제 #4
0
        public EmitterDock(Control parent, ParticleEmitterInfo info, string emitterName)
        {
            this.info = info;

            panel        = new TableLayoutPanel();
            panel.Parent = parent;

            panel.BackColor = Color.Transparent;
            panel.AutoSize  = true;
            panel.Dock      = DockStyle.Top | DockStyle.Left;

            CreateEndLabel("ID", 0);
            AddTextBox(0, "id", emitterName);

            CreateEndLabel("Min Mass", 1);
            AddTextBox(1, "minMass", "" + info.MinMass);

            CreateEndLabel("Max Mass", 2);
            AddTextBox(2, "maxMass", "" + info.MaxMass);

            CreateEndLabel("Min Life Time", 3);
            AddTextBox(3, "minLife", "" + info.MinLifeTime);

            CreateEndLabel("Max Life Time", 4);
            AddTextBox(4, "maxLife", "" + info.MaxLifeTime);

            maxRow += 2;
            CreateEndLabel("", maxRow);
            CreateEndLabel("", maxRow);

            startingRow = maxRow;

            options = new List <string[]>()
            {
                GetOptions(FileSource.EmittionTypes.Keys),
                GetOptions(FileSource.RenderTypes.Keys),
                GetOptions(FileSource.Cycles.Keys),
                GetOptions(FileSource.Attachments.Keys)
            };

            for (int i = 0; i < 3; i++)
            {
                maxRow++;

                ParameterCollection obj = null;

                if (i == 0)
                {
                    obj = info.EmittionType;
                }
                else if (i == 1)
                {
                    obj = info.RenderType;
                }
                else if (i == 2)
                {
                    obj = info.CycleType;
                }

                DisplayObject(obj, (DockType)i, options[i], maxOrder);
            }

            if (info.Attachments != null)
            {
                for (int i = 0; i < info.Attachments.Length; i++)
                {
                    DisplayAttachment(info.Attachments[i]);
                }
            }
            else
            {
                info.Attachments = new ParameterCollection[0];
            }

            ReAddEnding();
        }
예제 #5
0
        void cboSelectionChanged(SelectionDock sender)
        {
            int idx = 0;

            if (sender is AddableDock)
            {
                maxRow = sender.MaxRow;

                idx  = sender.Index;
                idx -= 3;

                info.Attachments[idx] = sender.Object;
            }

            if (sender.Index == maxOrder)
            {
                ReAddEnding();
            }
            else
            {
                info = Info;

                for (int i = sender.Index; i < docks.Count; i++)
                {
                    docks[i].Destroy();
                }

                int count = docks.Count;
                count -= sender.Index;

                docks.RemoveRange(sender.Index, count);

                int max = maxOrder;
                maxOrder = sender.Index;

                for (int i = sender.Index; i < max; i++)
                {
                    if (i >= 0 && i < 3)
                    {
                        ParameterCollection obj = null;

                        if (i == 0)
                        {
                            obj = info.EmittionType;
                        }
                        else if (i == 1)
                        {
                            obj = info.RenderType;
                        }
                        else if (i == 2)
                        {
                            obj = info.CycleType;
                        }

                        DisplayObject(obj, (DockType)i, options[i], i);
                    }
                    else
                    {
                        idx  = i;
                        idx -= 3;

                        DisplayAttachment(info.Attachments[idx]);
                    }
                }

                ReAddEnding();
            }
        }