示例#1
0
    IEnumerator Explode(Character offendingCharacter)
    {
        yield return(new WaitForSeconds(0.1f));

        Explosions.Explosion(transform.position, radius, damage, explosionParticle, offendingCharacter);
        Destroy(gameObject);
    }
示例#2
0
        /// <summary>
        /// Creates a new explosion.
        /// </summary>
        /// <param name="position">The Position.</param>
        private void CreateExplosion(Vector2 position)
        {
            var explosion = new Explosion(_explosionTexture)
            {
                Position = position
            };

            Explosions.Add(explosion);
        }
示例#3
0
 public void Reset()
 {
     Bots.Clear();
     Bombs.Clear();
     Missiles.Clear();
     Explosions.Clear();
     Board = new BoardTile[Board.GetLength(0), Board.GetLength(1)];
     OnArenaChanged();
 }
示例#4
0
 public void DrawGameScreen(SpriteBatch spriteBatch)
 {
     Asteroid_Manager.Draw(spriteBatch);
     PowerUp_Manager.Draw(spriteBatch);
     Ship_Manager.Draw(spriteBatch);
     Projectile_Manager.Draw(spriteBatch);
     Explosions.Draw(spriteBatch);
     HUD.Draw(spriteBatch);
 }
示例#5
0
 public void AddForceToAllObject()
 {
     Collider2D[] objectsInArea = Physics2D.OverlapCircleAll(transform.position, Radius);
     foreach (Collider2D collider in objectsInArea)
     {
         if (collider.gameObject.layer == 8)
         {
             Explosions.ExplosionEffect(collider.gameObject, this.gameObject, explosionForce);
         }
     }
 }
示例#6
0
    public void OnTriggerEnter(Collider other)
    {
        var go = other.attachedRigidbody.gameObject;

        //Debug.Log($"Laser hit {go.name}");
        if (go.HasEntityTag(EntityTags.IsDamageable))
        {
            //Debug.Log($"Adding dmg component to ship");
            go.GetEntity().GetComponent <DamageComp>().damagePackets.Push(new DamagePacket(10, 10));
        }
        Explosions.Create(Res.Prefabs.ExplosionPFX_Blue, transform.position);
        gameObject.Release();
    }
        public override void Update()
        {
            var hcs = engine.Get(ComponentTypes.HullComp);

            for (int i = hcs.Count - 1; i >= 0; i--)
            {
                if (((HullComp)hcs[i]).CurrentHull <= 0)
                {
                    Explosions.Create(Res.Prefabs.Explosion_01, hcs[i].GetComponent <PositionComp>().Position);
                    engine.DestroyEntity(hcs[i].Owner);
                }
            }
        }
示例#8
0
 // Use this for initialization
 void Awake()
 {
     instance = this;
     //load all explosions into the object pool
     explosions = new GameObject[poolSize];
     for (int i = 0; i < poolSize; ++i)
     {
         explosions[i] = Instantiate(explosionPrefab);
         explosions[i].transform.SetParent(transform);
         explosions[i].SetActive(false);
     }
     audioS = GetComponent <AudioSource>();
 }
示例#9
0
        public void UpdateGameScreen(GameTime gameTime, bool otherScreenHasFocus)
        {
            if (otherScreenHasFocus)
            {
                return;
            }

            Collision_Manager.Update(gameTime);
            Asteroid_Manager.Update(gameTime);
            Ship_Manager.Update(gameTime);
            Projectile_Manager.Update(gameTime);
            PowerUp_Manager.Update(gameTime);
            Explosions.Update(gameTime);
            GameOver_Manager.Update(gameTime);
        }
示例#10
0
    // Поучить взрыв
    private GameObject GetExplosion()
    {
        foreach (GameObject expl in Explosions)
        {
            if (!expl.activeInHierarchy)
            {
                return(expl);
            }
        }
        GameObject explosion = (GameObject)Instantiate(ExplosionObj);

        Explosions.Add(explosion);
        explosion.SetActive(false);
        return(explosion);
    }
示例#11
0
    void Start()
    {
        AngleControlScript    = GetComponent <AngleControl>();
        ScoreMultiplierScript = GetComponent <ScoreMultiplier>();
        ExplosionsScript      = GetComponent <Explosions>();

        rbBalloon = GetComponent <Rigidbody2D>();

        balloonAnimator         = Top.GetComponent <Animator>();
        basketAnimator          = Bottom.GetComponent <Animator>();
        balloonAnimator.enabled = false;
        basketAnimator.enabled  = false;

        freezeObject(true);  // stabilize the balloon
    }
示例#12
0
 /// <summary>
 /// Updates the explosions.
 /// </summary>
 /// <param name="gameTime">The GameTime.</param>
 private void UpdateExplosion(GameTime gameTime)
 {
     for (int i = 0; i < Explosions.Count; i++)
     {
         Explosion explosion = Explosions[i];
         if (explosion.RemainingLifeTime <= 0)
         {
             Explosions.Remove(explosion);
             i++;
         }
         else
         {
             explosion.Update(gameTime);
         }
     }
 }
示例#13
0
    public override void OnTriggerEnter(Collider other)
    {
        // Similar to base trigger enter

        Character hitCharacter = other.GetComponent <Character>();

        if (hitCharacter)
        {
            if (hitCharacter == character)
            {
                return;
            }
            hitCharacter.TakeDamage(damage, character);
        }
        Explosions.Explosion(transform.position, radius, explosiveDamage, explosionPrefab, character);
        DestroySaveable();
    }
        private void OnParticleCollision(GameObject other)
        {
            if (NeedsDamageInit)
            {
                NeedsDamageInit = false;
                BuildDamagePacket();
            }
            //Debug.Log($"Creating explosion at: {other.transform.position}");

            //Debug.Log($"Laser hit {go.name}");
            if (other.HasEntityTag(EntityTags.IsDamageable))
            {
                //Debug.Log($"Adding dmg component to ship");
                //#TODO: Change damage packet to match weapon info
                other.GetEntity().GetComponent <DamageComp>().damagePackets.Push(particleDmgPacket);
            }
            Explosions.Create(Res.Prefabs.ExplosionPFX_Blue_Local, other.transform.position);
            //Debug.Break();
        }
示例#15
0
        public int Update(GameTime gameTime, float screenWidth, float screenHeight, double totalGameTime)
        {
            //foreach (var ship in _shipCollection)
            //    ship.Update(elapsedTime, screenWidth, screenHeight);

            //for (int i = _projectiles.Count - 1; i >= 0; i--)
            //{
            //    if (_projectiles[i].Y > screenHeight)
            //        _projectiles.Remove(_projectiles[i]);
            //    else
            //        _projectiles[i].Update(elapsedTime, screenWidth, screenHeight);
            //}

            var newShips = CreateShips(gameTime, screenWidth, totalGameTime);

            for (int i = Ships.Count - 1; i >= 0; i--)
            {
                if (Ships[i].Position.Y > screenHeight)
                {
                    Ships.Remove(Ships[i]);
                }
                else
                {
                    Ships[i].Update(gameTime, screenWidth, screenHeight);
                }
            }

            for (int i = Explosions.Count - 1; i >= 0; i--)
            {
                if (!Explosions[i].Active)
                {
                    Explosions.Remove(Explosions[i]);
                }
                else
                {
                    Explosions[i].Update(gameTime);
                }
            }

            return(newShips);
        }
示例#16
0
        private async Task SelectedChangedAsync(Event _event)
        {
            if (SelectedEvents.All(e => e != _event))
            {
                foreach (var report in Reports.ToArray())
                {
                    if (report.Event.Id == _event.Id)
                    {
                        Reports.Remove(report);
                    }
                }
                foreach (var explosion in Explosions.ToArray())
                {
                    if (explosion.Event.Id == _event.Id)
                    {
                        Explosions.Remove(explosion);
                    }
                }
            }
            else
            {
                var reports = await MapModel.GetReports(_event.Id);

                var explosions = await MapModel.GetExplosions(_event.Id);

                foreach (var report in reports)
                {
                    Reports.Add(report);
                }
                foreach (var explosion in explosions)
                {
                    Explosions.Add(explosion);
                }
            }
            OnPropertyChanged(nameof(LocationList));
        }
示例#17
0
 public void AddExplosion(Explosion explosion)
 {
     Explosions.Add(explosion);
 }
示例#18
0
        public void Update()
        {
            if (Ship != null)
            {
                if ((DateTime.Now - lastSpawn).TotalMilliseconds >= SPAWN_INTERVAL)
                {
                    SpawnEnemy();
                }
            }

            for (int b = 0; b < Bullets.Count; b++)
            {
                Bullets[b].Update();
                Bullets[b].Clear();

                if (Bullets[b].IsInMap)
                {
                    bool hit = false;

                    for (int e = 0; e < Enemies.Count; e++)
                    {
                        if (Enemies[e].IsAtCoordinates(Bullets[b].X, Bullets[b].Y) ||
                            Enemies[e].IsAtCoordinates(Bullets[b].LastX, Bullets[b].LastY))
                        {
                            hit = true;

                            Explosions.Add(new Explosion(this, Bullets[b].X, Bullets[b].LastY));
                            if (Enemies[e].Hit())
                            {
                                DestroyedShips++;
                                Enemies[e].Explode();
                                Enemies[e].Delete();
                                Enemies.RemoveAt(e--);
                            }
                            break;
                        }
                    }

                    if (hit)
                    {
                        Bullets.RemoveAt(b--);
                        IncreaseScore(1);
                    }
                    else
                    {
                        Bullets[b].Redraw();
                    }
                }
                else
                {
                    Bullets.RemoveAt(b--);
                }
            }

            for (int e = 0; e < Enemies.Count; e++)
            {
                Enemies[e].Update();
                Enemies[e].Clear();

                if (Enemies[e].IsInMap)
                {
                    if (Ship != null)
                    {
                        bool hit = false;

                        int y = Enemies[e].Y;
                        foreach (int x in Enemies[e].GetXValues())
                        {
                            if (Ship.IsAtCoordinates(x, y) || Ship.WasAtCoordinates(x, y))
                            {
                                hit = true;
                                break;
                            }
                        }

                        if (hit)
                        {
                            Explosions.Add(new Explosion(this, Ship.X, Ship.Y));

                            Enemies[e].Explode();
                            Enemies[e].Delete();
                            Enemies.RemoveAt(e--);

                            Ship.Explode();
                            Ship.Delete();
                            Ship = null;
                            break;
                        }
                        else
                        {
                            Enemies[e].Redraw();
                        }
                    }

                    Enemies[e].Redraw();
                }
                else
                {
                    Enemies[e].Clear();
                    Enemies.RemoveAt(e--);
                }
            }

            for (int e = 0; e < Explosions.Count; e++)
            {
                Explosions[e].Update();
                Explosions[e].Clear();

                if (Explosions[e].IsFinished)
                {
                    Explosions.RemoveAt(e--);
                }
                else
                {
                    Explosions[e].Redraw();
                }
            }

            if (Ship != null)
            {
                Ship.Update();
                Ship.Clear();
                Ship.Redraw();
            }
        }
示例#19
0
 void Explode()
 {
     Explosions.Explosion(transform.position, explosionRadius, damage, particlePrefab, character);
     Destroy(this.gameObject);
 }
 public OnTurnExplodeAction(Explosions explosion, Transform parent, bool isTurnAction)
 {
     this.explosion    = explosion;
     this.parent       = parent;
     this.isTurnAction = isTurnAction;
 }
示例#21
0
        public void Load(DocumentParser file)
        {
            int possibleSounds = file.ReadInt();

            for (int k = 0; k < possibleSounds; k++)
            {
                Sounds.Add(file.ReadInt());
            }

            int shrapnelCount = file.ReadInt();

            for (int k = 0; k < shrapnelCount; k++)
            {
                SmashDataShrapnel shrapnel = new SmashDataShrapnel
                {
                    ShrapnelType = file.ReadEnum <SmashDataShrapnel.SmashDataShrapnelType>()
                };

                shrapnel.InitialVelocity.TowardsYouSpeed        = file.ReadVector2();
                shrapnel.InitialVelocity.ImpacteeVelocityFactor = file.ReadSingle();
                shrapnel.InitialVelocity.MaxRandomVelocity      = file.ReadSingle();
                shrapnel.InitialVelocity.MaxUpVelocity          = file.ReadSingle();
                shrapnel.InitialVelocity.MaxNormalVelocity      = file.ReadSingle();
                shrapnel.InitialVelocity.MaxRandomSpinRate      = file.ReadSingle();

                if (shrapnel.ShrapnelType != SmashDataShrapnel.SmashDataShrapnelType.shards)
                {
                    shrapnel.InitialPositionType = file.ReadEnum <SmashDataShrapnel.SmashDataInitialPositionType>();

                    if (shrapnel.InitialPositionType == SmashDataShrapnel.SmashDataInitialPositionType.sphereclumped)
                    {
                        shrapnel.ClumpingRadius = file.ReadSingle();
                        shrapnel.ClumpingCentre = file.ReadEnum <SmashDataShrapnel.ClumpCentre>();
                    }
                }

                if (shrapnel.ShrapnelType != SmashDataShrapnel.SmashDataShrapnelType.noncars)
                {
                    shrapnel.Time = file.ReadVector2();
                }

                if (shrapnel.ShrapnelType == SmashDataShrapnel.SmashDataShrapnelType.shards)
                {
                    shrapnel.CutLength    = file.ReadSingle();
                    shrapnel.Flags        = file.ReadInt();
                    shrapnel.MaterialName = file.ReadLine();
                }
                else if (shrapnel.ShrapnelType == SmashDataShrapnel.SmashDataShrapnelType.ghostparts)
                {
                    int[] count = file.ReadInts();
                    shrapnel.MinCount = count[0];
                    shrapnel.MaxCount = count.Length == 2 ? count[1] : count[0];

                    int numActors = file.ReadInt();
                    if (numActors > 0)
                    {
                        for (int l = 0; l < numActors; l++)
                        {
                            shrapnel.GhostPartActors.Add(file.ReadLine());
                        }
                    }
                    else
                    {
                        shrapnel.GhostPartActors.Add(file.ReadLine());
                    }
                }
                else if (shrapnel.ShrapnelType == SmashDataShrapnel.SmashDataShrapnelType.noncars)
                {
                    int[] count = file.ReadInts();
                    shrapnel.MinCount     = count[0];
                    shrapnel.MaxCount     = count[1];
                    shrapnel.ChanceOfFire = file.ReadInt();

                    if (shrapnel.ChanceOfFire > 0)
                    {
                        shrapnel.NumFires   = file.ReadInt();
                        shrapnel.SmokeLevel = file.ReadInts();
                    }

                    shrapnel.Actor = file.ReadLine();
                    int numActors = file.ReadInt();

                    for (int l = 0; l < numActors; l++)
                    {
                        shrapnel.Actors.Add(new SmashDataShrapnelActor
                        {
                            Name     = file.ReadLine(),
                            FileName = file.ReadLine()
                        });
                    }
                }
                else
                {
                    shrapnel.MinCount = file.ReadInt();
                    shrapnel.MaxCount = file.ReadInt();
                    shrapnel.Actor    = file.ReadLine();
                }

                Shrapnel.Add(shrapnel);
            }

            int explosionCount = file.ReadInt();

            for (int k = 0; k < explosionCount; k++)
            {
                Explosions.Add(SmashDataExplosion.Load(file));
            }

            SlickMaterial = file.ReadLine();

            int noncarCuboidCount = file.ReadInt();

            for (int k = 0; k < noncarCuboidCount; k++)
            {
                NoncarCuboids.Add(SmashDataNoncarActivationCuboid.Load(file));
            }

            int smashCuboidCount = file.ReadInt();

            for (int k = 0; k < smashCuboidCount; k++)
            {
                SmashCuboids.Add(SmashDataSmashActivationCuboid.Load(file));
            }

            ExtensionFlags = file.ReadInt();
            RoomTurnOnCode = file.ReadInt();
            AwardCode      = file.ReadEnum <AwardCodeType>();

            if (AwardCode != AwardCodeType.none)
            {
                PointsAwarded = file.ReadInt();
                TimeAwarded   = file.ReadInt();
                HudIndex      = file.ReadInt();
                FancyHUDIndex = file.ReadInt();
            }

            int runtimeVariableChanges = file.ReadInt();

            for (int k = 0; k < runtimeVariableChanges; k++)
            {
                RuntimeVariableChanges.Add(file.ReadLine());
            }
        }
        public override void DoImpact(Target target, Actor firedBy, IEnumerable <int> damageModifiers)
        {
            if (!target.IsValidFor(firedBy))
            {
                return;
            }

            var random     = firedBy.World.SharedRandom;
            var pos        = target.CenterPosition + new WVec(Radius.X == 0 ? 0 : random.Next(-Radius.X, Radius.X), Radius.Y == 0 ? 0 : random.Next(-Radius.Y, Radius.Y), 0);
            var world      = firedBy.World;
            var targetTile = world.Map.CellContaining(pos);
            var isValid    = IsValidImpact(pos, firedBy);

            if ((!world.Map.Contains(targetTile)) || (!isValid))
            {
                return;
            }

            var palette = ExplosionPalette;

            if (UsePlayerPalette)
            {
                palette += firedBy.Owner.InternalName;
            }

            if (ForceDisplayAtGroundLevel)
            {
                var dat = world.Map.DistanceAboveTerrain(pos);
                pos = new WPos(pos.X, pos.Y, pos.Z - dat.Length);
            }

            var explosion = Explosions.RandomOrDefault(Game.CosmeticRandom);

            if (Image != null && explosion != null)
            {
                world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, w, Image, explosion, palette)));
            }

            if (ShrapnelWeapon != null)
            {
                WeaponInfo weaponInfo;
                var        weaponToLower = ShrapnelWeapon.ToLowerInvariant();

                if (!Game.ModData.DefaultRules.Weapons.TryGetValue(weaponToLower, out weaponInfo))
                {
                    throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(weaponToLower));
                }

                var rotation      = WRot.FromFacing(world.SharedRandom.Next(1024));
                var range         = world.SharedRandom.Next(ShrapnelRange[0].Length, ShrapnelRange[1].Length);
                var passiveTarget = pos + new WVec(range, 0, 0).Rotate(rotation);

                var args = new ProjectileArgs
                {
                    Weapon              = weaponInfo,
                    DamageModifiers     = new int[0],
                    InaccuracyModifiers = new int[0],
                    RangeModifiers      = new int[0],
                    Source              = pos,
                    CurrentSource       = () => pos,
                    SourceActor         = firedBy,
                    PassiveTarget       = passiveTarget,
                    GuidedTarget        = target
                };

                world.AddFrameEndTask(x =>
                {
                    if (args.Weapon.Projectile != null)
                    {
                        var projectile = args.Weapon.Projectile.Create(args);
                        if (projectile != null)
                        {
                            world.Add(projectile);
                        }
                    }
                    else
                    {
                        foreach (var warhead in args.Weapon.Warheads.Keys)
                        {
                            var wh = warhead;                             // force the closure to bind to the current warhead

                            if (wh.Delay > 0)
                            {
                                firedBy.World.AddFrameEndTask(w => w.Add(new DelayedImpact(wh.Delay, wh, Target.FromPos(args.PassiveTarget), args.SourceActor, new int[0])));
                            }
                            else
                            {
                                wh.DoImpact(Target.FromPos(args.PassiveTarget), args.SourceActor, new int[0]);
                            }
                        }
                    }
                });
            }

            var impactSound = ImpactSounds.RandomOrDefault(Game.CosmeticRandom);

            if (impactSound != null && Game.CosmeticRandom.Next(0, 100) < ImpactSoundChance)
            {
                Game.Sound.Play(SoundType.World, impactSound, pos);
            }
        }
示例#23
0
 private void Awake()
 {
     explosions  = FindObjectOfType <Explosions>();
     bombSpawner = FindObjectOfType <BombSpawner>();
 }