private void spawnParticles(ISceneObject other)
        {
            Vector direction;
            Vector collision;

            if (other is Asteroid)
            {
                Asteroid a = other as Asteroid;
                collision = a.Center + (a.Direction * a.Radius);
            }
            else if (other is IMovable)
            {
                IMovable o = other as IMovable;
                collision = o.Center;
            }
            else
            {
                return;
            }

            direction = new Vector(0, -1);

            EmmitorGroup g = ParticleEmmitorFactory.CreateBaseExplosionEmmitors(baze, collision, direction);

            g.Attach(me.SceneMgr);
        }
Exemple #2
0
        public static EmmitorGroup CreateAsteroidExplosionEmmitors(SceneMgr mgr, Vector position)
        {
            ParticleEmmitor smokeEmmitor = CreateFireParticleEmmitor(mgr, position, Color.FromArgb(135, 0, 0, 0));

            smokeEmmitor.EmitingTime = 0.5f;
            smokeEmmitor.Amount      = 20;
            smokeEmmitor.MinLife     = 1.0f;
            smokeEmmitor.MaxLife     = 1.2f;
            smokeEmmitor.MinSize     = 5;
            smokeEmmitor.MaxSize     = 6f;
            smokeEmmitor.MinForce    = 3;
            smokeEmmitor.MaxForce    = 4;
            smokeEmmitor.FireAll     = true;

            ParticleEmmitor fireEmmitor = CreateFireParticleEmmitor(mgr, position, Color.FromArgb(120, 255, 120, 0));

            fireEmmitor.EmitingTime = 0.5f;
            fireEmmitor.Amount      = 20;
            fireEmmitor.MinLife     = 0.8f;
            fireEmmitor.MaxLife     = 1.0f;
            fireEmmitor.MinSize     = 5;
            fireEmmitor.MaxSize     = 6f;
            fireEmmitor.MinForce    = 3;
            fireEmmitor.MaxForce    = 4;
            fireEmmitor.FireAll     = true;

            EmmitorGroup g = new EmmitorGroup();

            g.Position = position;
            g.Add(smokeEmmitor);
            g.Add(fireEmmitor);

            return(g);
        }
        private void CreateEmmitor(Vector position)
        {
            EmmitorGroup g = ParticleEmmitorFactory.CreateFireEmmitors(me.SceneMgr, position);

            emmitors.Push(g);

            g.Attach(me.SceneMgr, false);
        }
        public virtual void HitAsteroid(IDestroyable asteroid)
        {
            if (hit)
            {
                return;
            }
            else
            {
                hit = true;
            }

            if (bullet.Owner.IsCurrentPlayerOrBot())
            {
                bullet.Owner.AddScoreAndShow(ScoreDefines.CANNON_HIT);
                if (bullet.Owner.IsCurrentPlayer())
                {
                    bullet.SceneMgr.FloatingTextMgr.AddFloatingText(ScoreDefines.CANNON_HIT, bullet.Center, FloatingTextManager.TIME_LENGTH_1,
                                                                    FloatingTextType.SCORE);
                }

                if (asteroid is UnstableAsteroid)
                {
                    Rect   opponentLoc = PlayerBaseLocation.GetBaseLocation(bullet.Owner.GetPosition() == PlayerPosition.RIGHT ? PlayerPosition.LEFT : PlayerPosition.RIGHT);
                    double xMin        = opponentLoc.X;
                    double xMax        = opponentLoc.X + opponentLoc.Width;

                    if (asteroid.Position.Y > SharedDef.VIEW_PORT_SIZE.Height * 0.4 &&
                        asteroid.Position.X >= xMin && asteroid.Position.X <= xMax)
                    {
                        if (bullet.Owner.IsCurrentPlayer())
                        {
                            bullet.SceneMgr.FloatingTextMgr.AddFloatingText(Strings.ft_score_cannon_unstable_above_enemy, bullet.Center,
                                                                            FloatingTextManager.TIME_LENGTH_4, FloatingTextType.BONUS_SCORE, FloatingTextManager.SIZE_BIG, false, true);
                        }
                        bullet.Owner.AddScoreAndShow(ScoreDefines.CANNON_DESTROYED_UNSTABLE_ASTEROID_ABOVE_ENEMY);
                    }
                }
            }

            asteroid.TakeDamage(bullet.Damage, bullet);

            NetOutgoingMessage msg = bullet.SceneMgr.CreateNetMessage();

            msg.Write((int)PacketType.BULLET_HIT);
            msg.Write(bullet.Id);
            msg.Write(asteroid.Id);
            msg.Write(bullet.Damage);
            bullet.SceneMgr.SendMessage(msg);

            EmmitorGroup g = ParticleEmmitorFactory.CreateBulletImplosionEmmitor(bullet.SceneMgr, bullet.Center, bullet.Color);

            g.Attach(bullet.SceneMgr, false);
        }
        private void DespawnEmmitor()
        {
            if (emmitors.Count == 0)
            {
                return;
            }

            EmmitorGroup g = emmitors.Pop();

            g.Stop();

            dead.Enqueue(g);
        }
        public void DoCollideWith(ISceneObject other, float tpf)
        {
            if (other is Asteroid && (other as Asteroid).Enabled)
            {
                other.DoRemoveMe();

                // nebudou hitovat objekty, ktere jsou uz pod horizontem
                if (other.Center.Y > baze.Position.Y + baze.Size.Height)
                {
                    return;
                }

                int damage = (other as Asteroid).Radius / 2;

                // score
                Player otherPlayer = baze.SceneMgr.GetOtherActivePlayer(baze.Owner.GetId());
                if (otherPlayer != null && otherPlayer.IsCurrentPlayer())
                {
                    Vector textPos = new Vector(otherPlayer.GetBaseLocation().X + (otherPlayer.GetBaseLocation().Width / 2), otherPlayer.GetBaseLocation().Y - 20);
                    baze.SceneMgr.FloatingTextMgr.AddFloatingText(damage * ScoreDefines.DAMAGE_DEALT, textPos, FloatingTextManager.TIME_LENGTH_2,
                                                                  FloatingTextType.SCORE, FloatingTextManager.SIZE_MEDIUM);
                }

                if (otherPlayer != null && otherPlayer.IsCurrentPlayerOrBot())
                {
                    otherPlayer.AddScoreAndShow(damage * ScoreDefines.DAMAGE_DEALT);
                }

                // damage
                baze.SceneMgr.FloatingTextMgr.AddFloatingText(damage, new Vector((other as Asteroid).Center.X, (other as Asteroid).Center.Y - 10),
                                                              FloatingTextManager.TIME_LENGTH_1, FloatingTextType.DAMAGE, FloatingTextManager.SIZE_MEDIUM);

                SoundManager.Instance.StartPlayingOnce(SharedDef.MUSIC_DAMAGE_TO_BASE);

                baze.Integrity -= damage;
                baze.Owner.Statistics.DamageTaken += damage;

                EmmitorGroup g = ParticleEmmitorFactory.CreateAsteroidExplosionEmmitors(me.SceneMgr, other.Center);
                g.Attach(me.SceneMgr, false);

                if (baze.Owner.IsCurrentPlayer())
                {
                    me.SceneMgr.ScreenShakingMgr.Start(ShakePower.WEAK);
                }

                if (baze.Owner.IsCurrentPlayerOrBot())
                {
                    spawnParticles(other);
                }
            }
        }
Exemple #7
0
        public static EmmitorGroup CreateBaseExplosionEmmitors(Base baze, Vector collision, Vector direction)
        {
            ParticleEmmitor f = CreateFlashParticleEmmitor(baze.SceneMgr, collision, Color.FromRgb(250, 250, 150));

            f.MinSize = 2;
            f.MaxSize = 3;

            ParticleEmmitor d = CreateBaseDebrisEmmitor(baze.SceneMgr, collision, direction, baze.Color);

            EmmitorGroup g = new EmmitorGroup();

            g.Add(f);
            g.Add(d);

            return(g);
        }
Exemple #8
0
        public static EmmitorGroup CreateBulletImplosionEmmitor(SceneMgr mgr, Vector position, Color color)
        {
            ParticleEmmitor e1 = CreateShockWaveParticleEmmitor(mgr, position, color);

            e1.SizeMultiplier = 20;
            e1.MinLife        = 0.25f;
            e1.MaxLife        = 0.25f;
            e1.MinSize        = 0.2f;
            e1.MaxSize        = 0.2f;

            EmmitorGroup g = new EmmitorGroup();

            g.Add(e1);

            return(g);
        }
Exemple #9
0
        protected override void OnDeath()
        {
            if (me is MiningModule)
            {
                module.Owner.Statistics.DeadTime += SharedDef.SPECTATOR_RESPAWN_TIME;
            }

            module.GetControlOfType <HpBarControl>().Bar.Percentage = 0;
            module.GetControlOfType <RespawningObjectControl>().Die(SharedDef.SPECTATOR_RESPAWN_TIME);
            Vulnerable = false;

            EmmitorGroup g = ParticleEmmitorFactory.CreateExplosionEmmitors(module.SceneMgr, module.Center);

            g.Attach(module.SceneMgr, false);

            if (me.SceneMgr.GetCurrentPlayer().Device == module)
            {
                me.SceneMgr.ScreenShakingMgr.Start(ShakePower.STRONG);
            }
        }
Exemple #10
0
        public static EmmitorGroup CreateFireEmmitors(SceneMgr mgr, Vector position)
        {
            ParticleEmmitor smokeEmmitor = CreateFireParticleEmmitor(mgr, position, Color.FromArgb(80, 0, 0, 0));

            smokeEmmitor.Amount    = 60;
            smokeEmmitor.MinLife   = 4f;
            smokeEmmitor.MaxLife   = 5f;
            smokeEmmitor.MinSize   = 0.7f;
            smokeEmmitor.MaxSize   = 1.2f;
            smokeEmmitor.MinForce  = 2;
            smokeEmmitor.MaxForce  = 3;
            smokeEmmitor.Direction = new Vector(0, -1);
            smokeEmmitor.MinAngle  = (float)-Math.PI / 30;
            smokeEmmitor.MaxAngle  = (float)Math.PI / 30;
            smokeEmmitor.Infinite  = true;

            ParticleEmmitor fireEmmitor = CreateFireParticleEmmitor(mgr, position, Color.FromArgb(120, 255, 155, 0));

            fireEmmitor.Amount    = 50;
            fireEmmitor.MinLife   = 0.5f;
            fireEmmitor.MaxLife   = 1.2f;
            fireEmmitor.MinSize   = 1f;
            fireEmmitor.MaxSize   = 1.5f;
            fireEmmitor.MinForce  = 5;
            fireEmmitor.MaxForce  = 6;
            fireEmmitor.Direction = new Vector(0, -1);
            fireEmmitor.MinAngle  = (float)-Math.PI / 20;
            fireEmmitor.MaxAngle  = (float)Math.PI / 20;
            fireEmmitor.Infinite  = true;


            EmmitorGroup g = new EmmitorGroup();

            g.Position = position;
            g.Add(smokeEmmitor);
            g.Add(fireEmmitor);

            return(g);
        }
        private void SpawnEmmitor()
        {
            Vector v = new Vector(1, 0);

            v = v.Rotate(FastMath.LinearInterpolate(0, -Math.PI, rand.NextDouble()));
            //v *= FastMath.LinearInterpolate(0, baze.Size.Height, rand.NextDouble());
            v *= baze.Size.Height;

            v.X += baze.Position.X + baze.Size.Width / 2;
            v.Y += baze.Position.Y + baze.Size.Height;

            if (dead.Count > 0)
            {
                EmmitorGroup g = dead.Dequeue();
                g.Position = v;

                g.Start();
                emmitors.Push(g);
            }
            else
            {
                CreateEmmitor(v);
            }
        }
        private void CreateSpark()
        {
            ParticleNode node = new ParticleNode(me.SceneMgr, IdMgr.GetNewId(me.SceneMgr.GetCurrentPlayer().GetId()));

            // TODO spawn in a whole volume
            bool left = me.SceneMgr.GetRandomGenerator().Next(2) == 0 ? false : true;

            if (left)
            {
                Vector position = (meNode.Center - (meNode.Direction.Rotate(Math.PI / 4) * (asteroid.Radius)));
                position      += meNode.Direction * (asteroid.Radius * 1.5);
                node.Position  = position;
                node.Direction = meNode.Direction.Rotate(FastMath.DegToRad(-10));
            }
            else
            {
                Vector position = (meNode.Center - (meNode.Direction.Rotate(-Math.PI / 4) * (asteroid.Radius)));
                position      += meNode.Direction * (asteroid.Radius * 1.5);
                node.Position  = position;
                node.Direction = meNode.Direction.Rotate(FastMath.DegToRad(10));
            }

            float minSize = (float)FastMath.LinearInterpolate(0.2, 0.5, me.SceneMgr.GetRandomGenerator().NextDouble());
            float maxSize = minSize * 1.2f;

            ParticleEmmitor smokeEmmitor = ParticleEmmitorFactory.CreateBasicFire(me.SceneMgr, Color.FromArgb(80, 0, 0, 0));

            smokeEmmitor.Amount      = 20;
            smokeEmmitor.MinLife     = 0.3f;
            smokeEmmitor.MaxLife     = 0.4f;
            smokeEmmitor.MinSize     = minSize * 1.3f;
            smokeEmmitor.MaxSize     = maxSize * 1.3f;
            smokeEmmitor.SpawnRadius = 4f;
            smokeEmmitor.Infinite    = true;

            ParticleEmmitor fireEmmitor = ParticleEmmitorFactory.CreateBasicFire(me.SceneMgr, Color.FromArgb(150, 255, 100, 0));

            fireEmmitor.Amount   = 20;
            fireEmmitor.MinLife  = 0.1f;
            fireEmmitor.MaxLife  = 0.2f;
            fireEmmitor.MinSize  = minSize * 1.1f;
            fireEmmitor.MaxSize  = maxSize * 1.1f;
            fireEmmitor.Infinite = true;

            ParticleEmmitor fireEmmitor2 = ParticleEmmitorFactory.CreateBasicFire(me.SceneMgr, Color.FromArgb(200, 255, 200, 0));

            fireEmmitor2.Amount   = 20;
            fireEmmitor2.MinLife  = 0.1f;
            fireEmmitor2.MaxLife  = 0.1f;
            fireEmmitor2.MinSize  = minSize;
            fireEmmitor2.MaxSize  = maxSize;
            fireEmmitor2.Infinite = true;

            EmmitorGroup grp = new EmmitorGroup();

            grp.Add(smokeEmmitor);
            grp.Add(fireEmmitor);
            grp.Add(fireEmmitor2);

            node.AddEmmitorGroup(grp, new Vector(), false);

            NewtonianMovementControl nmc = new NewtonianMovementControl();

            nmc.Speed = (asteroid.GetControlOfType <IMovementControl>().RealSpeed / tpf) * 0.75f;
            node.AddControl(nmc);
            node.AddControl(new LimitedLifeControl((float)FastMath.LinearInterpolate(0.5, 2, me.SceneMgr.GetRandomGenerator().NextDouble())));

            me.SceneMgr.DelayedAttachToScene(node);
        }