public void QuickExpand(GameObject responsibleOne) //ONLY overwrites responsible one IF not null (was flooded or in progress) { if (RecursiveQuick) { return; } //was here before? if (responsibleOne == null) { return; } //is there responsible one to overwrite? RecursiveQuick = true; this.responsibleOne = responsibleOne.GetComponent <DoorsScript>(); //fix room for (int i = 0; i < Doors.Count; i++) { var door = Doors[i].GetComponent <DoorsScript>(); if (door.open) { if (!door.airlock) { var room = door.roomA; if (room == gameObject) { room = door.roomB; } room.GetComponent <RoomScript>().QuickExpand(Doors[i]); } } } //expand change }
public void Scanner() { GameMaster.GeenLight = true; Objective = (int)ObjectiveDefninitions.Scanner; rooms = new List <RoomScript>(); var room = GetRoomImIn(); if (room == null) { Objective = (int)ObjectiveDefninitions.Wait; return; } var var = room.GetComponent <RoomScript>().Doors; rooms = new List <RoomScript>(); room.GetComponent <RoomScript>().Doors.ForEach(d => { DoorsScript ds = d.GetComponent <DoorsScript>(); if (room.name != ds.roomA.name) { rooms.Add(ds.roomA.GetComponent <RoomScript>()); } if (room.name != ds.roomB.name) { rooms.Add(ds.roomB.GetComponent <RoomScript>()); } }); currentDestination = null; }
//enviroment public void Exposed(bool Void, bool Radiation, DoorsScript responsibleOne) { //if responsibleOne is null, we conside room breeched. //first time exposure => set timers rest will be handled in HandleExpousere() if (Void && !IsVoid && (VoidTakes < VoidIn)) { VoidIn = VoidTakes; this.responsibleOne = responsibleOne; GameMaster.WriteInConsole.Add("SYS: Room " + gameObject.name + " is vented into space!\n"); }//if NOT contaminated AND NOT already counting if (Radiation && !IsContaminated && (RadiationTakes < RadiationIn)) { RadiationIn = RadiationTakes; this.responsibleOne = responsibleOne; GameMaster.WriteInConsole.Add("SYS: Room " + gameObject.name + " is flooding with radiation!\n"); } }
public bool RecursiveExpousureCheckCaller(out RoomScript ExpandFromHere, out GameObject responsibleOne) { ExpandFromHere = null; responsibleOne = null; if (RecursiveCheckMarker) { return(false); } //was here before? RecursiveCheckMarker = true; for (int i = 0; i < Doors.Count; i++) { var door = Doors[i].GetComponent <DoorsScript>(); if (door.open) { if (door.airlock) { ExpandFromHere = this; responsibleOne = Doors[i]; return(true);//this room has open airlock } else { var room = door.roomA; if (room == gameObject) { room = door.roomB; } if (room.GetComponent <RoomScript>().RecursiveExpousureCheckCaller(out var source, out var airlock)) { ExpandFromHere = source; responsibleOne = airlock; return(true);//this room have ref to room with open airlock } } } } return(false); //no airlock found on this rooms OR any folowing }
public void QuickClean() //cleans ALL following rooms that have responsible one != null { if (RecursiveQuick) { return; } //was here before? if (responsibleOne == null) { return; } //is there responsible one to overwrite? RecursiveQuick = true; responsibleOne = null; IsVoid = false; VoidIn = VoidTakes + 1; RadiationIn = RadiationTakes + 1; VoidMarker.SetActive(false); //fix room for (int i = 0; i < Doors.Count; i++) { var door = Doors[i].GetComponent <DoorsScript>(); if (door.open) { if (!door.airlock) { var room = door.roomA; if (room == gameObject) { room = door.roomB; } room.GetComponent <RoomScript>().QuickClean(); } } } //expand change }
private void PlayEnemy() { TimeToAIRefresh -= Time.deltaTime; if (TimeToAIRefresh < 0) { TimeToAIRefresh = 1; GameObject enemy = GameMaster.GetRobotForEnemy(transform.position); IsOnTheMove = !(enemy == null || 15 < (Vector3.Distance(transform.position, enemy.transform.position))); if (IsOnTheMove) { hull.SetActive(true); if (enemy != null) { if (enemy.name.StartsWith("B")) { try { var navMeshPath = new NavMeshPath(); nav.CalculatePath(enemy.transform.position, navMeshPath); IsOnTheMove = (navMeshPath.status == NavMeshPathStatus.PathComplete); if (IsOnTheMove) { NavigateTo(enemy.transform.position); OnCloseContact(enemy, TimeToAIRefresh);//====================================>work around dla private void OnTriggerStay(Collider other) } } catch (Exception ex) { GameMaster.Console.text += ex.ToString(); } } } } if (!IsOnTheMove) { hull.SetActive(false); TimeToRoomChange -= TimeToAIRefresh; if (TimeToRoomChange < 0) { TimeToRoomChange = 30; GameObject room = GetRoomImIn(); if (room != null) { List <GameObject> rooms = new List <GameObject>(); room.GetComponent <RoomScript>().Doors.ForEach(d => { DoorsScript ds = d.GetComponent <DoorsScript>(); if (ds.open && !ds.airlock) { if (room.name != ds.roomA.name) { rooms.Add(ds.roomA); } if (room.name != ds.roomB.name) { rooms.Add(ds.roomB); } } }); rooms.Add(room); int index = Random.Range(0, rooms.Count); currentDestination = rooms[index]; var tmp = rooms.ToArray(); } NavigateTo(currentDestination.transform.position); } } } }//todo check for collisions and kill/damage
private void HandleExpousere() { HandleExpousereTimeStep -= Time.deltaTime; if (HandleExpousereTimeStep < 0) { HandleExpousereTimeStep = 1; //sim update env once a sec if (!(VoidTakes < VoidIn)) {//is beign exposed to void for first time VoidIn -= HandleExpousereTimeStep; if (VoidIn <= 0) { VoidIn = VoidTakes + 1; IsVoid = true; VoidMarker.SetActive(true); GameMaster.WriteInConsole.Add("SYS: Room " + gameObject.name + " is now void\n"); } } if (!(RadiationTakes < RadiationIn)) {//is beign exposed to radiation for first time RadiationIn -= HandleExpousereTimeStep; if (RadiationIn <= 0) { RadiationIn = RadiationTakes + 1; IsContaminated = true; RadiationMarker.SetActive(true); GameMaster.WriteInConsole.Add("SYS: Room " + gameObject.name + " is now contaminated\n"); } } //update clocks if needed RecursiveCheckMarker = false; RecursiveQuick = false; //reset values if needed; if ((IsVoid || IsContaminated) && responsibleOne != null) //it there reason to care and is there source? { if (!responsibleOne.open) //is source of this mess closed? { if (RecursiveExpousureCheckCaller(out var room, out var airlock)) { room.QuickExpand(airlock); } else { QuickClean(); responsibleOne = null; } } } //check if hole sealed if (IsVoid || IsContaminated) { Doors.ForEach(door => { var script = door.GetComponent <DoorsScript>(); if (!script.airlock && script.open) { script.roomA.GetComponent <RoomScript>().Exposed(IsVoid, IsContaminated, script); script.roomB.GetComponent <RoomScript>().Exposed(IsVoid, IsContaminated, script); } }); } //expand if posible (after check so that noting weird can happen if was source) } }