/// <summary>
    /// 初始化
    /// </summary>
    public virtual void Init()
    {
        Time.timeScale = 1;
        gameState      = GameState.Play;
        GameDataController.GetInstance();

        Application.targetFrameRate = 60;

        if (gameData != null)
        {
            DiamantController[] diamants = FindObjectsOfType <DiamantController>();
            for (int i = 0; i < diamants.Length; i++)
            {
                if (diamants[i])
                {
                    diamants[i].SetGameData = gameData;
                    diamants[i].Init();
                }
            }
        }

        if (gameAwakeEvent != null)
        {
            gameAwakeEvent?.Invoke(0);
        }
    }
Beispiel #2
0
    private void ActivePlayer()
    {
        if (!isReset)
        {
            return;
        }
        if (InputController.GetInstance().TargetObj == this.gameObject && InputController.GetInstance().IsInputing)
        {
            if (generateGravity != null)
            {
                generateGravity.SetIsGravity = true;
                generateGravity.SetIsKinematic(false);
                isReset = false;
                isDie   = false;
            }
            if (particleController != null)
            {
                particleController.Play();
            }

            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                MusicMgr.GetInstance().PlaySound(GameDataController.GetInstance().musicData.GetSEClip(3));
            }

            if (particleDoTW)
            {
                particleDoTW.gameObject.SetActive(false);
            }
        }
    }
    public override void ShowUI()
    {
        //RemoveListener();
        if (!gameObject.activeSelf)
        {
            gameObject.SetActive(true);
        }

        oriRaidus = raidus;
        dir       = (raidus - targetRaidus) >= 0 ? 1 : -1;

        isForward = dir == 1 ? false : true;

        if (isForward)
        {
            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                MusicMgr.GetInstance().PlaySound(GameDataController.GetInstance().musicData.GetSEClip(1), false, 0.3f, true);
            }
        }
        else
        {
            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                MusicMgr.GetInstance().PlaySound(GameDataController.GetInstance().musicData.GetSEClip(2), false, 0.3f, true);
            }
        }

        tempTime = 0;

        cicle = new Vector4(center.x, center.y, raidus);
        AddListener();
    }
    public void UpdatedBGMMusic(AudioClip _clip)
    {
        if (MusicMgr.GetInstance() != null)
        {
            if (MusicMgr.GetInstance().GetBGMusic != null)
            {
                if (MusicMgr.GetInstance().GetBGMusic.clip != _clip)
                {
                    MusicMgr.GetInstance().PlayBGMMusicTransition(_clip, transitionTime);
                }
            }
            else
            {
                switch (target)
                {
                case DayAndNight.Day:
                default:
                    if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
                    {
                        MusicMgr.GetInstance().LoadPlayBGMusic(GameDataController.GetInstance().musicData.GetBGMClip(0));
                    }
                    break;

                case DayAndNight.Night:
                    if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
                    {
                        MusicMgr.GetInstance().LoadPlayBGMusic(GameDataController.GetInstance().musicData.GetBGMClip(1));
                    }
                    break;
                }
            }
        }
    }
    public void GameEnd()
    {
        Vector3 campoint = InputController.GetInstance().GetMainCam.WorldToScreenPoint(transform.parent.position);
        Vector2 center   = new Vector2(campoint.x / Screen.width, campoint.y / Screen.height);

        EventCenter.GetInstance().EventTrigger <Vector2>("GameEndVector2", center);
        EventCenter.GetInstance().EventTrigger("GameEnd");
        EventCenter.GetInstance().RemoveEventListener(EventData.playerReset, GameReset);

        if (gameData != null)
        {
            gameData.gameClearanceTime = (System.DateTime.Now - gameData.startTime).ToString();
            gameData.gameClearanceDate = System.DateTime.Now.ToString();
        }

        if (GameDataController.GetInstance() != null && GameDataController.GetInstance().sceneData != null)
        {
            string sceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
            if (GameDataController.GetInstance().sceneData.GetIsLock(sceneName))
            {
                //Debug.Log("GetIsLock");
                GameDataController.GetInstance().sceneData.ChangeSceneLock(sceneName, false);
            }

            GameDataController.GetInstance().GameSave();
        }



#if UNITY_IOS || UNITY_ANDROID
        InputController.GetInstance().IphoneShake();
#endif
    }
Beispiel #6
0
 private void ReplayButtonEvent()
 {
     if (!isButton)
     {
         EventCenter.GetInstance().EventTrigger(EventData.gameReset);
         if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
         {
             ButtonMusicEvent(GameDataController.GetInstance().musicData.GetSEClip(0), false);
         }
     }
 }
    public void GameStart()
    {
        isButton = false;

        EventCenter.GetInstance().RemoveEventListener("PartUIToMainUI", ShowUI);
        EventCenter.GetInstance().RemoveEventListener(EventData.HideHelpUI, ShowUI);

        if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
        {
            isPlayingMusic = GameDataController.GetInstance().musicData.isPlaying;
        }

        if (isPlayingMusic)
        {
            if (MusicMgr.GetInstance().GetBGMusic == null)
            {
                if (musicData)
                {
                    MusicMgr.GetInstance().LoadPlayBGMusic(musicData.GetBGMClip(0));
                }
                else
                {
                    MusicMgr.GetInstance().LoadPlayBGMusic("BGM");
                }
            }
            else if (MusicMgr.GetInstance().BGMusicIsPlaing == false)
            {
                MusicMgr.GetInstance().PlayBGMusic();
            }
        }
        else
        {
            if (MusicMgr.GetInstance().GetBGMusic == null)
            {
                if (musicData)
                {
                    MusicMgr.GetInstance().LoadBGMusic(musicData.GetBGMClip(0));
                }
                else
                {
                    MusicMgr.GetInstance().LoadBGMusic("BGM");
                }
            }
        }

        if (audioOpenImg != null && audioCloseImg != null)
        {
            audioOpenImg.gameObject.SetActive(isPlayingMusic);
            audioCloseImg.gameObject.SetActive(!isPlayingMusic);
        }

        //RemoveListener();
        AddListener();
    }
 private void BackPartButtonEvent()
 {
     if (!isButton)
     {
         EventCenter.GetInstance().EventTrigger <Vector2>("GameEndVector2", new Vector2(0.47f, 0.5f));
         if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
         {
             ButtonMusicEvent(GameDataController.GetInstance().musicData.GetSEClip(0), false);
         }
         isButton = true;
     }
 }
    private void HelpButtonEvent()
    {
        if (!isButton)
        {
            EventCenter.GetInstance().EventTrigger(EventData.ShowHelpUI);

            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                ButtonMusicEvent(GameDataController.GetInstance().musicData.GetSEClip(0), false);
            }

            isButton = true;
        }
    }
    private void OnTriggerEnter(Collider other)
    {
        if (gameData != null)
        {
            sOpNum = gameData.tempOpNum;
        }

        if (sOpNum < 0)
        {
            return;
        }

        if (Physics.CheckBox(transform.position, Vector3.one / 2, transform.rotation, layer))
        {
            if (sOpNum > 0)
            {
                sOpNum--;
                if (gameData != null && gameData.tempOpNum != sOpNum)
                {
                    gameData.tempOpNum = sOpNum;
                }
            }
            else if (sOpNum == 0)
            {
                sOpNum--;
                if (gameData != null && gameData.tempOpNum != sOpNum)
                {
                    gameData.tempOpNum = sOpNum;
                }
                GameEnd();
            }


            if (gameEndEvent != null)
            {
                gameEndEvent?.Invoke(null);
            }

            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                MusicMgr.GetInstance().PlaySound(GameDataController.GetInstance().musicData.GetSEClip(6));
            }

            this.gameObject.SetActive(false);
        }
    }
Beispiel #11
0
    public void DownColliderEvent()
    {
        if (Physics.CheckSphere(transform.position, transform.lossyScale.x / 1.5f, 1 << 0))
        {
            if (!isDowning)
            {
                isDowning = true;

                if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
                {
                    MusicMgr.GetInstance().PlaySound(GameDataController.GetInstance().musicData.GetSEClip(4));
                }
            }
        }
        else
        {
            isDowning = false;
        }
    }
    public void BackButtonEvent()
    {
        if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
        {
            ButtonMusicEvent(GameDataController.GetInstance().musicData.GetSEClip(0), false);
        }

        if (isButton)
        {
            return;
        }

        EventCenter.GetInstance().EventTrigger("PartUIToMainUI");
        isButton = true;
        HideUI();
        if (gameObject.activeSelf)
        {
            gameObject.SetActive(false);
        }
    }
    public void UpdatedBGMMusic()
    {
        switch (target)
        {
        case DayAndNight.Day:
        default:
            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                UpdatedBGMMusic(GameDataController.GetInstance().musicData.GetBGMClip(0));
            }
            break;

        case DayAndNight.Night:
            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                UpdatedBGMMusic(GameDataController.GetInstance().musicData.GetBGMClip(1));
            }
            break;
        }
    }
Beispiel #14
0
    public void BackButtonEvent()
    {
        if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
        {
            ButtonMusicEvent(GameDataController.GetInstance().musicData.GetSEClip(0), false);
        }

        if (isButton)
        {
            return;
        }

        if (backButtonEvent != null)
        {
            backButtonEvent.Invoke(0);
        }
        isButton = true;

        HideUI();
    }
Beispiel #15
0
    public void DownPlayerEvnet()
    {
        if (player == null)
        {
            return;
        }

        if (!isDie && player.transform.position.y < -5.5f)
        {
            isDie = true;
            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                MusicMgr.GetInstance().PlaySound(GameDataController.GetInstance().musicData.GetSEClip(5));
            }
        }

        if (player.transform.position.y < -8)
        {
            ResetPlayer();
        }
    }
Beispiel #16
0
    public void ListButtonEvent(string _sceneName)
    {
        //Debug.Log(_sceneName);
        /* ScenesMgr.GetInstance()*/
        //if (isButton) return;
        // isButton = true;
        if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
        {
            ButtonMusicEvent(GameDataController.GetInstance().musicData.GetSEClip(0), false);
        }

        EventCenter.GetInstance().EventTrigger <string>("MainMuneToGameScene", _sceneName);
        isButton = true;
#if UNITY_IOS || UNITY_ANDROID
        if (isButton)
        {
            return;
        }
        isButton = true;
        InputController.GetInstance().IphoneShake();
#endif
    }
    private void OnEnable()
    {
        if (partTrans != null && partUIDatas.buttonDatas != null)
        {
            if (partUIDatas != null && partUIDatas.buttonDatas != null && GameDataController.GetInstance() != null)
            {
                for (int j = 0; j < partUIDatas.buttonDatas.Length; j++)
                {
                    if (partUIDatas.buttonDatas[j] != null)
                    {
                        if (j == 0)
                        {
                            partUIDatas.buttonDatas[j].isLock = false;
                            continue;
                        }

                        if (GameDataController.GetInstance().IsPartClearance(partUIDatas.buttonDatas[j - 1].partName))
                        {
                            partUIDatas.buttonDatas[j].isLock = false;
                        }
                        else
                        {
                            partUIDatas.buttonDatas[j].isLock = true;
                        }
                    }
                }
            }

            for (int i = 0; i < partTrans.Count; i++)
            {
                btnPartID[i] = i;
                if (partBtn[i] != null && partUIDatas.buttonDatas[i] != null)
                {
                    partBtn[i].interactable = !partUIDatas.buttonDatas[i].isLock;
                }
            }
        }
    }
    private void MusicButtonEvent()
    {
        if (!isButton)
        {
            isButton = true;

            if (musicImag != null && musicOn != null && musicOff != null)
            {
                if (MusicMgr.GetInstance() != null)
                {
                    if (MusicMgr.GetInstance().BGMusicIsPlaing)
                    {
                        MusicMgr.GetInstance().PauseBGMusic();
                        musicImag.sprite = musicOff;
                        isMusic          = false;
                    }
                    else
                    {
                        //Debug.Log("MusicButtonEvent");
                        MusicMgr.GetInstance().UnPauseBGMusic();
                        musicImag.sprite = musicOn;
                        isMusic          = true;
                    }

                    if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
                    {
                        ButtonMusicEvent(GameDataController.GetInstance().musicData.GetSEClip(0), false);
                        GameDataController.GetInstance().musicData.isPlaying = isMusic;
                    }
                }
            }


            isButton = false;
        }
    }
    private void ListButtonEvent(int _num)
    {
        if (isButton)
        {
            return;
        }
        // Debug.Log(_num);


        EventCenter.GetInstance().EventTrigger <int>("PartUIToListUI", _num);
        if (GameDataController.GetInstance() != null)
        {
            GameDataController.GetInstance().SetPartID(_num);
            if (GameDataController.GetInstance().musicData != null)
            {
                ButtonMusicEvent(GameDataController.GetInstance().musicData.GetSEClip(0), false);
            }
        }
        // HideUI();
        // if (gameObject.activeSelf)
        //     gameObject.SetActive(false);
        isButton = true;
        RemoveListener();
    }
Beispiel #20
0
    protected override void ResetPlayer()
    {
        if (player == null)
        {
            return;
        }

        if (generateGravity != null)
        {
            if (particleDoTW)
            {
                particleDoTW.gameObject.SetActive(true);
            }
            StopPlayer();
            EventCenter.GetInstance().EventTrigger(EventData.playerReset);

            if (GameDataController.GetInstance() != null && GameDataController.GetInstance().musicData != null)
            {
                MusicMgr.GetInstance().StopSound(GameDataController.GetInstance().musicData.GetSEClip(5));
            }

            isReset = true;
        }
    }
    public override void Init()
    {
        EventCenter.GetInstance().RemoveEventListener("MainUIToPartUI", ShowUI);

        btnPartID = new int[partTrans.Count];
        partBtn   = new Button[partTrans.Count];
        Image[] partImage = new Image[partTrans.Count];
        Text[]  textA     = new Text[partTrans.Count];
        Text[]  textB     = new Text[partTrans.Count];

        Transform[] childTextA  = new Transform[partTrans.Count];
        Transform[] childTextB  = new Transform[partTrans.Count];
        Transform[] childButton = new Transform[partTrans.Count];

        if (partTrans != null && partTrans.Count > 0 && partUIDatas != null && partTrans.Count <= partUIDatas.buttonDatas.Length)
        {
            for (int i = 0; i < partTrans.Count; i++)
            {
                if (partTrans[i] == null)
                {
                    continue;
                }
                childTextA[i]  = partTrans[i].GetChild(0);
                childTextB[i]  = partTrans[i].GetChild(1);
                childButton[i] = partTrans[i].GetChild(2);

                childTextA[i].name  = i.ToString();
                childTextB[i].name  = partUIDatas.buttonDatas[i].partIDName != string.Empty ? partUIDatas.buttonDatas[i].partIDName : ((char)(65 + i)).ToString();
                childButton[i].name = partUIDatas.buttonDatas[i].partName != string.Empty ? partUIDatas.buttonDatas[i].partName : partTrans[i].gameObject.name;
                btnPartID[i]        = i;
            }
        }


        base.Init();

        sampleUI   = GetComponent <Animator>();
        showAnimID = AnimationMgr.GetInstance().GetAnimationID(animName);

        backBtn = GetControl <Button>(backButtonName);


        if (partUIDatas != null && partUIDatas.buttonDatas != null && GameDataController.GetInstance() != null)
        {
            for (int j = 0; j < partUIDatas.buttonDatas.Length; j++)
            {
                if (partUIDatas.buttonDatas[j] != null)
                {
                    if (j == 0)
                    {
                        partUIDatas.buttonDatas[j].isLock = false;
                        continue;
                    }

                    if (GameDataController.GetInstance().IsPartClearance(partUIDatas.buttonDatas[j - 1].partName))
                    {
                        partUIDatas.buttonDatas[j].isLock = false;
                        // Debug.Log("islock");
                    }
                    else
                    {
                        partUIDatas.buttonDatas[j].isLock = true;
                    }
                }
            }
        }


        if (partTrans != null && partUIDatas.buttonDatas != null)
        {
            for (int i = 0; i < partTrans.Count; i++)
            {
                btnPartID[i] = i;
                partBtn[i]   = GetControl <Button>(childButton[i].name);
                partImage[i] = GetControl <Image>(childButton[i].name);

                if (partImage[i] && partUIDatas.buttonDatas[i] != null)
                {
                    partImage[i].sprite = partUIDatas.buttonDatas[i].buttonImage;
                }

                if (partBtn[i] != null && partUIDatas.buttonDatas[i] != null)
                {
                    partBtn[i].interactable = !partUIDatas.buttonDatas[i].isLock;
                }

                textA[i] = GetControl <Text>(childTextA[i].name);
                textB[i] = GetControl <Text>(childTextB[i].name);

                if (textA[i] && partUIDatas.buttonDatas[i] != null)
                {
                    textA[i].text = partUIDatas.buttonDatas[i].partName;
                }
                if (textB[i])
                {
                    textB[i].text = childTextB[i].name;
                }
            }
        }

        ABtn = GetControl <Button>("ANAXIMANDER");

        partImage   = null;
        textA       = null;
        textB       = null;
        childTextA  = null;
        childTextB  = null;
        childButton = null;

        isButton = true;
        EventCenter.GetInstance().AddEventListener("MainUIToPartUI", ShowUI);
    }
Beispiel #22
0
 public void StartShowUI()
 {
     UpdateRoomData(GameDataController.GetInstance().GetPartID);
     ShowUI();
 }