Пример #1
0
    void HandleLevelDoneState()
    {
        if (IsBallTouchingFinish() && !isLevelFinished)
        {
            isLevelFinished = true;
        }

        if (!isLevelFinished)
        {
            return;
        }

        GlobalSettings.finishTime = timePlaying;
        //keep ball on the same position if level is finished
        ball.GetComponent <Rigidbody2D>().isKinematic = true;
        ball.GetComponent <Ball>().isAtFinishLine     = true;

        afterFinishedTimer.Tick(Time.deltaTime);
        if (afterFinishedTimer.IsFinished())
        {
            LevelDesignInfo.SetTimeChangesOnLevelComplete(world, level, timePlaying);
            ScreenPrefabHolder prefabHolder = GameObject.Find("ScreenPrefabHolder").GetComponent <ScreenPrefabHolder>();
            Instantiate(prefabHolder.GetPrefab(ScreenPrefabHolder.e_screenID.AFTER_LEVEL_FINISHED), new Vector2(0, 0), Quaternion.identity);
            DestroyLevelObjects();
            Destroy(gameObject);
        }
    }
Пример #2
0
    void SetListeners()
    {
        //HOME
        homeBtn.onClick.AddListener(delegate {
            ScreenPrefabHolder prefabHolder = GameObject.Find("ScreenPrefabHolder").GetComponent <ScreenPrefabHolder>();
            Instantiate(prefabHolder.GetPrefab(ScreenPrefabHolder.e_screenID.MAIN_MENU), new Vector2(0, 0), Quaternion.identity);
            Destroy(gameObject);
        });

        //NEXT LEVEL
        nextBtn.onClick.AddListener(delegate {
            HandleNextLevelChange();

            ScreenPrefabHolder prefabHolder = GameObject.Find("ScreenPrefabHolder").GetComponent <ScreenPrefabHolder>();
            Instantiate(prefabHolder.GetPrefab(ScreenPrefabHolder.e_screenID.LEVEL), new Vector2(0, 0), Quaternion.identity);
            Destroy(gameObject);
        });

        //RESTART
        restartBtn.onClick.AddListener(delegate {
            ScreenPrefabHolder prefabHolder = GameObject.Find("ScreenPrefabHolder").GetComponent <ScreenPrefabHolder>();
            Instantiate(prefabHolder.GetPrefab(ScreenPrefabHolder.e_screenID.LEVEL), new Vector2(0, 0), Quaternion.identity);
            Destroy(gameObject);
        });
    }
Пример #3
0
    void InitButtonListeners()
    {
        //PLAY BUTTON
        playBtn.onClick.AddListener(delegate {
            ScreenPrefabHolder prefabHolder = GameObject.Find("ScreenPrefabHolder").GetComponent <ScreenPrefabHolder>();
            Instantiate(prefabHolder.GetPrefab(ScreenPrefabHolder.e_screenID.LEVEL_CHOICE), new Vector2(0, 0), Quaternion.identity);
            Destroy(gameObject);
        });

        //MUTE BUTTON
        muteBtn.onClick.AddListener(delegate {
            SoundManager soundManager = GameObject.Find("SoundManager").GetComponent <SoundManager>();
            if (soundManager.isMusicPlaying)
            {
                soundManager.StopBackgroundMusic();
                muteBtn.GetComponent <Image>().sprite = mutedSprite;
            }
            else
            {
                soundManager.PlayBackgroundMusic();
                muteBtn.GetComponent <Image>().sprite = notMutedSprite;
            }
        });

        //EXIT BUTTON
        exitBtn.onClick.AddListener(delegate {
            Application.Quit();
        });
    }
Пример #4
0
    void InitButtonListeners()
    {
        //HOME BUTTON...
        homeBtn.onClick.AddListener(delegate {
            ScreenPrefabHolder prefabHolder = GameObject.Find("ScreenPrefabHolder").GetComponent <ScreenPrefabHolder>();
            Instantiate(prefabHolder.GetPrefab(ScreenPrefabHolder.e_screenID.MAIN_MENU), new Vector2(0, 0), Quaternion.identity);
            Destroy(gameObject);
        });

        //LEFT BUTTON...
        leftBtn.onClick.AddListener(delegate {
            if (selectedWorld - 1 <= 0)
            {
                return;
            }
            selectedWorld--;
            SetLevelSlots(selectedWorld);
            redSignTxt.text = "World " + selectedWorld;
        });

        //RIGHT BUTTON...
        rightBtn.onClick.AddListener(delegate {
            if (selectedWorld + 1 > GlobalSettings.WORLD_COUNT)
            {
                return;
            }
            selectedWorld++;
            SetLevelSlots(selectedWorld);
            redSignTxt.text = "World " + selectedWorld;
        });

        //PLAY BUTTON...
        playBtn.onClick.AddListener(delegate {
            CreateLevelObject(selectedWorld, selectedLevel);
        });

        //LEVEL ITEM BUTTONS...
        for (int i = 0; i < slotList.Length; ++i)
        {
            GameObject loc_currSlot = slotList[i];
            loc_currSlot.GetComponent <Button>().onClick.AddListener(delegate {
                int newSelectedLvl = int.Parse(loc_currSlot.transform.FindChild("Text").GetComponent <Text>().text);
                SetSelectedLevel(newSelectedLvl);
            });
        }
    }