Created
December 14, 2017 11:17
-
-
Save TinkerWorX/d9a6c78c11e19679cbd7dfe1dd32d605 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using TinkerWorX.HazardousDungeonNightmare.Bodies; | |
using TinkerWorX.HazardousDungeonNightmare.Entities; | |
using TinkerWorX.HazardousDungeonNightmare.Euclidean; | |
using TinkerWorX.HazardousDungeonNightmare.Scripting; | |
namespace TinkerWorX.HazardousDungeonNightmare.Core | |
{ | |
public class Core : HDNScript | |
{ | |
public override String Author { get { return "MindWorX"; } } | |
public override String Name { get { return "Core"; } } | |
public override String Version { get { return "0.00"; } } | |
public override void Load() | |
{ | |
this.Context.AddArchetype(new WarriorArchetype()); | |
this.Context.AddArchetype(new MageArchetype()); | |
this.Context.AddArchetype(new PaladinArchetype()); | |
this.Context.AddArchetype(new RogueArchetype()); | |
this.Context.AddArchetype(new EngineerArchetype()); | |
this.Context.AddGenerator(new CorePestyMinesGenerator()); | |
this.Context.AddGenerator(new CoreFPSTestGenerator(10, 10)); | |
this.Context.AddGenerator(new CoreFPSTestGenerator(10, 20)); | |
this.Context.AddGenerator(new CoreFPSTestGenerator(15, 20)); | |
this.Context.AddGenerator(new CoreFPSTestGenerator(20, 20)); | |
this.Context.AddAttack(new BroadswordAttack()); | |
} | |
public class BroadswordAttack : Attack | |
{ | |
public BroadswordAttack() : base(AttackType.Active) { } | |
public override String Name { get { return "Broadsword"; } } | |
public override String Description { get { return null; } } | |
public override Frame Icon { get { return new Frame(TextureIds.DawnLikeWarrior, Point.Zero); } } | |
public override AttackCategories Category { get { return AttackCategories.Melee; } } | |
public override Attack DeepClone() | |
{ | |
return new BroadswordAttack(); | |
} | |
public override Attack Clone() | |
{ | |
return new BroadswordAttack(); | |
} | |
} | |
public class EngineerArchetype : Archetype | |
{ | |
public static FrameSet FrameSet = new FrameSet() | |
{ | |
StandSouth = new List<Frame>() { new Frame(TextureIds.DawnLikeEngineer, new Point(0, 0)) }, | |
WalkSouth = new List<Frame>() { new Frame(TextureIds.DawnLikeEngineer, new Point(1, 0)), new Frame(TextureIds.DawnLikeEngineer, new Point(2, 0)), new Frame(TextureIds.DawnLikeEngineer, new Point(3, 0)), new Frame(TextureIds.DawnLikeEngineer, new Point(2, 0)) }, | |
StandWest = new List<Frame>() { new Frame(TextureIds.DawnLikeEngineer, new Point(0, 1)) }, | |
WalkWest = new List<Frame>() { new Frame(TextureIds.DawnLikeEngineer, new Point(1, 1)), new Frame(TextureIds.DawnLikeEngineer, new Point(2, 1)), new Frame(TextureIds.DawnLikeEngineer, new Point(3, 1)), new Frame(TextureIds.DawnLikeEngineer, new Point(2, 1)) }, | |
StandEast = new List<Frame>() { new Frame(TextureIds.DawnLikeEngineer, new Point(0, 2)) }, | |
WalkEast = new List<Frame>() { new Frame(TextureIds.DawnLikeEngineer, new Point(1, 2)), new Frame(TextureIds.DawnLikeEngineer, new Point(2, 2)), new Frame(TextureIds.DawnLikeEngineer, new Point(3, 2)), new Frame(TextureIds.DawnLikeEngineer, new Point(2, 2)) }, | |
StandNorth = new List<Frame>() { new Frame(TextureIds.DawnLikeEngineer, new Point(0, 3)) }, | |
WalkNorth = new List<Frame>() { new Frame(TextureIds.DawnLikeEngineer, new Point(1, 3)), new Frame(TextureIds.DawnLikeEngineer, new Point(2, 3)), new Frame(TextureIds.DawnLikeEngineer, new Point(3, 3)), new Frame(TextureIds.DawnLikeEngineer, new Point(2, 3)) }, | |
}; | |
public override String Name { get { return "Engineer"; } } | |
public override String Description { get { return "The clever engineer!"; } } | |
public override IList<Frame> Icon { get { return EngineerArchetype.FrameSet.StandSouth; } } | |
public override PlayerEntity Create(Vector2 position) | |
{ | |
return new PlayerEntity(EngineerArchetype.FrameSet, position) { LightColor = Color.White, LightPower = 32 }; | |
} | |
} | |
public class MageArchetype : Archetype | |
{ | |
public static FrameSet FrameSet = new FrameSet() | |
{ | |
StandSouth = new List<Frame>() { new Frame(TextureIds.DawnLikeMage, new Point(0, 0)) }, | |
WalkSouth = new List<Frame>() { new Frame(TextureIds.DawnLikeMage, new Point(1, 0)), new Frame(TextureIds.DawnLikeMage, new Point(2, 0)), new Frame(TextureIds.DawnLikeMage, new Point(3, 0)), new Frame(TextureIds.DawnLikeMage, new Point(2, 0)) }, | |
StandWest = new List<Frame>() { new Frame(TextureIds.DawnLikeMage, new Point(0, 1)) }, | |
WalkWest = new List<Frame>() { new Frame(TextureIds.DawnLikeMage, new Point(1, 1)), new Frame(TextureIds.DawnLikeMage, new Point(2, 1)), new Frame(TextureIds.DawnLikeMage, new Point(3, 1)), new Frame(TextureIds.DawnLikeMage, new Point(2, 1)) }, | |
StandEast = new List<Frame>() { new Frame(TextureIds.DawnLikeMage, new Point(0, 2)) }, | |
WalkEast = new List<Frame>() { new Frame(TextureIds.DawnLikeMage, new Point(1, 2)), new Frame(TextureIds.DawnLikeMage, new Point(2, 2)), new Frame(TextureIds.DawnLikeMage, new Point(3, 2)), new Frame(TextureIds.DawnLikeMage, new Point(2, 2)) }, | |
StandNorth = new List<Frame>() { new Frame(TextureIds.DawnLikeMage, new Point(0, 3)) }, | |
WalkNorth = new List<Frame>() { new Frame(TextureIds.DawnLikeMage, new Point(1, 3)), new Frame(TextureIds.DawnLikeMage, new Point(2, 3)), new Frame(TextureIds.DawnLikeMage, new Point(3, 3)), new Frame(TextureIds.DawnLikeMage, new Point(2, 3)) }, | |
}; | |
public override String Name { get { return "Mage"; } } | |
public override String Description { get { return "The powerful mage!"; } } | |
public override IList<Frame> Icon { get { return MageArchetype.FrameSet.StandSouth; } } | |
public override PlayerEntity Create(Vector2 position) | |
{ | |
return new PlayerEntity(MageArchetype.FrameSet, position) { LightColor = Color.White, LightPower = 32 }; | |
} | |
} | |
public class PaladinArchetype : Archetype | |
{ | |
public static FrameSet FrameSet = new FrameSet() | |
{ | |
StandSouth = new List<Frame>() { new Frame(TextureIds.DawnLikePaladin, new Point(0, 0)) }, | |
WalkSouth = new List<Frame>() { new Frame(TextureIds.DawnLikePaladin, new Point(1, 0)), new Frame(TextureIds.DawnLikePaladin, new Point(2, 0)), new Frame(TextureIds.DawnLikePaladin, new Point(3, 0)), new Frame(TextureIds.DawnLikePaladin, new Point(2, 0)) }, | |
StandWest = new List<Frame>() { new Frame(TextureIds.DawnLikePaladin, new Point(0, 1)) }, | |
WalkWest = new List<Frame>() { new Frame(TextureIds.DawnLikePaladin, new Point(1, 1)), new Frame(TextureIds.DawnLikePaladin, new Point(2, 1)), new Frame(TextureIds.DawnLikePaladin, new Point(3, 1)), new Frame(TextureIds.DawnLikePaladin, new Point(2, 1)) }, | |
StandEast = new List<Frame>() { new Frame(TextureIds.DawnLikePaladin, new Point(0, 2)) }, | |
WalkEast = new List<Frame>() { new Frame(TextureIds.DawnLikePaladin, new Point(1, 2)), new Frame(TextureIds.DawnLikePaladin, new Point(2, 2)), new Frame(TextureIds.DawnLikePaladin, new Point(3, 2)), new Frame(TextureIds.DawnLikePaladin, new Point(2, 2)) }, | |
StandNorth = new List<Frame>() { new Frame(TextureIds.DawnLikePaladin, new Point(0, 3)) }, | |
WalkNorth = new List<Frame>() { new Frame(TextureIds.DawnLikePaladin, new Point(1, 3)), new Frame(TextureIds.DawnLikePaladin, new Point(2, 3)), new Frame(TextureIds.DawnLikePaladin, new Point(3, 3)), new Frame(TextureIds.DawnLikePaladin, new Point(2, 3)) }, | |
}; | |
public override String Name { get { return "Paladin"; } } | |
public override String Description { get { return "The righteous paladin!"; } } | |
public override IList<Frame> Icon { get { return PaladinArchetype.FrameSet.StandSouth; } } | |
public override PlayerEntity Create(Vector2 position) | |
{ | |
return new PlayerEntity(PaladinArchetype.FrameSet, position) { LightColor = Color.White, LightPower = 32 }; | |
} | |
} | |
public class RogueArchetype : Archetype | |
{ | |
public static FrameSet FrameSet = new FrameSet() | |
{ | |
StandSouth = new List<Frame>() { new Frame(TextureIds.DawnLikeRogue, new Point(0, 0)) }, | |
WalkSouth = new List<Frame>() { new Frame(TextureIds.DawnLikeRogue, new Point(1, 0)), new Frame(TextureIds.DawnLikeRogue, new Point(2, 0)), new Frame(TextureIds.DawnLikeRogue, new Point(3, 0)), new Frame(TextureIds.DawnLikeRogue, new Point(2, 0)) }, | |
StandWest = new List<Frame>() { new Frame(TextureIds.DawnLikeRogue, new Point(0, 1)) }, | |
WalkWest = new List<Frame>() { new Frame(TextureIds.DawnLikeRogue, new Point(1, 1)), new Frame(TextureIds.DawnLikeRogue, new Point(2, 1)), new Frame(TextureIds.DawnLikeRogue, new Point(3, 1)), new Frame(TextureIds.DawnLikeRogue, new Point(2, 1)) }, | |
StandEast = new List<Frame>() { new Frame(TextureIds.DawnLikeRogue, new Point(0, 2)) }, | |
WalkEast = new List<Frame>() { new Frame(TextureIds.DawnLikeRogue, new Point(1, 2)), new Frame(TextureIds.DawnLikeRogue, new Point(2, 2)), new Frame(TextureIds.DawnLikeRogue, new Point(3, 2)), new Frame(TextureIds.DawnLikeRogue, new Point(2, 2)) }, | |
StandNorth = new List<Frame>() { new Frame(TextureIds.DawnLikeRogue, new Point(0, 3)) }, | |
WalkNorth = new List<Frame>() { new Frame(TextureIds.DawnLikeRogue, new Point(1, 3)), new Frame(TextureIds.DawnLikeRogue, new Point(2, 3)), new Frame(TextureIds.DawnLikeRogue, new Point(3, 3)), new Frame(TextureIds.DawnLikeRogue, new Point(2, 3)) }, | |
}; | |
public override String Name { get { return "Rogue"; } } | |
public override String Description { get { return "The sneaky rogue!"; } } | |
public override IList<Frame> Icon { get { return RogueArchetype.FrameSet.StandSouth; } } | |
public override PlayerEntity Create(Vector2 position) | |
{ | |
return new PlayerEntity(RogueArchetype.FrameSet, position) { LightColor = Color.White, LightPower = 32 }; | |
} | |
} | |
public class WarriorArchetype : Archetype | |
{ | |
public static FrameSet FrameSet = new FrameSet() | |
{ | |
StandSouth = new List<Frame>() { new Frame(TextureIds.DawnLikeWarrior, new Point(0, 0)) }, | |
WalkSouth = new List<Frame>() { new Frame(TextureIds.DawnLikeWarrior, new Point(1, 0)), new Frame(TextureIds.DawnLikeWarrior, new Point(2, 0)), new Frame(TextureIds.DawnLikeWarrior, new Point(3, 0)), new Frame(TextureIds.DawnLikeWarrior, new Point(2, 0)) }, | |
StandWest = new List<Frame>() { new Frame(TextureIds.DawnLikeWarrior, new Point(0, 1)) }, | |
WalkWest = new List<Frame>() { new Frame(TextureIds.DawnLikeWarrior, new Point(1, 1)), new Frame(TextureIds.DawnLikeWarrior, new Point(2, 1)), new Frame(TextureIds.DawnLikeWarrior, new Point(3, 1)), new Frame(TextureIds.DawnLikeWarrior, new Point(2, 1)) }, | |
StandEast = new List<Frame>() { new Frame(TextureIds.DawnLikeWarrior, new Point(0, 2)) }, | |
WalkEast = new List<Frame>() { new Frame(TextureIds.DawnLikeWarrior, new Point(1, 2)), new Frame(TextureIds.DawnLikeWarrior, new Point(2, 2)), new Frame(TextureIds.DawnLikeWarrior, new Point(3, 2)), new Frame(TextureIds.DawnLikeWarrior, new Point(2, 2)) }, | |
StandNorth = new List<Frame>() { new Frame(TextureIds.DawnLikeWarrior, new Point(0, 3)) }, | |
WalkNorth = new List<Frame>() { new Frame(TextureIds.DawnLikeWarrior, new Point(1, 3)), new Frame(TextureIds.DawnLikeWarrior, new Point(2, 3)), new Frame(TextureIds.DawnLikeWarrior, new Point(3, 3)), new Frame(TextureIds.DawnLikeWarrior, new Point(2, 3)) }, | |
}; | |
public override String Name { get { return "Warrior"; } } | |
public override String Description { get { return "The mighty warrior!"; } } | |
public override IList<Frame> Icon { get { return WarriorArchetype.FrameSet.StandSouth; } } | |
public override PlayerEntity Create(Vector2 position) | |
{ | |
return new PlayerEntity(WarriorArchetype.FrameSet, position) { LightColor = Color.White, LightPower = 32 }; | |
} | |
} | |
public class CorePestyMinesGenerator : ISceneGenerator | |
{ | |
public String Name { get { return "Pesky Mines"; } } | |
public Scene Generate() | |
{ | |
var scene = new Scene(1, 1); | |
scene.StartLocations.Add(new Vector2(88, 88)); | |
var dirtFloor = new Tile(TextureIds.DawnLikeFloor, new Point(1, 19)); | |
for (var y = 0; y < scene.RoomsHigh * 11; y++) | |
{ | |
for (var x = 0; x < scene.RoomsWide * 11; x++) | |
{ | |
scene.SetTile(TileLayers.Background, x, y, dirtFloor); | |
} | |
} | |
return scene; | |
} | |
} | |
public class CoreFPSTestGenerator : ISceneGenerator | |
{ | |
public CoreFPSTestGenerator(Int32 width, Int32 height) | |
{ | |
this.Width = width; | |
this.Height = height; | |
this.Name = "FPS Test (" + width * height + ")"; | |
} | |
public Int32 Width { get; set; } | |
public Int32 Height { get; set; } | |
public String Name { get; set; } | |
public Scene Generate() | |
{ | |
var scene = new Scene(2, 2); | |
scene.StartLocations.Add(new Vector2(88, 88)); | |
var dirtFloor = new Tile(TextureIds.DawnLikeFloor, new Point(1, 22)); | |
var wallTL = new Tile(TextureIds.DawnLikeWall, new Point(7, 3)); | |
var wallH = new Tile(TextureIds.DawnLikeWall, new Point(8, 3)); | |
var wallTR = new Tile(TextureIds.DawnLikeWall, new Point(9, 3)); | |
var wallBL = new Tile(TextureIds.DawnLikeWall, new Point(7, 5)); | |
var wallV = new Tile(TextureIds.DawnLikeWall, new Point(7, 4)); | |
var wallBR = new Tile(TextureIds.DawnLikeWall, new Point(9, 5)); | |
for (int x = 1; x <= this.Width; x++) | |
{ | |
for (int y = 1; y <= this.Height; y++) | |
{ | |
scene.Add(new MoverEntity(new Vector2(8 + x * 16, 8 + y * 16))); | |
} | |
} | |
var random = new Random(); | |
for (var y = 0; y < scene.RoomsHigh * 11; y++) | |
{ | |
for (var x = 0; x < scene.RoomsWide * 11; x++) | |
{ | |
scene.SetTile(TileLayers.Background, x, y, dirtFloor); | |
} | |
} | |
for (var x = 1; x < scene.RoomsWide * 11 - 1; x++) | |
{ | |
scene.SetTile(TileLayers.Structure, x, 0, wallH); | |
scene.Add(WallEntity.FromRectangle(x * Tile.WIDTH, 0, Tile.WIDTH, Tile.HEIGHT)); | |
scene.SetTile(TileLayers.Structure, x, scene.RoomsHigh * 11 - 1, wallH); | |
scene.Add(WallEntity.FromRectangle(x * Tile.WIDTH, (scene.RoomsHigh * 11 - 1) * Tile.HEIGHT, Tile.WIDTH, Tile.HEIGHT)); | |
} | |
for (var y = 1; y < scene.RoomsHigh * 11 - 1; y++) | |
{ | |
scene.SetTile(TileLayers.Structure, 0, y, wallV); | |
scene.Add(WallEntity.FromRectangle(0, y * Tile.HEIGHT, Tile.WIDTH, Tile.HEIGHT)); | |
scene.SetTile(TileLayers.Structure, scene.RoomsWide * 11 - 1, y, wallV); | |
scene.Add(WallEntity.FromRectangle((scene.RoomsWide * 11 - 1) * Tile.WIDTH, y * Tile.HEIGHT, Tile.WIDTH, Tile.HEIGHT)); | |
} | |
return scene; | |
} | |
} | |
public class MoverEntity : ComplexAnimatedEntity | |
{ | |
private static List<Frame> frames = new List<Frame>() | |
{ | |
new Frame(TextureIds.DawnLikePest0, new Point(0, 4)), | |
new Frame(TextureIds.DawnLikePest1, new Point(0, 4)) | |
}; | |
private static FrameSet frameSet = new FrameSet() | |
{ | |
StandSouth = new List<Frame>() { new Frame(TextureIds.DawnLikeWarrior, new Point(0, 0)) }, | |
WalkSouth = new List<Frame>() { new Frame(TextureIds.DawnLikeWarrior, new Point(1, 0)), new Frame(TextureIds.DawnLikeWarrior, new Point(2, 0)), new Frame(TextureIds.DawnLikeWarrior, new Point(3, 0)), new Frame(TextureIds.DawnLikeWarrior, new Point(2, 0)) }, | |
StandWest = new List<Frame>() { new Frame(TextureIds.DawnLikeWarrior, new Point(0, 1)) }, | |
WalkWest = new List<Frame>() { new Frame(TextureIds.DawnLikeWarrior, new Point(1, 1)), new Frame(TextureIds.DawnLikeWarrior, new Point(2, 1)), new Frame(TextureIds.DawnLikeWarrior, new Point(3, 1)), new Frame(TextureIds.DawnLikeWarrior, new Point(2, 1)) }, | |
StandEast = new List<Frame>() { new Frame(TextureIds.DawnLikeWarrior, new Point(0, 2)) }, | |
WalkEast = new List<Frame>() { new Frame(TextureIds.DawnLikeWarrior, new Point(1, 2)), new Frame(TextureIds.DawnLikeWarrior, new Point(2, 2)), new Frame(TextureIds.DawnLikeWarrior, new Point(3, 2)), new Frame(TextureIds.DawnLikeWarrior, new Point(2, 2)) }, | |
StandNorth = new List<Frame>() { new Frame(TextureIds.DawnLikeWarrior, new Point(0, 3)) }, | |
WalkNorth = new List<Frame>() { new Frame(TextureIds.DawnLikeWarrior, new Point(1, 3)), new Frame(TextureIds.DawnLikeWarrior, new Point(2, 3)), new Frame(TextureIds.DawnLikeWarrior, new Point(3, 3)), new Frame(TextureIds.DawnLikeWarrior, new Point(2, 3)) }, | |
}; | |
public MoverEntity(Vector2 position) : base(frameSet, new CircleBody(position, 7.00f)) | |
{ | |
this.LightPower = 4; | |
var random = new Random(position.GetHashCode()); | |
this.LightColor = Color.FromNonPremultiplied(random.Next(256), random.Next(256), random.Next(256), 255); | |
} | |
public override void UpdateState(TimeSpan delta, TimeSpan total) | |
{ | |
this.Body.Velocity = new Vector2((Single)Math.Cos(total.TotalSeconds), (Single)Math.Sin(total.TotalSeconds)) * 128; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment