public override void Update(GameTime gameTime)
        {
            Vector3 Position3 = new Vector3(Position.X(), 0, Position.Y());

            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 50, 1);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 100 + Rand.F() * 100, 1);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 25 + Rand.F() * 25, 2);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 25 + Rand.F() * 25, 0);

            base.Update(gameTime);
        }
        public override void Update(GameTime gameTime)
        {
            int Mult = Big ? 2 : 1;

            Vector3 Position3 = new Vector3(Position.X(), 0, Position.Y());

            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 80 * Mult, 1);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, (100 + Rand.F() * 100) * Mult, 1);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, (20 + Rand.F() * 40) * Mult, 2);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, (20 + Rand.F() * 40) * Mult, 0);

            if (!Flashed)
            {
                Mult *= 2;
                ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 80 * Mult, 0);
                ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 80 * Mult, 4);
                Flashed = true;
            }

            base.Update(gameTime);
        }
        public override void Update(GameTime gameTime)
        {
            if (!Dead)
            {
                MineAddTime += gameTime.ElapsedGameTime.Milliseconds;
                if (MineAddTime > MaxMineAddTime)
                {
                    MinesToAdd++;
                    MineAddTime = 0;

                    SearchTime -= MaxSearchTime;

                    QuadGrid quad = Parent2DScene.quadGrids.First.Value;

                    foreach (Basic2DObject o in quad.Enumerate(Position.get(), new Vector2(MaxEngagementDistance * 2)))
                    {
                        if (o.GetType().IsSubclassOf(typeof(UnitBasic)))
                        {
                            UnitBasic s = (UnitBasic)o;
                            float     d = Vector2.Distance(Position.get(), o.Position.get());
                            if (!s.IsAlly(this) && s.CanBeTargeted() && d < MaxEngagementDistance + o.Size.X() / 2)
                            {
                                if (Mines.Count > 0)
                                {
                                    float BestDistance = 10000;
                                    Mine  BestMine     = null;

                                    foreach (Mine m in Mines)
                                    {
                                        float MineDist = Vector2.Distance(m.Position.get(), o.Position.get());
                                        if (MineDist < BestDistance)
                                        {
                                            BestDistance = MineDist;
                                            BestMine     = m;
                                        }
                                    }

                                    BestMine.SetAttackTarget(s);
                                    Mines.Remove(BestMine);

                                    SoundManager.Play3DSound("MineFieldTarget", new Vector3(Position.X(), Y, Position.Y()), 0.35f,
                                                             1000, 2);
                                }
                                if (d < (Size.X() + o.Size.X()))
                                {
                                    MinesToAdd = 0;
                                }

                                break;
                            }
                        }
                    }
                }

                if (Mines.Count >= MaxMines)
                {
                    MinesToAdd = 0;
                }

                while (MinesToAdd > 0)
                {
                    Mine m = new Mine(this, FactionNumber);
                    ParentLevel.AddObject(m);
                    Mines.AddLast(m);

                    Vector2 toPosition = Position.get() + Rand.V2() * Size.X() / 2;

                    m.Position.set(toPosition);
                    MinesToAdd--;
                }
            }
            base.Update(gameTime);
        }
        public override void Destroy()
        {
            int Mult = Big ? 2 : 1;

            Vector3 Position3 = new Vector3(Position.X(), Y, Position.Y());

            for (int i = 0; i < 10; i++)
            {
                ParticleManager.CreateParticle(Position3, Rand.V3() * 200, ParticleColor, 20 * Mult, 5);
            }

            FlareSystem.AddLightingPoint(Position3, new Vector3(1, 0.25f, 0.25f), new Vector3(0.5f, 0, 0.25f), 5 * Mult, 20 * Mult, 3, 5);
            ParticleManager.CreateParticle(Position3, Vector3.Zero, ParticleColor, 400 * Mult, 5);
            for (int i = 0; i < 3; i++)
            {
                FlamingChunkSystem.AddParticle(Position3, Rand.V3() / 4, Vector3.Zero, Rand.V3() * Mult, Vector3.Zero, 20 * Mult, 10, ParticleColor.ToVector3(), ParticleColor.ToVector3(), 0, 2);
            }

            base.Destroy();
        }
Exemplo n.º 5
0
        public override void Update(GameTime gameTime)
        {
            Interpolation += gameTime.ElapsedGameTime.Milliseconds / (4f * Math.Max(1, Vector3.Distance(To, From)));
            while (Interpolation > 1)
            {
                Interpolation -= 1;
                //LineParticleSystem.AddParticle(To, From, LineColor);
                From = To;

                if (CellX < 1 || CellY < 1 ||
                    CellX > Parent.CellsX.get() - 2 || CellY > Parent.CellsY.get() - 2 ||
                    Parent.CellGrid[CellX, CellY] == PathFindingManager.StartingCell)
                {
                    Destroy();
                    return;
                }

                for (int i = 0; i < 5; i++)
                {
                    int MaxValue = Max(Parent.CellGrid[CellX - 1, CellY], Parent.CellGrid[CellX + 1, CellY],
                                       Parent.CellGrid[CellX, CellY - 1], Parent.CellGrid[CellX, CellY + 1]);

                    if (MaxValue == Parent.CellGrid[CellX - 1, CellY])
                    {
                        CellX--;
                    }
                    if (MaxValue == Parent.CellGrid[CellX + 1, CellY])
                    {
                        CellX++;
                    }
                    if (MaxValue == Parent.CellGrid[CellX, CellY - 1])
                    {
                        CellY--;
                    }
                    if (MaxValue == Parent.CellGrid[CellX, CellY + 1])
                    {
                        CellY++;
                    }

                    if (MaxValue == PathFindingManager.DeadCell || CellX < 1 || CellY < 1 ||
                        CellX > Parent.CellsX.get() - 2 || CellY > Parent.CellsY.get() - 2)
                    {
                        Destroy();
                        return;
                    }
                }

                Vector2 Position2 = Parent.WorldPosition(CellX, CellY);
                To = new Vector3(Position2.X - 50 + Rand.F() * 100, 0, Position2.Y - 50 + Rand.F() * 100);
            }

            Vector3 InterpolatedPosition = Vector3.Lerp(From, To, Interpolation);

            ParticleManager.CreateParticle(InterpolatedPosition, Vector3.Zero, LineColor, 50, 1);
            ParticleManager.CreateParticle(InterpolatedPosition, Vector3.Zero, LineColor * 0.1f, 250, 1);

            base.Update(gameTime);
        }