Ejemplo n.º 1
0
        private void ShowGarbageTriggerEffect(bool value, Vector3 position, Action animOverCallback)
        {
            AnimationOnce effect = value ? _rightBinEffect : _wrongBinEffect;

            effect.gameObject.SetActive(true);
            effect.transform.position = position;
            if (animOverCallback != null)
            {
                effect.animationOver += animOverCallback;
            }
        }
Ejemplo 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;
        }