Beispiel #1
0
        //  This mine collides with something after which it must explode
        public override void Explode()
        {
            MyExplosion newExplosion = MyExplosions.AddExplosion();

            if (newExplosion != null)
            {
                newExplosion.Start(m_ammoProperties.HealthDamage, m_ammoProperties.ShipDamage, m_ammoProperties.EMPDamage, MyExplosionTypeEnum.FLASH_EXPLOSION, new BoundingSphere(GetPosition(), m_ammoProperties.ExplosionRadius), MyExplosionsConstants.EXPLOSION_LIFESPAN, CascadedExplosionLevel, ownerEntity: OwnerEntity, particleScale: 0.001f);
            }

            bool isBotFlashBomb = OwnerEntity as MySmallShipBot != null;

            //If ship is another player, add flash to his view
            BoundingSphere flashSphere = new BoundingSphere(GetPosition(), MyFlashBombConstants.FLASH_RADIUS);

            m_targetEntities.Clear();
            MyEntities.GetIntersectionWithSphere(ref flashSphere, this, null, true, false, ref m_targetEntities);
            foreach (MyEntity ob in m_targetEntities)
            {
                if (ob is MySmallShip)
                {
                    if (MyEnemyTargeting.CanSee(this, ob) == null)
                    {
                        Vector3 bombPosition = GetPosition();
                        if (ob == MySession.PlayerShip)
                        {
                            if (MyCamera.IsInFrustum(ref bombPosition))
                            {
                                MyFlashes.MakeFlash();
                            }
                        }
                        else if (!isBotFlashBomb && ob is MySmallShipBot)  //If this flashbomb is from bot, dont flash bots
                        {
                            //If it is bot, make him panic
                            MySmallShipBot bot = ob as MySmallShipBot;
                            bot.Flash();
                        }
                    }
                }
            }

            MarkForClose();
        }