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);
        }
        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);
        }
        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);
                }
            }
        }
Пример #5
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);
            }
        }