Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (SelectedMECell != null)
        {
            Vector2 v = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            SelectedMECell.transform.position = v;

            if (Input.GetMouseButtonUp(1))
            {
                MapGenerator.mapGenerator.SelectedMECell = null;
            }
        }

        if (Input.GetKey(KeyCode.LeftShift))
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (GetComponent <Collider2D>().OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)))
                {
                    Vector2 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    verts.Add(pos);
                }
            }
            if (Input.GetMouseButtonDown(1))
            {
                if (GetComponent <Collider2D>().OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)))
                {
                    GameObject go = new GameObject();
                    MeshObject mo = go.AddComponent <MeshObject>();
                    mo.SetVerts(verts);
                    verts = new List <Vector3>();
                }
            }
        }


        if (Input.GetKey(KeyCode.LeftControl))
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (GetComponent <Collider2D>().OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)))
                {
                    Vector2            pos  = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    GameObject         go   = Instantiate(MECell, pos, Quaternion.identity) as GameObject;
                    LevelData.CellBall ball = new LevelData.CellBall();

                    ball.position = go.transform.position;

                    go.GetComponent <MECell>().ConnectToCell(ball);
                    go.GetComponent <MECell>().ToBrush();

                    mCurrentLevelData.CellBallList.Add(ball);
                }
            }
        }
    }