示例#1
0
 /// <summary>
 /// 发送数据
 /// </summary>
 private void SendData(byte[] data)
 {
     MyDebug.Log("--chatSocketUrl-------SendData-----sendMsg----");
     try
     {
         if (stream != null)
         {
             stream.Write(data, 0, data.Length);
         }
         else
         {
             //TipsManagerScript.getInstance ().setTips ("聊天服务器断开,正在重连。。。");
             Connect();
         }
     }
     catch (Exception ex)
     {
         Debug.Log(ex.ToString());
     }
 }
示例#2
0
    //	public void toggleHongClick(){
    //
    //		if (zhuanzhuanGameRule [2].isOn) {
    //			zhuanzhuanGameRule [0].isOn = true;
    //		}
    //	}
    //
    //	public void toggleQiangGangHuClick(){
    //		if (zhuanzhuanGameRule [1].isOn) {
    //			zhuanzhuanGameRule [2].isOn = false;
    //		}
    //	}

    public void onCreateRoomCallback(ClientResponse response)
    {
        if (watingPanel != null)
        {
            watingPanel.gameObject.SetActive(false);
        }
        MyDebug.Log(response.message);
        if (response.status == 1)
        {
            print(sendVo);
            //RoomCreateResponseVo responseVO = JsonMapper.ToObject<RoomCreateResponseVo> (response.message);
            int roomid = Int32.Parse(response.message);
            sendVo.roomId           = roomid;
            GlobalDataScript.roomVo = sendVo;
            GlobalDataScript.loginResponseData.roomId   = roomid;
            GlobalDataScript.loginResponseData.main     = true;
            GlobalDataScript.loginResponseData.isOnLine = true;
            GlobalDataScript.reEnterRoomData            = null;
            //SceneManager.LoadSceneAsync(1);

            /**
             * if (gameSence == null) {
             *      gameSence = Instantiate (Resources.Load ("Prefab/Panel_GamePlay")) as GameObject;
             *      gameSence.transform.parent = GlobalDataScript.getInstance ().canvsTransfrom;
             *      gameSence.transform.localScale = Vector3.one;
             *      gameSence.GetComponent<RectTransform> ().offsetMax = new Vector2 (0f, 0f);
             *      gameSence.GetComponent<RectTransform> ().offsetMin = new Vector2 (0f, 0f);
             *      gameSence.GetComponent<MyMahjongScript> ().createRoomAddAvatarVO (GlobalDataScript.loginResponseData);
             * }*/
            GlobalDataScript.gamePlayPanel = PrefabManage.loadPerfab("Prefab/Panel_GamePlay");

            //GlobalDataScript.gamePlayPanel.GetComponent<MyMahjongScript> ().createRoomAddAvatarVO (GlobalDataScript.loginResponseData);

            closeDialog();
            //closeXiazui();
        }
        else
        {
            TipsManagerScript.getInstance().setTips(response.message);
        }
    }
    protected override void GameSetup()
    {
        coldStart = true;

        GS.GameSparksAuthenticated = (playerId) => {
            MyDebug.Log("GS Auth: " + playerId);

            if (coldStart)
            {
                SyncRestore();
                SyncLevels();
            }

            if (_pushToken != null)
            {
                SetupPushToken();
            }

            if (!coldStart)                 // if it is not an app cold start, then preferences are not synced and is safe to get awards
            {
                GetAwards();
            }

            SetLanguage(LocaliseText.Language);

            coldStart = false;

            SendPoints(0, "UserAuth"); // to send all offline points if any
        };

        GSMessageHandler._AllMessages += HandleGameSparksMessageReceived;

        GameManager.SafeAddListener <UserLogoutMessage> (UserLogoutHandler);
        GameManager.SafeAddListener <UserLoginMessage> (UserLoginHandler);
        GameManager.SafeAddListener <UserRegisterMessage> (UserRegisterHandler);
        GameManager.SafeAddListener <LocalisationChangedMessage>(LocalisationHandler);

        UploadCompleteMessage.Listener += GetUploadMessage;

        //Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;
    }
示例#4
0
    private void ReadBuffer(BinaryReader buffers)
    {
        byte flag = buffers.ReadByte();
        int  lens = ReadInt(buffers.ReadBytes(4));

        if (lens > buffers.BaseStream.Length)
        {
            waitLen = lens;
            isWait  = true;
            buffers.BaseStream.Position = 0;
            byte[] dd   = new byte[buffers.BaseStream.Length];
            byte[] temp = buffers.ReadBytes((int)buffers.BaseStream.Length);
            Array.Copy(temp, 0, dd, 0, (int)buffers.BaseStream.Length);
            if (sources == null)
            {
                sources = dd;
            }

            return;
        }

        int headcode = ReadInt(buffers.ReadBytes(4));
        int sendUuid = ReadInt(buffers.ReadBytes(4));
        int soundLen = ReadInt(buffers.ReadBytes(4));

        if (flag == 1)
        {
            byte[]         sound    = buffers.ReadBytes(soundLen);
            ClientResponse response = new ClientResponse();
            response.headCode = headcode;
            response.bytes    = sound;
            response.message  = sendUuid.ToString();
            MyDebug.Log("chat.headCode = " + response.headCode + "  sound.lenght =   " + soundLen);
            SocketEventHandle.Instance.AddResponse(response);
        }

        if (buffers.BaseStream.Position < buffers.BaseStream.Length)
        {
            ReadBuffer(buffers);
        }
    }
示例#5
0
        public void ShareHighscore(ButtonEventArgs args)
        {
            if (!CoreUtility.Me.ShowInternetConnection())
            {
                return;
            }

            MyDebug.Log("GameUtility::ShareHighscore => Share to: " + args.data);
            CoreUtility.Me.shareMode = ShareMode.Highscore;
            string shareText       = GetRandomHighScoreShareMessage();
            int    score           = GetBestScore();
            string hScoreShareText = string.Format(shareText, score);

            MyDebug.Log(args.data + ": Share is => " + hScoreShareText);
#if UNITY_EDITOR
            GameAnax.Core.Utility.Popup.PopupMessages.Me.NativeFuncionNonAvailableMessage();
            return;
#endif

            if (args.data.Equals("Facebook", StringComparison.OrdinalIgnoreCase))
            {
#if SOCIALNETWORKING
                FBService.Me.ShareTextOnFB(hScoreShareText, STORE_LONG_URL);
#endif
            }
            else if (args.data.Equals("Native", StringComparison.OrdinalIgnoreCase))
            {
#if UNITY_IOS && SOCIALNETWORKING
                Prime31.SharingBinding.shareItems(new[] { hScoreShareText, STORE_SHORT_URL }, _excludeActivity);
#endif
#if UNITY_ANDROID && ETCETERA
                EtceteraB.shareWithNativeShareIntent(hScoreShareText + "\n" + STORE_SHORT_URL, "", "Share On", null);
#endif
            }
            else if (args.data.Equals("Twitter", StringComparison.OrdinalIgnoreCase))
            {
#if SOCIALNETWORKING
                FBService.Me.ShareOnTwitter(hScoreShareText, STORE_SHORT_URL);
#endif
            }
        }
示例#6
0
		private void ShowRewardAd(StoreInfo al) {
			MyDebug.Log(false, "AdsMCG::ShowRewardAd => Show Reward Ads Called");
			switch(al.ShowAdsFrom) {
#if ADCOLONY
			case Provider.AdColony:
				string rawStatus, status;
				rawStatus = AdColony.StatusForZone (al.AdColonyZone);
				status = string.Format ("Zone {0} status is {1}", al.AdColonyZone, rawStatus);
				MyDebug.Log (false,status);
				if (AdColony.IsVideoAvailable (al.AdColonyZone)) {
					ShowAdColonyAds (al.AdColonyZone);
				} else {
					NotificationCenter.Me.PostNotification (new Notification (this, "AdsFail", "AdColony"));
				}
				break;
#endif

#if ADMOB
			case Provider.AdMob:
				if(GoogleMobileAdsScript.Me.IsRewardVideoAdReady(al.AdMobUnitID)) {
					ShowAdMobRewardAds(al.AdMobUnitID);
				} else {
					NotificationCenter.Me.PostNotification(new NotificationInfo(this, "AdsFail", "AdMob"));
				}
				break;
#endif

#if CHARTBOOST
			case Provider.Chartboost:
				if(Chartboost.hasRewardedVideo(new CBLocation(al.CBLoation))) {
					ShowCBRewardAd(al.CBLoation);
				} else {
					NotificationCenter.Me.PostNotification(new NotificationInfo(this, "AdsFail", "Chartboost"));
				}
				break;
#endif
			case Provider.Inmobi:
				break;

			}
		}
示例#7
0
    /// <summary>
    /// 连接到服务器
    /// </summary>
    /// <param name="ip">服务器IP</param>
    /// <returns></returns>
    public void Connect()
    {
        //disCountTimer ();

        try
        {
            tcpclient = new TcpClient();
            //防止延迟,即时发送!
            tcpclient.NoDelay = true;
            tcpclient.BeginConnect(APIS.socketUrl, 10122, new AsyncCallback(ConnectCallback), tcpclient);
        }
        catch (Exception ex)
        {
            //设置标志,连接服务端失败!
            showMessageTip("服务器断开连接,请重新运行程序或稍后再试");
            MyDebug.Log("11111111111111111111111111111111");
            //	ReConnectScript.getInstance().ReConnectToServer();
            Debug.Log(ex.ToString());
            isConnected = false;
        }
    }
示例#8
0
    /// <summary>
    /// 客户端连接至服务器返回信息
    /// </summary>
    /// <param name="ar"></param>
    private void Accept_Callback(IAsyncResult ar)
    {
        Socket socket = serverSocket.EndAccept(ar);

        MyDebug.Log(">>>" + socket.LocalEndPoint.ToString() + " 连接至服务器", MyColor.State.blue);
        if (!clientSockets.Contains(socket))
        {
            clientSockets.Add(socket);
            StateObject stateObject = new StateObject(BUFFER_SIZE, socket);

            try
            {
                socket.BeginReceive(stateObject.buffer, 0, BUFFER_SIZE, 0, new AsyncCallback(Receive_Callback), stateObject);
            }
            catch (Exception e)
            {
                MyDebug.Log(e.Message, MyColor.State.red);
            }
        }
        Accept();
    }
 void GetFeverPoint()
 {
     MyDebug.Log("GetFeverPoint");
     if (this.tag == "Range")
     {
         scoreManager.fp += 5;
     }
     else if (this.tag == "Melee")
     {
         scoreManager.fp += 10;
     }
     else if (this.tag == "Mage")
     {
         scoreManager.fp += 20;
     }
     else
     {
         MyDebug.Log("not found");
         return;
     }
 }
示例#10
0
    /// <summary>
    /// 加载头像
    /// </summary>
    /// <returns>The image.</returns>
    private IEnumerator LoadImg()
    {
        //开始下载图片
        WWW www = new WWW(avatarvo.headIcon);

        yield return(www);

        if (www != null)
        {
            Texture2D texture2D = www.texture;
            byte[]    bytes     = texture2D.EncodeToPNG();
            //将图片赋给场景上的Sprite
            Sprite tempSp = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height),
                                          new Vector2(0, 0));
            headerIcon.overrideSprite = tempSp;
        }
        else
        {
            MyDebug.Log("没有加载到图片");
        }
    }
示例#11
0
 // Returns an ad request with custom ad targeting.
 private AdRequest CreateAdRequest()
 {
     MyDebug.Log(string.Format("GMAS::CreateAdRequest"));
     // Google Test Ad Unit ID
     // ca-app-pub-3940256099942544/1033173712
     return(new AdRequest.Builder()
            .AddTestDevice(AdRequest.TestDeviceSimulator)
            .Build());
     //
     //	.AddTestDevice("81769a040e7adaf577ac7b9012a34fa9") // iPad SKM 3rd Gen GSM		iOS 9.1
     //	.AddTestDevice("d55111b6e8a6776f81fc05b1d4846501") // iPad 2nd Gen				iOS 9.2
     //	.AddTestDevice("f4a07362ca0c2a18a829f08783ecc939") // iPhone 5					iOS 9.2
     //	.AddTestDevice("bf66b38bc1f66ba917476918bb20541f") // iPhone 6 (LBL 8)			iOS 9.2
     //
     //.AddExtra("color_bg", "9B30FF")
     //.AddKeyword("Unity3D")
     //.AddKeyword(GUtility.Me.APPNAME)
     //.SetGender(Gender.Male)
     //.SetBirthday(new DateTime(1985, 1, 1))
     //.TagForChildDirectedTreatment(false)
 }
示例#12
0
    IEnumerator transition(SceneType name, float duration)
    {
        yield return(new WaitWhile(() => m_isFade));

        yield return(SceneManager.LoadSceneAsync(name.ToString(), LoadSceneMode.Additive));

        UnLoadScene(m_currentScene);
        m_currentScene = name;

        if (duration != 0)
        {
            FadeMgr.Instance.FadeIn(duration, () =>
            {
                MyDebug.Log(name.ToString() + "_Scene : LoadComplete!!");
            });
        }
        else
        {
            MyDebug.Log(name.ToString() + "_Scene : LoadComplete!!");
        }
    }
示例#13
0
        private void OnConnectionError(object sender, ErrorEventArgs e)
        {
            MyDebug.Log("Error: " + e.Message);
            Response socketError = new Response();

            socketError.code    = 200;
            socketError.message = e.Message;
            socketError.status  = false;
            socketError.source  = "OnConnectionError";

            socketError.error.data            = e.Exception.Data;
            socketError.error.message         = e.Exception.Message;
            socketError.error.exceptionSource = e.Exception.Source;
            socketError.error.helpLink        = e.Exception.HelpLink;

            _client = null;
            string jsonData;

            jsonData = JsonUtility.ToJson(socketError);
            OnSocketConnectionError(jsonData);
        }
示例#14
0
        private IEnumerator Reconnect()
        {
            MyDebug.Log("Reconnect Called");
            _reConnect = true;
            yield return(new WaitForSecondsRealtime(0.1f));

            while (_reConnect)
            {
                if (_client == null || _client.ReadyState == WebSocketState.Closed)
                {
                    MyDebug.Log("Tyring to connect with Web Socket");
                    ConnectSocket();
                    yield return(new WaitForSeconds(5));
                }
                else
                {
                    //MyDebug.Warning("WebSocket connetion status is: {0}", webSocket.ReadyState);
                }
                yield return(new WaitForSeconds(1));
            }
        }
        /// <summary>
        /// Try and setup the singleton
        /// </summary>
        /// This will only let one instance of the component exist.
        /// If any other instances are attempted created then they will be automatically destroyed.
        void Awake()
        {
            TypeName = typeof(T).FullName;
            MyDebug.Log(TypeName + ": Awake");

            // First we check if there are any other instances conflicting then destroy this and return
            if (Instance != null)
            {
                if (Instance != this)
                {
                    Destroy(gameObject);
                }
                return;             // return is my addition so that the inspector in unity still updates
            }

            // Here we save our singleton instance
            Instance = this as T;

            // setup specifics.
            GameSetup();
        }
示例#16
0
    private IEnumerator loadImg()
    {
        if (imgUrl != null && imgUrl != "")
        {
            WWW www = new WWW(APIS.PIC_PATH + imgUrl);

            yield return(www);

            //下载完成,保存图片到路径filePath
            try {
                texture2D = www.texture;
                byte[] bytes = texture2D.EncodeToPNG();
                //将图片赋给场景上的Sprite
                Sprite tempSp = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), new Vector2(0, 0));
                img.sprite = tempSp;
                img.SetNativeSize();
            } catch (Exception e) {
                MyDebug.Log("LoadImg" + e.Message);
            }
        }
    }
示例#17
0
    public void PlayClipData(Int16[] intArr)
    {
        if (intArr.Length == 0)
        {
            Debug.Log("get intarr clipdata is null");
            return;
        }
        MyDebug.Log("PlayClipData");
        //从Int16[]到float[]
        float[] samples       = new float[intArr.Length];
        int     rescaleFactor = 32767;

        for (int i = 0; i < intArr.Length; i++)
        {
            samples[i] = (float)intArr[i] / rescaleFactor;
        }

        playAudio.clip.SetData(samples, 0);
        playAudio.mute = false;
        playAudio.Play();
    }
示例#18
0
    private IEnumerator UnPreccFiles()
    {
        UIPanel_SceneLoading.percentV           = 100 - (DicMD5UpdateName.Count * 100.0f / updateCount);
        UIPanel_SceneLoading.instance.tips.text = "正在解压资源,过程不消耗流量(" + (updateCount - DicMD5UpdateName.Count) + "/" + updateCount + ")";
        yield return(new WaitForEndOfFrame());

        if (DicMD5UpdateName.Count <= 0)
        {
            string      savePath = Application.persistentDataPath + "/StreamingAssets";
            XmlDocument sXmlDoc  = new XmlDocument();
            XmlElement  SXmlRoot;
            MyDebug.Log("本地资源配置不存在");
            SXmlRoot = sXmlDoc.CreateElement("Files");
            sXmlDoc.AppendChild(SXmlRoot);
            foreach (KeyValuePair <string, List <string> > pair in DicMD5)
            {
                XmlElement xmlElem = sXmlDoc.CreateElement("File");
                SXmlRoot.AppendChild(xmlElem);
                xmlElem.SetAttribute("FileName", pair.Key);
                xmlElem.SetAttribute("MD5", pair.Value[0]);
                xmlElem.SetAttribute("Size", pair.Value[1]);
            }
            sXmlDoc.Save(savePath + "/VersionMD5.xml");
            sXmlDoc = null;
            isDone  = true;
            if (Directory.Exists(Application.persistentDataPath + "/Zip"))
            {
                MyDebug.Log("删除本地资源文件夹");
                Directory.Delete(Application.persistentDataPath + "/Zip", true);
            }
            DoneLoaded();
        }
        else
        {
            string file = DicMD5UpdateName[0];
            DicMD5UpdateName.RemoveAt(0);
            //  Debug.Log("Decompress:" + file);
            DecompressFileLZMA(Application.persistentDataPath + "/Zip/" + file, Application.persistentDataPath + "/" + file);
        }
    }
示例#19
0
    private IEnumerator Request(string requestUrl, string dataString, string callback)
    {
        string error = null;

        if (GlobalConsts.EnableLogNetwork)
        {
            MyDebug.Log(string.Format("[Http] {0}/{1}", requestUrl, dataString));
        }
        using (var www = new WWW(requestUrl, Encoding.UTF8.GetBytes(dataString)))
        {
            yield return(www);

            if (!string.IsNullOrEmpty(www.error))
            {
                error = www.error;
            }
            else if (string.IsNullOrEmpty(www.text))
            {
                error = "Receive data is Empty.";
            }
            else
            {
                //去掉结尾的 '\0' 字符 要不然会解析不出json  这个查了很多资料
                //最终通过打印2进制数组一个一个字节对比才发现的 - -!
                //2018年12月10日:发现原来是否content-type 使用  "text/plain" 就不用了
                //string json = Encoding.UTF8.GetString(www.bytes,0, www.bytes.Length - 1);
                string json = Encoding.UTF8.GetString(www.bytes, 0, www.bytes.Length);
                MyDebug.Log("[Http recv] " + json);
                JsonData netData = JsonMapper.ToObject(json);
                SendMessage(callback, netData);
                yield break;
            }
        }
        if (error == null)
        {
            error = "Empty responding contents";
        }
        MyDebug.LogError("HTTP POST Error! Cmd:" + callback + " Error:" + error);
        //MyDebug.Log("进入游戏失败!服务器停机或维护。");
    }
示例#20
0
    private string downloadPath;                                     //应用下载链接

    /**
     * 检测升级
     */
    public IEnumerator  updateCheck()
    {
        WWW www = new WWW(Constants.UPDATE_INFO_JSON_URL);

        yield return(www);

        byte[] buffer = www.bytes;

        if (string.IsNullOrEmpty(www.error))
        {
            string returnxml = System.Text.Encoding.UTF8.GetString(buffer);
            MyDebug.Log("returnxml  =  " + returnxml);
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(returnxml);
            XmlNodeList nodeList = xmlDoc.SelectNodes("versions/version");
            foreach (XmlNode xmlNodeVersion in nodeList)
            {
                Version123 temp = new Version123();
                temp.title   = xmlNodeVersion.SelectSingleNode("title").InnerText;
                temp.url     = xmlNodeVersion.SelectSingleNode("url").InnerText;
                temp.note    = xmlNodeVersion.SelectSingleNode("note").InnerText;
                temp.version = xmlNodeVersion.SelectSingleNode("versionname").InnerText;
                XmlElement xe = (XmlElement)xmlNodeVersion;
                if (xe.GetAttribute("id") == "ios")
                {
                    serviceVersionVo.ios      = temp;
                    serviceVersionVo.ios.url += "l=zh&mt=8";
                }
                else if (xe.GetAttribute("id") == "android")
                {
                    serviceVersionVo.Android = temp;
                }
            }
            compareVersion();
        }
        else
        {
            TipsManager.getInstance().setTips("更新文件加载失败");
        }
    }
示例#21
0
    // Update is called once per frame
    void Update()
    {
        // Find a PlayerIndex, for a single player game
        if (!playerIndexSet || !prevState.IsConnected)
        {
            for (int i = 0; i < 4; ++i)
            {
                PlayerIndex  testPlayerIndex = (PlayerIndex)i;
                GamePadState testState       = GamePad.GetState(testPlayerIndex);
                if (testState.IsConnected)
                {
                    MyDebug.Log(string.Format("GamePad found {0}", testPlayerIndex));
                    playerIndex    = testPlayerIndex;
                    playerIndexSet = true;
                }
            }
        }

        state = GamePad.GetState(playerIndex);

        string text = "Use left stick to turn the cube\n";

        text += string.Format("IsConnected {0} Packet #{1}\n", state.IsConnected, state.PacketNumber);
        text += string.Format("\tTriggers {0} {1}\n", state.Triggers.Left, state.Triggers.Right);
        text += string.Format("\tD-Pad {0} {1} {2} {3}\n", state.DPad.Up, state.DPad.Right, state.DPad.Down, state.DPad.Left);
        text += string.Format("\tButtons Start {0} Back {1}\n", state.Buttons.Start, state.Buttons.Back);
        text += string.Format("\tButtons LeftStick {0} RightStick {1} LeftShoulder {2} RightShoulder {3}\n", state.Buttons.LeftStick, state.Buttons.RightStick, state.Buttons.LeftShoulder, state.Buttons.RightShoulder);
        text += string.Format("\tButtons A {0} B {1} X {2} Y {3}\n", state.Buttons.A, state.Buttons.B, state.Buttons.X, state.Buttons.Y);
        text += string.Format("\tSticks Left {0} {1} Right {2} {3}\n", state.ThumbSticks.Left.X, state.ThumbSticks.Left.Y, state.ThumbSticks.Right.X, state.ThumbSticks.Right.Y);
        GamePad.SetVibration(playerIndex, state.Triggers.Left, state.Triggers.Right);

        // Display the state information
        textObject.guiText.text = text;

        // Make the cube turn
        cubeAngle += state.ThumbSticks.Left.X * 25.0f * Time.deltaTime;
        cubeObject.transform.localRotation = Quaternion.Euler(0.0f, cubeAngle, 0.0f);

        prevState = state;
    }
示例#22
0
        void OnProductDataResponse(GetProductDataResponse args)
        {
            string sku          = string.Empty;
            string productType  = string.Empty;
            string price        = string.Empty;
            string title        = string.Empty;
            string description  = string.Empty;
            string smallIconUrl = string.Empty;

            string status    = args.Status;
            string requestId = args.RequestId;
            Dictionary <string, ProductData> productDataMap = args.ProductDataMap;

            unavailableSkus = args.UnavailableSkus;

            /*
             * if(productDataMap != null) {
             *      // for each item in the productDataMap you can get the following values for a given SKU
             *      // (replace "sku" with the actual SKU)
             *      sku = productDataMap["sku"].Sku;
             *      productType = productDataMap["sku"].ProductType;
             *      price = productDataMap["sku"].Price;
             *      title = productDataMap["sku"].Title;
             *      description = productDataMap["sku"].Description;
             *      smallIconUrl = productDataMap["sku"].SmallIconUrl;
             * }
             */
            string rdata = string.Format("R_ID: {0}\nStatus: {1}",
                                         requestId, status);

            MyDebug.Log("InAppManager::OnProductDataResponse => " + rdata);

            if (status.ToUpper().Equals("NOT_SUPPORTED"))
            {
                MarketPlaceNotSuported();
                return;
            }

            isRestore = false;
        }
示例#23
0
    /// <summary>
    /// 加载头像
    /// </summary>
    /// <returns>The image.</returns>
    private IEnumerator LoadImg()
    {
        if (avatarvo.account.headicon.IndexOf("http") == -1)
        {
            ShowOrDisShowHeadImage(1);
            headerIcon.sprite = GlobalDataScript.getInstance().headSprite;
            yield break;
        }

        if (FileIO.wwwSpriteImage.ContainsKey(avatarvo.account.headicon))
        {
            ShowOrDisShowHeadImage(1);
            headerIcon.sprite = FileIO.wwwSpriteImage[avatarvo.account.headicon];
            yield break;
        }

        //开始下载图片
        WWW www = new WWW(avatarvo.account.headicon);

        yield return(www);

        //下载完成,保存图片到路径filePath
        if (www != null)
        {
            Texture2D texture2D = www.texture;
            byte[]    bytes     = texture2D.EncodeToPNG();

            //将图片赋给场景上的Sprite
            Sprite tempSp = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), new Vector2(0, 0));

            ShowOrDisShowHeadImage(1);

            headerIcon.sprite = tempSp;
            FileIO.wwwSpriteImage.Add(avatarvo.account.headicon, tempSp);
        }
        else
        {
            MyDebug.Log("没有加载到图片");
        }
    }
示例#24
0
    public void Continue()
    {
        CloseUI();
        MyDebug.Log("GlobalDataScript.hupaiResponseVo.bAllGameEnd:" + GlobalDataScript.hupaiResponseVo.bAllGameEnd);
        if (GlobalDataScript.hupaiResponseVo.bAllGameEnd)
        {
            SocketEngine.Instance.SocketQuit();
            MySceneManager.instance.BackToMain();
            return;
        }

        SoundManager.Instance.PlaySoundBGM("clickbutton");
        SoundManager.Instance.SetSoundV(PlayerPrefs.GetFloat("SoundVolume", 1));
        var cgu = new CMD_GF_UserReady
        {
            wChairID = (ushort)GlobalDataScript.loginResponseData.chairID,
            bReady   = 1
        };
        var temp = NetUtil.StructToBytes(cgu);
        //SocketSendManager.Instance.SendData((int) GameServer.MDM_GF_FRAME, (int) MDM_GF_FRAME.SUB_GF_USER_READY, temp,
        //    Marshal.SizeOf(cgu));
    }
示例#25
0
        public static void LogState()
        {
            StringBuilder sb = new StringBuilder();

            foreach (var language in Languages)
            {
                sb.Append(language + ", ");
            }
            MyDebug.Log(sb);

            sb = new StringBuilder();
            foreach (var key in Localisations.Keys)
            {
                sb.Append(key + ": ");
                foreach (var value in Localisations[key])
                {
                    sb.Append(value + ",");
                }
                sb.AppendLine();
            }
            MyDebug.Log(sb);
        }
示例#26
0
        private void CheckResponse(object sender, MessageEventArgs e)
        {
            int    receivedFor = -1;
            string rId;
            string rData = string.Empty;

            if (e.IsPing)
            {
                MyDebug.Log("Ping Received");
                return;
            }
            else if (e.IsText)
            {
                rData = e.Data;
            }
            else if (e.IsBinary && e.RawData != null)
            {
                rData = _encoding.GetString(e.RawData);
            }
            if (string.IsNullOrEmpty(rData))
            {
                return;
            }

            IDictionary data = (IDictionary)Json.decode(rData);

            if (null != data && data.Contains("rerquestId"))
            {
                rId = data["rerquestId"].ToString();
                int.TryParse(rId, out receivedFor);
                if (receivedFor > 0)
                {
                    QueueResponse(receivedFor, rData);
                    return;
                }
            }
            MyDebug.Log("Recevied Unknown Data: {0}", rData);
            OnSocketReceivedUnknownData(rData);
        }
示例#27
0
    public void PlayClipData(Int16[] intArr)
    {
        if (intArr.Length == 0)
        {
            MyDebug.Log("get intarr clipdata is null");
            return;
        }

        MyDebug.Log("PlayClipData");
        //从Int16[]到float[]
        var       samples       = new float[intArr.Length];
        const int rescaleFactor = 32767;

        for (int i = 0; i < intArr.Length; i++)
        {
            samples[i] = (float)intArr[i] / rescaleFactor;
        }

        SoundManager.Instance.GamePlayAudio.clip.SetData(samples, 0);
        SoundManager.Instance.GamePlayAudio.mute = false;
        SoundManager.Instance.GamePlayAudio.Play();
    }
示例#28
0
        protected virtual void Parse(string str)
        {
            if (_count > 0)
            {
                return;
            }
            //MyDebug.Log("解析:" + fileName);
            string[] arrLine = str.Split(new string[] { "\r\n" }, StringSplitOptions.None);
            _count = arrLine.Length;
            //UnityEngine.Debug.Log(arrLine[_count - 1]);
            if (string.IsNullOrEmpty(arrLine[_count - 1]))
            {
                _count--;                //去掉配置最后一行空白
            }
            arrCfg = new string[_count][];
            for (int i = 0; i < _count; i++)
            {
                arrCfg[i] = arrLine[i].Split("\t"[0]);
                RestoreLanguage(arrCfg[i]);
            }
            //Debug.Log(fileName + ",count=" + _count + ",arrLine[0]" + arrLine[0]);

            dictHead = new Dictionary <string, int>();
            for (int j = 0; j < arrCfg[0].Length; j++)
            {
                if (dictHead.ContainsKey(arrCfg[0][j]))
                {
                    MyDebug.LogError("已经包含key:" + fileName + ",列=" + j + ",值=" + arrCfg[0][j]);
                    return;
                }
                dictHead.Add(arrCfg[0][j], j);
                //if (fileName == "arena_data.txt")
                //{
                //	Debug.Log(j + "=" + arrCfg[0][j]);
                //}
            }
            MyDebug.Log("解析成功:" + fileName);
            ConfigManager.GetInstance().currCount++;
        }
示例#29
0
    public void number(int number)
    {
        SoundCtrl.getInstance().playSoundByActionButton(1);
        if (number == 100)
        {
            clear();
            return;
        }
        MyDebug.Log(number.ToString());
        if (inputChars.Count >= 6)
        {
            return;
        }
        inputChars.Add(number + "");
        int index = inputChars.Count;

        inputTexts[index - 1].text = number.ToString();
        if (index == inputTexts.Count)
        {
            sureRoomNumber();
        }
    }
示例#30
0
 //
 public void ShowBanner(string adUnitId, AdPosition position = AdPosition.Bottom)
 {
     if (string.IsNullOrEmpty(adUnitId))
     {
         MyDebug.Log("GMAS::ShowBanner => Empty adUnitId not Allowed...");
         if (this.OnBannerAdFailedToLoad != null)
         {
             this.OnBannerAdFailedToLoad.Invoke(adUnitId, ErrorCode.EmptyAdUnitID + " - ");
         }
         return;
     }
     this.IsHideBanner = false;
     if (!this.bannerViews.ContainsKey(adUnitId))
     {
         this.RequestBanner(adUnitId, position);
     }
     else
     {
         this.bannerViews[adUnitId].Show();
         this.HandleOnBannerAdLoaded(bannerViews[adUnitId], null);
     }
 }