示例#1
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);
        }
示例#2
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);
    }
示例#3
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));
        }
示例#4
0
 public void AddExplosion(Explosion explosion)
 {
     Explosions.Add(explosion);
 }
示例#5
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());
            }
        }
示例#6
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();
            }
        }