public MapData(MapPart map) { GameObject obj; info = map; obj = GameObject.Instantiate(info.prefab, info.bound.center, Quaternion.identity); inst = obj; }
protected void OnMapButtonClick(MapPart mp) { //Debug.Log("Invoked for button " + mp.gameObject.name + " on room " + mp.AssociatedRoom.name); if (_isEnabled) { TutorialManager.Instance.HideCurrentMessage(); //Inside transition coroutine hides approaching of another tutorial message GameManager.Instance.TransitionToRoom(mp.AssociatedRoom); HideMap(); } }
public void UpdateMap(Room newRoom) { MapPart mapPart = _mapParts.Find(x => x.Room == newRoom); mapPart.gameObject.SetActive(true); mapPart.SetPlayer(true); foreach (var mp in _mapParts) { if (mp.Room != newRoom) { mp.SetPlayer(false); } } }
public void Generate() { for (int i = 0; i < m_ResolutionCount; i++) { MapPart part = Instantiate <MapPart> (BasePrefab); float initZ = (m_ZOffsetCount + i) * m_Unit; part.transform.localPosition = new Vector3(0, m_PosY, initZ); part.transform.SetParent(transform); part.Initialize(); } }
internal void Replace(string oldValue, string newValue, int startIndex = 0, StringComparison stringComparison = StringComparison.CurrentCulture) { var i = Text.IndexOf(oldValue, startIndex, stringComparison); var dirty = i != -1; while (i != -1) { var part = new MapPart { StartIndex = i, EndIndex = i + oldValue.Length - 1 }; Replace(part, newValue); startIndex = i + newValue.Length; i = Text.IndexOf(oldValue, startIndex, stringComparison); } IsDirty = dirty; }
public MapData() { info = null; inst = null; }
// Use this for initialization protected void Start() { InputManager.Instance.OnInputClickUp.AddListener(PickUp); _totalMapLength = RoomsOnMap.Count + 1; _mapParts = new List <MapPart>(); Button[] buttons = MapObject.gameObject.GetComponentsInChildren <Button>(); int count = buttons.Length; for (int i = 0; i < count; ++i) { if (buttons[i].name.Contains("MapButtonBack")) { //_exitButton = buttons[i]; buttons[i].onClick.AddListener(new UnityAction(HideMap)); } } _mapButtonsGroup = MapObject.gameObject.GetComponentsInChildren <CanvasGroup>()[1]; _mapTitle = _mapButtonsGroup.gameObject.GetComponentsInChildren <Image>()[1]; MapEdgeFade[] fades = MapObject.gameObject.GetComponentsInChildren <MapEdgeFade>(); _fadeLeft = fades[0]; _fadeRight = fades[1]; _visiblePos = MapObject.GetComponent <RectTransform>().localPosition; _invisiblePos = new Vector2(_visiblePos.x + MapObject.GetComponent <RectTransform>().rect.width, _visiblePos.y); // calculate movementOneClick and scale factor RectTransform r = _mapTitle.GetComponent <RectTransform>(); _movementOneClick = new Vector2(r.rect.width /* * MAP_PART_PIECE_OVERLAY_MPLIER*/, 0.0f); _movementOneClickFromStart = new Vector2(r.rect.width * MAP_PART_PIECE_OVERLAY_MPLIER, 0.0f); // instantiate map parts according to part list Vector2 d = _movementOneClick; foreach (Room room in RoomsOnMap) { GameObject container = (GameObject)Instantiate(MapElementPrefab, Vector3.zero, Quaternion.identity); container.transform.SetParent(_mapButtonsGroup.transform, false); RectTransform tr = container.GetComponent <RectTransform>(); tr.sizeDelta = r.sizeDelta; //tr.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, MAP_PART_PIECE_OVERLAY_MPLIER); tr.localPosition += new Vector3(d.x, d.y, 0.0f); tr.localScale = Vector3.one; MapPart mp = container.GetComponent <MapPart>(); mp.AssociatedRoom = room; room.AssociatedMapPart = mp; mp.ClickedEvent.AddListener(new UnityAction <MapPart>(OnMapButtonClick)); if (room.Locked) { mp.Lock(); } else { mp.Unlock(); } _mapParts.Add(mp); if (mp.AssociatedRoom.Locked) { mp.GetComponentInChildren <FlashingButton>().enabled = false; } d.x += _movementOneClick.x; } InputManager.Instance.OnInputSwipe.AddListener(MoveInDirection); _fadeLeft.HideImmediate(); MapObject.gameObject.SetActive(false); MapObject.alpha = 0.0f; }
internal Text ReplaceWithText(MapPart part, string newText) { var startText = this[part.StartIndex].Element as Text; var startIndex = this[part.StartIndex].Index; var endText = this[part.EndIndex].Element as Text; var endIndex = this[part.EndIndex].Index; var addedText = new Text { Text = newText, Space = SpaceProcessingModeValues.Preserve }; var parents = new List <OpenXmlElement>(); var parent = startText.Parent; while (parent != null) { parents.Add(parent); parent = parent.Parent; } for (var i = Elements.IndexOf(endText); i >= Elements.IndexOf(startText); --i) { var element = Elements[i]; if (parents.Contains(element)) { // Do not remove parents. continue; } if (element == startText) { startText.Space = SpaceProcessingModeValues.Preserve; if (startText == endText) { string postScriptum = null; if (endIndex + 1 != startText.Text.Length) { postScriptum = startText.Text.Substring(endIndex + 1); } startText.Text = startText.Text.Substring(0, startIndex); if (!string.IsNullOrEmpty(postScriptum)) { startText.InsertAfterSelf(new Text { Text = postScriptum, Space = SpaceProcessingModeValues.Preserve }); } startText.InsertAfterSelf(addedText); } else { startText.Text = startText.Text.Substring(0, startIndex); startText.InsertAfterSelf(addedText); } } else if (element == endText) { endText.Space = SpaceProcessingModeValues.Preserve; endText.Text = endText.Text.Substring(endIndex + 1); } else { element.Remove(); } } return(addedText); }