コード例 #1
0
        public void FromXML(XmlDocument doc)
        {
            EmptyMap();
            EffectFire  fire  = new EffectFire();
            XmlNodeList tiles = doc.SelectNodes("//tile");

            foreach (XmlNode node in tiles)
            {
                int      x   = Convert.ToInt16(node.Attributes ["x"].InnerText);
                int      y   = Convert.ToInt16(node.Attributes ["y"].InnerText);
                Vector   v   = GetTilePos(x, y);
                TileType typ = (TileType)Enum.Parse(typeof(TileType), node.Attributes ["type"].InnerText, true);
                if (typ == TileType.Fire && editor)
                {
                    map [y] [x].tileGraphic = new Graphic(Color.Orange, Tile.WIDTH, Tile.HEIGHT);
                }
                else
                {
                    map [y] [x].tileGraphic = lookup [typ].Clone();
                }
                if (typ == TileType.Fire && !editor)
                {
                    Vector xPos = new Vector(new Point((int)v.X, (int)v.X + Tile.WIDTH));
                    Vector yPos = new Vector(new Point((int)v.Y - EffectFire.HEIGHT, (int)v.Y -
                                                       EffectFire.HEIGHT));
                    ParticleOptions p = fire.template.Clone();
                    p.xPosRange        = xPos;
                    p.yPosRange        = yPos;
                    map [y] [x].system = new ParticleSystem(p);
                }
                map [y] [x].tileType = typ;
                map [y] [x].x        = (int)v.X;
                map [y] [x].y        = (int)v.Y;
            }
        }
コード例 #2
0
        public ParticleSystem(ParticleOptions _ops)
        {
            particles = new List <Particle> ();
            rand      = new Random();
            ops       = _ops;
            int n = rand.Next((int)ops.numberRange.X, (int)ops.numberRange.Y);

            for (int i = 0; i < n; i++)
            {
                newParticle();
            }
        }
コード例 #3
0
 public EffectDie(Color colour, KillableSprite kS)
 {
     xDirRange = new Vector (new PointF (-1.0f, 2.0f));
     yDirRange = new Vector (new PointF (-1.0f, -1.0f));
     xSpeedRange = new Vector (new Point (150, 200));
     ySpeedRange = new Vector (new Point (150, 200));
     numberRange = new Vector (new Point (100, 200));
     xStopRange = new Vector (new Point ((int)(kS.width*1.1), kS.width*2));
     yStopRange = new Vector (new Point ((int)(kS.height*1.1), kS.height*2));//(Tile.HEIGHT - 5, Tile.HEIGHT-2));
     newParticlesNumberRange = new Vector (new Point (0, 0));
     newParticlesTimeRange = new Vector (new PointF (0, 0));
     alpha = 255;
     alphaStep = -200;
     repeat = false;
     graphics = new Graphic[]{new Graphic(colour, WIDTH, HEIGHT), new Graphic(Color.Red, WIDTH, HEIGHT)};
     Vector blank = new Vector (0);
     template = new ParticleOptions (blank, blank, xDirRange, yDirRange, xSpeedRange, ySpeedRange, numberRange,
         xStopRange,yStopRange, newParticlesTimeRange, newParticlesNumberRange, alpha, alphaStep, repeat, graphics);
 }
コード例 #4
0
 public virtual void Update(float elapsed, Camera camera, Player player, Map map)
 {
     rect = new Rectangle(new Point((int)x, (int)y), new Size(width, height));
     if (health <= 0)
     {
         dead = true;
     }
     if (dead)
     {
         if (system == null)
         {
             ParticleOptions ops = (new EffectDie(colour, (KillableSprite)this)).template.Clone();
             ops.xPosRange = new Vector(new Point((int)x, (int)x + width));
             ops.yPosRange = new Vector(new Point((int)y, (int)y + height));
             system        = new ParticleSystem(ops);
         }
         system.Update(elapsed, camera);
         return;
     }
 }
コード例 #5
0
        public EffectDie(Color colour, KillableSprite kS)
        {
            xDirRange               = new Vector(new PointF(-1.0f, 2.0f));
            yDirRange               = new Vector(new PointF(-1.0f, -1.0f));
            xSpeedRange             = new Vector(new Point(150, 200));
            ySpeedRange             = new Vector(new Point(150, 200));
            numberRange             = new Vector(new Point(100, 200));
            xStopRange              = new Vector(new Point((int)(kS.width * 1.1), kS.width * 2));
            yStopRange              = new Vector(new Point((int)(kS.height * 1.1), kS.height * 2));//(Tile.HEIGHT - 5, Tile.HEIGHT-2));
            newParticlesNumberRange = new Vector(new Point(0, 0));
            newParticlesTimeRange   = new Vector(new PointF(0, 0));
            alpha     = 255;
            alphaStep = -200;
            repeat    = false;
            graphics  = new Graphic[] { new Graphic(colour, WIDTH, HEIGHT), new Graphic(Color.Red, WIDTH, HEIGHT) };
            Vector blank = new Vector(0);

            template = new ParticleOptions(blank, blank, xDirRange, yDirRange, xSpeedRange, ySpeedRange, numberRange,
                                           xStopRange, yStopRange, newParticlesTimeRange, newParticlesNumberRange, alpha, alphaStep, repeat, graphics);
        }
コード例 #6
0
        public EffectFire()
        {
            xDirRange               = new Vector(new PointF(-0.5f, 0.5f));
            yDirRange               = new Vector(new Point(-1, -1));
            xSpeedRange             = new Vector(new Point(0, 0));
            ySpeedRange             = new Vector(new Point(100, 600));
            numberRange             = new Vector(new Point(8, 10));
            xStopRange              = new Vector(new Point(Tile.WIDTH, Tile.WIDTH));
            yStopRange              = new Vector(new Point(1, 20)); //(Tile.HEIGHT - 5, Tile.HEIGHT-2));
            newParticlesNumberRange = new Vector(new Point(1, 6));
            newParticlesTimeRange   = new Vector(new PointF(0.01f, 0.34f));
            alpha     = 255;
            alphaStep = -200;
            repeat    = true;
            graphics  = new Graphic[] { new Graphic(Color.Orange, WIDTH, HEIGHT), new Graphic(Color.Red, WIDTH, HEIGHT),
                                        new Graphic(Color.Yellow, WIDTH, HEIGHT) };
            Vector blank = new Vector(0);

            template = new ParticleOptions(blank, blank, xDirRange, yDirRange, xSpeedRange, ySpeedRange, numberRange,
                                           xStopRange, yStopRange, newParticlesTimeRange, newParticlesNumberRange, alpha, alphaStep, repeat, graphics);
        }
コード例 #7
0
 public ParticleSystem(ParticleOptions _ops)
 {
     particles = new List<Particle> ();
     rand = new Random ();
     ops = _ops;
     int n = rand.Next ((int)ops.numberRange.X, (int)ops.numberRange.Y);
     for (int i=0; i < n; i++) {
         newParticle ();
     }
 }
コード例 #8
0
 public EffectFire()
 {
     xDirRange = new Vector (new PointF (-0.5f, 0.5f));
     yDirRange = new Vector (new Point (-1, -1));
     xSpeedRange = new Vector (new Point (0, 0));
     ySpeedRange = new Vector (new Point (100, 600));
     numberRange = new Vector (new Point (8, 10));
     xStopRange = new Vector (new Point (Tile.WIDTH, Tile.WIDTH));
     yStopRange = new Vector (new Point (1, 20));//(Tile.HEIGHT - 5, Tile.HEIGHT-2));
     newParticlesNumberRange = new Vector (new Point (1, 6));
     newParticlesTimeRange = new Vector (new PointF (0.01f, 0.34f));
     alpha = 255;
     alphaStep = -200;
     repeat = true;
     graphics = new Graphic[]{new Graphic(Color.Orange, WIDTH, HEIGHT), new Graphic(Color.Red, WIDTH, HEIGHT),
         new Graphic(Color.Yellow, WIDTH,HEIGHT)};
     Vector blank = new Vector (0);
     template = new ParticleOptions (blank, blank, xDirRange, yDirRange, xSpeedRange, ySpeedRange, numberRange,
         xStopRange, yStopRange, newParticlesTimeRange, newParticlesNumberRange, alpha, alphaStep, repeat, graphics);
 }