Exemplo n.º 1
0
        public void SetPath(TDPath Path)
        {
            this.Path = Path;

            // automatically set the starting location to the first point on the path.
            this.Location = new TDLocation(Path.PathPoints[0].Location.X, Path.PathPoints[0].Location.Y);
        }
Exemplo n.º 2
0
        private static TDPath LoadPathFromDataTable(DataTable t)
        {
            TDPath p = new TDPath();

            for (int x = 1; x <= t.Columns.Count; x++)
            {
                for (int y = 2; y <= t.Rows.Count; y++) // start at 2 because of the 'name' row
                {
                    string val = t.Rows[y - 1][x - 1].ToString().ToLower();

                    if (!String.IsNullOrEmpty(val))
                    {
                        p.PathPoints.Add(new TDPathPoint(Int32.Parse(val), x * TDMap.GridSize, y * TDMap.GridSize));
                    }
                }
            }
            p.PathPoints.Sort();
            return(p);
        }
Exemplo n.º 3
0
        private void GenerateAttackersForLevel(int lvl, List <TDPath> Paths)
        {
            // waves
            this._WaveCount = 9 + (lvl);

            if (testing)
            {
                _WaveCount = 0;
            }

            // wave attacker type
            bool mixed = (TDMath.D(100) > 70); // 30% mixed

            // attackers per wave
            int attPerWave = 5 + TDMath.D(10 * lvl);

            if (testing)
            {
                attPerWave = 0;
            }

            // if 80, then betwen 41 and 80;
            int ThisWaveDelay = (WaveDelay / 2) + TDMath.D(WaveDelay / 2);

            if (testing)
            {
                ThisWaveDelay = WaveDelay;
            }

            int MaxDelay = 0;

            // for each wave
            for (int i = 0; i < this._WaveCount; i++)
            {
                // set the type and path for this wave
                AttackerTypes t = GetWeightedAttackerType(false);
                TDPath        p = Paths[TDMath.D(Paths.Count) - 1];

                // vary the attacker separation for this wave (between 1/2 and full value)
                int AttackerDelayWithinThisWave = (AttackerDelayWithinWave / 2) + TDMath.D((AttackerDelayWithinWave / 2));

                if (testing)
                {
                    AttackerDelayWithinThisWave = AttackerDelayWithinWave;
                }

                for (int j = 0; j < attPerWave; j++)
                {
                    // check for mixed attacker type
                    if (mixed && lvl > 3) // don't mix until lvl 4+
                    {
                        // randomized the type for the next attacker
                        t = GetWeightedAttackerType(true);
                        p = Paths[TDMath.D(Paths.Count) - 1];
                    }

                    // generate the new attacker
                    TDAttacker a = new TDAttacker(t, lvl);
                    a.WaveIndex = i + 1;

                    int delayMS = Math.Max(1, (i * ThisWaveDelay) + (j * AttackerDelayWithinThisWave)); // slightly stagger each attacker within the wave (j)
                    a.Effects.Add(new TDEffect(TDEffectTypes.WaveDelay, 0, new TimeSpan(0, 0, 0, 0, delayMS), false));
                    a.SetPath(p);

                    this.Attackers.Add(a);

                    // remember the MaxDelay for the Boss
                    MaxDelay = Math.Max(MaxDelay, delayMS);
                }
            }

            // and finally, add the level boss
            TDAttacker boss = new TDAttacker(AttackerTypes.Boss, lvl + 10);

            boss.Size     += 4;
            boss.HPMax     = boss.HPMax * 6;
            boss.HPCurrent = boss.HPMax;
            int AdditionalBossDelay = 500;

            if (testing)
            {
                AdditionalBossDelay = 10000;
            }
            boss.Effects.Add(new TDEffect(TDEffectTypes.WaveDelay, 0, new TimeSpan(0, 0, 0, 0, MaxDelay + AdditionalBossDelay), false)); // 1/2 second after last attacker
            TDPath pBoss = Paths[TDMath.D(Paths.Count) - 1];

            boss.SetPath(pBoss);
            this.Attackers.Add(boss);
        }