public void Initialization(MapDataHolder mapDataHolder) { #region Initialize Grids Proto_Grid[] gridOutlines = FindObjectsOfType <Proto_Grid>(); for (int j = 0; j < gridOutlines.Length; ++j) { this.gridOutlines.Add(gridOutlines[j]); } ResetGridAlpha(); #endregion reflectorColorsPanel.gameObject.SetActive(false); #region Initialize End Points allEndPoints = GameObject.FindGameObjectsWithTag("EndPoint"); numOfEndPoints = allEndPoints.Length; #endregion #region Initialize Max Window Time currentWindowTime = maxWindowTime = mapDataHolder.timeLimit; TimerSuccessText.text = maxWindowTime.ToString("F2"); #endregion #region Initialize Reflector Amount BasicWhiteReflectorStock = mapDataHolder.basicReflectorAmount; BasicRedReflectorStock = mapDataHolder.redBasicReflectorAmount; BasicYellowReflectorStock = mapDataHolder.yellowBasicReflectorAmount; BasicBlueReflectorStock = mapDataHolder.blueBasicReflectorAmount; TranslucentWhiteReflectorStock = mapDataHolder.translucentReflectorAmount; TranslucentRedReflectorStock = mapDataHolder.redTranslucentReflectorAmount; TranslucentYellowReflectorStock = mapDataHolder.yellowTranslucentReflectorAmount; TranslucentBlueReflectorStock = mapDataHolder.blueTranslucentReflectorAmount; DoubleWayWhiteReflectorStock = mapDataHolder.doubleWayReflectorAmount; DoubleWayRedReflectorStock = mapDataHolder.redDoubleWayReflectorAmount; DoubleWayYellowReflectorStock = mapDataHolder.yellowDoubleWayReflectorAmount; DoubleWayBlueReflectorStock = mapDataHolder.blueDoubleWayReflectorAmount; SplitWhiteReflectorStock = mapDataHolder.splitReflectorAmount; SplitRedReflectorStock = mapDataHolder.redSplitReflectorAmount; SplitYellowReflectorStock = mapDataHolder.yellowSplitReflectorAmount; SplitBlueReflectorStock = mapDataHolder.blueSplitReflectorAmount; ThreeWayWhiteReflectorStock = mapDataHolder.threeWayReflectorAmount; ThreeWayRedReflectorStock = mapDataHolder.redThreeWayReflectorAmount; ThreeWayYellowReflectorStock = mapDataHolder.yellowThreeWayReflectorAmount; ThreeWayBlueReflectorStock = mapDataHolder.blueThreeWayReflectorAmount; #endregion }
public MapEngine(Map map, MapDataHolder mapDataHolder) { _map = map; _spawnX = 400; _spawnY = 300; _usersOut = mapDataHolder.users; _usersMoveCoordinatesOut = mapDataHolder.usersMoveCoordinates; _killMonstersOut = mapDataHolder.killMonsters; _outInfoCurrentStateMap = mapDataHolder.outInfoCurrentStateMap; _disconnectUserOut = mapDataHolder.disconnectUser; _random = new Random(); _mapServiceDB = new MapServiceDB(); }
public Dictionary <int, MapDataHolder> RunMapsEngine() { foreach (var map in _maps) { MapDataHolder mapDataHolder = new MapDataHolder() { users = new List <User>(), usersMoveCoordinates = new List <Coordinates <User> >(), outInfoCurrentStateMap = new InfoCurrentStateMap(), killMonsters = new List <Monster>(), disconnectUser = new List <User>(), }; _collections.Add(map.Value.Id, mapDataHolder); MapEngine mapEnjine = new MapEngine(map.Value, mapDataHolder); Thread th = new Thread(mapEnjine.Run); th.Start(); break; } return(_collections); }
//------------------------------- OLD SCROLL SNAP SYSTEM -------------------------------// public void PopularizeDisplay(MainMenuLevelUI mainMenuLevelUI) { string targetStageStr = ""; if (mainMenuLevelUI.TargetMapInfo.mapName.Contains("(")) { int startIndex = mainMenuLevelUI.TargetMapInfo.mapName.IndexOf('(') + 1; int endIndex = mainMenuLevelUI.TargetMapInfo.mapName.IndexOf(')'); for (int i = startIndex; i < endIndex; i++) { targetStageStr += mainMenuLevelUI.TargetMapInfo.mapName[i]; } } else { targetStageStr = (mainMenuLevelUI.MapIndex + 1).ToString(); } txtStageNumber.text = targetStageStr; mapData = PersistentDataManager.Instance.GetMapDataHolder(mainMenuLevelUI.TargetMapInfo.mapName); btnSelectStage.onClick.RemoveAllListeners(); btnSelectStage.onClick.AddListener(() => { if (!MainMenuUIManager.Instance.SwitchingLevelPage) { PersistentDataManager.Instance.SelectedMapDataHolderNamePair = PersistentDataManager.Instance.GetMapDataHolderNamePair(mainMenuLevelUI.TargetMapInfo.mapName); PersistentDataManager.Instance.UpdateSelectedMapIndex(); btnSelectStage.interactable = false; SceneLoader.Instance.LoadSceneWithLoadingScreen(SCENE_ENUM.GAMEPLAY_SCENE); } }); // Toggle all to off for (int i = 0; i < levelLayout.transform.childCount; i++) { levelLayout.transform.GetChild(i).GetComponent <MapGridUI>().ToggleAllWalls(false); levelLayout.transform.GetChild(i).GetComponent <MapGridUI>().ToggleOriginPoint(default, Quaternion.identity, false);
public void LoadLevel(string levelName) { TextAsset loadedLevel = Resources.Load <TextAsset>("Map Datas/" + levelName); MapDataHolder mapDataHolder = JsonUtility.FromJson <MapDataHolder>(loadedLevel.text); foreach (var inSceneObjData in mapDataHolder.inSceneObjectDatas) { switch (inSceneObjData.inSceneObjectType) { case IN_SCENE_OBJECT_TYPES.NORMAL_HORIZONTAL_LINE: case IN_SCENE_OBJECT_TYPES.NORMAL_VERTICAL_LINE: transformBorders.GetChild(inSceneObjData.mapGridIndex).GetComponent <MapGridGameplay>().ToggleBorder(LASER_COLOR.DEFAULT, inSceneObjData.borderDir, true); break; case IN_SCENE_OBJECT_TYPES.WHITE_HORIZONTAL_LINE: case IN_SCENE_OBJECT_TYPES.WHITE_VERTICAL_LINE: transformBorders.GetChild(inSceneObjData.mapGridIndex).GetComponent <MapGridGameplay>().ToggleBorder(LASER_COLOR.WHITE, inSceneObjData.borderDir, true); break; case IN_SCENE_OBJECT_TYPES.RED_HORIZONTAL_LINE: case IN_SCENE_OBJECT_TYPES.RED_VERTICAL_LINE: transformBorders.GetChild(inSceneObjData.mapGridIndex).GetComponent <MapGridGameplay>().ToggleBorder(LASER_COLOR.RED, inSceneObjData.borderDir, true); break; case IN_SCENE_OBJECT_TYPES.YELLOW_HORIZONTAL_LINE: case IN_SCENE_OBJECT_TYPES.YELLOW_VERTICAL_LINE: transformBorders.GetChild(inSceneObjData.mapGridIndex).GetComponent <MapGridGameplay>().ToggleBorder(LASER_COLOR.YELLOW, inSceneObjData.borderDir, true); break; case IN_SCENE_OBJECT_TYPES.BLUE_HORIZONTAL_LINE: case IN_SCENE_OBJECT_TYPES.BLUE_VERTICAL_LINE: transformBorders.GetChild(inSceneObjData.mapGridIndex).GetComponent <MapGridGameplay>().ToggleBorder(LASER_COLOR.BLUE, inSceneObjData.borderDir, true); break; case IN_SCENE_OBJECT_TYPES.ORIGIN_POINT_WHITE: LaserOrigin originPointWhite = Instantiate(originPointPrefab, transformBorders.GetChild(inSceneObjData.mapGridIndex).transform.position, inSceneObjData.rotation, transformBorders.GetChild(inSceneObjData.mapGridIndex).transform); transformGrids.GetChild(inSceneObjData.mapGridIndex).gameObject.SetActive(false); originPointWhite.LaserColor = LASER_COLOR.WHITE; originPointWhite.Initialization(); break; case IN_SCENE_OBJECT_TYPES.ORIGIN_POINT_RED: LaserOrigin originPointRed = Instantiate(originPointPrefab, transformBorders.GetChild(inSceneObjData.mapGridIndex).transform.position, inSceneObjData.rotation, transformBorders.GetChild(inSceneObjData.mapGridIndex).transform); transformGrids.GetChild(inSceneObjData.mapGridIndex).gameObject.SetActive(false); originPointRed.LaserColor = LASER_COLOR.RED; originPointRed.Initialization(); break; case IN_SCENE_OBJECT_TYPES.ORIGIN_POINT_YELLOW: LaserOrigin originPointYellow = Instantiate(originPointPrefab, transformBorders.GetChild(inSceneObjData.mapGridIndex).transform.position, inSceneObjData.rotation, transformBorders.GetChild(inSceneObjData.mapGridIndex).transform); transformGrids.GetChild(inSceneObjData.mapGridIndex).gameObject.SetActive(false); originPointYellow.LaserColor = LASER_COLOR.YELLOW; originPointYellow.Initialization(); break; case IN_SCENE_OBJECT_TYPES.ORIGIN_POINT_BLUE: LaserOrigin originPointBlue = Instantiate(originPointPrefab, transformBorders.GetChild(inSceneObjData.mapGridIndex).transform.position, inSceneObjData.rotation, transformBorders.GetChild(inSceneObjData.mapGridIndex).transform); transformGrids.GetChild(inSceneObjData.mapGridIndex).gameObject.SetActive(false); originPointBlue.LaserColor = LASER_COLOR.BLUE; originPointBlue.Initialization(); break; case IN_SCENE_OBJECT_TYPES.DESTINATION_POINT_WHITE: LaserDestination endPointWhite = Instantiate(endPointPrefab, transformBorders.GetChild(inSceneObjData.mapGridIndex).transform.position, inSceneObjData.rotation, transformBorders.GetChild(inSceneObjData.mapGridIndex).transform); transformGrids.GetChild(inSceneObjData.mapGridIndex).gameObject.SetActive(false); endPointWhite.LaserColor = LASER_COLOR.WHITE; endPointWhite.Initialization(); break; case IN_SCENE_OBJECT_TYPES.DESTINATION_POINT_RED: LaserDestination endPointRed = Instantiate(endPointPrefab, transformBorders.GetChild(inSceneObjData.mapGridIndex).transform.position, inSceneObjData.rotation, transformBorders.GetChild(inSceneObjData.mapGridIndex).transform); transformGrids.GetChild(inSceneObjData.mapGridIndex).gameObject.SetActive(false); endPointRed.LaserColor = LASER_COLOR.RED; endPointRed.Initialization(); break; case IN_SCENE_OBJECT_TYPES.DESTINATION_POINT_YELLOW: LaserDestination endPointYellow = Instantiate(endPointPrefab, transformBorders.GetChild(inSceneObjData.mapGridIndex).transform.position, inSceneObjData.rotation, transformBorders.GetChild(inSceneObjData.mapGridIndex).transform); transformGrids.GetChild(inSceneObjData.mapGridIndex).gameObject.SetActive(false); endPointYellow.LaserColor = LASER_COLOR.YELLOW; endPointYellow.Initialization(); break; case IN_SCENE_OBJECT_TYPES.DESTINATION_POINT_BLUE: LaserDestination endPointBlue = Instantiate(endPointPrefab, transformBorders.GetChild(inSceneObjData.mapGridIndex).transform.position, inSceneObjData.rotation, transformBorders.GetChild(inSceneObjData.mapGridIndex).transform); transformGrids.GetChild(inSceneObjData.mapGridIndex).gameObject.SetActive(false); endPointBlue.LaserColor = LASER_COLOR.BLUE; endPointBlue.Initialization(); break; case IN_SCENE_OBJECT_TYPES.PORTAL_1ST_SET_HORIZONTAL: case IN_SCENE_OBJECT_TYPES.PORTAL_1ST_SET_VERTICAL: Teleporter teleporter1stSet = Instantiate(teleporterSetAPrefab, transformBorders.GetChild(inSceneObjData.mapGridIndex).GetComponent <MapGridGameplay>().GetBorderTransform(inSceneObjData.borderDir)); teleporter1stSet.SetRotation(inSceneObjData.borderDir); break; case IN_SCENE_OBJECT_TYPES.PORTAL_2ND_SET_HORIZONTAL: case IN_SCENE_OBJECT_TYPES.PORTAL_2ND_SET_VERTICAL: Teleporter teleporter2ndSet = Instantiate(teleporterSetBPrefab, transformBorders.GetChild(inSceneObjData.mapGridIndex).GetComponent <MapGridGameplay>().GetBorderTransform(inSceneObjData.borderDir)); teleporter2ndSet.SetRotation(inSceneObjData.borderDir); break; } } GameManager.Instance.Initialization(mapDataHolder); }