public Item(string NameOfItem, string DescriptionOfItem, int ItemID, int SlotsAmount, float WeightOfItem, ItemOfType TypeOfItem, ItemSpawnPoint SpawnPointOfItem, ItemRarity RarityOfItem, GameObject DragDropPrefabOfItem, GameObject PickupPrefabOfItem, Vector2 CellSizeOfItem, Vector2 DragOffsetOfItem) { itemName = NameOfItem; itemDesc = DescriptionOfItem; itemID = ItemID; amountOfSlots = SlotsAmount; itemWeight = WeightOfItem; itemType = TypeOfItem; itemSpawnPoint = SpawnPointOfItem; itemRarity = RarityOfItem; itemDragDropPrefab = DragDropPrefabOfItem; itemPickupPrefab = PickupPrefabOfItem; cellSize = CellSizeOfItem; dragOffset = DragOffsetOfItem; }
ItemSpawnPoint SelectRandomSpawnPoint(Floor floor) { // If the room has an available spawn point: if (CheckForAvailableSpawnPoint(floor)) { // Select a random spawn point from the list of available spawns: ItemSpawnPoint randomSpawnPoint = floor.itemSpawnPoints[Random.Range(0, floor.itemSpawnPoints.Count)]; // Return that random spawn point: return(randomSpawnPoint); } // Else if the room has no available spawn points: else { // Do nothing. The PlaceAllObjectives() while loop will continue running until it finds a room with an available spawn point. return(null); } }
private ItemSpawnPoint m_ItemSpawnPosition; //The location in the room at which objects are spawned from private void Awake() { //initalize private lists m_PlayersInRoom = new List <Player>(); m_EnemiesInRoom = new List <AI>(); //"error checking", making sure that the lists of values actually have there appropriate values within them. This is for spawn points and portals EnemySpawnPoint[] spawnPoints = GetComponentsInChildren <EnemySpawnPoint>(); foreach (EnemySpawnPoint point in spawnPoints) { if (!RoomSpawnPoints.Contains(point)) { RoomSpawnPoints.Add(point); } } m_ItemSpawnPosition = GetComponentInChildren <ItemSpawnPoint>(); Portal[] portals = GetComponentsInChildren <Portal>(); foreach (Portal portal in portals) { if (!PortalsInRoom.Contains(portal)) { PortalsInRoom.Add(portal); } } //next we must change all of the spawn points in this room to know that they're in this room foreach (EnemySpawnPoint point in RoomSpawnPoints) { point.SpawnPointRoom = this; } //finally we do the same thing but with the portals, this way they know what room they're in foreach (Portal portal in PortalsInRoom) { portal.Room = this; } //double check if the useable count isn't greater then the portals in room count if (UsablePortals > PortalsInRoom.Count) { UsablePortals = PortalsInRoom.Count; } }
// Spawn the items which only appear in the locked storerooms: public void SpawnStoreroomItems() { storeroomSpawnPoints = lvlGen.storeroomSpawnPoints; ItemSpawnPoint randomSpawnPoint = storeroomSpawnPoints[Random.Range(0, storeroomSpawnPoints.Count)]; if (randomSpawnPoint != null) { Item powerCoil = rareItemList[Random.Range(0, rareItemList.Count)]; Instantiate(powerCoil, randomSpawnPoint.transform.position, randomSpawnPoint.transform.rotation, randomSpawnPoint.transform); storeroomSpawnPoints.Remove(randomSpawnPoint); } else { Debug.Log("Couldn't find a storeroom spawn point :("); } }
public void PlaceObjectives() { // While there are still objective items to spawn: while (objectiveItemList.Count > 0) { // Select a random spawn point on a random floor: Floor randomFloor = SelectRandomFloor(); ItemSpawnPoint randomSpawnPoint = SelectRandomSpawnPoint(randomFloor); if (randomSpawnPoint != null) { // Spawn the item: ObjectiveItem currentItem = objectiveItemList[Random.Range(0, objectiveItemList.Count)]; Instantiate(currentItem, randomSpawnPoint.transform.position, randomSpawnPoint.transform.rotation, randomSpawnPoint.transform); randomFloor.itemSpawnPoints.Remove(randomSpawnPoint); objectiveItemList.Remove(currentItem); spawnedObjectives.Add(currentItem); } else if (randomSpawnPoint == null) { // Do nothing. The while loop will continue running until it finds an available spawn point. Debug.Log("Floor has no available spawn points. Trying another floor."); } } // Spawn a single keycard somewhere in the level for access to locked rooms: Floor randomFloor2 = SelectRandomFloor(); ItemSpawnPoint randomSpawnPoint2 = SelectRandomSpawnPoint(randomFloor2); Keycard keycard = keycardPrefab; Instantiate(keycardPrefab, randomSpawnPoint2.transform.position, randomSpawnPoint2.transform.rotation, randomSpawnPoint2.transform); randomFloor2.itemSpawnPoints.Remove(randomSpawnPoint2); spawnedKeycards.Add(keycard); }
// Use this for initialization void Start() { Circlefield = GameObject.Find("CircleField"); itemSpawnPoint = GetComponent <ItemSpawnPoint>(); //LoadCirclefieldInfo(); //初始化网络事件 NetworkManager.AddEventListener("GetMapItemData", OnGetMapItemDataBack); NetworkManager.AddEventListener("Circlefield", OnCirclefieldBack); NetworkManager.AddEventListener("CirclefieldTime", OnCirclefieldTimeBack); NetworkManager.AddEventListener("DoorOpen", OnDoorOpen); NetworkManager.AddEventListener("AllPlayerLoaded", OnAllPlayerLoaded); NetworkManager.AddEventListener("PickItem", OnPickItem); NetworkManager.AddEventListener("DropItem", OnDropItem); //门加入字典 for (int i = 0; i < itemSpawnPoint.DoorSpawnPoints.Length; i++) { itemSpawnPoint.DoorSpawnPoints[i].GetComponent <DoorControl>().DoorID = i; Doors.Add(i, itemSpawnPoint.DoorSpawnPoints[i]); } ProbabilityValue = ItemInfoManager.Instance.GetTotalOccurrenceProbability(); ItemsID = ItemInfoManager.Instance.GetAllItemsID(); }
internal static void UnRegisterStartPosition(ItemSpawnPoint spawnpoint) { ItemManager.ItemSpawnPoints.Remove(spawnpoint); }
internal static void RegisterStartPosition(ItemSpawnPoint spawnpoint) { ItemManager.ItemSpawnPoints.Add(spawnpoint); }