예제 #1
0
    // Connecting objects

    public void Select(GameObject gameObject)
    {
        if (_selectedObjects.Count == 0 && gameObject.GetComponent <TurbineManager>() != null)
        {
            return;
        }


        if (_selectedObjects.Count == 1 && _selectedObjects.First().Equals(gameObject))
        {
            _selectedObjects = new List <GameObject> ();
            return;
        }

        _selectedObjects.Add(gameObject);

        if (_selectedObjects.Count == 2)
        {
            if (_selectedObjects[1].GetComponent <TurbineManager>() != null)
            {
                var temp = _selectedObjects[0];
                _selectedObjects[0] = _selectedObjects[1];
                _selectedObjects[1] = temp;
            }

            Debug.Assert(_selectedObjects[0].transform != null);
            Debug.Assert(_selectedObjects[1].transform != null);

            LineHelper.Connect(_selectedObjects [0].transform, _selectedObjects [1].transform);

            _selectedObjects [0].GetComponent <TurbineManager> ().GridManager.GridObjects.Add(_selectedObjects [1]);
            //GridManager.GridObjects.Add(_selectedObjects[1]);
            _selectedObjects = new List <GameObject> ();
            return;
        }
    }