예제 #1
0
    // Use this for initialization
    void Start()
    {
        if (FreeModeCtrl.IsServer)
        {
            AudioListener.volume = 0f;
        }
        else
        {
            AudioListener.volume = (float)GlobalData.GetInstance().ReadGameAudioVolume() / 10f;
        }

        TimeLast = Time.realtimeSinceStartup;
        if (GameMovieCtrl.GetInstance() == null)
        {
            GameObject obj  = (GameObject)Instantiate(MoviePrefab);
            Transform  tran = obj.transform;
            tran.parent           = transform;
            tran.localPosition    = new Vector3(0.0f, 0.0f, 0.0f);
            tran.localEulerAngles = new Vector3(0.0f, 0.0f, 0.0f);
            tran.localScale       = new Vector3(1.0f, 1.0f, 1.0f);
        }
        else
        {
            GameMovieCtrl.GetInstance().PlayMovie();
            Transform tran = GameMovieCtrl.GetInstance().transform;
            tran.parent           = transform;
            tran.localPosition    = new Vector3(0.0f, 0.0f, 0.0f);
            tran.localEulerAngles = new Vector3(0.0f, 0.0f, 0.0f);
            tran.localScale       = new Vector3(1.0f, 1.0f, 1.0f);
        }
    }
예제 #2
0
    void Awake()
    {
        if (GameMovieCtrl.GetInstance() != null &&
            GameMovieCtrl.GetInstance().GameLinkSt == GameMovieCtrl.GameLinkEnum.NO_LINK)
        {
            return;
        }

        if (!pcvr.bIsHardWare)
        {
            MasterServerIp = HandleJson.GetInstance().ReadFromFilePathXml(MasterServerIpFile, "MasterServerIp");
            if (MasterServerIp == null || MasterServerIp == "")
            {
                MasterServerIp = "192.168.0.2";
                HandleJson.GetInstance().WriteToFilePathXml(MasterServerIpFile, "MasterServerIp", MasterServerIp);
            }
        }
        Debug.Log("MasterServerIp " + MasterServerIp);

        if (MasterServerIp == Network.player.ipAddress)
        {
            XKMasterServerCtrl.CheckMasterServerIP();
        }

        MasterServer.ipAddress   = MasterServerIp;
        Network.natFacilitatorIP = MasterServerIp;
    }
    private void ClickTVYaoKongExitBtEvent(pcvr.ButtonState val)
    {
        switch (val)
        {
        case pcvr.ButtonState.DOWN:
        {
            ClickTVYaoKongLeftBtEvent(val);
            QuXiaoUI.mainTexture = QuXiaoImg[1];
            break;
        }

        case pcvr.ButtonState.UP:
        {
            QuXiaoUI.mainTexture = QuXiaoImg[0];
            Debug.Log("Unity:" + "Player close exit game ui...");
            if (XkGameCtrl.GetInstance() != null)
            {
                XkGameCtrl.GetInstance().RemoveExitGameUI();
            }

            if (GameMovieCtrl.GetInstance() != null)
            {
                GameMovieCtrl.GetInstance().RemoveExitGameUI();
            }
            break;
        }
        }
    }
    private void ClickTVYaoKongEnterBtEvent(pcvr.ButtonState val)
    {
        if (m_ExitType == ExitEnum.QuXiao)
        {
            switch (val)
            {
            case pcvr.ButtonState.DOWN:
            {
                QuXiaoUI.mainTexture = QuXiaoImg[1];
                break;
            }

            case pcvr.ButtonState.UP:
            {
                QuXiaoUI.mainTexture = QuXiaoImg[0];
                Debug.Log("Unity:" + "Player close exit game ui...");
                if (XkGameCtrl.GetInstance() != null)
                {
                    XkGameCtrl.GetInstance().RemoveExitGameUI();
                }

                if (GameMovieCtrl.GetInstance() != null)
                {
                    GameMovieCtrl.GetInstance().RemoveExitGameUI();
                }
                break;
            }
            }
        }

        if (m_ExitType == ExitEnum.QueDing)
        {
            switch (val)
            {
            case pcvr.ButtonState.DOWN:
            {
                QueDingUI.mainTexture = QueDingImg[1];
                break;
            }

            case pcvr.ButtonState.UP:
            {
                QueDingUI.mainTexture = QueDingImg[0];
                Debug.Log("Unity:" + "Player exit application...");
                if (XkGameCtrl.GetInstance() != null)
                {
                    XkGameCtrl.GetInstance().RemoveExitGameUI();
                }

                if (GameMovieCtrl.GetInstance() != null)
                {
                    GameMovieCtrl.GetInstance().RemoveExitGameUI();
                }
                Application.Quit();
                break;
            }
            }
        }
    }
    void CloseMovie()
    {
        GameMovieCtrl.GetInstance().stopPlayMovie();
        MovieObj.SetActive(false);
        InsertCoinObj.SetActive(false);

        if (!GlobalData.GetInstance().IsFreeMode)
        {
            StartBtObj.SetActive(true);
        }
        CenterObj.SetActive(true);
        AudioManager.Instance.PlayBGM(AudioListCtrl.GetInstance().AudioMovieBeiJing, true);
    }
예제 #6
0
    void loadLevelSetPanel()
    {
        if (XkGameCtrl.IsLoadingLevel)
        {
//			Debug.Log("*************Loading...");
            return;
        }

        if (!XkGameCtrl.IsGameOnQuit)
        {
            if (GameMovieCtrl.GetInstance() != null)
            {
                GameMovieCtrl.GetInstance().StopPlayMovie();
            }
            System.GC.Collect();
            SceneManager.LoadScene((int)GameLevel.SetPanel);
        }
    }
    void loadLevelSetPanel()
    {
        if (XkGameCtrl.IsLoadingLevel)
        {
//			Debug.Log("*************Loading...");
            return;
        }
        XkGameCtrl.IsLoadingLevel = true;

        if (!XkGameCtrl.IsGameOnQuit)
        {
            if (GameMovieCtrl.GetInstance() != null)
            {
                GameMovieCtrl.GetInstance().StopPlayMovie();
            }
            System.GC.Collect();
            Application.LoadLevel((int)GameLevel.SetPanel);
        }
    }
    void clickStartBtOne()
    {
        if (!StartBtObj.activeSelf)
        {
            return;
        }

        if (!isActiveMode)
        {
            isActiveMode = true;
            HiddenActiveJiaShi();
            backgroudSprite.color = new Color(47f / 255f, 47f / 255f, 47f / 255f, 1f);

            AudioManager.Instance.PlaySFX(AudioListCtrl.GetInstance().AudioXuanZe);
            StartBtObj.SetActive(false);
            if (GameMovieCtrl.GetInstance().GameLinkSt == GameMovieCtrl.GameLinkEnum.LINK)
            {
                ModeObj.SetActive(true);
                SelecteCartoon.GetInstance().Invoke("InitSelecteCartoon", 0.5f);
            }

            if (!GlobalData.GetInstance().IsFreeMode)
            {
                //ScreenLog.Log("****************1111JianBi");
                if (!pcvr.bIsHardWare)
                {
                    if (GlobalData.GetInstance().Icoin >= GlobalData.GetInstance().XUTOUBI)
                    {
                        GlobalData.GetInstance().Icoin -= GlobalData.GetInstance().XUTOUBI;
                        ConvertNumToImg("yi", GlobalData.GetInstance().Icoin);
                    }
                }
                else
                {
                    subPlayerCoin();
                }
            }
            else
            {
                if (MovieObj.activeSelf)
                {
                    movieTScale         = MovieObj.GetComponent <TweenScale>();
                    movieTScale.enabled = true;
                    EventDelegate.Add(movieTScale.onFinished, delegate {
                        Invoke("CloseMovie", 0f);
                    });
                }
            }

            if (GameMovieCtrl.GetInstance().GameLinkSt == GameMovieCtrl.GameLinkEnum.NO_LINK)
            {
                if (!isSelectMode)
                {
                    GlobalData.GetInstance().gameMode = GameMode.SoloMode;
                    InitHiddenMode();
                }
            }
        }
        else if (!isSelectMode)
        {
            InitHiddenMode();
        }

        if (IsInvoking("LoopWait"))
        {
            StopShowWait(0);
        }
    }
    /// <summary>
    /// Get网络数据.
    /// </summary>
    IEnumerator SendGet(string _url, PostCmd cmd, int userIdVal = 0)
    {
        WWW getData = new WWW(_url);

        yield return(getData);

        if (getData.error != null)
        {
            Debug.Log("Unity:" + "GetError: " + getData.error);
            //网络故障,请检查网络并重启游戏.

            /*if (SSUIRoot.GetInstance().m_GameUIManage != null)
             * {
             *  SSUIRoot.GetInstance().m_GameUIManage.CreatWangLuoGuZhangUI();
             * }*/
        }
        else
        {
            Debug.Log("Unity:" + cmd + " -> GetData: " + getData.text);
            switch (cmd)
            {
            case PostCmd.GET_HDD_GAME_SCREEN_ID:
            {
                //红点点线下游戏屏幕码Id.
                //{"code":0,"message":"成功","data":{"id":10004,"boxId":"89leitingzhanche68q1q6o30765"}}
                break;
            }

            case PostCmd.GET_HDD_PLAYER_PAY_DATA:
            {
                //玩家在红点点平台的账户信息.
                //{"code":-1,"message":"NO ACCOUNT FOR THIS MEMBER"} //没有该账户.
                //{"code":0,"message":"成功","data":{"account":1,"memberId":93124}} //成功获取账户信息.
                JsonData jd = JsonMapper.ToObject(getData.text);
                if (Convert.ToInt32(jd["code"].ToString()) == (int)BoxLoginRt.Success)
                {
                    //如果有账户信息数据,需要将账户信息数据转换为游戏币.
                    int userId = Convert.ToInt32(jd["data"]["memberId"].ToString());
                    int money  = Convert.ToInt32(jd["data"]["account"].ToString());
                    //money = 200; //test
                    ReceivedWXPlayerHddPayData(userId, money);
                }
                else
                {
                    //没有账户信息.
                    //发送充值消息给微信手柄.
                    if (m_WebSocketSimpet != null)
                    {
                        m_WebSocketSimpet.NetSendWeiXinPadShowTopUpPanel(userIdVal);
                    }
                }
                break;
            }

            case PostCmd.ServerTimeGet:
            {
                //GetData: {"code":0,"message":"成功","data":"2018-09-28 12:58:56"}
                JsonData jd = JsonMapper.ToObject(getData.text);
                if (Convert.ToInt32(jd["code"].ToString()) == (int)BoxLoginRt.Success)
                {
                    string   timeSystem   = DateTime.Now.ToString("yyyy-MM-dd");
                    string   serverTime   = jd["data"].ToString().Substring(0, 10);
                    DateTime systemTimeDt = DateTime.Now;
                    DateTime serverTimeDt = Convert.ToDateTime(jd["data"].ToString());
                    //test
                    //systemTimeDt = Convert.ToDateTime("2018-10-01 15:58:56");
                    //serverTimeDt = Convert.ToDateTime("2018-09-30 12:58:56");
                    //test
                    TimeSpan sp         = systemTimeDt.Subtract(serverTimeDt);
                    int      daysOffset = sp.Days;
                    //if (pcvr.GetInstance() != null)
                    //{
                    //    pcvr.GetInstance().AddDebugMsg("Unity: daysOffset == " + Mathf.Abs(daysOffset));
                    //    pcvr.GetInstance().AddDebugMsg("Unity: serverTime == " + serverTime + ", systemTime == " + timeSystem);
                    //}

                    if (Mathf.Abs(daysOffset) > 1)
                    {
                        //系统与服务器日期信息不一致,请修改机器系统日期信息!
                        if (GameMovieCtrl.GetInstance() != null)
                        {
                            GameMovieCtrl.GetInstance().CreatFixSystemTimeUI();
                        }
                    }

                    //string timeSystem = DateTime.Now.ToString("yyyy-MM-dd");
                    //string serverTime = jd["data"].ToString().Substring(0, 10);
                    //if (pcvr.GetInstance() != null)
                    //{
                    //    pcvr.GetInstance().AddDebugMsg("Unity: serverTime == " + serverTime + ", systemTime == " + timeSystem);
                    //}
                    //Debug.Log("Unity: serverTime == " + serverTime + ", systemTime == " + timeSystem);
                    //if (serverTime != timeSystem)
                    //{
                    //    //系统与服务器日期信息不一致,请修改机器系统日期信息!
                    //    if (GameMovieCtrl.GetInstance() != null)
                    //    {
                    //        GameMovieCtrl.GetInstance().CreatFixSystemTimeUI();
                    //    }
                    //}
                }
                break;
            }

            case PostCmd.WX_XCX_URL_GET:
            {
                /**
                 * code : 响应码
                 * message:响应状态说明
                 * data:数据信息
                 *         qrcodeUrl:获取微信小程序码的请求地址
                 *         scene:传入的boxNumber
                 *         page:小程序码对应的小程序入口
                 */
                JsonData jd = JsonMapper.ToObject(getData.text);
                //m_BoxLoginRt = (BoxLoginRt)Convert.ToInt32(jd["code"].ToString());
                if (Convert.ToInt32(jd["code"].ToString()) == (int)BoxLoginRt.Success)
                {
                    if (m_BoxLoginData != null)
                    {
                        string scene    = jd["data"]["scene"].ToString();
                        string sceneTmp = m_BoxLoginData.boxNumber + "," + m_BoxLoginData.GetWXCodeGame(m_GamePadState);
                        Debug.Log("Unity: scene == " + scene + ", sceneTmp ==== " + sceneTmp);
                        if (sceneTmp == scene)
                        {
                            //盒子编号和游戏代码信息一致.
                            //重新刷新微信虚拟手柄二维码.
                            string qrcodeUrl = jd["data"]["qrcodeUrl"].ToString();
                            string page      = jd["data"]["page"].ToString();
                            Debug.Log("Unity: qrcodeUrl == " + qrcodeUrl + ", page == " + page);

                            WeiXinXiaoChengXuData data = new WeiXinXiaoChengXuData();
                            data.qrcodeUrl = qrcodeUrl;
                            data.scene     = scene;
                            data.page      = page;
                            HttpRequestWeiXinXiaoChengXuErWeiMa(data);
                        }
                        else
                        {
                            //盒子编号信息错误.
                            Debug.LogWarning("Unity: scene was wrong! scene ==== " + scene + ", sceneTmp == " + sceneTmp);
                        }
                    }
                    HttpSendGetGameScreenId();
                }
                else
                {
                    Debug.Log("Unity:" + "Get  WX_XCX_URL failed! code == " + jd["code"]);
                }
                break;
            }
            }
        }
    }