示例#1
0
 public override void Update(BaseScene scene, FrameTick elapsedTime)
 {
 }
示例#2
0
        public override void Update(BaseScene scene, FrameTick elapsedTime)
        {
            ActionTime += elapsedTime;
            int prevRadius = CurrentRadius;

            CurrentRadius = (int)ActionTime.FractionOf(Speed, GraphicsManager.MAX_FPS);
            if (CurrentRadius > Range)
            {
                CurrentRadius = Range;
            }

            int totalParticles   = (int)Math.Round(ParticlesPerTile * (Math.PI * Range * Range) / GraphicsManager.TileSize / GraphicsManager.TileSize);
            int prevParticles    = 0;
            int currentParticles = totalParticles;

            if (Range > 0)
            {
                prevParticles    = totalParticles * prevRadius * prevRadius / Range / Range;
                currentParticles = totalParticles * CurrentRadius * CurrentRadius / Range / Range;
            }

            for (int ii = prevParticles; ii < currentParticles; ii++)
            {
                List <int> openDirs  = getOpenDirs();
                int        openIndex = openDirs[MathUtils.Rand.Next(openDirs.Count)];
                Coverages[openIndex] = true;

                double angle      = (openIndex + MathUtils.Rand.NextDouble()) * Math.PI / 4;
                Loc    startDelta = new Loc();
                int    dist       = CurrentRadius;
                if (AreaLimit == Dungeon.Hitbox.AreaLimit.Cone)
                {
                    angle = (45 * (int)Dir + 45) * Math.PI / 180 + angle / 4;
                }
                else if (AreaLimit == Dungeon.Hitbox.AreaLimit.Sides)
                {
                    dist -= GraphicsManager.TileSize / 2;
                    int diffDist = MathUtils.Rand.Next(GraphicsManager.TileSize / 2 + 1);
                    startDelta += new Loc((int)Math.Round(Math.Cos(angle) * diffDist), (int)Math.Round(Math.Sin(angle) * diffDist));
                    if (Dir.IsDiagonal())
                    {
                        //either +135 or -135 from the direction
                        if (MathUtils.Rand.Next(2) == 0)
                        {
                            angle = (45 * (int)Dir + 90 + 135) * Math.PI / 180;
                        }
                        else
                        {
                            angle = (45 * (int)Dir + 90 - 135) * Math.PI / 180;
                        }
                    }
                    else
                    {
                        //either +90 or -90 from the direction
                        if (MathUtils.Rand.Next(2) == 0)
                        {
                            angle = (45 * (int)Dir + 90 + 90) * Math.PI / 180;
                        }
                        else
                        {
                            angle = (45 * (int)Dir + 90 - 90) * Math.PI / 180;
                        }
                    }
                }

                if (dist >= 0 && dist <= Range)
                {
                    startDelta += new Loc((int)Math.Round(Math.Cos(angle) * dist), (int)Math.Round(Math.Sin(angle) * dist));

                    Loc randDiff = new Loc((int)((MathUtils.Rand.NextDouble() * 2 - 1) * SpeedDiff), 0);

                    if (Anims.Count > 0)
                    {
                        IParticleEmittable chosenAnim = Anims[MathUtils.Rand.Next(Anims.Count)];
                        scene.Anims[(int)DrawLayer.Normal].Add(chosenAnim.CreateParticle(Origin + startDelta, randDiff, Loc.Zero, StartHeight, HeightSpeed, 0, AnimDir));
                    }
                }
            }
        }