private RoomData ConvertRoomToData(GameObject room) { RoomData roomData = new RoomData(); var position = room.transform.position; roomData.x = (int)position.x; roomData.y = (int)position.y; ObjectScript os = room.GetComponent <ObjectScript>(); roomData.rotation = os.rotAdjust; roomData.isPrePlaced = os.preplacedRoom; roomData.objectNum = os.objectNum; RoomStats roomStats = room.GetComponent <RoomStats>(); roomData.crew = roomStats.currentCrew; roomData.usedRoom = roomStats.usedRoom; roomData.roomLevel = roomStats.GetRoomLevel(); roomData.resourceActiveAmounts = new int[roomStats.resources.Count]; for (var i = 0; i < roomStats.resources.Count; i++) { roomData.resourceActiveAmounts[i] = roomStats.resources[i].activeAmount; } return(roomData); }
private void TrackRoomMetricsOnDelete(RoomStats roomStats) { _gameMetrics.TrackRoomDestroyed(); if (roomStats != null) { _gameMetrics.TrackMaxSendQueueSize(roomStats.GetMaxQueueSize()); _gameMetrics.TrackAvgSendQueueSize((int)(roomStats.GetAvgQueueSize() * 100)); _gameMetrics.TrackRoomTotalTrafficSent(roomStats.TotalTrafficSent); _gameMetrics.TrackRoomTotalTrafficReceived(roomStats.TotalTrafficReceived); _gameMetrics.TrackTotalRoomLiveTime(roomStats.TotalLiveTimeSec); var messageStatistics = roomStats.BuildMessageStatistics(); _gameMetrics.TrackRoomTotalMessagesReceived(messageStatistics.Received.Sum(m => m.Item3)); _gameMetrics.TrackRoomTotalMessagesSent(messageStatistics.Sent.Sum(m => m.Item3)); foreach (var item in messageStatistics.Received) { _gameMetrics.TrackRoomTotalMessagesReceived(item.Item3, item.Item1.ToString()); } foreach (var item in messageStatistics.Sent) { _gameMetrics.TrackRoomTotalMessagesSent(item.Item3, item.Item1.ToString()); } } }
public void SetRoomInfo(RoomStats roomStats) { roomNameUI.text = roomStats.roomName; roomDescUI.text = roomStats.roomDescription; roomPrice.text = roomStats.price.ToString(); if (roomStats.maxPower <= 0) { roomPower.transform.parent.gameObject.SetActive(false); } else { roomPower.text = $"{roomStats.minPower}-{roomStats.maxPower}"; } if (roomStats.maxCrew <= 0) { roomCrew.transform.parent.gameObject.SetActive(false); } else { roomCrew.text = $"{roomStats.minCrew}-{roomStats.maxCrew}"; } foreach (var resource in roomStats.GetComponents <Resource>()) { GameObject resourceGO = Instantiate(resourceUI, statsUI); resourceGO.transform.GetChild(0).GetComponent <Image>().sprite = resource.resourceType.resourceIcon; // resource icon resourceGO.transform.GetChild(1).GetComponent <TMP_Text>().text = resource.resourceType.resourceName; // resource name resourceGO.transform.GetChild(2).GetComponent <TMP_Text>().text = resource.amount.ToString(); // resource amount } }
public void ChangeCurrentRoom(GameObject room) { if (selectedRoom != null) { selectedRoom.GetComponent <RoomHighlight>().Unhighlight(); } selectedRoom = room; roomStats = room.GetComponent <RoomStats>(); overclockRoom = room.GetComponent <OverclockRoom>(); shipStats.roomBeingPlaced = selectedRoom; roomDetailsTab.SetInteractableState(true); if (FindObjectOfType <RoomPanelToggle>().GetIsOpen()) { room.GetComponent <RoomHighlight>().Highlight(); } else { room.GetComponent <RoomHighlight>().Unhighlight(); } UpdatePanelInfo(); if (!tutorialAlreadyPlayed) { Tutorial.Instance.SetCurrentTutorial(2, true); tutorialAlreadyPlayed = true; } }
/// <summary> /// TODO: Refactor into single method /// This caps room ends after the base map has been created. I think this can get refactored into the method above /// </summary> /// <param name="prefabList"></param> private void CapRoomEnds(GameObject[] prefabList) { Vector3 spawnVector; GameObject roomToConnectTo; for (int i = 0; i < connectionKeys.Count; i++) { spawnVector = connectionKeys[i]; roomToConnectTo = connectionPoints[spawnVector]; RoomStats roomToConStats = roomToConnectTo.GetComponent <RoomStats>(); Vector3 roomToConNORTH = new Vector3(roomToConnectTo.transform.position.x, roomToConnectTo.transform.position.y + (roomToConStats.connectionOffset + 2), roomToConnectTo.transform.position.z); Vector3 roomToConEAST = new Vector3(roomToConnectTo.transform.position.x + (roomToConStats.connectionOffset * 2), roomToConnectTo.transform.position.y, roomToConnectTo.transform.position.z); Vector3 roomToConSOUTH = new Vector3(roomToConnectTo.transform.position.x, roomToConnectTo.transform.position.y + (-roomToConStats.connectionOffset * 2), roomToConnectTo.transform.position.z); Vector3 roomToConWEST = new Vector3(roomToConnectTo.transform.position.x + (-roomToConStats.connectionOffset * 2), roomToConnectTo.transform.position.y, roomToConnectTo.transform.position.z); foreach (var prefab in prefabList) { GameObject roomPrefab = GameObject.Instantiate(prefab, new Vector3(-100, -100, 0), Quaternion.identity); RoomStats prefabStats = roomPrefab.GetComponent <RoomStats>(); if (!CheckOverlap(spawnVector, roomPrefab)) { if (!roomToConStats.isConnNorth && spawnVector == roomToConNORTH) { spawnVector = new Vector3(roomToConnectTo.transform.position.x, roomToConnectTo.transform.position.y + (roomToConStats.connectionOffset + prefabStats.connectionOffset), 0); PlaceRoom(roomPrefab, spawnVector, -90f); FlagRoomConnections(prefabStats, 0, roomToConStats); } if (!roomToConStats.isConnEast && spawnVector == roomToConEAST) { spawnVector = new Vector3(roomToConnectTo.transform.position.x + (roomToConStats.connectionOffset + prefabStats.connectionOffset), roomToConnectTo.transform.position.y, 0); PlaceRoom(roomPrefab, spawnVector, 180f); FlagRoomConnections(prefabStats, 1, roomToConStats); } if (!roomToConStats.isConnSouth && spawnVector == roomToConSOUTH) { spawnVector = new Vector3(roomToConnectTo.transform.position.x, roomToConnectTo.transform.position.y + -(roomToConStats.connectionOffset + prefabStats.connectionOffset), 0); PlaceRoom(roomPrefab, spawnVector, 90f); FlagRoomConnections(prefabStats, 2, roomToConStats); } if (!roomToConStats.isConnWest && spawnVector == roomToConWEST) { spawnVector = new Vector3(roomToConnectTo.transform.position.x + -(roomToConStats.connectionOffset + prefabStats.connectionOffset), roomToConnectTo.transform.position.y, 0); PlaceRoom(roomPrefab, spawnVector, 0f); FlagRoomConnections(prefabStats, 3, roomToConStats); } } if (roomPrefab.transform.position == new Vector3(-100, -100, 0)) { Destroy(roomPrefab); } } } }
//Adds connection points to our connection array and dictionary private void AddConnectionPoints() { GameObject[] roomObjs = GameObject.FindGameObjectsWithTag("Room"); GameObject[] hallObjs = GameObject.FindGameObjectsWithTag("Hall"); var allObjects = roomObjs.Union(hallObjs).ToArray(); Dictionary <Vector3, GameObject> newPoints = new Dictionary <Vector3, GameObject>(); List <Vector3> newKeys = new List <Vector3>(); foreach (var room in allObjects) { if (room.transform.position == new Vector3(-100, -100, 0)) { Destroy(room); continue; } RoomStats roomInfo = room.GetComponent <RoomStats>(); if (roomInfo.isConnNorth == false) { Vector3 cp = new Vector3(room.transform.position.x, room.transform.position.y + (roomInfo.connectionOffset * 2), room.transform.position.z); if (!newPoints.ContainsKey(cp)) { newKeys.Add(cp); newPoints.Add(cp, room); } } if (roomInfo.isConnEast == false) { Vector3 cp = new Vector3(room.transform.position.x + (roomInfo.connectionOffset * 2), room.transform.position.y, room.transform.position.z); if (!newPoints.ContainsKey(cp)) { newPoints.Add(cp, room); newKeys.Add(cp); } } if (roomInfo.isConnSouth == false) { Vector3 cp = new Vector3(room.transform.position.x, room.transform.position.y + (-roomInfo.connectionOffset * 2), room.transform.position.z); if (!newPoints.ContainsKey(cp)) { newPoints.Add(cp, room); newKeys.Add(cp); } } if (roomInfo.isConnWest == false) { Vector3 cp = new Vector3(room.transform.position.x + (-roomInfo.connectionOffset * 2), room.transform.position.y, room.transform.position.z); if (!newPoints.ContainsKey(cp)) { newPoints.Add(cp, room); newKeys.Add(cp); } } } connectionKeys = newKeys; connectionPoints = newPoints; }
void Start() { roomStat = Resources.FindObjectsOfTypeAll <RoomStats>()[0]; roomStat.finishGeneration = false; templates = GameObject.FindGameObjectWithTag("Rooms").GetComponent <RoomTemplates>(); Invoke("Spawn", 0.2f); }
/*@Input * RoomStats _room -> the RoomStats object which has been selected to be added * ---- * @Output * int -> the index of the instance that has just been created * ---- * //UPDATE * @Method: Create a new instance of a room to gather stats of how the player has performed */ public int createInstance(RoomStats _room) { if (!allStatistics.ContainsKey(_room.roomID)) { allStatistics.Add(_room.roomID, new Dictionary <int, List <RoomStats> >()); } createModInstance(_room); return(allStatistics [_room.roomID].Count - 1); }
// FOR LEVEL2 private void noMiniMapSwap(GameObject nextLevel, string doorSide) { RoomStats next = nextLevel.GetComponent <RoomStats>(); // Move camera next.setCamLocation(); // Move Hero mHero.transform.position = next.sendPlayerToDoor(doorSide); }
public RoomStats(RoomStats _room) { roomID = _room.roomID; startTime = _room.startTime; endTime = _room.endTime; complete = _room.isComplete(); timeToKillFirstEnemy = _room.timeToKillFirstEnemy; damageTakenInRoom = _room.damageTakenInRoom; }
private IEnumerator UpdateRoomStat(RoomStats roomStats, RoomData roomData) { yield return(new WaitUntil((() => roomStats.GetComponent <Resource>()))); for (var i = 0; i < roomStats.resources.Count; i++) { Resource resource = roomStats.resources[i]; roomStats.SetStatOnLoad(resource, roomData.resourceActiveAmounts[i]); } }
/// <summary> /// Increases count for passed room if first time placed. Otherwise, adds entry for new room. /// </summary> /// <param name="room">The room being added.</param> public static void AddRoomForAnalytics(RoomStats room) { if (shipRooms.ContainsKey(room.roomName)) { shipRooms[room.roomName]++; } else { shipRooms.Add(room.roomName, 1); } }
/// <summary> /// Evaluates available connections on game objects and flags them as connected /// </summary> /// <param name="roomPrefab"></param> /// <param name="tarDir"></param> /// <param name="roomToConnectTo"></param> private void FlagRoomConnections(RoomStats roomPrefab, int tarDir, RoomStats roomToConnectTo) { switch (tarDir) { case 0: //north if (roomPrefab.type == RoomStats.Type.corridor) { roomPrefab.isConnEast = true; roomToConnectTo.isConnEast = true; roomPrefab.isConnWest = true; roomToConnectTo.isConnWest = true; } roomPrefab.isConnSouth = true; roomToConnectTo.isConnNorth = true; break; case 1: //east if (roomPrefab.type == RoomStats.Type.corridor) { roomPrefab.isConnNorth = true; roomToConnectTo.isConnNorth = true; roomPrefab.isConnSouth = true; roomToConnectTo.isConnSouth = true; } roomPrefab.isConnWest = true; roomToConnectTo.isConnEast = true; break; case 2: //south if (roomPrefab.type == RoomStats.Type.corridor) { roomPrefab.isConnEast = true; roomToConnectTo.isConnEast = true; roomPrefab.isConnWest = true; roomToConnectTo.isConnWest = true; } roomPrefab.isConnNorth = true; roomToConnectTo.isConnSouth = true; break; case 3: //west if (roomPrefab.type == RoomStats.Type.corridor) { roomPrefab.isConnNorth = true; roomToConnectTo.isConnNorth = true; roomPrefab.isConnSouth = true; roomToConnectTo.isConnSouth = true; } roomPrefab.isConnEast = true; roomToConnectTo.isConnWest = true; break; } }
//Transfers all data from currentFloor into allStatistics public void storeFloorData() { for (int i = 0; i < currentFloor.Length; i++) { RoomStats _room = currentFloor [i]; //Checks if the room has been complete if (_room != null) { //Add this room to allStatistics createInstance(_room); } } }
/// <summary> /// Main creation function, this takes a prefab list and spawns the object /// It does so by grabbing an available connection location from the dictionary /// Then evaluating a position that qualifies for placement /// </summary> /// <param name="prefabList"></param> private void SpawnPrefab(GameObject[] prefabList) { Vector3 spawnVector = connectionKeys[Random.Range(0, connectionKeys.Count - 1)]; GameObject roomToConnectTo = connectionPoints[spawnVector]; RoomStats roomToConStats = roomToConnectTo.GetComponent <RoomStats>(); GameObject roomPrefab = GameObject.Instantiate(prefabList[Random.Range(0, prefabList.Length)], new Vector3(-100, -100, 0), Quaternion.identity); RoomStats prefabStats = roomPrefab.GetComponent <RoomStats>(); Vector3 roomToConNORTH = new Vector3(roomToConnectTo.transform.position.x, roomToConnectTo.transform.position.y + (roomToConStats.connectionOffset * 2), roomToConnectTo.transform.position.z); Vector3 roomToConEAST = new Vector3(roomToConnectTo.transform.position.x + (roomToConStats.connectionOffset * 2), roomToConnectTo.transform.position.y, roomToConnectTo.transform.position.z); Vector3 roomToConSOUTH = new Vector3(roomToConnectTo.transform.position.x, roomToConnectTo.transform.position.y + (-roomToConStats.connectionOffset * 2), roomToConnectTo.transform.position.z); Vector3 roomToConWEST = new Vector3(roomToConnectTo.transform.position.x + (-roomToConStats.connectionOffset * 2), roomToConnectTo.transform.position.y, roomToConnectTo.transform.position.z); //Evaluating placement if (!CheckOverlap(spawnVector, roomPrefab)) { if (!roomToConStats.isConnNorth && spawnVector == roomToConNORTH) { roomToConNORTH = new Vector3(roomToConnectTo.transform.position.x, roomToConnectTo.transform.position.y + (roomToConStats.connectionOffset + prefabStats.connectionOffset), 0); PlaceRoom(roomPrefab, roomToConNORTH, 90f); FlagRoomConnections(prefabStats, 0, roomToConStats); return; } if (!roomToConStats.isConnEast && spawnVector == roomToConEAST) { roomToConEAST = new Vector3(roomToConnectTo.transform.position.x + (roomToConStats.connectionOffset + prefabStats.connectionOffset), roomToConnectTo.transform.position.y, 0); PlaceRoom(roomPrefab, roomToConEAST, 0f); FlagRoomConnections(prefabStats, 1, roomToConStats); return; } if (!roomToConStats.isConnSouth && spawnVector == roomToConSOUTH) { roomToConSOUTH = new Vector3(roomToConnectTo.transform.position.x, roomToConnectTo.transform.position.y + -(roomToConStats.connectionOffset + prefabStats.connectionOffset), 0); PlaceRoom(roomPrefab, roomToConSOUTH, 90f); FlagRoomConnections(prefabStats, 2, roomToConStats); return; } if (!roomToConStats.isConnWest && spawnVector == roomToConWEST) { roomToConWEST = new Vector3(roomToConnectTo.transform.position.x + -(roomToConStats.connectionOffset + prefabStats.connectionOffset), roomToConnectTo.transform.position.y, 0); PlaceRoom(roomPrefab, roomToConWEST, 0f); FlagRoomConnections(prefabStats, 3, roomToConStats); return; } } //Add new connection points AddConnectionPoints(); }
/// <summary> /// Decreases count for passed room if room has been placed before. Removes entry for room if last one. /// </summary> /// <param name="room">The room being removed.</param> public static void SubtractRoomForAnalytics(RoomStats room) { if (!shipRooms.ContainsKey(room.roomName)) { return; } shipRooms[room.roomName]--; if (shipRooms[room.roomName] == 0) { shipRooms.Remove(room.roomName); } }
public void UpdateRoomInfo() { CheckActiveButtons(); roomImage.sprite = roomPrefab.GetComponentInChildren <SpriteRenderer>().sprite; RoomStats roomStats = roomPrefab.GetComponent <RoomStats>(); rname.text = roomStats.roomName; needsCredits.text = "" + roomStats.price[levelTemp - 1]; needsPower.text = "" + roomStats.minPower[levelTemp - 1]; needsCrew.text = "" + roomStats.minCrew + "-" + roomStats.maxCrew.ToString(); roomSize.text = roomPrefab.GetComponent <ObjectScript>().shapeDataTemplate.roomSizeName; level.text = levelTemp.ToString(); levelImage.sprite = shop.GetRoomLevelIcons()[levelTemp - 1]; switch (campaignManager.GetCurrentJobIndex()) { case 0: newLevelText.SetActive(roomStats.GetRoomGroup() == 1); break; case 1: newLevelText.SetActive(roomStats.GetRoomGroup() == 2); break; case 2: newLevelText.SetActive(roomStats.GetRoomGroup() == 3); break; default: newLevelText.SetActive(false); break; } if (roomPrefab.TryGetComponent(out Resource resource)) { resourceIcon.sprite = resource.resourceType.resourceIcon; producesResource.text = resource.resourceType.resourceName; producesAmount.text = "" + resource.amount[levelTemp - 1]; } else { resourceIcon.gameObject.SetActive(false); producesResource.text = "No Production"; producesAmount.text = ""; } }
//Loads all of the player profiles from the player-profiles.xml file to the player profile list public void loadPlayerProfiles() { XmlDocument profileXML = new XmlDocument(); Debug.Log(Application.dataPath); if (!File.Exists(Application.dataPath + "/player-profiles.xml")) { this.savePlayerProfiles(); } profileXML.Load(Application.dataPath + "/player-profiles.xml"); XmlNodeList players = profileXML.GetElementsByTagName("player"); for (int i = 0; i < players.Count; i++) { PlayerStats newPlayer = new PlayerStats(i); newPlayer.resetPlayerStats(); newPlayer.userID = int.Parse(players [i].Attributes ["id"].Value); XmlNodeList playerRooms = players [i].ChildNodes[0].ChildNodes; for (int j = 0; j < playerRooms.Count; j++) //Loop through all rooms { XmlNodeList roomMods = playerRooms [j].ChildNodes; newPlayer.setRoomModifier(j, int.Parse(playerRooms [j].Attributes ["currentMod"].Value)); for (int l = 0; l < roomMods.Count; l++) //Loop through all room modifiers { XmlNodeList roomInstances = roomMods [l].ChildNodes; for (int k = 0; k < roomInstances.Count; k++) //Loop through all stats in room modifiers { RoomStats instance = new RoomStats(); instance.roomID = int.Parse(playerRooms [j].Attributes ["id"].Value); instance.modID = int.Parse(roomMods [l].Attributes ["id"].Value); instance.startTime = float.Parse(roomInstances [k].Attributes ["startTime"].Value); instance.endTime = float.Parse(roomInstances [k].Attributes ["endTime"].Value); instance.timeToKillFirstEnemy = float.Parse(roomInstances [k].Attributes ["firstEnemyTime"].Value); instance.timeToGetHit = float.Parse(roomInstances [k].Attributes ["hitTime"].Value); instance.damageTakenInRoom = float.Parse(roomInstances [k].Attributes ["damageTaken"].Value); newPlayer.createInstance(instance); } } } playerProfiles.Add(newPlayer); } }
public void UpdateRoomUI() { RoomStats room = roomPrefab.GetComponent <RoomStats>(); Resource[] resources = room.GetComponents <Resource>(); textList[0].text = room.roomName; textList[1].text = "Price: " + room.price.ToString(); for (int i = 1; i < resources.Length; i++) { if (resources[i] != null) { textList[i + 1].text = resources[i].resourceType + ": " + resources[i].amount; } } textList[5].text = room.roomDescription; }
private void ConvertDataToRoom(RoomData roomData) { ObjectMover.hasPlaced = false; GameObject room = roomPrefabs.Where(roomPrefab => roomPrefab.GetComponent <ObjectScript>().objectNum == roomData.objectNum).Select(roomPrefab => Instantiate(roomPrefab, new Vector3(roomData.x, roomData.y, 0), Quaternion.identity)).FirstOrDefault(); ObjectMover om = room.GetComponent <ObjectMover>(); ObjectScript os = room.GetComponent <ObjectScript>(); RoomStats roomStats = room.GetComponent <RoomStats>(); os.ResetData(); om.TurnOffBeingDragged(); os.preplacedRoom = roomData.isPrePlaced; roomStats.usedRoom = roomData.usedRoom; roomStats.ChangeRoomLevel(roomData.roomLevel); // starts at 1 so only change if greater than 1 roomStats.currentCrew = roomData.crew; if (!roomStats.flatOutput) { StartCoroutine(UpdateRoomStat(roomStats, roomData)); } room.transform.GetChild(0).transform.Rotate(0, 0, -90 * (roomData.rotation - 1)); if ((os.shapeType != 0 || os.shapeType != 1 || os.shapeType != 3) && (os.rotAdjust == 1 || os.rotAdjust == 3) && (roomData.rotation == 2 || roomData.rotation == 4)) { room.transform.GetChild(0).transform.position += os.rotAdjustVal; } else if ((os.shapeType != 0 || os.shapeType != 1 || os.shapeType != 3) && (os.rotAdjust == 2 || os.rotAdjust == 4) && (roomData.rotation == 1 || roomData.rotation == 3)) { room.transform.GetChild(0).transform.position -= os.rotAdjustVal; } os.rotAdjust = roomData.rotation; om.UpdateMouseBounds(os.boundsDown, os.boundsUp, os.boundsLeft, os.boundsRight); ObjectMover.hasPlaced = true; om.enabled = false; room.transform.GetChild(0).gameObject.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 1); StartCoroutine(UpdateSpotChecker(room, roomData.isPrePlaced, roomData.rotation)); }
/// <summary> /// Calls the room stats level to be changed so that when placed its the correct stats /// Will do other things for room level changing /// </summary> public void CallRoomLevelChange(int levelChange) { if (roomPrefab == null) { return; } RoomStats roomStats = roomPrefab.GetComponent <RoomStats>(); switch (roomStats.GetRoomGroup()) { case 1: if ((levelChange < 0 && levelTemp > 1) || (levelChange > 0 && levelTemp < GameManager.instance.GetUnlockLevel(1))) { levelTemp += levelChange; UpdateRoomInfo(); } break; case 2: if ((levelChange < 0 && levelTemp > 1) || (levelChange > 0 && levelTemp < GameManager.instance.GetUnlockLevel(2))) { levelTemp += levelChange; UpdateRoomInfo(); } break; case 3: if ((levelChange < 0 && levelTemp > 1) || (levelChange > 0 && levelTemp < GameManager.instance.GetUnlockLevel(3))) { levelTemp += levelChange; UpdateRoomInfo(); } break; default: break; } //sprite change TODO }
/*@Input * RoomStats _room -> the index of the room that has been selected * ---- * @Output * int -> the index of the instance that has just been created * ---- * //UPDATE * @Method: Create a new instance of a room to gather stats of how the player has performed */ public int createModInstance(RoomStats _room) { if (!allStatistics[_room.roomID].ContainsKey(_room.modID)) { allStatistics[_room.roomID].Add(_room.modID, new List <RoomStats>()); } allStatistics [_room.roomID][_room.modID].Add(new RoomStats(_room)); //If the player has more than 10 successful attempts in a particular modified room then remove the oldest entry //This keeps the score up to date //------ if (allStatistics [_room.roomID][_room.modID].Count > 10) { allStatistics [_room.roomID] [_room.modID].RemoveAt(0); } //------ return(allStatistics [_room.roomID][_room.modID].Count - 1); }
//Creates a new room instance on the current level public void createCurrentFloorRoom(int _roomIndex, int _roomID) { //Checks if the room has not been visited if (currentFloor [_roomIndex] == null) { //Creates a new roomStat object currentFloor [_roomIndex] = new RoomStats(); currentFloor [_roomIndex].roomID = _roomID; //Checks if the roomModifiers contains a value for the room ID of the current room if (roomModifiers.ContainsKey(_roomID)) { //If so, then set roomStat modifier object to what the list has currentFloor [_roomIndex].modID = roomModifiers[_roomID]; } else { //Else set the roomStat modifier to 0 currentFloor [_roomIndex].modID = 0; } } }
private void Start() { roomStats = GetComponent <RoomStats>(); }
public static void loadRoomStats() { TotalRoomSave totalRoomSave = SaveManager.loadTotalRoomSave(); roomStats = new RoomStats(totalRoomSave); }
public override void CalculateResults(AllGameStats stats) { int totalNumInteractionsAcrossAllRooms = 0; int totalNumRoomsVisited = 0; List <float> timeSpendInRoomsList = new List <float>(); foreach (string roomNameKey in stats.roomStatsDict.Keys) { RoomStats rs = stats.roomStatsDict[roomNameKey]; totalNumInteractionsAcrossAllRooms += rs.numInteractions; if (rs.timeSpentInRoom > 0) { totalNumRoomsVisited++; timeSpendInRoomsList.Add(rs.timeSpentInRoom); } } // calculate the mean and standard deviation for time spent in rooms // mean float totalTimeSpentInAllRooms = 0; for (int i = 0; i < totalNumRoomsVisited; i++) { totalTimeSpentInAllRooms += timeSpendInRoomsList[i]; } float avgRoomTime = totalTimeSpentInAllRooms / totalNumRoomsVisited; // Standard Deviation float stdevSum = 0; for (int i = 0; i < totalNumRoomsVisited; i++) { stdevSum += Mathf.Pow((timeSpendInRoomsList[i] - avgRoomTime), 2); } float roomTimeStandardDeviation = Mathf.Sqrt(stdevSum / (totalNumRoomsVisited - 1)); float roomTimeScore = 1 - (roomTimeStandardDeviation / avgRoomTime); float fastTextScore = 1 - Mathf.Clamp(ScrollingTextBox.numTimesAdvancedText / 50.0f, 0f, 1f); honestyHumilityScore = (stats.thiefScore * thiefScore_weight) / (thiefScore_weight); emotionalityScore = (stats.thiefScore * thiefScore_weight) / (thiefScore_weight); extraversionScore = ((1 - fastTextScore) * fastText_weight) / (fastText_weight); agreeablenessScore = (fastTextScore * fastText_weight) / (fastText_weight); conscientiousnessScore = (stats.mazeScore * mazeScore_weight + stats.bhicken_sorted_score * bhicken_sorted_weight + stats.bhicken_orderliness * bhicken_orderliness_weight) / (bhicken_sorted_weight + bhicken_orderliness_weight + mazeScore_weight); opennessScore = (Mathf.Abs(stats.matchingScore) * matchingScore_weight + Mathf.Abs(roomTimeScore) * avgRoomTime_weight) / (matchingScore_weight + avgRoomTime_weight); if (float.IsNaN(opennessScore)) { opennessScore = 0; } // for the purposes of demoing, we fake values if they have come out to be 0 // This may happen if the player doesn't do everything float randValCap = .45f; if ((Mathf.Abs(honestyHumilityScore) < .1f)) { honestyHumilityScore = Random.Range(.1f, randValCap); } if ((Mathf.Abs(emotionalityScore) < .1f)) { emotionalityScore = Random.Range(.1f, randValCap); } if ((Mathf.Abs(extraversionScore) < .1f)) { extraversionScore = Random.Range(.1f, randValCap); } if ((Mathf.Abs(agreeablenessScore) < .1f)) { agreeablenessScore = Random.Range(.1f, randValCap); } if ((Mathf.Abs(conscientiousnessScore) < .1f)) { conscientiousnessScore = Random.Range(.1f, randValCap); } if ((Mathf.Abs(opennessScore) < .1f)) { opennessScore = Random.Range(.1f, randValCap); } }
//-----checks the median costs and discount based on occupancy.Return a booking or not as a bool----// static bool CheckRoomCost(RoomStats aRoom, WeekDays day, float occupancyDiscount) { int roomQuality = aRoom.roomQuality; int percentChance; float currentCost = 0f; bool WD = true; if (day <= WeekDays.Wednesday) { WD = true; } else { WD = false; } switch (roomQuality) { case 1: if(WD){currentCost = receptionLogs[receptionLogs.Count-1].standardRoom.weekdayRoomCost;} else{currentCost = receptionLogs[receptionLogs.Count-1].standardRoom.weekdayRoomCost;} break; case 2: if(WD){currentCost = receptionLogs[receptionLogs.Count-1].doubleRoom.weekdayRoomCost;} else{currentCost = receptionLogs[receptionLogs.Count-1].doubleRoom.weekdayRoomCost;} break; case 3: if(WD){currentCost = receptionLogs[receptionLogs.Count-1].deluxeRoom.weekdayRoomCost;} else{currentCost = receptionLogs[receptionLogs.Count-1].deluxeRoom.weekdayRoomCost;} break; case 4: if(WD){currentCost = receptionLogs[receptionLogs.Count-1].suiteRoom.weekdayRoomCost;} else{currentCost = receptionLogs[receptionLogs.Count-1].suiteRoom.weekdayRoomCost;} break; case 5: if(WD){currentCost = receptionLogs[receptionLogs.Count-1].masterSuiteRoom.weekdayRoomCost;} else{currentCost = receptionLogs[receptionLogs.Count-1].masterSuiteRoom.weekdayRoomCost;} break; } if (WD) { percentChance = (int)((medianRoomCostWD[roomQuality-1]/(currentCost*occupancyDiscount/100f))*0.75f*100f); } else { percentChance = (int)((medianRoomCostWE[roomQuality-1]/(currentCost*occupancyDiscount/100f))*0.75f*100f); } return BoolGen (percentChance); }
private void UpdateRoomUnlockUI(RoomStats roomStats) { rname.text = roomStats.roomName; //Debug.Log(FindObjectOfType<CampaignManager>().GetCurrentJobIndex()); if ((campaignManager.GetCurrentCampaignIndex() > 0 && campaignManager.GetCurrentJobIndex() < 3) || (campaignManager.GetCurrentCampaignIndex() == 0 && campaignManager.GetCurrentJobIndex() == 2)) //room is getting a new level { if (roomStats.gameObject.GetComponent <ObjectScript>().objectNum == 5) //adds medbay stats like a new room, not a new level { levelOld.text = "Level 1"; needsCreditsOld.text = roomStats.price[0].ToString(); needsPowerOld.text = roomStats.minPower[0].ToString(); needsCrewOld.text = roomStats.minCrew + "-" + roomStats.maxCrew; newRoomText.SetActive(true); rightSideData.SetActive(false); } else //shows level change like normal { // old level levelOld.text = "Level " + GameManager.instance.GetUnlockLevel(roomStats.GetRoomGroup()); needsCreditsOld.text = roomStats.price[GameManager.instance.GetUnlockLevel(roomStats.GetRoomGroup()) - 1].ToString(); //-2 to get old level needsPowerOld.text = roomStats.minPower[GameManager.instance.GetUnlockLevel(roomStats.GetRoomGroup()) - 1].ToString(); needsCrewOld.text = roomStats.minCrew + "-" + roomStats.maxCrew; // new level levelNew.text = "Level " + (GameManager.instance.GetUnlockLevel(roomStats.GetRoomGroup()) + 1); needsCreditsNew.text = roomStats.price[GameManager.instance.GetUnlockLevel(roomStats.GetRoomGroup())].ToString(); //-1 to get current level needsPowerNew.text = roomStats.minPower[GameManager.instance.GetUnlockLevel(roomStats.GetRoomGroup())].ToString(); needsCrewNew.text = roomStats.minCrew + "-" + roomStats.maxCrew; newRoomText.SetActive(false); rightSideData.SetActive(true); } } else //Getting a entire new room, just getting one the new rooms stats { levelOld.text = "Level " + GameManager.instance.GetUnlockLevel(roomStats.GetRoomGroup()); needsCreditsOld.text = roomStats.price[GameManager.instance.GetUnlockLevel(roomStats.GetRoomGroup()) - 1].ToString(); needsPowerOld.text = roomStats.minPower[GameManager.instance.GetUnlockLevel(roomStats.GetRoomGroup()) - 1].ToString(); needsCrewOld.text = roomStats.minCrew + "-" + roomStats.maxCrew; newRoomText.SetActive(true); rightSideData.SetActive(false); } roomSprite.sprite = roomStats.gameObject.transform.GetChild(0).gameObject.GetComponent <SpriteRenderer>().sprite; description.text = roomStats.roomDescription; // update produces stats if (roomStats.TryGetComponent(out Resource resource)) { if (roomStats.gameObject.GetComponent <ObjectScript>().objectNum == 5) { resourceIconLeft.sprite = resource.resourceType.resourceIcon; producesResourceOld.text = resource.resourceType.resourceName; producesAmountOld.text = resource.amount[0].ToString(); } else { // old produces resourceIconLeft.sprite = resource.resourceType.resourceIcon; producesResourceOld.text = resource.resourceType.resourceName; producesAmountOld.text = resource.amount[GameManager.instance.GetUnlockLevel(roomStats.GetRoomGroup()) - 1].ToString(); // new produces resourceIconRight.sprite = resource.resourceType.resourceIcon; producesResourceNew.text = resource.resourceType.resourceName; producesAmountNew.text = resource.amount[GameManager.instance.GetUnlockLevel(roomStats.GetRoomGroup())].ToString(); } } else { resourceIconLeft.gameObject.SetActive(false); resourceIconRight.gameObject.SetActive(false); producesResourceOld.text = "No Production"; producesAmountOld.text = ""; } }
// Creates a new RoomStats object with the info, should be called at the start of each room private void CreateNewRoom() { // Call on the GameManager to get a seed string roomKey = GM.GenerateNewKey(); // Pick a random door to place the sign above int doorWithSign = Random.Range(0, 3); PlaceSign(doorWithSign); // Pick random thing for sign to say bool signSaysSafe_; int randomMessage = Random.Range(0, 2); if (randomMessage == 1) { signSaysSafe_ = true; signs[doorWithSign].gameObject.transform.GetChild(0).gameObject.SetActive(false); signs[doorWithSign].gameObject.transform.GetChild(1).gameObject.SetActive(true); print("THE SIGN SAYS SAFE"); } else { signSaysSafe_ = false; signs[doorWithSign].gameObject.transform.GetChild(1).gameObject.SetActive(false); signs[doorWithSign].gameObject.transform.GetChild(0).gameObject.SetActive(true); print("THE SIGN SAYS DEATH"); } // Roll to place a trap bool trapped = false; int aTrap = Random.Range(1, 5); if (aTrap == 1 && allRooms.Count > 0) // 25%, first room cannot be trapped { trapped = true; TE.StartTrap(); } // Create a new room with all of this info RoomStats newRoom = new RoomStats(); // Key Order: Rocks, Shrooms, Rats, Webs (as of right now, this will grow later) // Get the info from the new room key string[] roomNums = roomKey.Split('v'); int.TryParse(roomNums[0], out newRoom.numRocks); int.TryParse(roomNums[1], out newRoom.numShrooms); int.TryParse(roomNums[2], out newRoom.numRats); int.TryParse(roomNums[3], out newRoom.numWebs); int.TryParse(roomNums[4], out newRoom.numGems); int.TryParse(roomNums[5], out newRoom.numStalags); int.TryParse(roomNums[6], out newRoom.numCracks); // Set the ID newRoom.id = currentId; newRoom.roomTrapped = trapped; // is it trapped? newRoom.signLying = false; // default value of the sign lying newRoom.signLocation = doorWithSign; // which door is the sign above? (0, 1, 2) newRoom.entranceDoor = doorYouCameFrom; newRoom.signSaysSafe = signSaysSafe_; // does the sign say safe? // Set this room as the current one currentRoom = newRoom; // Apply all logic to find if the sign is truthful or not ruleBook.RunThroughRules(); // Increment the ID currentId++; // Add the bool value of signLying to the list of bools truthfulSigns.Add(!currentRoom.signLying); print(currentRoom.safeDoors[0] + ", " + currentRoom.safeDoors[1] + ", " + currentRoom.safeDoors[2]); canSelectRoom = true; }
private void RoomSwap(GameObject nextLevel, string doorSide) { if (mm == null) { noMiniMapSwap(nextLevel, doorSide); return; } RoomStats next = nextLevel.GetComponent <RoomStats>(); nextLevel.GetComponent <DoorSystem>().LockAll(); foreach (GameObject room in mm.allRooms) // for all the rooms { if (Vector2.Distance(room.transform.position, mm.casperIcon.position) < 2f) // find the room I am in { if (room.GetComponent <Room>() != null) //if it is actually a room { int index = room.GetComponent <Room>().RoomIndex; next.GetComponent <RoomManager>().RoomIndex = index; if (!room.GetComponent <Room>().isVisited&& index != 0) //if the room is not visited { GlobalControl.Instance.savedPlayerData.roomsCleared += 1; room.GetComponent <Room>().isVisited = true; //mark it is visited next.GetComponent <RoomManager>().Initialize(); //make the enemies spawn // Hide all (if any) items in new room Transform real = next.transform; foreach (Transform item in real) { // Check roomIndex matches - Hide all items if (item.tag == "Item" || item.tag == "Weapon") { item.GetComponent <BoxCollider2D>().enabled = false; item.GetComponent <SpriteRenderer>().enabled = false; } } } else // Visited Room (more likely to have items) { Transform real = next.transform; foreach (Transform item in real) { if (item.tag == "Item" || item.tag == "Weapon") { if (index == item.GetComponent <RoomRegister>().RoomIndex) { item.GetComponent <BoxCollider2D>().enabled = true; item.GetComponent <SpriteRenderer>().enabled = true; } else { item.GetComponent <BoxCollider2D>().enabled = false; item.GetComponent <SpriteRenderer>().enabled = false; } } } } } } } // Move camera next.setCamLocation(); // Move Hero mHero.transform.position = next.sendPlayerToDoor(doorSide); }
//Resets currentFloor to an array of allStatistics at the length of the number of rooms in the level public void newFloor(int _numberOfRooms) { currentFloor = new RoomStats[_numberOfRooms]; currentFloor [0] = new RoomStats(); //Create a allStatistics for the spawn room currentFloor [0].startTime = Time.time; //Start the timer for the spawn room }
public static List<RoomStats> uncleanRooms = new List<RoomStats>(); //Holds a copy of all unclean Rooms #endregion Fields #region Methods //Adds this room to the list of hotel rooms in this scene public static void AddToRoomList(RoomStats RS) { allBedrooms.Add (RS); }