public MapGridObject.Type RevealGridPosition(Vector3 position) { MapGridObject mapGridObject = grid.GetGridObject(position); if (mapGridObject != null && !mapGridObject.IsRevealed() && !mapGridObject.IsFlagged()) { return(RevealGridPosition(mapGridObject)); } return(default);
private void SetupVisualNode(Transform visualNodeTransform, MapGridObject mapGridObject) { SpriteRenderer iconSpriteRenderer = visualNodeTransform.Find("iconSprite").GetComponent <SpriteRenderer>(); SpriteRenderer backgroundSprite = visualNodeTransform.Find("backgroundSprite").GetComponent <SpriteRenderer>(); SpriteRenderer Node = visualNodeTransform.Find("Node").GetComponent <SpriteRenderer>(); TextMeshPro indicatorText = visualNodeTransform.Find("mineIndicatorText").GetComponent <TextMeshPro>(); Transform hiddenTransform = visualNodeTransform.Find("hiddenSprite"); SpriteRenderer background = visualNodeTransform.Find("background").GetComponent <SpriteRenderer>(); if (mapGridObject.IsRevealed() || revealEntireMap) { // Node is revealed hiddenTransform.gameObject.SetActive(false); background.gameObject.SetActive(false); backgroundSprite.gameObject.SetActive(true); //iconSpriteRenderer.gameObject.SetActive(false); switch (mapGridObject.GetGridType()) { default: case MapGridObject.Type.Empty: backgroundSprite.gameObject.SetActive(false); indicatorText.gameObject.SetActive(false); iconSpriteRenderer.gameObject.SetActive(false); Node.gameObject.SetActive(true); break; case MapGridObject.Type.Mine: backgroundSprite.gameObject.SetActive(false); indicatorText.gameObject.SetActive(false); iconSpriteRenderer.gameObject.SetActive(true); Node.gameObject.SetActive(true); iconSpriteRenderer.sprite = mineSprite; break; case MapGridObject.Type.MineNum_1: case MapGridObject.Type.MineNum_2: case MapGridObject.Type.MineNum_3: case MapGridObject.Type.MineNum_4: case MapGridObject.Type.MineNum_5: case MapGridObject.Type.MineNum_6: case MapGridObject.Type.MineNum_7: case MapGridObject.Type.MineNum_8: backgroundSprite.gameObject.SetActive(false); indicatorText.gameObject.SetActive(true); iconSpriteRenderer.gameObject.SetActive(false); Node.gameObject.SetActive(true); switch (mapGridObject.GetGridType()) { default: case MapGridObject.Type.MineNum_1: indicatorText.SetText("1"); indicatorText.color = UtilsClass.GetColorFromString("2F58EF"); break; case MapGridObject.Type.MineNum_2: indicatorText.SetText("2"); indicatorText.color = UtilsClass.GetColorFromString("4DE700"); break; case MapGridObject.Type.MineNum_3: indicatorText.SetText("3"); indicatorText.color = UtilsClass.GetColorFromString("E53144"); break; case MapGridObject.Type.MineNum_4: indicatorText.SetText("4"); indicatorText.color = UtilsClass.GetColorFromString("000000"); break; case MapGridObject.Type.MineNum_5: indicatorText.SetText("5"); indicatorText.color = UtilsClass.GetColorFromString("000000"); break; case MapGridObject.Type.MineNum_6: indicatorText.SetText("6"); indicatorText.color = UtilsClass.GetColorFromString("000000"); break; case MapGridObject.Type.MineNum_7: indicatorText.SetText("7"); indicatorText.color = UtilsClass.GetColorFromString("000000"); break; case MapGridObject.Type.MineNum_8: indicatorText.SetText("8"); indicatorText.color = UtilsClass.GetColorFromString("000000"); break; } break; } } else { // Node is hidden if (mapGridObject.IsFlagged()) { //iconSpriteRenderer.gameObject.SetActive(true); backgroundSprite.gameObject.SetActive(false); background.gameObject.SetActive(true); hiddenTransform.gameObject.SetActive(true); iconSpriteRenderer.sprite = flagSprite; } //else //{ // iconSpriteRenderer.gameObject.SetActive(false); //} } }
private void SetupVisualNode(Transform visualNode, MapGridObject mapGridObject) { SpriteRenderer iconSpriteRenderer = visualNode.Find(GRID_OBJECT_ICON_SPRITE_NAME).GetComponent <SpriteRenderer>(); TextMeshPro indicatorText = visualNode.Find(GRID_OBJECT_MINE_INDICATOR_NAME).GetComponent <TextMeshPro>(); Transform nodeTopTransform = visualNode.Find(GRID_OBJECT_TOP_SPRITE_NAME); if (mapGridObject.IsRevealed() || revealMap) { nodeTopTransform.gameObject.SetActive(false); switch (mapGridObject.GetGridObjectType()) { default: case MapGridObject.Type.Empty: indicatorText.gameObject.SetActive(false); iconSpriteRenderer.gameObject.SetActive(false); break; case MapGridObject.Type.Mine: indicatorText.gameObject.SetActive(false); iconSpriteRenderer.gameObject.SetActive(true); iconSpriteRenderer.sprite = mineSprite; break; case MapGridObject.Type.MineNum_1: case MapGridObject.Type.MineNum_2: case MapGridObject.Type.MineNum_3: case MapGridObject.Type.MineNum_4: case MapGridObject.Type.MineNum_5: case MapGridObject.Type.MineNum_6: case MapGridObject.Type.MineNum_7: case MapGridObject.Type.MineNum_8: indicatorText.gameObject.SetActive(true); iconSpriteRenderer.gameObject.SetActive(false); switch (mapGridObject.GetGridObjectType()) { default: case MapGridObject.Type.MineNum_1: indicatorText.SetText("1"); break; case MapGridObject.Type.MineNum_2: indicatorText.SetText("2"); break; case MapGridObject.Type.MineNum_3: indicatorText.SetText("3"); break; case MapGridObject.Type.MineNum_4: indicatorText.SetText("4"); break; case MapGridObject.Type.MineNum_5: indicatorText.SetText("5"); break; case MapGridObject.Type.MineNum_6: indicatorText.SetText("6"); break; case MapGridObject.Type.MineNum_7: indicatorText.SetText("7"); break; case MapGridObject.Type.MineNum_8: indicatorText.SetText("8"); break; } break; } } else { nodeTopTransform.gameObject.SetActive(true); if (mapGridObject.IsFlagged()) { iconSpriteRenderer.gameObject.SetActive(true); iconSpriteRenderer.sortingOrder = 4; iconSpriteRenderer.sprite = flagSprite; } else { iconSpriteRenderer.gameObject.SetActive(false); } } }