public void SetTile(int x, int y, int tx, int ty) { MapKey mapKey = new MapKey(Mathf.FloorToInt(x / (float)mapSizeX), Mathf.FloorToInt(y / (float)mapSizeY)); if (worldMap == null) { worldMap = new MapDictionary(); } if (!worldMap.ContainsKey(mapKey)) { GameObject newmap = new GameObject(); newmap.transform.SetParent(transform, false); newmap.transform.localPosition = new Vector3(mapKey.x * mapSizeX, mapKey.y * mapSizeY, 0); newmap.hideFlags = HideFlags.HideInHierarchy; TileMap tmap = newmap.AddComponent <TileMap> (); tmap.tile_width = tileWidth; tmap.tile_height = tileHeight; tmap.GetComponent <MeshRenderer>().material = material; tmap.setTexture(texture); tmap.size_x = mapSizeX; tmap.size_y = mapSizeY; tmap.CreateMap(); worldMap.Add(mapKey, tmap); } worldMap [mapKey].setTile((x % mapSizeX + mapSizeX) % mapSizeX, (y % mapSizeY + mapSizeY) % mapSizeY, tx, ty); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { string region = value as string; if (region == null) { return(false); } return(MapDictionary.MapExists(region)); }
//--------------------------------------------------------------- public void WaveChangeHandling() { if (currentWaveChild) { if (currentWaveChild.childCount <= 0) { isWaveCleared = true; currentWaveChild.gameObject.SetActive(false); //clear the enemy paddle if all the enemy objects are removed /*if(enemyPaddleSpawner && enemyPaddleSpawner.transform.childCount>0){ * Destroy(enemyPaddleSpawner.transform.GetChild(0).gameObject); * }*/ if (currentWaveIndex + 1 < waveLength) { currentWaveIndex++; PlayerPrefManager.SetUITextStatus(PlayerPrefManager.GUITEXT_STATUS_CHANGING); UITextController.SetUITextStatusType(UITextController.DISPLAY_TEXT.WAVE, ""); currentWaveChild = enemyWaveSpawner.transform.GetChild(currentWaveIndex); } else if (currentWaveIndex + 1 >= waveLength && !saved) { waveHasStarted = false; WinLoseCondition wlCondition = GameObject.FindGameObjectWithTag("Win Lose Condition").GetComponent <WinLoseCondition>(); wlCondition.Win(); //Saving data when the stage was cleared //store collected gold to player data Inventory inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent <Inventory>(); PlayerProgress.playerData.gold += inventory.GetCollectedCoin(); //if the first time completing map if (!PlayerProgress.playerData.completedMaps.Contains(mapName)) { //store in to completed map list PlayerProgress.playerData.completedMaps.Add(mapName); if (!MapDictionary.CheckIsSecretMap(mapName)) { CheckForTheNextMap(); } } else // this map had been cleared before { RewardLoot.GetComponent <Reward>().SetHadLooted(); } SaveLoadSystem.SaveGame(PlayerProgress.playerData); saved = true; } } } }
//--------------------------------------------------------------- private string GetNextMapName() { string nextMapName = ""; int normalMapLength = MapDictionary.GetNormalMapsNumOfNowWorld(); for (int mapIndexOfCurrentWorld = 0; mapIndexOfCurrentWorld < normalMapLength; mapIndexOfCurrentWorld++) { if (mapName == MapDictionary.GetThisWorldLocations()[mapIndexOfCurrentWorld] && //and if this is not the last normal map in this current world mapIndexOfCurrentWorld != (normalMapLength - 1)) { nextMapName = MapDictionary.GetThisWorldLocations()[mapIndexOfCurrentWorld + 1]; return(nextMapName); } } return(nextMapName); }
public MapTab() { InitializeComponent(); MainWindow.Instance.PropertyChanged += (sender, e) => { if (e.PropertyName == nameof(MainWindow.Instance.CurrentSave)) { Debug.WriteLine("Currentsave changed"); if (MainWindow.Instance.CurrentSave == null) { region = null; UpdateMap(); return; } region = MainWindow.Instance.CurrentSave.Boot.m_SceneName.Value; playerPosition = new Point(MainWindow.Instance.CurrentSave.Global.PlayerManager.m_SaveGamePosition[0], MainWindow.Instance.CurrentSave.Global.PlayerManager.m_SaveGamePosition[2]); if (!MapDictionary.MapExists(region)) { region = MainWindow.Instance.CurrentSave.Global.GameManagerData.SceneTransition.m_LastOutdoorScene; playerPosition = new Point(MainWindow.Instance.CurrentSave.Global.GameManagerData.SceneTransition.m_PosBeforeInteriorLoad[0], MainWindow.Instance.CurrentSave.Global.GameManagerData.SceneTransition.m_PosBeforeInteriorLoad[2]); } UpdateMap(); var saveGamePosition = MainWindow.Instance.CurrentSave.Global.PlayerManager.m_SaveGamePosition; saveGamePosition.CollectionChanged += (sender2, e2) => { if ((e2.NewStartingIndex == 0 && saveGamePosition[0] != (float)playerPosition.X) || (e2.NewStartingIndex == 2 && saveGamePosition[2] != (float)playerPosition.Y)) { playerPosition.X = saveGamePosition[0]; playerPosition.Y = saveGamePosition[2]; UpdatePlayerPosition(); } }; MainWindow.Instance.CurrentSave.Boot.m_SceneName.PropertyChanged += (sender2, e2) => { if ((e2.PropertyName == "Value") && (region != MainWindow.Instance.CurrentSave.Boot.m_SceneName.Value)) { region = MainWindow.Instance.CurrentSave.Boot.m_SceneName.Value; Debug.WriteLine("New region: " + region); UpdateMap(); } }; } }; }
private void UpdateMap() { if (!IsLoaded) { return; } if (region == null) { mapImage.Source = null; mapInfo = null; player.Visibility = Visibility.Hidden; canvasLabel.Text = ""; canvasLabel.Visibility = Visibility.Visible; return; } if (!MapDictionary.MapExists(region)) { mapImage.Source = null; mapInfo = null; player.Visibility = Visibility.Hidden; canvasLabel.Text = "No map found for current region"; canvasLabel.Visibility = Visibility.Visible; return; } player.Visibility = Visibility.Visible; canvasLabel.Visibility = Visibility.Hidden; mapInfo = MapDictionary.GetMapInfo(region); mapImage.Source = ((Image)Resources[region]).Source; mapImage.Width = mapInfo.width; mapImage.Height = mapInfo.height; double wScale = canvas.ActualWidth / mapInfo.width; double hScale = canvas.ActualHeight / mapInfo.height; scaleMap.ScaleX = Math.Max(Math.Min(wScale, hScale), 0.5); scaleMap.ScaleY = Math.Max(Math.Min(wScale, hScale), 0.5); scaleOfPlayerIcon.ScaleX = 1 / scaleMap.ScaleX; scaleOfPlayerIcon.ScaleY = 1 / scaleMap.ScaleY; UpdatePlayerPosition(); }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { var result = new HashSet <string>(); foreach (object o in values) { if (o.GetType() == typeof(List <string>)) { var l = (List <string>)o; result.UnionWith(l); } else if (o.GetType() == typeof(string)) { result.Add((string)o); } } return(result.Select(item => new EnumerationMember { Value = item, Description = MapDictionary.GetInGameName(item) })); }
// Use this for initialization void Start() { mapDict = GameObject.FindObjectOfType <MapDictionary> (); inputField = inputFieldGameObj.GetComponent <InputField> (); textOfSttText = statusText.GetComponent <Text> (); //EXTENDABLE #1 optionally disable input or just keep player able to input /*inputSucceeded = mapDict.IsAllSecretMapRevealed(); * if(inputSucceeded){ * TurnOnOffInputFieldContent (true); * SetSttText(hasExistedText, Color.white); * inputField.interactable = false; * preventInputFlag = false; * return; * }*/ inputField.interactable = true; TurnOnOffMaptileDisplay(false); textOfSttText.text = introText; delayForRetry = maxDelayForRetry; }
//--------------------------------------------------------------- // Use this for initialization void Start() { mapScroller = mapPanel.transform.GetChild(0); scrollSnapRect = mapScroller.GetComponent <ScrollSnapRect>(); dotLocationNames = new string[MapDictionary.GetThisWorldLocations().Length]; //initialise name of each dot location based on the database map dictionary if (transform.childCount != MapDictionary.GetThisWorldLocations().Length) { Debug.LogError("the number of location dots is not equal to number of maps stored in database." + " Please make sure they are equal"); } for (int i = 0; i < transform.childCount; i++) { dotLocationNames[i] = MapDictionary.GetThisWorldLocations()[i]; } originRotation = transform.rotation; //ShowCorrespondIndicator(); mapPanel.SetActive(false); }
public void modifyHeight(Vector2 center, float range, float value) { int rangeX = (int)range / mapSizeX + 1; int rangeY = (int)range / mapSizeY + 1; for (int i = -rangeX; i <= rangeX; i++) { for (int j = -rangeY; j <= rangeY; j++) { MapKey mapKey = new MapKey(Mathf.FloorToInt((int)center.x / (float)mapSizeX + i), Mathf.FloorToInt((int)center.y / (float)mapSizeY + j)); if (worldMap == null) { worldMap = new MapDictionary(); } if (!worldMap.ContainsKey(mapKey)) { GameObject newmap = new GameObject(); newmap.transform.SetParent(transform, false); newmap.transform.localPosition = new Vector3(mapKey.x * mapSizeX, mapKey.y * mapSizeY, 0); newmap.hideFlags = HideFlags.HideInHierarchy; TileMap tmap = newmap.AddComponent <TileMap>(); tmap.tile_width = tileWidth; tmap.tile_height = tileHeight; tmap.GetComponent <MeshRenderer>().material = material; tmap.setTexture(texture); tmap.size_x = mapSizeX; tmap.size_y = mapSizeY; tmap.CreateMap(); worldMap.Add(mapKey, tmap); } Vector2 mcenter = center - (Vector2)worldMap[mapKey].transform.localPosition; worldMap[mapKey].modifyHeight(mcenter, range, value); } } }
private void Awake() { instance = this; DontDestroyOnLoad(gameObject); }
//------------------------------------------------------------------------ void Start() { _scrollRectComponent = GetComponent <ScrollRect>(); _scrollRectRect = GetComponent <RectTransform>(); _container = _scrollRectComponent.content; if (mapList.childCount != MapDictionary.GetThisWorldLocations().Length) { Debug.LogError("the number of maps in scene is not equal to the number of maps in the database"); } _pageCount = 0; mapList.gameObject.SetActive(true); for (int index = 0; index < mapList.childCount; index++) { string locationName = MapDictionary.GetThisWorldLocations()[index]; Transform mapTileObj = mapList.GetChild(index); //Set name for the map tile mapTileObj.GetComponent <MapTile>().SetMapName(locationName); //Compare the name with the name available in player data if (PlayerProgress.playerData.availableMaps.Contains(locationName)) { //copy the map tile and move to container GameObject mapTileToDisplay = Instantiate(mapTileObj.gameObject) as GameObject; mapTileToDisplay.transform.SetParent(_container.transform, false); //increase page number _pageCount++; //display corresponding dot worldMapGameObject.transform.GetChild(index).gameObject.SetActive(true); } else { worldMapGameObject.transform.GetChild(index).gameObject.SetActive(false); } } //Destroy(mapList.gameObject); mapList.gameObject.SetActive(false); // is it horizontal or vertical scrollrect if (_scrollRectComponent.horizontal && !_scrollRectComponent.vertical) { _horizontal = true; } else if (!_scrollRectComponent.horizontal && _scrollRectComponent.vertical) { _horizontal = false; } else { Debug.LogWarning("Confusing setting of horizontal/vertical direction. Default set to horizontal."); _horizontal = true; } _lerp = false; // init SetPagePositions(); SetPage(startingPage); //InitPageSelection(); SetPageSelection(startingPage); maptileSetUpEnd = true; // prev and next buttons if (nextButton) { nextButton.GetComponent <Button>().onClick.AddListener(() => { NextScreen(); }); } if (prevButton) { prevButton.GetComponent <Button>().onClick.AddListener(() => { PreviousScreen(); }); } }