public ShopStep() : base() { Filters = new List <BaseRoomFilter>(); Items = new SpawnList <MapItem>(); ItemThemes = new SpawnList <ItemTheme>(); Mobs = new SpawnList <MobSpawn>(); }
private void Update() { // find the player gameobject to pass spawn info if (player == null) { player = GameObject.Find(player_name); } // pull the selected value from the select bar gameobject which tells us which bot out of the 4 built // is currently selected by the player select_val = select_bar.GetComponent <BarSelectParentLink>().selected_box; // convert that int into a gameobject. Could be done also by using an index with an array of gameObjects, makes no difference if (select_val == 1) { selected_spawn_bot = spawn_bot_1; } else if (select_val == 2) { selected_spawn_bot = spawn_bot_2; } else if (select_val == 3) { selected_spawn_bot = spawn_bot_3; } else if (select_val == 4) { selected_spawn_bot = spawn_bot_4; } // the spawn_list is then the spawn list of the selected bot if (selected_spawn_bot != null) { spawn_list = selected_spawn_bot.GetComponent <SpawnList>(); } }
protected override void PrepareZoneSpawnScript(Triggers triggers, SpawnList spawnList) { triggers // trigger on world init .Add(GetTrigger <TriggerWorldInit>()) // trigger on time interval .Add(GetTrigger <TriggerTimeInterval>().Configure(TimeSpan.FromMinutes(30))); spawnList.CreatePreset(interval: 10, padding: 2, useSectorDensity: false) .Add <ObjectMineralPragmiumNode>(); // mob spawn var presetLizard = spawnList.CreatePreset(interval: 22, padding: 0.5, useSectorDensity: false) .Add <MobCloakedLizard>() .SetCustomPaddingWithSelf(12); var presetScorpion = spawnList.CreatePreset(interval: 26, padding: 0.5, useSectorDensity: false) .Add <MobScorpion>() .SetCustomPaddingWithSelf(15); var presetCrawler = spawnList.CreatePreset(interval: 13, padding: 0.5, useSectorDensity: false) .Add <MobCrawler>() .SetCustomPaddingWithSelf(1); // define custom spawn padding between different mobs presetLizard.SetCustomPaddingWith(presetScorpion, 5); presetLizard.SetCustomPaddingWith(presetCrawler, 5); presetCrawler.SetCustomPaddingWith(presetScorpion, 5); }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { foreach (string asset in importedAssets) { if (!filePath.Equals(asset)) { continue; } SpawnList data = (SpawnList)AssetDatabase.LoadAssetAtPath(assetFilePath, typeof(SpawnList)); if (data == null) { data = ScriptableObject.CreateInstance <SpawnList> (); data.sheetName = filePath; data.worksheetName = sheetName; AssetDatabase.CreateAsset((ScriptableObject)data, assetFilePath); //data.hideFlags = HideFlags.NotEditable; } //data.dataArray = new ExcelQuery(filePath, sheetName).Deserialize<SpawnListData>().ToArray(); //ScriptableObject obj = AssetDatabase.LoadAssetAtPath (assetFilePath, typeof(ScriptableObject)) as ScriptableObject; //EditorUtility.SetDirty (obj); ExcelQuery query = new ExcelQuery(filePath, sheetName); if (query != null && query.IsValid()) { data.dataArray = query.Deserialize <SpawnListData>().ToArray(); ScriptableObject obj = AssetDatabase.LoadAssetAtPath(assetFilePath, typeof(ScriptableObject)) as ScriptableObject; EditorUtility.SetDirty(obj); } } }
public void SpawnListAddNegative() { // add negative var spawnList = new SpawnList <string>(); Assert.Throws <ArgumentException>(() => { spawnList.Add("apple", -1); }); }
public Tweener Spawn(Type tweenType) { Tweener result; if (DeSpawnList.Count > 0) { var index = DeSpawnList.Count - 1; result = DeSpawnList[index]; DeSpawnList.RemoveAt(index); } else { result = Activator.CreateInstance(tweenType) as Tweener; } SpawnList.Add(result); if (result != null) { result.Reset(); return(result); } else { return(null); } }
protected SpreadRoomPostProc(SpreadRoomPostProc other, ulong seed) : this() { Spawns = other.Spawns; PriorityGrid = other.PriorityGrid; PriorityList = other.PriorityList; SpreadPlan = other.SpreadPlan.Instantiate(seed); }
public MonsterHouseBaseStep() { Items = new SpawnList <MapItem>(); ItemThemes = new SpawnList <ItemTheme>(); Mobs = new SpawnList <MobSpawn>(); MobThemes = new SpawnList <MobTheme>(); }
public void GetPossiblePlacementsNone() { // can't place anywhere, so resort to the middle // verify all possible positions are checked Mock <IRoomGen> mockFrom = new Mock <IRoomGen>(MockBehavior.Strict); mockFrom.SetupGet(p => p.Draw).Returns(new Rect(3, 3, 6, 6)); Mock <IRoomGen> mockTo = new Mock <IRoomGen>(MockBehavior.Strict); mockTo.SetupGet(p => p.Draw).Returns(new Rect(0, 0, 3, 3)); var adjacentsByDir = new Dictionary <Dir4, List <IRoomGen> >(); foreach (Dir4 dir in DirExt.VALID_DIR4) { adjacentsByDir[dir] = new List <IRoomGen>(); } var mockRooms = new Mock <IRandPicker <RoomGen <IFloorPlanTestContext> > >(MockBehavior.Strict); var mockHalls = new Mock <IRandPicker <PermissiveRoomGen <IFloorPlanTestContext> > >(MockBehavior.Strict); var pathGen = new Mock <SetSpecialRoomTestStep>(mockRooms.Object, mockHalls.Object) { CallBase = true }; pathGen.Setup(p => p.GetAllBorderMatch(adjacentsByDir, mockTo.Object, mockFrom.Object, It.IsAny <Loc>())).Returns(0); SpawnList <Loc> spawns = pathGen.Object.GetPossiblePlacements(adjacentsByDir, mockTo.Object, mockFrom.Object); Assert.That(spawns.Count, Is.EqualTo(4)); Assert.That(spawns.GetSpawn(0), Is.EqualTo(new Loc(4, 4))); Assert.That(spawns.GetSpawn(1), Is.EqualTo(new Loc(4, 5))); Assert.That(spawns.GetSpawn(2), Is.EqualTo(new Loc(5, 4))); Assert.That(spawns.GetSpawn(3), Is.EqualTo(new Loc(5, 5))); }
public Map() { AssetName = ""; Name = new LocalText(); Comment = ""; Music = ""; ScriptEvents = new Dictionary <LuaEngine.EDungeonMapCallbacks, ScriptEvent>(); TileSight = SightRange.Clear; CharSight = SightRange.Clear; TeamSpawns = new SpawnList <TeamSpawner>(); ItemSpawns = new CategorySpawnChooser <InvItem>(); Background = new MapBG(); BlankBG = new AutoTile(); MapEffect = new ActiveEffect(); CheckEvents = new List <SingleCharEvent>(); Status = new Dictionary <int, MapStatus>(); TextureMap = new Dictionary <int, AutoTile>(); CurrentTurnMap = new TurnState(); }
private void addToQueue(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue) { int id = zoneContext.CurrentID; IMonsterHouseBaseStep monsterHouseStep = HouseStepSpawns.Pick(context.Rand).CreateNew(); SpawnList <MapItem> itemListSlice = Items.GetSpawnList(id); for (int jj = 0; jj < itemListSlice.Count; jj++) { monsterHouseStep.Items.Add(new MapItem(itemListSlice.GetSpawn(jj)), itemListSlice.GetSpawnRate(jj)); } SpawnList <ItemTheme> itemThemeListSlice = ItemThemes.GetSpawnList(id); for (int jj = 0; jj < itemThemeListSlice.Count; jj++) { monsterHouseStep.ItemThemes.Add(itemThemeListSlice.GetSpawn(jj).Copy(), itemThemeListSlice.GetSpawnRate(jj)); } SpawnList <MobSpawn> mobListSlice = Mobs.GetSpawnList(id); for (int jj = 0; jj < mobListSlice.Count; jj++) { MobSpawn newSpawn = mobListSlice.GetSpawn(jj).Copy(); monsterHouseStep.Mobs.Add(newSpawn, mobListSlice.GetSpawnRate(jj)); } SpawnList <MobTheme> mobThemeListSlice = MobThemes.GetSpawnList(id); for (int jj = 0; jj < mobThemeListSlice.Count; jj++) { monsterHouseStep.MobThemes.Add(mobThemeListSlice.GetSpawn(jj).Copy(), mobThemeListSlice.GetSpawnRate(jj)); } queue.Enqueue(Priority, monsterHouseStep); }
public CombineGridRoomStep(int combineChance, List <BaseRoomFilter> filters) { CombineChance = combineChance; GiantRooms = new SpawnList <RoomGen <T> >(); RoomComponents = new ComponentCollection(); Filters = filters; }
protected override IEnumerable <int> GetSpecies(BaseMapGenContext map, SpawnList <MobSpawn> specialMobs) { foreach (int specie in Species) { yield return(specie); } }
protected MobSpawn GetSeedChar(BaseMapGenContext map, SpawnList <MobSpawn> specialMobs) { //the contents of that theme can be selected randomly, MobSpawn seedSpawn = null; //or, to add some sensibility, make it seeded from a random spawn that can already be found in the map if (map.TeamSpawns.CanPick) { TeamSpawner spawn = map.TeamSpawns.Pick(map.Rand); if (spawn != null) { List <MobSpawn> exampleList = spawn.ChooseSpawns(map.Rand); if (exampleList.Count > 0) { seedSpawn = exampleList[map.Rand.Next(exampleList.Count)]; } } } //choose the spawn, then seed the theme with it //the theme will take the aspects of the seedspawn and then be ready to spit out a list if (seedSpawn == null && specialMobs.CanPick) { seedSpawn = specialMobs.Pick(map.Rand); } return(seedSpawn); }
public void GetPossiblePlacementsNoneNoRoom(int w, int h) { // can't place anywhere, can't resort to middle Mock <IRoomGen> mockFrom = new Mock <IRoomGen>(MockBehavior.Strict); mockFrom.SetupGet(p => p.Draw).Returns(new Rect(3, 3, 4, 4)); Mock <IRoomGen> mockTo = new Mock <IRoomGen>(MockBehavior.Strict); mockTo.SetupGet(p => p.Draw).Returns(new Rect(0, 0, w, h)); var adjacentsByDir = new Dictionary <Dir4, List <IRoomGen> >(); foreach (Dir4 dir in DirExt.VALID_DIR4) { adjacentsByDir[dir] = new List <IRoomGen>(); } var mockRooms = new Mock <IRandPicker <RoomGen <IFloorPlanTestContext> > >(MockBehavior.Strict); var mockHalls = new Mock <IRandPicker <PermissiveRoomGen <IFloorPlanTestContext> > >(MockBehavior.Strict); var pathGen = new Mock <AddSpecialRoomTestStep>(mockRooms.Object, mockHalls.Object) { CallBase = true }; pathGen.Setup(p => p.GetAllBorderMatch(adjacentsByDir, mockTo.Object, mockFrom.Object, It.IsAny <Loc>())).Returns(0); SpawnList <Loc> spawns = pathGen.Object.GetPossiblePlacements(adjacentsByDir, mockTo.Object, mockFrom.Object); Assert.That(spawns.Count, Is.EqualTo(0)); }
private void Update() { if (!MyPlayer) { if (PlayerTeam >= 0 && _respawnDelay < 0.0f) { SpawnList list = TeamSpawns[PlayerTeam]; SpawnPoint selectedSpawn = list.Spawns[Random.Range(0, list.Spawns.Count)]; Vector3? spawnPos = selectedSpawn.GetSpawnLocation(); if (spawnPos.HasValue) { MyPlayer = PhotonNetwork.Instantiate( Path.Combine("PlayerPrefabs", "PlayerAvatar"), spawnPos.Value, Quaternion.identity, 0, new object[] { PlayerTeam, PlayerInfo.PI.mySelectedCharacter } ); } } else { _respawnDelay -= Time.deltaTime; // visual effects ChromaticAberration settings; GlobalPostProcessing.profile.TryGetSettings(out settings); settings.intensity.Override(Mathf.Max( 0.0f, settings.intensity.value - DeadEffectDecay * Time.deltaTime )); } } }
public AddLargeRoomStep() : base() { GiantRooms = new SpawnList <LargeRoom <T> >(); RoomComponents = new ComponentCollection(); Filters = new List <BaseRoomFilter>(); }
public void GetPossiblePlacementsNarrow() { // only vertical sliding allowed Mock <IRoomGen> mockFrom = new Mock <IRoomGen>(MockBehavior.Strict); mockFrom.SetupGet(p => p.Draw).Returns(new Rect(3, 3, 4, 4)); Mock <IRoomGen> mockTo = new Mock <IRoomGen>(MockBehavior.Strict); mockTo.SetupGet(p => p.Draw).Returns(new Rect(0, 0, 4, 2)); var adjacentsByDir = new Dictionary <Dir4, List <IRoomGen> >(); foreach (Dir4 dir in DirExt.VALID_DIR4) { adjacentsByDir[dir] = new List <IRoomGen>(); } var mockRooms = new Mock <IRandPicker <RoomGen <IFloorPlanTestContext> > >(MockBehavior.Strict); var mockHalls = new Mock <IRandPicker <PermissiveRoomGen <IFloorPlanTestContext> > >(MockBehavior.Strict); var pathGen = new Mock <AddSpecialRoomTestStep>(mockRooms.Object, mockHalls.Object) { CallBase = true }; pathGen.Setup(p => p.GetAllBorderMatch(adjacentsByDir, mockTo.Object, mockFrom.Object, It.IsAny <Loc>())).Returns(1); SpawnList <Loc> spawns = pathGen.Object.GetPossiblePlacements(adjacentsByDir, mockTo.Object, mockFrom.Object); Assert.That(spawns.Count, Is.EqualTo(3)); Assert.That(spawns.GetSpawn(0), Is.EqualTo(new Loc(3, 3))); Assert.That(spawns.GetSpawn(1), Is.EqualTo(new Loc(3, 5))); Assert.That(spawns.GetSpawn(2), Is.EqualTo(new Loc(3, 4))); }
public Map() { Name = new LocalText(); Comment = ""; Music = ""; TileSight = SightRange.Clear; CharSight = SightRange.Clear; TeamSpawns = new SpawnList <TeamSpawner>(); ItemSpawns = new SpawnList <InvItem>(); BlankBG = new AutoTile(); PrepareEvents = new List <SingleCharEvent>(); StartEvents = new List <SingleCharEvent>(); CheckEvents = new List <SingleCharEvent>(); Status = new Dictionary <int, MapStatus>(); FloorBG = new AutoTile(); TextureMap = new Dictionary <int, AutoTile>(); CurrentTurnMap = new TurnState(); }
protected PoolTeamSpawner(PoolTeamSpawner other) { NormalSpawns = new SpawnList <MobSpawn>(); for (int ii = 0; ii < other.NormalSpawns.Count; ii++) { NormalSpawns.Add(other.NormalSpawns.GetSpawn(ii).Copy(), other.NormalSpawns.GetSpawnRate(ii)); } LeaderSpawns = new SpawnList <MobSpawn>(); for (int ii = 0; ii < other.LeaderSpawns.Count; ii++) { LonerSpawns.Add(other.LeaderSpawns.GetSpawn(ii).Copy(), other.LeaderSpawns.GetSpawnRate(ii)); } LonerSpawns = new SpawnList <MobSpawn>(); for (int ii = 0; ii < other.LonerSpawns.Count; ii++) { LonerSpawns.Add(other.LonerSpawns.GetSpawn(ii).Copy(), other.LonerSpawns.GetSpawnRate(ii)); } SupportSpawns = new SpawnList <MobSpawn>(); for (int ii = 0; ii < other.SupportSpawns.Count; ii++) { SupportSpawns.Add(other.SupportSpawns.GetSpawn(ii).Copy(), other.SupportSpawns.GetSpawnRate(ii)); } TeamSizes = new SpawnList <int>(); for (int ii = 0; ii < other.TeamSizes.Count; ii++) { TeamSizes.Add(other.TeamSizes.GetSpawn(ii), other.TeamSizes.GetSpawnRate(ii)); } }
public BaseDetourStep() { Treasures = new BulkSpawner <T, MapItem>(); TileTreasures = new BulkSpawner <T, EffectTile>(); GuardTypes = new BulkSpawner <T, MobSpawn>(); GenericRooms = new SpawnList <RoomGen <T> >(); }
public void RandomRoomSpawnStep() { Mock <IPlaceableRoomTestContext> mockMap = new Mock <IPlaceableRoomTestContext>(MockBehavior.Strict); Mock <FloorPlan> mockFloor = new Mock <FloorPlan>(MockBehavior.Strict); mockFloor.SetupGet(p => p.RoomCount).Returns(3); mockFloor.Setup(p => p.GetRoom(0)).Returns(new TestFloorPlanGen('A')); mockFloor.Setup(p => p.GetRoom(1)).Returns(new TestFloorPlanGen('B')); mockFloor.Setup(p => p.GetRoom(2)).Returns(new TestFloorPlanGen('C')); mockMap.SetupGet(p => p.RoomPlan).Returns(mockFloor.Object); Mock <List <SpawnableChar> > mockSpawns = new Mock <List <SpawnableChar> >(MockBehavior.Strict); var roomSpawner = new Mock <RandomRoomSpawnStep <IPlaceableRoomTestContext, SpawnableChar> >(null, false) { CallBase = true }; SpawnList <RoomHallIndex> compare = new SpawnList <RoomHallIndex> { new RoomHallIndex(0, false), new RoomHallIndex(1, false), new RoomHallIndex(2, false), }; roomSpawner.Setup(p => p.SpawnRandInCandRooms(mockMap.Object, It.IsAny <SpawnList <RoomHallIndex> >(), mockSpawns.Object, 100)); roomSpawner.Object.DistributeSpawns(mockMap.Object, mockSpawns.Object); roomSpawner.Verify(p => p.SpawnRandInCandRooms(mockMap.Object, It.Is <SpawnList <RoomHallIndex> >(s => s.Equals(compare)), mockSpawns.Object, 100), Times.Exactly(1)); }
// Start is called before the first frame update void Start() { wavelist = new List <List <GameObject> >(); spawnlist = GameObject.FindGameObjectWithTag("Spawnlist"); listscript = spawnlist.GetComponent <SpawnList>(); wavelist.Add(listscript.wave1); wavelist.Add(listscript.wave2); wavelist.Add(listscript.wave3); wavelist.Add(listscript.wave4); wavelist.Add(listscript.wave5); wavelist.Add(listscript.wave6); wavelist.Add(listscript.wave7); wavelist.Add(listscript.wave8); wavelist.Add(listscript.wave9); wavelist.Add(listscript.wave10); wavelist.Add(listscript.wave11); wavelist.Add(listscript.wave12); wavelist.Add(listscript.wave13); wavelist.Add(listscript.wave14); wavelist.Add(listscript.wave15); wavelist.Add(listscript.wave16); wavelist.Add(listscript.wave17); wavelist.Add(listscript.wave18); wavelist.Add(listscript.wave19); wavelist.Add(listscript.wave20); }
public void DueSpawnStepStraightNoHall() { // order of rooms // A=>0=>B Mock <IViewPlaceableRoomTestContext> mockMap = new Mock <IViewPlaceableRoomTestContext>(MockBehavior.Strict); Mock <FloorPlan> mockFloor = new Mock <FloorPlan>(MockBehavior.Strict); mockFloor.SetupGet(p => p.RoomCount).Returns(2); Mock <TestFloorPlanGen> startRoom = new Mock <TestFloorPlanGen>(MockBehavior.Strict); startRoom.SetupProperty(p => p.Draw); startRoom.SetupGet(p => p.Draw).Returns(new Rect(2, 2, 4, 4)); startRoom.Object.Identifier = 'A'; mockFloor.Setup(p => p.GetRoomPlan(0)).Returns(new FloorRoomPlan(startRoom.Object, new ComponentCollection())); mockFloor.Setup(p => p.GetRoomPlan(1)).Returns(new FloorRoomPlan(new TestFloorPlanGen('B'), new ComponentCollection())); mockFloor.Setup(p => p.GetRoomHall(new RoomHallIndex(0, false))).Returns(new FloorRoomPlan(startRoom.Object, new ComponentCollection())); mockFloor.Setup(p => p.GetRoomHall(new RoomHallIndex(0, true))).Returns(new FloorHallPlan(new TestFloorPlanGen('0'), new ComponentCollection())); mockFloor.Setup(p => p.GetRoomHall(new RoomHallIndex(1, false))).Returns(new FloorRoomPlan(new TestFloorPlanGen('B'), new ComponentCollection())); mockMap.SetupGet(p => p.RoomPlan).Returns(mockFloor.Object); List <RoomHallIndex> adjacents = new List <RoomHallIndex> { new RoomHallIndex(0, true) }; mockFloor.Setup(p => p.GetAdjacents(new RoomHallIndex(0, false))).Returns(adjacents); adjacents = new List <RoomHallIndex> { new RoomHallIndex(0, false), new RoomHallIndex(1, false) }; mockFloor.Setup(p => p.GetAdjacents(new RoomHallIndex(0, true))).Returns(adjacents); adjacents = new List <RoomHallIndex> { new RoomHallIndex(0, true) }; mockFloor.Setup(p => p.GetAdjacents(new RoomHallIndex(1, false))).Returns(adjacents); mockMap.SetupGet(p => p.RoomPlan).Returns(mockFloor.Object); mockMap.Setup(p => p.GetLoc(0)).Returns(new Loc(3, 3)); Mock <List <SpawnableChar> > mockSpawns = new Mock <List <SpawnableChar> >(MockBehavior.Strict); var roomSpawner = new Mock <DueSpawnStep <IViewPlaceableRoomTestContext, SpawnableChar, TestEntryPoint> >(null, 100, false) { CallBase = true }; const int maxVal = 3; const int rooms = 3; SpawnList <RoomHallIndex> compare = new SpawnList <RoomHallIndex> { { new RoomHallIndex(0, false), int.MaxValue / maxVal / rooms * 1 }, { new RoomHallIndex(1, false), int.MaxValue / maxVal / rooms * 3 }, }; roomSpawner.Setup(p => p.SpawnRandInCandRooms(mockMap.Object, It.IsAny <SpawnList <RoomHallIndex> >(), mockSpawns.Object, 100)); roomSpawner.Object.DistributeSpawns(mockMap.Object, mockSpawns.Object); roomSpawner.Verify(p => p.SpawnRandInCandRooms(mockMap.Object, It.Is <SpawnList <RoomHallIndex> >(s => s.Equals(compare)), mockSpawns.Object, 100), Times.Exactly(1)); }
protected override void PrepareZoneSpawnScript(Triggers triggers, SpawnList spawnList) { triggers // trigger on world init .Add(GetTrigger <TriggerWorldInit>()) // trigger on time interval // (please note when changing this value to adjust the destruction timeout in ObjectMineralPragmiumNode) .Add(GetTrigger <TriggerTimeInterval>().Configure(TimeSpan.FromMinutes(30))); spawnList.CreatePreset(interval: 10, padding: 2, useSectorDensity: false) .Add <ObjectMineralPragmiumNode>(); // mob spawn var presetLizard = spawnList.CreatePreset(interval: 22, padding: 0.5, useSectorDensity: false) .Add <MobFireLizard>() .SetCustomPaddingWithSelf(12); var presetScorpion = spawnList.CreatePreset(interval: 26, padding: 0.5, useSectorDensity: false) .Add <MobScorpion>() .SetCustomPaddingWithSelf(15); var presetBeetle = spawnList.CreatePreset(interval: 15, padding: 0.5, useSectorDensity: false) .Add <MobPragmiumBeetle>() .SetCustomPaddingWithSelf(5); // define custom spawn padding between different mobs presetLizard.SetCustomPaddingWith(presetScorpion, 5); presetLizard.SetCustomPaddingWith(presetBeetle, 5); presetBeetle.SetCustomPaddingWith(presetScorpion, 5); }
internal void Spawn(Gate gate) { SpawnList spawnList = SpawnLists[gate.SpawnListIndex]; List <ObjectType> objectsToSpawn = spawnList.Spawn(gate); StartCoroutine(SpawnObjectList(gate, objectsToSpawn)); }
public RoomGenWaterRing(ITile waterTerrain, RandRange padWidth, RandRange padHeight, int itemAmount) { WaterTerrain = waterTerrain; PadWidth = padWidth; PadHeight = padHeight; ItemAmount = itemAmount; Treasures = new SpawnList <MapItem>(); }
public PoolTeamSpawner() { NormalSpawns = new SpawnList <MobSpawn>(); LeaderSpawns = new SpawnList <MobSpawn>(); LonerSpawns = new SpawnList <MobSpawn>(); SupportSpawns = new SpawnList <MobSpawn>(); TeamSizes = new SpawnList <int>(); }
public void DueSpawnStepMiddleABC() { // order of rooms // A<=B=>C Mock <IViewPlaceableRoomTestContext> mockMap = new Mock <IViewPlaceableRoomTestContext>(MockBehavior.Strict); Mock <FloorPlan> mockFloor = new Mock <FloorPlan>(MockBehavior.Strict); mockFloor.SetupGet(p => p.RoomCount).Returns(3); mockFloor.Setup(p => p.GetRoom(0)).Returns(new TestFloorPlanGen('A')); Mock <TestFloorPlanGen> startRoom = new Mock <TestFloorPlanGen>(MockBehavior.Strict); startRoom.SetupProperty(p => p.Draw); startRoom.SetupGet(p => p.Draw).Returns(new Rect(2, 2, 4, 4)); startRoom.Object.Identifier = 'B'; mockFloor.Setup(p => p.GetRoom(1)).Returns(startRoom.Object); mockFloor.Setup(p => p.GetRoom(2)).Returns(new TestFloorPlanGen('C')); mockMap.SetupGet(p => p.RoomPlan).Returns(mockFloor.Object); List <int> adjacents = new List <int> { 1 }; mockFloor.Setup(p => p.GetAdjacentRooms(0)).Returns(adjacents); adjacents = new List <int> { 0, 2 }; mockFloor.Setup(p => p.GetAdjacentRooms(1)).Returns(adjacents); adjacents = new List <int> { 1 }; mockFloor.Setup(p => p.GetAdjacentRooms(2)).Returns(adjacents); mockMap.SetupGet(p => p.RoomPlan).Returns(mockFloor.Object); mockMap.Setup(p => p.GetLoc(0)).Returns(new Loc(3, 3)); Mock <List <SpawnableChar> > mockSpawns = new Mock <List <SpawnableChar> >(MockBehavior.Strict); var roomSpawner = new Mock <DueSpawnStep <IViewPlaceableRoomTestContext, SpawnableChar, TestEntryPoint> >(null, 100) { CallBase = true }; const int maxVal = 2; const int rooms = 3; SpawnList <RoomHallIndex> compare = new SpawnList <RoomHallIndex> { { new RoomHallIndex(0, false), int.MaxValue / maxVal / rooms * 2 }, { new RoomHallIndex(1, false), int.MaxValue / maxVal / rooms * 1 }, { new RoomHallIndex(2, false), int.MaxValue / maxVal / rooms * 2 }, }; roomSpawner.Setup(p => p.SpawnRandInCandRooms(mockMap.Object, It.IsAny <SpawnList <RoomHallIndex> >(), mockSpawns.Object, 100)); roomSpawner.Object.DistributeSpawns(mockMap.Object, mockSpawns.Object); roomSpawner.Verify(p => p.SpawnRandInCandRooms(mockMap.Object, It.Is <SpawnList <RoomHallIndex> >(s => s.Equals(compare)), mockSpawns.Object, 100), Times.Exactly(1)); }
public void DeSpawn <T>(T tween) where T : Tweener { if (!SpawnList.Contains(tween)) { return; } SpawnList.Remove(tween); DeSpawnList.Add(tween); }
public void Generate() { Dungeon dungeon = new Dungeon (); dungeon.min_size = minRoomSize; dungeon.max_size = maxRoomSize; dungeon.minimumRoomCount = minimumRoomCount; dungeon.maximumRoomCount = maximumRoomCount; dungeon.roomMargin = roomMargin; dungeon.prune = pruneCollidingRooms; dungeon.Generate (); for (var y = 0; y < Dungeon.map_size; y++) { for (var x = 0; x < Dungeon.map_size; x++) { int tile = Dungeon.map [x, y].type; GameObject created_tile; Vector3 tile_location; tile_location = new Vector3 (x * tileScaling, y * tileScaling, 0); created_tile = null; if (tile == 1) { created_tile = GameObject.Instantiate (floorPrefab, tile_location, Quaternion.identity) as GameObject; } if (tile == 2) { created_tile = GameObject.Instantiate (wallPrefab, tile_location, Quaternion.identity) as GameObject; } if (tile == 3) { created_tile = GameObject.Instantiate (floorPrefab, tile_location, Quaternion.identity) as GameObject; } if (Dungeon.corners.Contains(tile)) { if(cornerPrefab){ created_tile = GameObject.Instantiate (cornerPrefab, tile_location, Quaternion.identity) as GameObject; if(cornerRotation) { created_tile.transform.Rotate(Vector3.forward * (-90 * (tile -4))); } } else { created_tile = GameObject.Instantiate (wallPrefab, tile_location, Quaternion.identity) as GameObject; } } if (created_tile) { created_tile.transform.parent = transform; } } } GameObject end_point = GameObject.Instantiate (exitPrefab, new Vector3 (Dungeon.goalRoom.x * tileScaling, Dungeon.goalRoom.y * tileScaling, 0), Quaternion.identity) as GameObject; GameObject start_point = GameObject.Instantiate (startPrefab, new Vector3 (Dungeon.startRoom.x * tileScaling, Dungeon.startRoom.y * tileScaling, 0), Quaternion.identity) as GameObject; end_point.transform.parent = transform; start_point.transform.parent = transform; //Spawn Objects; List<SpawnList> spawnedObjectLocations = new List<SpawnList> (); //OTHERS for (int x = 0; x < Dungeon.map_size; x++) { for (int y = 0; y < Dungeon.map_size; y++) { if (Dungeon.map [x, y].type == 1 && ((Dungeon.startRoom != Dungeon.map [x, y].room && Dungeon.goalRoom != Dungeon.map [x, y].room) || maximumRoomCount <= 3)) { var location = new SpawnList (); location.x = x; location.y = y; if (Dungeon.map [x + 1, y].type == 2 || Dungeon.map [x - 1, y].type == 2 || Dungeon.map [x, y + 1].type == 2 || Dungeon.map [x, y - 1].type == 2) { location.byWall = true; } if (Dungeon.map [x + 1, y].type == 3 || Dungeon.map [x - 1, y].type == 3 || Dungeon.map [x, y + 1].type == 3 || Dungeon.map [x, y - 1].type == 3) { location.byCorridor = true; } if (Dungeon.map [x + 1, y + 1].type == 3 || Dungeon.map [x - 1, y - 1].type == 3 || Dungeon.map [x - 1, y + 1].type == 3 || Dungeon.map [x + 1, y - 1].type == 3) { location.byCorridor = true; } spawnedObjectLocations.Add (location); } else if (Dungeon.map[x, y].type == 3) { var location = new SpawnList (); location.x = x; location.y = y; if ( (Dungeon.map [x + 1, y].type == 1 || Dungeon.map [x - 1, y].type == 1 || Dungeon.map [x, y + 1].type == 1 || Dungeon.map [x, y - 1].type == 1) && ( (Dungeon.map [x + 1, y].type == 2 && Dungeon.map [x - 1, y].type == 2) || (Dungeon.map [x, y + 1].type == 2 && Dungeon.map [x, y - 1].type == 2) ) ) { location.byCorridor = true; location.asDoor = true; spawnedObjectLocations.Add (location); } } } } for (int i = 0; i < spawnedObjectLocations.Count; i++) { SpawnList temp = spawnedObjectLocations [i]; int randomIndex = Random.Range (i, spawnedObjectLocations.Count); spawnedObjectLocations [i] = spawnedObjectLocations [randomIndex]; spawnedObjectLocations [randomIndex] = temp; } int objectCountToSpawn = 0; //DOORS if (doorPrefab) { for (int i = 0; i < spawnedObjectLocations.Count; i++) { if (spawnedObjectLocations[i].asDoor){ GameObject newObject; SpawnList spawnLocation = spawnedObjectLocations[i]; newObject = GameObject.Instantiate(doorPrefab,new Vector3(spawnLocation.x * tileScaling ,spawnLocation.y * tileScaling,0),Quaternion.identity) as GameObject; newObject.transform.parent = transform; spawnedObjectLocations[i].spawnedObject = newObject; } } } //OTHERS foreach (SpawnOption objectToSpawn in spawnOptions){ objectCountToSpawn = Random.Range(objectToSpawn.minSpawnCount,objectToSpawn.maxSpawnCount); while (objectCountToSpawn > 0){ for (int i = 0; i < spawnedObjectLocations.Count; i++){ bool createHere= false; if (!spawnedObjectLocations[i].spawnedObject && !spawnedObjectLocations[i].byCorridor){ if ( objectToSpawn.spawnByWall && spawnedObjectLocations[i].byWall ) { createHere = true; } else { createHere = true; } } if (createHere){ SpawnList spawnLocation = spawnedObjectLocations[i]; GameObject newObject; newObject = GameObject.Instantiate(objectToSpawn.gameObject,new Vector3(spawnLocation.x * tileScaling ,spawnLocation.y * tileScaling,0),Quaternion.identity) as GameObject; newObject.transform.parent = transform; spawnedObjectLocations[i].spawnedObject = newObject; objectCountToSpawn--; break; } } //THIS DOESN'T WORK FIX THIS DON'T FORGET /* * * 8=D SO HAPPY * * PHIL * */ } } }