// Update cells models to display when entering a new room void UpdateCellsModels() { OneCellClass current = GetCurrentCell(); CellTypes curType = current.cellType; int curId = current.cellId; m_CentreModels.SetActiveModel(curType); m_NorthModels.SetActiveModel(GetNorthType(curId)); m_EastModels.SetActiveModel(GetEastType(curId)); m_SouthModels.SetActiveModel(GetSouthType(curId)); m_WestModels.SetActiveModel(GetWestType(curId)); if (curType == CellTypes.Exit) { float light_range = 4.0f; Color light_colour = new Color(0.9f, 1.0f, 0.9f, 1.0f); SetupLights(m_CentreModels, light_range, light_colour); //remove the north wall "Trap_1" from south_cell... GameObject southModel = m_SouthModels.GetActiveModel(); if (southModel) { GameObject northWall = southModel.transform.Find("Trap_1").gameObject; //Debug.Log($"[GameMgr][{Time.fixedTime - startingTime}s] {m_SouthModels.transform.name}, model: {northWall.name}"); if (northWall != null) { northWall.SetActive(false); } } } else if (curType == CellTypes.Deadly) { SetupLightsBySubType(m_CentreModels, current.cellSubType); } // Activate levers for centre model only if (m_CentreModels.m_GenCellA.activeSelf == true) { //Debug.Log($"[GameMgr][{Time.fixedTime - startingTime}s] {m_CentreModels.m_GenCellA.name}, MechanismNorth= {current.cellId}"); /* * GameObject genAModel = m_CentreModels.m_GenCellA.gameObject; * GameObject h1 = genAModel.transform.Find("Trap_1").gameObject; * GameObject h2 = h1.transform.Find("manche_base").gameObject; * GameObject h3 = h2.transform.Find("manche").gameObject; * h3.SetActive(true); * OneCellClass toto = GetCurrentCell(); * MechanismMove mec = h3.GetComponentInChildren<MechanismMove>(); * toto.MechanismNorth = mec; */ if (current.MechanismNorth.m_modelSet == false) { MechanismMove[] mecs = m_CentreModels.m_GenCellA.GetComponentsInChildren <MechanismMove>(); foreach (MechanismMove mec in mecs) { mec.enabled = true; switch (mec.cardinal) { case CardinalPoint.North: current.MechanismNorth = mec; current.MechanismNorth.m_modelSet = true; break; case CardinalPoint.East: current.MechanismEast = mec; current.MechanismEast.m_modelSet = true; break; case CardinalPoint.South: current.MechanismSouth = mec; current.MechanismSouth.m_modelSet = true; break; case CardinalPoint.West: current.MechanismWest = mec; current.MechanismWest.m_modelSet = true; break; default: Debug.LogWarning($"Wrong cardinal {mec.cardinal} for MechanismMove"); break; } } } } SetupAdjacentLights(null, 0.0f, Color.red); }
// Open the shutters to look through cells public void ScanTriggerAction(CardinalPoint point) { switch (point) { case CardinalPoint.North: { if (m_displayCell_N == false) { m_displayCell_N = true; GameObject front = null; if (m_CentreModels.m_EntryCell.activeSelf == true) { front = m_CentreModels.m_EntryCell.transform.Find("trap_0").gameObject; front = front.transform.Find("trape_2").gameObject; } else if (m_CentreModels.m_GenCellA.activeSelf == true) { front = m_CentreModels.m_GenCellA.transform.Find("Trap_1").gameObject; front = front.transform.Find("trape_1").gameObject; } // JowNext: Make sure the back is set considering the right active model as for the front GameObject back = m_NorthModels.GetActiveModel(); if (m_NorthModels.m_CurrentType == CellsModels.CellsModelsType.Entry) { back = back.transform.Find("trap_0").gameObject; back = back.transform.Find("trape_2").gameObject; StartCoroutine(OpenShutters(point, front, back)); } else if (m_NorthModels.m_CurrentType == CellsModels.CellsModelsType.GenA) { back = back.transform.Find("trap_0").gameObject; back = back.transform.Find("trape_2").gameObject; StartCoroutine(OpenShutters(point, front, back)); } } break; } case CardinalPoint.East: { if (m_displayCell_E == false) { m_displayCell_E = true; GameObject front = null; if (m_CentreModels.m_EntryCell.activeSelf == true) { front = m_CentreModels.m_EntryCell.transform.Find("trap_2").gameObject; front = front.transform.Find("trape_2 1").gameObject; } else if (m_CentreModels.m_GenCellA.activeSelf == true) { front = m_CentreModels.m_GenCellA.transform.Find("trap_3").gameObject; front = front.transform.Find("trape_2 2").gameObject; } GameObject back = m_EastModels.GetActiveModel(); if (m_EastModels.m_CurrentType == CellsModels.CellsModelsType.Entry) { back = back.transform.Find("trap_3").gameObject; back = back.transform.Find("trape_2 2").gameObject; StartCoroutine(OpenShutters(point, front, back)); } else if (m_EastModels.m_CurrentType == CellsModels.CellsModelsType.GenA) { back = back.transform.Find("trap_2").gameObject; back = back.transform.Find("trape_2 1").gameObject; StartCoroutine(OpenShutters(point, front, back)); } else if (m_EastModels.m_CurrentType == CellsModels.CellsModelsType.Exit) { back = back.transform.Find("trap_2").gameObject; back = back.transform.Find("trape_2").gameObject; StartCoroutine(OpenShutters(point, front, back)); } } break; } case CardinalPoint.South: { if (m_displayCell_S == false) { m_displayCell_S = true; GameObject front = null; if (m_CentreModels.m_EntryCell.activeSelf == true) { front = m_CentreModels.m_EntryCell.transform.Find("Trap_1").gameObject; front = front.transform.Find("trape_1").gameObject; } else if (m_CentreModels.m_GenCellA.activeSelf == true) { front = m_CentreModels.m_GenCellA.transform.Find("trap_0").gameObject; front = front.transform.Find("trape_2").gameObject; } GameObject back = m_SouthModels.GetActiveModel(); if (m_SouthModels.m_CurrentType == CellsModels.CellsModelsType.Entry) { back = back.transform.Find("trap_0").gameObject; back = back.transform.Find("trape_2").gameObject; StartCoroutine(OpenShutters(point, front, back)); } else if (m_SouthModels.m_CurrentType == CellsModels.CellsModelsType.GenA) { back = back.transform.Find("Trap_1").gameObject; back = back.transform.Find("trape_1").gameObject; StartCoroutine(OpenShutters(point, front, back)); } } break; } case CardinalPoint.West: { if (m_displayCell_W == false) { m_displayCell_W = true; GameObject front = null; if (m_CentreModels.m_EntryCell.activeSelf == true) { front = m_CentreModels.m_EntryCell.transform.Find("trap_3").gameObject; front = front.transform.Find("trape_2 2").gameObject; } else if (m_CentreModels.m_GenCellA.activeSelf == true) { front = m_CentreModels.m_GenCellA.transform.Find("trap_2").gameObject; front = front.transform.Find("trape_2 1").gameObject; } GameObject back = m_WestModels.GetActiveModel(); if (m_WestModels.m_CurrentType == CellsModels.CellsModelsType.Entry) { back = back.transform.Find("trap_2").gameObject; back = back.transform.Find("trape_2 1").gameObject; StartCoroutine(OpenShutters(point, front, back)); } else if (m_WestModels.m_CurrentType == CellsModels.CellsModelsType.GenA) { back = back.transform.Find("trap_3").gameObject; back = back.transform.Find("trape_2 2").gameObject; StartCoroutine(OpenShutters(point, front, back)); } else if (m_WestModels.m_CurrentType == CellsModels.CellsModelsType.Exit) { back = back.transform.Find("trap_3").gameObject; back = back.transform.Find("trape_2 1").gameObject; StartCoroutine(OpenShutters(point, front, back)); } } break; } } }