コード例 #1
0
    public void DestroyOneTile(Vector3 position)
    {
        Vector3 tilePosition = tilemapCollider2D.ClosestPoint(position);

        tilePositionInt = tilemap.WorldToCell(tilePosition);
        Invoke("DestroyLater", 0.05f);
    }
コード例 #2
0
    public void Exit(Collider2D col)
    {
        if (!isProcessing)
        {
            isProcessing = true;
            if (col.tag == "Player")
            {
                Vector3Int collisionPoint = map.WorldToCell(tileMapCollider2D.ClosestPoint(col.transform.position));
                TileBase   hasTile        = map.GetTile(collisionPoint);
                if (hasTile != null)
                {
                    if (!isLastDoor[(Vector2Int)collisionPoint])
                    {
                        int door = doors[(Vector2Int)collisionPoint];
                        DirectorManager.DirectorInstance.UpdateState(door);

                        SceneTransistionManager.SceneInstance.TransitionToScene(typeOfScene.Game);
                    }
                    else
                    {
                        UIManager.UiInstance.ChangeStateTo(UIState.InScoreboard);
                    }
                }
            }
            isProcessing = false;
        }
        else
        {
            UIManager.UiInstance.ChangeStateTo(UIState.InScoreboard);
        }
    }
コード例 #3
0
    void SelectCell()
    {
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            Vector3 wp       = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            var     touchPos = new Vector2(wp.x, wp.y);

            Vector2 tilePos = collider.ClosestPoint(touchPos);


            Cell tile = (Cell)tilemap.GetTile(new Vector3Int((int)tilePos.x, (int)tilePos.y, 0));
            tile.alive = !tile.alive;
        }
    }