Esempio n. 1
0
    private SpellEntry VolcanoEntry()
    {
      int volcRange = 6;

      SpellEntry entry = new SpellEntry();

      entry.Id = "volcano";
      entry.Target = SpellEntry.TargetType.Tile;

      entry.OnSpellStartTile = (game, gameEffect, caster, target) =>
      {
        gameEffect.LocalData.Add(target.GetElevation());
        ApplyOnSurroundingTiles(target, volcRange, (fTile, fRange) =>
        {
          gameEffect.LocalData.Add(fTile);
          gameEffect.LocalData.Add(fRange);
        });

        game.CreateTextScrollUpEffect(target, 100, 1, "Volcano");
      };

      entry.OnSpellStep = (game, gameEffect) =>
      {
        int baseLevel = (int)gameEffect.LocalData[0];
        for (int i = 1; i < gameEffect.LocalData.Count; i += 2)
        {
          IScriptTile tile = (IScriptTile)gameEffect.LocalData[i];
          int distance = (int)gameEffect.LocalData[i + 1];
          int increase = 2*Math.Max(volcRange - distance, 1);
          int dmg = increase * 10;

          var bldg = tile.GetBuilding();
          if (bldg != null)
          {
            int currentHp = bldg.GetHealth();
            if (currentHp == 0) continue;

            game.CreateTextScrollUpEffect(bldg.GetNearestTile(), 100, 1, "Destroyed by volcano");

            bldg.Kill();
          }

          foreach (var unit in tile.GetUnits())
          {
            int currentHp = unit.GetHealth();
            if (currentHp == 0) continue;

            unit.SetHealth(currentHp - dmg);
          }

          int projectedElevation = baseLevel + gameEffect.Time * increase / gameEffect.Duration;
          int currElevation = tile.GetElevation();
          tile.SetElevation(projectedElevation);
        }
      };

      entry.OnSpellFinish = null;

      return entry;
    }
Esempio n. 2
0
    private SpellEntry LevelEntry()
    {
      SpellEntry entry = new SpellEntry();

      entry.Id = "level";
      entry.Target = SpellEntry.TargetType.Tile;

      entry.OnSpellStartTile = (game, gameEffect, caster, target) =>
      {
        gameEffect.LocalData.Add(target.GetElevation());
        ApplyOnSurroundingTiles(target, 3, (fTile, fRange) =>
        {
          gameEffect.LocalData.Add(fTile);
        });
      };

      entry.OnSpellStep = (game, gameEffect) =>
      {
        for (int i = 1; i < gameEffect.LocalData.Count; i++)
        {
          IScriptTile tile = (IScriptTile)gameEffect.LocalData[i];
          int h = tile.GetElevation();
          if (h > (int)gameEffect.LocalData[0]) h--;
          if (h < (int)gameEffect.LocalData[0]) h++;
          tile.SetElevation(h);
        }
      };

      entry.OnSpellFinish = null;

      return entry;
    }
Esempio n. 3
0
    private SpellEntry Sample()
    {
      SpellEntry entry = new SpellEntry();

      entry.Id = "sample";
      entry.Target = SpellEntry.TargetType.Tile;

      entry.OnSpellStartTile = (game, gameEffect, caster, target) =>
      {
        var data = caster.GetDbEntry();
        data.Speed += 2f;
        caster.SetDbEntry(data);
        gameEffect.LocalData.Add(caster);

        game.CreateAnimationEffect(caster.GetNearestTile(), 2, 2,"redBuff", 1, 1, 0, false);
      };

      entry.OnSpellStep = (game, gameEffect) =>
        {
          var caster = gameEffect.LocalData[0] as IScriptUnit;
          if (caster.GetHealth() > 0)
          {
            game.CreateAnimationEffect(caster.GetNearestTile(), 2, 2, "redBuff", 1, 1, 0, false);
          }
        };

      return entry;
    }
Esempio n. 4
0
    private SpellEntry DisruptEntry()
    {
      int disriptRange = 3;

      SpellEntry entry = new SpellEntry();

      entry.Id = "disrupt";
      entry.Target = SpellEntry.TargetType.Tile;

      entry.OnSpellStartTile = (game, gameEffect, caster, target) =>
      {
        ApplyOnSurroundingTiles(target, disriptRange, (fTile, fRange) =>
          {
            gameEffect.LocalData.Add(fTile);
            gameEffect.LocalData.Add(fTile.GetElevation());
            gameEffect.LocalData.Add(fRange);
          });

        game.CreateTextScrollUpEffect(target, 100, 1, "Disruption");
      };

      entry.OnSpellStep = (game, gameEffect) =>
      {
        int phase = (gameEffect.Time / 2) % 4 - 2;
        if (phase == -2) phase = 0;
        for (int i = 0; i < gameEffect.LocalData.Count; i += 3)
        {
          IScriptTile tile = (IScriptTile)gameEffect.LocalData[i];
          int height = (int)gameEffect.LocalData[i + 1];
          int distance = (int)gameEffect.LocalData[i + 2];
          var bldg = tile.GetBuilding();
          if (bldg == null)
          {
            tile.SetElevation(height + phase);
          }
          else
          {
            int currentHp = bldg.GetHealth();
            if (currentHp == 0) continue;

            bldg.SetHealth(currentHp - 10);
          }
          int dmg = Math.Min(disriptRange - distance, 1);
          foreach (var unit in tile.GetUnits())
          {
            int currentHp = unit.GetHealth();
            if (currentHp == 0) continue;

            unit.SetHealth(currentHp - dmg);
          }
        }

        if (gameEffect.Time + 6 == gameEffect.Duration)
        {
          game.CreateTextScrollUpEffect( (IScriptTile)gameEffect.LocalData[0], 100, 1, "Disruption wearing off");
        }
      };

      entry.OnSpellFinish = (game, gameEffect) =>
      {
        for (int i = 0; i < gameEffect.LocalData.Count; i += 3)
        {
          IScriptTile tile = (IScriptTile)gameEffect.LocalData[i];
          int height = (int)gameEffect.LocalData[i + 1];
          int distance = (int)gameEffect.LocalData[i + 2];
          foreach (var unit in tile.GetUnits())
          {
            int currentHp = unit.GetHealth();
            if (currentHp == 0) continue;
            if (unit.GetDbEntry().Shaman) continue;

            game.CreateTextScrollUpEffect(unit.GetNearestTile(), 100, 1, "Killed by disruption");

            unit.Kill();
          }
        }
      };

      return entry;
    }