public void FromJson(Hashtable json) { ArrayList nodes = json["Nodes"] as ArrayList; foreach (Hashtable nodeHash in nodes) { XY coord = new XY(nodeHash["Coord"] as Hashtable); MapRoom room = new MapRoom(nodeHash["Room"] as Hashtable); Graph.AddNode(coord, room); } ArrayList edges = json["Edges"] as ArrayList; foreach (Hashtable edgeHash in edges) { MapNode from = Graph.GetNodeByCoord(new XY(edgeHash["From"] as Hashtable)); MapNode to = Graph.GetNodeByCoord(new XY(edgeHash["To"] as Hashtable)); MapPath path = new MapPath(edgeHash["Path"] as Hashtable); Graph.AddEdge(from, to, path); } Entrance = Graph.GetNodeByCoord(new XY(json["Entrance"] as Hashtable)); }
public MonsterSpawnInfo SpawnMonstersToRoom(MapRoom room, string monsterTypeName, MapRoom.RoomType type, int direction, int countRooms, int countMobsPerRoom, bool randomOffset = false, int level = 1, int chance = 100, bool exclude = true) { if (chance < 100 && !ChanceCheck(chance)) { return(null); } Tile[] rooms = room.GetSubRooms(type, direction, countRooms, exclude); MonsterSpawnInfo info = null; foreach (Tile t in rooms) { if (t == null) { break; } for (int i = 0; i < countMobsPerRoom; i++) { info = SpawnMonsterToRoom(room, monsterTypeName, t, randomOffset, level); } } return(info); }
void GoToRoom(MapRoom room) { _currentMapRoom = room; _currentMapRoom.SetHighlight(true); SetConnectedRoomsInteractable(true); if (_connections.ContainsKey(room)) { foreach (var connection in _connections[room]) { connection.GetComponent <Image>().enabled = true; } } AdjustContent(); _roomCallback?.Invoke(_currentMapRoom); //_currentMapRoom.Encounter.StartEncounter(battleRoom.transform, _her) //if (_currentMapRoom.Content == RoomContent.Battle) //{ // TriggerBattleRoom(true); //} if (!_visibleRooms.Contains(room)) { _visibleRooms.Add(room); } //AdjustTex(); }
public MapCorridor(MapRoom from, MapRoom to, int mapSize) { start = from.RandomPoint(); end = to.RandomPoint(); //50% horizontal_priority = Random.Range(0f, 1f) >= 0.5f; }
public Pose(PositioningSystem positioning, MapRoom startingRoom, Compass compass, double compassToMapCorrectionAngle) { this.CurrentRoom = startingRoom; this.Positioning = positioning; this.Compass = compass; this.CompassToMapCorrectionAngle = compassToMapCorrectionAngle; }
private void GenerateMap() { FillWithWalls(); int roomIterations = 0; while (rooms.Count < roomsToGenerate && roomIterations < maxRoomIterations) { roomIterations++; MapRoom room = new MapRoom(mapSize, maxRoomSize, minRoomSize); if (ScanRoom(room)) { //Fill with the room PlaceRoom(room); rooms.Add(room); } //Place a corridor if (rooms.Count > 1) { MapRoom from = rooms[rooms.Count - 2]; MapRoom to = rooms[rooms.Count - 1]; try { MapCorridor corridor = new MapCorridor(from, to, mapSize); PlaceCorridor(corridor); } catch (ImpossibleCorridorError) { } } } }
void AddRoomToDict(MapRoom room) { room.roomPos = currentPos; room.discovered = false; mapRooms.Add(room.roomName, room); }
public void CreateMap(DungeonRoom[] rooms) { ClearContent(); _visibleRooms = new List <MapRoom>(); _currentRooms = rooms; var maxHeight = _currentRooms.Max(e => e.Row); var height = Mathf.Abs(maxHeight) + Mathf.Abs(_currentRooms.Min(e => e.Row)) + 1; _mappedRooms = new Dictionary <RoomPosition, MapRoom>(); _createdColumns = new Dictionary <int, Transform>(); _createdConnections = new List <RoomConnection>(); _startRow = Instantiate(prefabRow, content); var startRoom = Instantiate(prefabStartRoom, _startRow); var startDungeonRoom = _currentRooms.FirstOrDefault(e => e.Content == RoomContent.Start); startRoom.SetData(startDungeonRoom, RoomSelected); _mappedRooms.Add(startDungeonRoom.Position, startRoom); foreach (var room in _currentRooms) { if (room.Content == RoomContent.Start || room.Content == RoomContent.Boss) { continue; } var pos = room.Position; if (!_createdColumns.TryGetValue(pos.Col, out var column)) { column = Instantiate(prefabRow, content); for (int i = 0; i < height; i++) { var mapRoom = Instantiate(prefabRoom, column); _mappedRooms.Add(new RoomPosition(pos.Col, maxHeight - i), mapRoom); } _createdColumns.Add(pos.Col, column); _lastCol = pos.Col; } var mappedRoom = _mappedRooms[pos]; mappedRoom.SetData(room, RoomSelected); } _endRow = Instantiate(prefabRow, content); var endRoom = Instantiate(prefabEndRoom, _endRow); var endDungeonRoom = _currentRooms.FirstOrDefault(e => e.Content == RoomContent.Boss); endRoom.SetData(endDungeonRoom, RoomSelected); endRoom.ShowRoom(true); _mappedRooms.Add(endDungeonRoom.Position, endRoom); FillRow(_startRow, startRoom, startDungeonRoom.Position, maxHeight, height); FillRow(_endRow, endRoom, endDungeonRoom.Position, maxHeight, height); _currentMapRoom = startRoom; _init = false; _p = 0; }
void FillRow(Transform row, MapRoom room, RoomPosition position, int maxHeight, int count) { for (int i = 1; i < count; i++) { Instantiate(emptyRoom, row); } room.transform.SetSiblingIndex(maxHeight - position.Row); }
static bool Prefix(MapRoom __instance, float DCEFKAOFGOG) { if (EngineerPlayer.IsPlayerEngineer(PlayerControl.LocalPlayer)) { return(false); } return(true); }
public void ChangeCurrentMapRoom(MapRoom room) { if (room.discovered == false) { room.DiscoverRoom(); } camMoveDir = new Vector3(room.roomPos.x, room.roomPos.y, camMoveDir.z); }
private void Start() { if (isStartRoom) { dungeonManager.startRoom = this; mapRoom = dungeonManager.map.gameObject.GetComponent <MapRoom>(); StartRoomGenerateRooms(); } }
private void PlaceRoom(MapRoom mr) { for (int x = mr.start.x; x <= mr.end.x; x++) { for (int y = mr.start.y; y <= mr.end.y; y++) { EditTile(new Vector2Int(x, y), true, true); } } }
static bool Prefix(MapRoom __instance, float DCEFKAOFGOG) { if (EngineerSettings.Engineer != null) { if (EngineerSettings.Engineer != null && EngineerSettings.Engineer.PlayerId == PlayerControl.LocalPlayer.PlayerId) { return(false); } } return(true); }
void OnRoomChanged(MapRoom room) { var encounterData = room.Encounter; if (encounterData == null) { return; } Debug.Log("Encounter Level = " + encounterData.level + " and Rarity=" + encounterData.rarity.ToString()); encounterData.encounter.StartEncounter(battleRoom, _enteredHeroes, encounterData.level, encounterData.rarity); }
/// <summary> /// 初始化房间信息 /// </summary> public void InitRoom() { foreach (var item in FloorNode.ChildNodes) { //Topologies.Find(Topo => Topo.Name == item.NodeName); MapRoom room = RoomList.Find(roomT => roomT.RoomName == item.NodeName); if (room != null) { room.RoomNode = item; } } }
static bool Prefix(MapRoom __instance) { if (EngineerSettings.Engineer != null && EngineerSettings.Engineer.PlayerId == PlayerControl.LocalPlayer.PlayerId && !PlayerControl.LocalPlayer.Data.IsDead) { if (!EngineerSettings.repairUsed && EngineerSettings.sabotageActive) { EngineerSettings.repairUsed = true; ShipStatus.Instance.RpcRepairSystem(SystemTypes.Laboratory, 16); } return(false); } return(true); }
static bool Prefix(MapRoom __instance) { if (PlayerControl.LocalPlayer.isPlayerRole("Engineer")) { if (!PlayerControl.LocalPlayer.getModdedControl().UsedAbility&& Main.Logic.sabotageActive && !PlayerControl.LocalPlayer.Data.IsDead) { PlayerControl.LocalPlayer.getModdedControl().UsedAbility = true; ShipStatus.Instance.RpcRepairSystem(SystemTypes.Laboratory, 16); } return(false); } return(true); }
void Start() { localhost = GameObject.FindWithTag("GameController").GetComponent <LocalConnections>(); GameObject mapChild = Instantiate(localhost.defaultMapRoom, Vector3.zero, Quaternion.identity) as GameObject; mapChild.transform.SetParent(localhost.MapParent.transform); mapChild.name = gameObject.name; mr = mapChild.GetComponent <MapRoom>(); mr.rc = this; mr.x = Mathf.RoundToInt(roomPosition.x); mr.y = Mathf.RoundToInt(roomPosition.y); }
public static bool HandleSabotage(MapRoom Map, SabotageType Type) { foreach (var Role in Role.ROLES) { if (Role.ActivateSabotage(Map, Type)) { // If that role handles sabotage activation then cancel default return(false); } } return(true); }
static bool Prefix(MapRoom __instance, float DCEFKAOFGOG) { if (TryGetSpecialRole(PlayerControl.LocalPlayer.PlayerId, out Engineer engineer)) { return(engineer.SetRepairButtonsActive()); } if (TryGetSpecialRole(PlayerControl.LocalPlayer.PlayerId, out Tracker tracker)) { return(tracker.SetMarkButtonsActive()); } return(true); }
void DrawRoom(string name) { GameObject go = Instantiate(roomText, currentPos, Quaternion.identity); go.transform.SetParent(mapParent.transform); TextMeshPro tmp = go.GetComponent <TextMeshPro>(); MapRoom room = go.GetComponent <MapRoom>(); room.roomName = name; AddRoomToDict(room); tmp.text = name; }
static bool Prefix(MapRoom __instance) { if (EngineerPlayer.IsPlayerEngineer(PlayerControl.LocalPlayer) && EngineerPlayer.GetEngineerFromPlayer(PlayerControl.LocalPlayer).canRepair&& EngineerRole.sabotageActive) { EngineerPlayer.GetEngineerFromPlayer(PlayerControl.LocalPlayer).lastRepair = DateTime.UtcNow; ShipStatus.Instance.RpcRepairSystem(SystemTypes.Reactor, 16); return(false); } else if (EngineerPlayer.IsPlayerEngineer(PlayerControl.LocalPlayer)) { return(false); } return(true); }
void AddConnection(MapRoom room, GameObject connection) { if (_connections.TryGetValue(room, out var connections)) { connections.Add(connection); } else { _connections.Add(room, new List <GameObject>() { connection }); } }
private bool ScanRoom(MapRoom mr) { //Returns true if the room can be safely placed for (int x = Mathf.Clamp(mr.start.x - 1, 0, mapSize - 1); x <= Mathf.Clamp(mr.end.x + 1, 0, mapSize - 1); x++) { for (int y = Mathf.Clamp(mr.start.y - 1, 0, mapSize - 1); y <= Mathf.Clamp(mr.end.y + 1, 0, mapSize - 1); y++) { if (GetTile(new Vector2Int(x, y)).roomPart) { return(false); } } } return(true); }
static bool Prefix(MapRoom __instance) { if (EngineerSettings.Engineer != null && EngineerSettings.Engineer.PlayerId == PlayerControl.LocalPlayer.PlayerId && !PlayerControl.LocalPlayer.Data.IsDead) { if (!EngineerSettings.repairUsed && EngineerSettings.sabotageActive) { EngineerSettings.repairUsed = true; SwitchSystem switchSystem = ShipStatus.Instance.Systems[SystemTypes.Electrical].Cast <SwitchSystem>(); switchSystem.ActualSwitches = switchSystem.ExpectedSwitches; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.FixLights, Hazel.SendOption.None, -1); AmongUsClient.Instance.FinishRpcImmediately(writer); } return(false); } return(true); }
static bool Prefix(MapRoom __instance) { if (PlayerControl.LocalPlayer.isPlayerRole("Engineer")) { if (!PlayerControl.LocalPlayer.getModdedControl().UsedAbility&& Main.Logic.sabotageActive && !PlayerControl.LocalPlayer.Data.IsDead) { PlayerControl.LocalPlayer.getModdedControl().UsedAbility = true; SwitchSystem switchSystem = ShipStatus.Instance.Systems[SystemTypes.Electrical].Cast <SwitchSystem>(); switchSystem.ActualSwitches = switchSystem.ExpectedSwitches; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.FixLights, Hazel.SendOption.None, -1); AmongUsClient.Instance.FinishRpcImmediately(writer); } return(false); } return(true); }
static bool Prefix(MapRoom __instance) { if (!PlayerControl.LocalPlayer.isPlayerRole(Role.Engineer)) { return(true); } if (!PlayerTools.canEngineerUseAbility()) { return(false); } PlayerControl.LocalPlayer.getModdedControl().UsedAbility = true; Rpc <FixLightsRpc> .Instance.Send(data : true, immediately : true); return(false); }
static bool Prefix(MapRoom __instance) { if (EngineerPlayer.IsPlayerEngineer(PlayerControl.LocalPlayer) && EngineerPlayer.GetEngineerFromPlayer(PlayerControl.LocalPlayer).canRepair&& EngineerRole.sabotageActive) { System.Console.WriteLine(EngineerPlayer.GetEngineerFromPlayer(PlayerControl.LocalPlayer).canRepair); EngineerPlayer.GetEngineerFromPlayer(PlayerControl.LocalPlayer).lastRepair = DateTime.UtcNow; ShipStatus.Instance.RpcRepairSystem(SystemTypes.LifeSupp, 0 | 64); ShipStatus.Instance.RpcRepairSystem(SystemTypes.LifeSupp, 1 | 64); return(false); } else if (EngineerPlayer.IsPlayerEngineer(PlayerControl.LocalPlayer)) { return(false); } return(true); }
public override bool ActivateSabotage(MapRoom Map, SabotageType Type) { if (!IsLocalPlayer()) { return(false); } if (PlayerControl.LocalPlayer.Data.IsDead) { return(true); } if (RepairUsed || !SabotageActive) { return(true); } RepairUsed = true; // ReSharper disable once SwitchStatementMissingSomeEnumCasesNoDefault switch (Type) { case SabotageType.Lights: SabotageCentralPatch.FixLights(); ExtraNetwork.Send(CustomRPC.FixLights); break; case SabotageType.Reactor: ShipStatus.Instance.RpcRepairSystem(SystemTypes.Reactor, 16); break; case SabotageType.Comms: ShipStatus.Instance.RpcRepairSystem(SystemTypes.Comms, 16 | 0); ShipStatus.Instance.RpcRepairSystem(SystemTypes.Comms, 16 | 1); break; case SabotageType.Oxygen: ShipStatus.Instance.RpcRepairSystem(SystemTypes.LifeSupp, 0 | 64); ShipStatus.Instance.RpcRepairSystem(SystemTypes.LifeSupp, 1 | 64); break; case SabotageType.Seismic: ShipStatus.Instance.RpcRepairSystem(SystemTypes.Laboratory, 16); break; } return(true); }
public void FromJson(Hashtable json) { ArrayList nodes = json["Nodes"] as ArrayList; foreach(Hashtable nodeHash in nodes) { XY coord = new XY(nodeHash["Coord"] as Hashtable); MapRoom room = new MapRoom(nodeHash["Room"] as Hashtable); Graph.AddNode(coord, room); } ArrayList edges = json["Edges"] as ArrayList; foreach(Hashtable edgeHash in edges) { MapNode from = Graph.GetNodeByCoord(new XY(edgeHash["From"] as Hashtable)); MapNode to = Graph.GetNodeByCoord(new XY(edgeHash["To"] as Hashtable)); MapPath path = new MapPath(edgeHash["Path"] as Hashtable); Graph.AddEdge(from, to, path); } Entrance = Graph.GetNodeByCoord(new XY(json["Entrance"] as Hashtable)); }