Esempio n. 1
0
 private void OnGarbageDestroy(Garbage garbage, bool value)
 {
     ++_destroyedGarbageCount;
     if (value)
     {
         if (IsAllGarbageCollected())
         {
             ShowGarbageTriggerEffect(true, garbage.transform.position, () => UIFacade.ShowUI?.Invoke(UIDef.ACCOMPLISHED));
         }
         else
         {
             ShowGarbageTriggerEffect(true, garbage.transform.position, null);
         }
     }
     else
     {
         Time.timeScale = 0;
         ShowGarbageTriggerEffect(false, garbage.transform.position, () => { UIFacade.ShowUIByParam?.Invoke(UIDef.TIPS, garbage.Conf); });
     }
 }
Esempio n. 2
0
        private void Awake()
        {
            transform.Find("AirBarrier/Tilemap").GetComponent <Tilemap>().color = Color.clear;

            _player = transform.Find("Player/Character").gameObject.AddComponent <Player>();

            Transform garbageRootTrans = transform.Find("Garbage");
            int       count            = garbageRootTrans.childCount;

            _garbageArray = new Garbage[count];
            ConfGarbage[] confList   = ConfGarbage.Array;
            int           confLength = confList.Length;

            if (confLength == 0)
            {
                return;
            }
            for (int i = 0; i < count; i++)
            {
                Garbage garbage     = garbageRootTrans.GetChild(i).gameObject.AddComponent <Garbage>();
                int     randomIndex = UnityEngine.Random.Range(0, confLength);
                garbage.Conf     = confList[randomIndex];
                _garbageArray[i] = garbage;
            }

            _rightBinEffect = transform.Find("Effects/RightBin").GetComponent <AnimationOnce>();
            _wrongBinEffect = transform.Find("Effects/WrongBin").GetComponent <AnimationOnce>();

            if (Camera.main != null)
            {
                Camera.main.gameObject.AddComponent <CameraController>();
            }

            UIFacade.HideUIAll?.Invoke();
            UIFacade.ShowUI?.Invoke(UIDef.LEVEL_MAIN);

            SceneFacade.IsAllGarbageCollected += IsAllGarbageCollected;
            SceneFacade.OnGarbageDestroy      += OnGarbageDestroy;
        }