-
Notifications
You must be signed in to change notification settings - Fork 8
Levels
Andrey edited this page Sep 21, 2023
·
8 revisions
There is a class Level that contains everything related to the editor.
Such as colors, blocks, background, guidelines and others
var local = await LocalLevels.LoadFileAsync();
var level = local.GetLevel("MyLevel", revision: 0).LoadLevel();revision is the number for levels with the same names.
In the game, it's written as "rev."
var response = await client.DownloadLevelAsync(id: 49395494);
if (response.GeometryDashStatusCode != 0)
throw new InvalidOperationException($"server return an error: {response.GeometryDashStatusCode}");
var levelString = response.GetResultOrDefault()?.Level?.LevelString;
if (string.IsNullOrEmpty(levelString))
throw new InvalidOperationException("malformed level string");
var level = new Level(levelString, compressed: true);var level = new Level();level.AddColor(new Color(10)
{
Rgb = RgbColor.FromHex("#ffa500") // orange
});level.AddBlock(new BaseBlock(id: 1)
{
PositionX = 120,
PositionY = 120,
Groups = new[] { 1, 2 },
DontFade = true
// and more
});Note that BaseBlock does not contain all possible properties!
For example, if you create a MoveTrigger instead of BaseBlock, you can specify TargetGroupId and MoveTime additionally
level.AddBlock(new MoveTrigger()
{
PositionX = 120,
PositionY = 120,
Groups = new[] { 1, 2 },
DontFade = true,
TargetGroupId = 51,
MoveTime = 0.5f
});The concept of blocks is such that there is an IBlock, this is an interface that contains all the basic properties, and then new properties are added by inheritance.
For MoveTrigger it's looks this: MoveTrigger -> Trigger -> Block -> IBlock
IBlock
└Block
├ Trigger
│ ├ MoveTrigger
│ ├ AlphaTrigger
│ ├ AnimateTrigger
│ ├ PickupTrigger
│ └ and more, see all triggers in "GeometryDashAPI/Levels/GameObjects/Triggers"
├ BaseBlock
│ └ there is any blocks that contain BaseColor
├ DetailBlock
│ └ there is any blocks that contain DetailColor
├ ColorBlock (both of BaseBlock and DetailBlock)
├ StartPos
├ JumpSphere
├ Coin
└ and more special blocks. You can find it in "GeometryDashAPI/Levels/GameObjects/Specific"