void OnVisibleChanged() { Debug.Log(string.Format("MemoryBoard.OnVisibleChanged. now visible: {0}", visible)); if (this.Tiles != null) { for (int i = 0; i < Tiles.Length; i++) { Tile tile = Tiles[i]; if (tile.Go == null || tile.TileMono == null) { continue; } TileMono tm = tile.TileMono; if (this.visible) { tm.ToBack(); } else { tm.ToSide(); } } if (this.visible) { this.ShowFlippedTiles(); } this.MemoryGui.InGameTextRoot.SetActive(this.visible); } }
public void CreateGameObject() { gameObject = (GameObject)MonoBehaviour.Instantiate(Resources.Load("Prefabs/Tiles/" + type.ToString()), new Vector3(position.x * 32, position.y * -32, 0), Quaternion.identity); TileMono tileMono = gameObject.AddComponent <TileMono>(); tileMono.tile = this; }
public GameObject ReapplyButton(GameObject button, string txt, string msgToCall, object parameter) { button.SetActive(true); TileMono tileMono = button.GetComponent <TileMono>(); tileMono.Front = new TileContent() { Text = txt, CallMessage = msgToCall, CallParameter = parameter }; tileMono.ToFront(); return(button); }
public void CreateGameObject() { if (type == TileType.VOID) { return; } gameObject = (GameObject)MonoBehaviour.Instantiate(Resources.Load("Prefabs/Tiles/" + type.ToString()), new Vector3( -ConfigManager.config.tileMap.width / 2 * ConfigManager.config.simulation.wallWidth + position.x * ConfigManager.config.simulation.wallWidth, +ConfigManager.config.tileMap.height / 2 * ConfigManager.config.simulation.wallWidth + position.y * -ConfigManager.config.simulation.wallWidth, 0), Quaternion.identity); gameObject.transform.SetParent(tileMap.ParentGameObject.transform); TileMono tileMono = gameObject.AddComponent <TileMono>(); tileMono.tile = this; }
void SetMousePosition() { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero, 200f, 1 << 8); //RaycastHit2D hitMouseLayer = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero, 200f, 1 << 9); if (hit) { if (hit.collider.gameObject.GetComponent <TileMono>()) { hoverTile = hit.collider.gameObject.GetComponent <TileMono>(); } } else { hoverTile = null; } mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); }
public void InitializeBoard() { ResetFlippedTiles(); DestroyAllTiles(); this.Tiles = new Tile[TileCount]; int y = 0; int x = 0; float xOffset = (TilesX / 2.0f) - 0.5f; float yOffset = (TilesY / 2.0f) - 0.5f; for (int i = 0; i < TileCount; i++) { this.Tiles[i] = new Tile() { Id = i }; GameObject cube = Instantiate(TilePrefab) as GameObject; cube.name = string.Format("Tile.{0:00}", i); cube.transform.parent = this.InGameRoot.transform; cube.transform.localPosition = new Vector3(x - xOffset, y - yOffset, 0); cube.transform.localScale = cube.transform.localScale * 0.95f; this.Tiles[i].Go = cube; TileMono tm = cube.GetComponent <TileMono>(); this.Tiles[i].TileMono = tm; x++; if (x >= TilesX) { x = 0; y++; } } }