Exemple #1
0
    // Use this for initialization
    void Awake()
    {
        _Instance = this;
        int max = NameAlphaArray.Length;

        for (int i = 0; i < max; i++)
        {
            NameAlphaArray[i].enabled = false;
        }
        IndexPlayerVal = -1;
        gameObject.SetActive(false);
    }
    void NetCtrlSendPlayerIndexNameInfo(string ipInfo, int indexVal)
    {
        if (Network.player.ipAddress != ipInfo)
        {
            return;
        }

        ScreenLog.Log("NetCtrlSendPlayerIndexNameInfo -> ipInfo " + ipInfo + ", indexVal " + indexVal);
        ScreenLog.Log("NetCtrlSendPlayerIndexNameInfo -> ipAddress " + Network.player.ipAddress);
        LinkPlayerNameCtrl.IndexPlayerVal = indexVal;
        if (LinkPlayerNameCtrl.GetInstance() != null)
        {
            LinkPlayerNameCtrl.GetInstance().ActivePlayerInfo();
        }
    }
    public void ActivePlayerLinkGame()
    {
        if (!Mode.activeSelf)
        {
            return;
        }

        if (CanAddMusic)
        {
            // guan ka xuan ze diao luo shi de yin xiao
            AudioManager.Instance.PlaySFX(modeSelectAudio);
            CanAddMusic = false;
        }

        //ScreenLog.Log("single player mode");
        StopAllCoroutines();
        IsChangeGameLevel = false;
        Mode.SetActive(false);
        Starts.SetActive(false);
        pcvr.StartLightStateP1 = LedState.Mie;
        Leve.SetActive(true);
//		SelectObj.SetActive(true);
        LinkPlayerNameCtrl.GetInstance().ActivePlayerInfo();
    }
    void ClickStartBtEvent(ButtonState val)
    {
        //ScreenLog.Log("StartSenceChangeUI::ClickStartBtEvent -> val " + val);
        if (val == ButtonState.DOWN)
        {
            return;
        }

        if (Starts.activeSelf && !Leve.activeSelf)
        {
            AudioManager.Instance.PlaySFX(startAudio);
        }

        if (Starts.activeSelf && !Mode.activeSelf && !Leve.activeSelf)
        {
            //an kai shi jian
            TouBiScript.subPlayerCoin();

            StartCoroutine(ColorCorrection(0));

            Starts.SetActive(false);
            pcvr.StartLightStateP1 = LedState.Mie;
            StopCoroutine("Timer");
            StartCoroutine("Tuise");
        }
        else if (Starts.activeSelf && Mode.activeSelf)
        {
            if (!IsSelectGameMode)
            {
                Invoke("resetIsSelectGameMode", 3.0f);
            }
            IsSelectGameMode = true;

            //mo shi xuan ze
            if (GlobalData.GetInstance().gameMode == GameMode.SoloMode)
            {
                if (CanAddMusic)
                {
                    // guan ka xuan ze diao luo shi de yin xiao
                    AudioManager.Instance.PlaySFX(modeSelectAudio);
                    CanAddMusic = false;
                }

                //ScreenLog.Log("single player mode");
                StopAllCoroutines();
                Mode.SetActive(false);
                Leve.SetActive(true);
                SelectObj.SetActive(true);
                LinkPlayerNameCtrl.GetInstance().HiddenPlayerInfo();
                if (NetworkServerNet.GetInstance() != null)
                {
                    NetworkServerNet.GetInstance().SetIsDisconnect();
                }
            }
            else
            {
                if (NetCtrlScript == null)
                {
                    //ScreenLog.LogWarning("NetCtrlScript is null");
                    return;
                }

                NetworkServerNet NetworkServerScript = NetworkServerNet.GetInstance();
                if (NetworkServerScript != null && !NetworkServerScript.CheckIsLinkedServerPort())
                {
                    //ScreenLog.LogWarning("the client have not linked server...");
                    return;
                }

                if (!isHandleNetLink)
                {
                    //ScreenLog.Log("link server mode");
                    isHandleNetLink = true;

                    NetCtrlScript.ClientCallHandleSelectLinkCount(true);
                }
            }
        }
    }
    void clickStartBt(int key)
    {
        if (!bIsClickStartBt)
        {
            return;
        }

        if (bIsSelectLeve)
        {
            return;
        }
        bIsClickStartBt     = false;
        bIsSelectLeve       = true;
        IsCanActiveSetPanel = false;

        //reset IsSelectGameMode
        StartSenceChangeUI.IsSelectGameMode = false;
        if ((Starts.activeSelf && key == 0) || key == 1)
        {
            Starts.SetActive(false);
            if (GlobalData.GetInstance().LinkModeState != 0 &&
                !GlobalData.GetInstance().IsFreeMode)
            {
                Toubi.GetInstance().subPlayerCoin();
            }

            pcvr.StartLightStateP1 = LedState.Mie;
            if (GlobalData.GetInstance().gameMode == GameMode.OnlineMode)
            {
                LinkPlayerNameCtrl.GetInstance().HiddenPlayerInfo();
                if (key == 0)
                {
                    NetCtrlScript.handleSelectLevel((int)GlobalData.GetInstance().gameLeve);
                }
                else
                {
                    SelectObj.SetActive(false);
                    GlobalData.GetInstance().gameLeve = NetCtrlScript.GetSelectGameLevel();
                    NetCtrlScript.handleResetLinkCount();
                    //ScreenLog.Log("********** level " + GlobalData.GetInstance().gameLeve);
                }
            }

            if (GlobalData.GetInstance().gameMode == GameMode.OnlineMode && key == 0)
            {
                NetCtrlScript.handleLoadLevel();
            }

            if (GlobalData.GetInstance().gameLeve == GameLeve.Leve1)
            {
                Leve2.SetActive(false);
                StopAllCoroutines();
                Leve1.GetComponent <TweenPosition>().enabled = false;
                Leve1Hover.enabled   = false;
                Leve1Unhover.enabled = false;
                //Leve1UI.spriteName="diYiGuanDaTu";
                //Leve1UITexture.mainTexture = Leve1Texture[2];
                Leve1.transform.position    = Vector3.zero;
                Leve1.transform.eulerAngles = Vector3.zero;
                TweenScale scale = Leve1.GetComponent <TweenScale>();
                scale.PlayForward();
                EventDelegate.Add(scale.onFinished, delegate {
                    //AudioManager.Instance.PlayBGM(BackgroundAudio,true);
                    AudioSourceObj      = AudioManager.Instance.audio;
                    AudioSourceObj.clip = BackgroundAudio;
                    AudioSourceObj.loop = true;
                    AudioSourceObj.Play();

                    InvokeRepeating("changeBackgroundSdVol", 0f, 1.5f);
                    StartCoroutine("ColorCorrection");
                });
            }
            else if (GlobalData.GetInstance().gameLeve == GameLeve.Leve2)
            {
                Leve1.SetActive(false);
                StopAllCoroutines();
                Leve2.GetComponent <TweenPosition>().enabled = false;
                Leve2Hover.enabled   = false;
                Leve2UnHover.enabled = false;
                //Leve2UITexture.mainTexture = Leve2Texture[2];
                //Leve2UI.spriteName="diErGuanDaTu";
                Leve2.transform.position    = Vector3.zero;
                Leve2.transform.eulerAngles = Vector3.zero;
                TweenScale scale = Leve2.GetComponent <TweenScale>();
                scale.PlayForward();
                EventDelegate.Add(scale.onFinished, delegate {
                    AudioSourceObj      = AudioManager.Instance.audio;
                    AudioSourceObj.clip = BackgroundAudio;
                    AudioSourceObj.loop = true;
                    AudioSourceObj.Play();

                    InvokeRepeating("changeBackgroundSdVol", 0f, 1.5f);
                    StartCoroutine("ColorCorrection");
                });
            }
        }
    }