Example #1
0
    private void Awake()
    {
        transitioner = GetComponent <Transitioner>();
        mainTrans    = mainCanvas.GetComponent <Transitionable>();
        connectTrans = connectCanvas.GetComponent <Transitionable>();

        onLobbyErrorListener = new Action <IEventParam>(
            (e) =>
        {
            connectText.text = "Error: " + ((StringParam)e).val;
            errorConfirmButton.gameObject.SetActive(true);
        });

        onTryConnectListener = new Action <IEventParam>(
            (e) =>
        {
            IpParam p        = (IpParam)e;
            connectText.text = (p.host) ? "Hosting match" : "Connecting to " + p.ip;
        });

        onTryConnectTimeoutListener = new Action <IEventParam>(
            (e) =>
        {
            BoolParam p      = (BoolParam)e;
            connectText.text = "Failed to Connect";
            errorConfirmButton.gameObject.SetActive(true);
        });

        connectListener = new Action <IEventParam>(
            (e) =>
        {
            connectText.text = "Starting match...";
            EventManager.Instance.Raise("request-scene", new IntParam(2));
        });
    }
    // We could enbed this into a custom editor for efficiency ( which would be a better option for a propper game ),
    // however to make this example easier to follow through we simply do it when the component is started. Basically,
    // This method is a complete performance mess, so apart from testing just dont use it.
    private void FindAllTransitioners()
    {
        List <Transitionable> _foundObjects = new List <Transitionable>();                     // All the objects that are found

        for (int _i = 0; _i < _transitionableTags.Length; _i++)                                // Itterate through the tags
        {
            GameObject[] _cFound = GameObject.FindGameObjectsWithTag(_transitionableTags[_i]); // Find the current objects which have the itterated tag

            for (int _iFound = 0; _iFound < _cFound.Length; _iFound++)                         // Loop through all the found objects
            {
                Transitionable _t = new Transitionable(_cFound[_iFound].transform);            // Create a new Transitionable with the found transform

                // Create a random end position for the object
                _t.ePos = new Float3(Random.Range(_minRandPos + _t.position.x, _maxRandPos + _t.position.x),
                                     Random.Range(_minRandPos + _t.position.y, _maxRandPos + _t.position.y),
                                     Random.Range(_minRandPos + _t.position.z, _maxRandPos + _t.position.z));

                // Get a random size and assign the end scale to the random size
                float _rSize = Random.Range(_minRandScale, _maxRandScale);
                _t.eScale = new Float3(_rSize, _rSize, _rSize);

                _foundObjects.Add(_t);                 // Add the object to the found objects list
            }
        }

        _toMove = _foundObjects.ToArray();         // Transform the found objects list into an array
    }
Example #3
0
    IEnumerator GoOneWayCo(Transitionable origin, Transitionable target)
    {
        float t = origin.Out();

        //// Let origin finish before target begins
        //yield return new WaitForEndOfFrame();
        yield return(new WaitForSeconds(t));

        target.In();

        yield return(null);
    }
Example #4
0
 public void GoOneWay(Transitionable origin, Transitionable target)
 {
     StartCoroutine(GoOneWayCo(origin, target));
 }