internal static void WriteNewEntrance(DungeonEntrance exit, DungeonEntrance newSpawn) { var spawnId = newSpawn.SpawnId(); foreach (var exitInfo in exit.ExitIndices()) { var sceneNumber = exitInfo.Item1; var exitIndex = exitInfo.Item2; EntranceUtils.WriteSceneExits(sceneNumber, exitIndex, spawnId); if (sceneSync.ContainsKey(sceneNumber)) { EntranceUtils.WriteSceneExits(sceneSync[sceneNumber], exitIndex, spawnId); } } foreach (var cutsceneExitInfo in exit.ExitCutscenes()) { var sceneNumber = cutsceneExitInfo.Item1; var setupIndex = cutsceneExitInfo.Item2; var cutsceneIndex = cutsceneExitInfo.Item3; EntranceUtils.WriteCutsceneExits(sceneNumber, setupIndex, cutsceneIndex, spawnId); if (sceneSync.ContainsKey(sceneNumber)) { EntranceUtils.WriteCutsceneExits(sceneSync[sceneNumber], setupIndex, cutsceneIndex, spawnId); } } foreach (var address in exit.ExitAddresses()) { ReadWriteUtils.WriteToROM(address, spawnId); } }
internal static void WriteSpawnToROM(DungeonEntrance newSpawn) { var spawnAddress = newSpawn.SpawnId(); ReadWriteUtils.WriteToROM(0xBDB882, spawnAddress); ReadWriteUtils.WriteToROM(0x02E90FD4, spawnAddress); ReadWriteUtils.WriteToROM(0x02E90FDC, spawnAddress); }
void DestroyDungeonEntrance() { if (_spawnedDungeonEntrance == null) { return; } Destroy(_spawnedDungeonEntrance.gameObject); _spawnedDungeonEntrance = null; }
private Dungeon GenerateDungeon(DungeonEntrance entrance) { switch (entrance.DungeonType) { case DungeonType.FIRE: return(GenerateFireDungeon(entrance)); case DungeonType.CAVE: return(GenerateCaveDungeon(entrance)); } return(null); }
private void CreateObject(TmxObject obj, Rectangle source, TmxTileset tileset, Texture2D tilesetTexture) { var random = new Random(); var type = tileset.Tiles[obj.Tile.Gid - tileset.FirstGid].Type; var rotation = MathHelper.ToRadians((float)obj.Rotation); var spawnPosition = GetObjectPosition(obj, source); Entity entity; switch (type) { case "Car": entity = new Car(this, tilesetTexture, (int)obj.Width, (int)obj.Height, spawnPosition, rotation, source); break; case "Enemy_Spawn": entity = new Enemy(tilesetTexture, spawnPosition, (int)obj.Width, (int)obj.Height, this, rotation, source); break; case "Dungeon_Entrance": entity = new DungeonEntrance(new ShooterScreen(), screenManager, tilesetTexture, (int)obj.Width, (int)obj.Height, spawnPosition, rotation, source); break; case "Collectable": entity = new Collectable(tilesetTexture, spawnPosition, (int)obj.Width, (int)obj.Height, rotation, source); break; case "Ammo": var randomBulletType = (BulletType)random.Next(Enum.GetNames(typeof(BulletType)).Length); entity = new AmmoPack(randomBulletType, random.Next(15, 30), tilesetTexture, spawnPosition, (int)obj.Width, (int)obj.Height, rotation, source); break; case "Health": entity = new HealthPack(random.Next(15, 30), tilesetTexture, spawnPosition, (int)obj.Width, (int)obj.Height, rotation, source); break; case "Gas": entity = new GasPump(tilesetTexture, (int)obj.Width, (int)obj.Height, spawnPosition, rotation, source); break; default: entity = new Entity(tilesetTexture, (int)obj.Width, (int)obj.Height, spawnPosition, rotation, source); break; } EntityManager.Instance.AddEntity(entity); }
private Dungeon GenerateCaveDungeon(DungeonEntrance entr) { ChunkStructure cStruc = entr.ChunkStructure; if (cStruc is BanditCamp) { BanditCaveDungeonBuilder bcdb = new BanditCaveDungeonBuilder(cStruc.Position, cStruc.Size); Dungeon dun = bcdb.Generate(entr, GenRan); entr.SetDungeon(dun); return(dun); } return(null); }
public override Dungeon Generate(DungeonEntrance entr, GenerationRandom ran = null) { if (ran == null) { ran = new GenerationRandom(ChunkPosition.x << 16 + ChunkPosition.z); } ChunkData[,] chunks = CreateChunks(); Vec2i dunEntr = ChunkPosition * World.ChunkSize + new Vec2i(World.ChunkSize / 2, World.ChunkSize / 2); List <Entity> dunEnt = GenerateEntities(); DungeonBoss dunBoss = GenerateDungeonBoss(); return(new Dungeon(chunks, new Vec2i(5, 5), dunEntr, dunEnt, dunBoss)); }
void SpawnDungeonEntrance() { if (_spawnedDungeonEntrance != null) { return; } GameObject g = Instantiate(dungeonEntrancePrefab, transform.position, transform.rotation) as GameObject; DungeonEntrance e = g.GetComponent <DungeonEntrance>(); e.name = "Dungeon Entrance " + dungeonNum.ToString(); e.transform.SetParent(_dungeonEntranceContainer); e.DungeonNum = dungeonNum; _spawnedDungeonEntrance = e; }
private Dungeon GenerateFireDungeon(DungeonEntrance entrance) { ChunkData[,] dungeonChunks = new ChunkData[5, 5]; Dictionary <int, WorldObjectData>[,] chunkObjects = new Dictionary <int, WorldObjectData> [5, 5]; for (int x = 0; x < 5; x++) { for (int z = 0; z < 5; z++) { chunkObjects[x, z] = new Dictionary <int, WorldObjectData>(); dungeonChunks[x, z] = new ChunkData(x, z, (int[, ])BASE_DIRT.Clone(), true, chunkObjects[x, z]); } } Vec2i chunkPos = World.GetChunkPosition(entrance.WorldPosition); Vec2i dungEntr = new Vec2i(5, 5); EntityFaction dungFact = new EntityFaction("Dungeon_faction"); List <Entity> dungeonEntities = new List <Entity>(); DungeonBoss testBoss = new DungeonBossTest(new BasicHumanoidCombatAI(), new CreatureTaskAI()); testBoss.SetEntityFaction(dungFact); for (int i = 0; i < 25; i++) { Vec2i randomPos = GenRan.RandomVec2i(World.ChunkSize, 5 * World.ChunkSize - 5); Entity newEnt = new Bandit(); newEnt.SetPosition(randomPos); newEnt.SetEntityFaction(dungFact); dungeonEntities.Add(newEnt); } Dungeon dungeon = new Dungeon(dungeonChunks, dungEntr, entrance.WorldPosition, dungeonEntities, testBoss); entrance.SetDungeon(dungeon); return(dungeon); }
public abstract Dungeon Generate(DungeonEntrance entr, GenerationRandom ran = null);
public void SetDungeonEntrance(DungeonEntrance dunEntrance) { DungeonEntrance = dunEntrance; }
public static IEnumerable <int> ExitAddresses(this DungeonEntrance entrance) { return(entrance.GetAttributes <ExitAddressAttribute>().Select(eaa => eaa.Address)); }
public static IEnumerable <Tuple <int, byte, byte> > ExitCutscenes(this DungeonEntrance entrance) { return(entrance.GetAttributes <ExitCutsceneAttribute>().Select(eca => new Tuple <int, byte, byte>(eca.SceneId, eca.SetupIndex, eca.CutsceneIndex))); }
public static IEnumerable <Tuple <int, byte> > ExitIndices(this DungeonEntrance entrance) { return(entrance.GetAttributes <ExitAttribute>().Select(ea => new Tuple <int, byte>(ea.SceneId, ea.ExitIndex))); }
public static ushort SpawnId(this DungeonEntrance entrance) { return(entrance.GetAttribute <SpawnAttribute>().SpawnId); }
public DungeonEntranceAttribute(DungeonEntrance entrance, DungeonEntrance pair) { Entrance = entrance; Pair = pair; }
public DungeonEntranceAttribute(DungeonEntrance entrance) { Entrance = entrance; }