예제 #1
0
        public Task <(Firebase, DataSnapshot)> PushStateToFirebaseAsync(WheatState state)
        {
            Init();
            var fbNode = fbRoot.Child("v1");
            var result = JsonUtility.ToJson(state);

            var taskCompletionSource = new TaskCompletionSource <(Firebase, DataSnapshot)>();

            fbNode.OnPushSuccess += (Firebase node, DataSnapshot pushedKeyInfo) => { taskCompletionSource.SetResult((node, pushedKeyInfo)); };;
            fbNode.OnPushFailed  += (Firebase fireBase, FirebaseError error) => { Debug.Log($"Error pushing data to firebase: {error.Message}"); taskCompletionSource.SetResult((fireBase, null)); };
            fbNode.Push(result);

            return(taskCompletionSource.Task);
        }
예제 #2
0
        private void InstantiateNewElement(WheatState state)
        {
            var newInstace = Instantiate(Prefab, new Vector3(0, 0, 0), Quaternion.identity); //location doesn't matter, gets overwritten by state's loc

            newInstace.State = state;

            // Set prefab copy so it doesn't disable itself automatically on Start & initialize it with state & enable
            newInstace.InitOnStart = true;
            newInstace.InitAndEnable();

            // fade new instance in -> set alpha to 0 & slowly move to 1
            newInstace.gameObject.SetFadeChildrenTextsAndSprites(0);
            newInstace.gameObject.DOFadeChildrenTextsAndSprites(1, 5, includeInactive: false);

            // need to update scale of other wheats to match final scale of generated wheat (after it grows to final size)
            newInstace.gameObject.transform.localScale *= UnzoomCoefInitial;
        }