예제 #1
0
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var ob = builder as MyObjectBuilder_AudioDefinition;

            MyDebug.AssertDebug(ob != null);

            this.SoundData           = ob.SoundData;
            this.SoundData.SubtypeId = base.Id.SubtypeId;

            if (this.SoundData.Loopable)
            {
                bool hasLoop = true;
                for (int i = 0; i < this.SoundData.Waves.Count; i++)
                {
                    hasLoop &= this.SoundData.Waves[i].Loop != null;
                }
                //MyDebug.AssertDebug(hasLoop, String.Format("Sound '{0}' has <Loopable> tag set to TRUE, but is missing a <Loop> in <Wave>, please fix the .sbc", this.SoundData.SubtypeId));
            }
        }
예제 #2
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            // Need to be initialized before base.Init because when loading world with producting refinery
            // it will be missing when recompute power and cause disappearing of refinery.
            UpgradeValues.Add("Productivity", 0f);
            UpgradeValues.Add("Effectiveness", 1f);
            UpgradeValues.Add("PowerEfficiency", 1f);

            base.Init(objectBuilder, cubeGrid);

            MyDebug.AssertDebug(BlockDefinition is MyRefineryDefinition);
            m_refineryDef = BlockDefinition as MyRefineryDefinition;

            if (InventoryAggregate.InventoryCount > 2)
            {
                Debug.Fail("Inventory aggregate has to many inventories, probably wrong save. If you continue the unused inventories will be removed. Save the world to correct it. Please report this is if problem prevail.");

                FixInputOutputInventories(m_refineryDef.InputInventoryConstraint, m_refineryDef.OutputInventoryConstraint);
            }

            InputInventory.Constraint = m_refineryDef.InputInventoryConstraint;
            bool removed = InputInventory.FilterItemsUsingConstraint();

            Debug.Assert(!removed, "Inventory filter removed items which were present in the object builder.");

            OutputInventory.Constraint = m_refineryDef.OutputInventoryConstraint;
            removed = OutputInventory.FilterItemsUsingConstraint();
            Debug.Assert(!removed, "Inventory filter removed items which were present in the object builder.");

            m_queueNeedsRebuild = true;

            m_baseIdleSound = BlockDefinition.PrimarySound;
            m_processSound  = BlockDefinition.ActionSound;

            ResourceSink.RequiredInputChanged += PowerReceiver_RequiredInputChanged;
            OnUpgradeValuesChanged            += UpdateDetailedInfo;

            UpdateDetailedInfo();
            NeedsUpdate |= VRage.ModAPI.MyEntityUpdateEnum.EACH_100TH_FRAME;
        }
        private void collectSignalSamples(int[] voltageSignal, int[] currentSignal)
        {
            sbyte[] values     = new sbyte[32];
            bool    bLastChunk = false;

            for (uint pass = 0; pass < 2; pass++)
            {
                int[] signal = (pass == 0) ? voltageSignal : currentSignal;
                if (signal == null)
                {
                    continue;
                }

                uint sampleIndex = 0;
                while (sampleIndex < signal.Length)
                {
                    if (sampleIndex + values.Length >= signal.Length)
                    {
                        bLastChunk = (pass == 1) || (currentSignal == null);
                    }

                    // Request the carrier voltage/current signal.
                    bool bGetVoltage = (pass == 0);
                    if (!deviceBoard.getCarrierSignal((ushort)sampleIndex, !bLastChunk,
                                                      pass == 0, values))
                    {
                        MyDebug.Fail("Response failed.");
                    }

                    for (uint i = 0; i < 32; i++)
                    {
                        signal[sampleIndex++] = values[i];
                        if (sampleIndex >= signal.Length)
                        {
                            break;
                        }
                    }
                }
            }
        }
예제 #4
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;
        }
예제 #5
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("进入游戏失败!服务器停机或维护。");
    }
예제 #6
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("更新文件加载失败");
        }
    }
예제 #7
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);
        }
    }
예제 #8
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)
        {
            //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.isReady = true;
            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();
        }
        else
        {
            TipsManagerScript.getInstance().setTips(response.message);
        }
    }
예제 #9
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("没有加载到图片");
        }
    }
예제 #10
0
    protected override void OnButtonClick(Button btn)
    {
        base.OnButtonClick(btn);
        switch (btn.name)
        {
        case "StatisticsBtn":
            GuiController.Instance.SwitchWrapperWithMove(GuiFrameID.StatisticsFrame, MoveID.LeftOrDown, true);
            break;

        case "CategoryBtn":
            GuiController.Instance.SwitchWrapperWithScale(GuiFrameID.CategoryFrame, true);
            break;

        case "SetUpBtn":
            GuiController.Instance.SwitchWrapperWithMove(GuiFrameID.SetUpFrame, MoveID.RightOrUp, true);
            break;

        case "ChapterBtn":
            GuiController.Instance.SwitchWrapperWithScale(GuiFrameID.ChapterFrame, true);
            break;

        case "BluetoothBtn":
            //if (Application.isEditor) return;
            if (string.IsNullOrEmpty(GameManager.Instance.UserName))
            {
                GuiController.Instance.SwitchWrapper(GuiFrameID.NameBoardFrame, true);
                return;
            }
            GuiController.Instance.SwitchWrapperWithScale(GuiFrameID.BluetoothFrame, true);
            break;

        case "RankBtn":
            GuiController.Instance.SwitchWrapperWithScale(GuiFrameID.RankFrame, true);
            break;

        default:
            MyDebug.LogYellow("Can not find Button: " + btn.name);
            break;
        }
    }
예제 #11
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;
    }
예제 #12
0
        /// <summary>
        /// Retourne une liste chargée en mémoire.
        /// </summary>
        public IEnumerable <T> GetListBatchLoading <T, TKey>(
            Expression <Func <T, TKey> > iOrderByProperty, ListSortDirection iSortDirection,
            List <Expression <Func <T, object> > > iNavigationProperties = null,
            Expression <Func <T, bool> > iWhere = null,
            int?iSkip = null, int?iTake = null) where T : class, IEntity
        {
            Func <IEnumerable <T> > theTask = () =>
            {
                if (iOrderByProperty == null)
                {
                    throw new ArgumentNullException();
                }
                if (iTake != null && iOrderByProperty == null)
                {
                    throw new ArgumentNullException();
                }
                if (iSkip != null && iOrderByProperty == null)
                {
                    throw new ArgumentNullException();
                }

                //batch loading
                Int64 entitiesCount = GetQuery <T, TKey>(iWhere, iNavigationProperties, iOrderByProperty, iSortDirection, iSkip, iTake).Count();
                int   totalPage     = (int)Math.Ceiling(decimal.Divide(entitiesCount, TAKECOUNT));

                //query
                var result = new List <T>();

                for (int a = 0; a < totalPage; a++)
                {
                    Notifier.ThrowIfCancellationRequested();
                    result.AddRange(GetQuery <T, TKey>(iWhere, iNavigationProperties, iOrderByProperty, iSortDirection, iSkip, iTake).Skip(TAKECOUNT * (a)).Take(TAKECOUNT).ToList());
                    MyDebug.PrintInformation("Chargement des données page par page", a + 1, totalPage);
                }

                return(result);
            };

            return(RetryExecution(theTask));
        }
예제 #13
0
        static void Validate <T>(Type type, T list) where T : IList <string>
        {
            Array values         = Enum.GetValues(type);
            Type  underlyingType = Enum.GetUnderlyingType(type);

            if (underlyingType == typeof(System.Byte))
            {
                foreach (byte value in values)
                {
                    MyDebug.AssertRelease(list[value] != null);
                }
            }
            else if (underlyingType == typeof(System.Int16))
            {
                foreach (short value in values)
                {
                    MyDebug.AssertRelease(list[value] != null);
                }
            }
            else if (underlyingType == typeof(System.UInt16))
            {
                foreach (ushort value in values)
                {
                    MyDebug.AssertRelease(list[value] != null);
                }
            }
            else if (underlyingType == typeof(System.Int32))
            {
                foreach (int value in values)
                {
                    MyDebug.AssertRelease(list[value] != null);
                }
            }
            else
            {
                //  Unhandled underlying type - probably "long"
                throw new InvalidBranchException();
            }
        }
예제 #14
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);
        }
예제 #15
0
    private static Dictionary <string, string> InitImageData()
    {
        TextAsset imageAsset = Resources.Load("Language/Image", typeof(TextAsset)) as TextAsset;

        if (imageAsset == null)
        {
            MyDebug.LogYellow("Load File Error!");
            return(null);
        }
        char[]        charSeparators = new char[] { "\r"[0], "\n"[0] };
        string[]      lineArray      = imageAsset.text.Split(charSeparators, System.StringSplitOptions.RemoveEmptyEntries);
        List <string> lineList;
        Dictionary <string, string> imageDict = new Dictionary <string, string>();

        for (int i = 0; i < lineArray.Length; i++)
        {
            lineList = new List <string>(lineArray[i].Split(','));
            imageDict.Add(lineList[1], lineList[0]);
        }

        return(imageDict);
    }
예제 #16
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();
        }
    }
예제 #17
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);
     }
 }
예제 #18
0
    private void Update()
    {
        lock (_actions)                          //等待当前事件执行完毕
        {
            _currentActions.Clear();             //防止执行上一次事件的回调
            AddRange(_actions, _currentActions); //添加当前事件回调
            _actions.Clear();                    //清空缓存事件
        }

        for (int i = 0; i < _currentActions.Count; i++)
        {
            var a = _currentActions[i];
            try
            {
                a.Action(a.Parameter);  //执行每个回调
            }
            catch (Exception e)
            {
                MyDebug.LogError(e);
            }
        }
    }
예제 #19
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();
    }
예제 #20
0
파일: ChatSocket.cs 프로젝트: iuvei/PKGame
    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("--chatSocketUrl---" + "chat.headCode = " + response.headCode + "  sound.lenght =   " + soundLen);
            MyDebug.Log("chat.headCode = " + response.headCode + "  sound.lenght =   " + soundLen);
            SocketEventHandle.getInstance().addResponse(response);
        }
        if (buffers.BaseStream.Position < buffers.BaseStream.Length)
        {
            readBuffer(buffers);
        }
    }
예제 #21
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);

            MyDebug.AssertDebug(BlockDefinition.Id.TypeId == typeof(MyObjectBuilder_Reactor));
            m_reactorDefinition = BlockDefinition as MyReactorDefinition;
            MyDebug.AssertDebug(m_reactorDefinition != null);

            SourceComp.Init(
                m_reactorDefinition.ResourceSourceGroup,
                new MyResourceSourceInfo
            {
                ResourceTypeId = MyResourceDistributorComponent.ElectricityId,
                DefinedOutput  = m_reactorDefinition.MaxPowerOutput,
                ProductionToCapacityMultiplier = 60 * 60
            });
            SourceComp.HasCapacityRemainingChanged += (id, source) => UpdateIsWorking();
            SourceComp.OutputChanged            += Source_OnOutputChanged;
            SourceComp.ProductionEnabledChanged += Source_ProductionEnabledChanged;
            SourceComp.Enabled = Enabled;

            m_inventory = new MyInventory(m_reactorDefinition.InventoryMaxVolume, m_reactorDefinition.InventorySize, MyInventoryFlags.CanReceive, this);

            var obGenerator = (MyObjectBuilder_Reactor)objectBuilder;

            m_inventory.Init(obGenerator.Inventory);
            m_inventory.ContentsChanged += inventory_ContentsChanged;
            m_inventory.Constraint       = m_reactorDefinition.InventoryConstraint;
            RefreshRemainingCapacity();

            UpdateText();

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;

            m_useConveyorSystem = obGenerator.UseConveyorSystem;
            UpdateMaxOutputAndEmissivity();
        }
예제 #22
0
        public void FastStopEffect()
        {
            MyDebug.Warning("FastStop Effect called");
            CancelInvoke("StopEffect");
            switch (curEffID)
            {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
                postEffects[curEffID].ForceStopFliter();
                break;

            default:
                break;
            }
        }
예제 #23
0
        public static CultureInfo GetCultureBasedLocale(string locale)
        {
            CultureInfo lcl;

            string[] lcl1 = locale.Split('-');
            lcl1[0] = lcl1[0].ToLower();
            if (lcl1.Length > 1)
            {
                lcl1[1] = lcl1[1].ToUpper();
            }
            locale = string.Join("-", lcl1);
            if (CultureExists(locale))
            {
                lcl = new CultureInfo(locale, true);
            }
            else
            {
                MyDebug.Warning("Culture Locale is not available: " + locale);
                lcl = new CultureInfo("en-US", true);
            }
            return(lcl);
        }
예제 #24
0
    public void StopRecord()
    {
        MyDebug.TestLog("StopRecord");
        if (micArray.Length == 0)
        {
            MyDebug.TestLog("No Record Device!");
            return;
        }
        if (!Microphone.IsRecording(null))
        {
            MyDebug.TestLog("StopRecord 1111111111");
            return;
        }

        MyDebug.TestLog("StopRecord 2222222222222");
        Microphone.End(null);
        MyDebug.TestLog("StopRecord 3333333333333");
        SoundManager.Instance.GamePlayAudio.clip = redioclip;
        MyDebug.TestLog("StopRecord 444444444444444444");
        // Test(GetClipData());
        SocketSendManager.Instance.ChewTheRag(GetClipData());
    }
예제 #25
0
        //  Add billboard for one frame only. This billboard isn't particle (it doesn't survive this frame, doesn't have update/draw methods, etc).
        //  It's used by other classes when they want to draw some billboard (e.g. rocket thrusts, reflector glare).
        public static void AddPointBillboard(string material,
                                             Vector4 color, Vector3D origin, int renderObjectID, ref MatrixD worldToLocal, float radius, float angle,
                                             int customViewProjection = -1, MyBillboard.BlenType blendType = MyBillboard.BlenType.Standard)
        {
            Debug.Assert(material != null);
            if (!IsEnabled)
            {
                return;
            }

            MyDebug.AssertIsValid(origin);
            MyDebug.AssertIsValid(angle);

            MyQuadD quad;
            Vector3 diff = MyTransparentGeometry.Camera.Translation - origin;

            if (MyUtils.GetBillboardQuadAdvancedRotated(out quad, origin, radius, radius, angle, (origin + (Vector3D)MyTransparentGeometry.Camera.Forward * diff.Length())) != false)
            {
                VRageRender.MyBillboard billboard = VRageRender.MyRenderProxy.BillboardsPoolWrite.Allocate();
                if (billboard == null)
                {
                    return;
                }

                CreateBillboard(billboard, ref quad, material, ref color, ref origin, customViewProjection);
                billboard.BlendType = blendType;

                if (renderObjectID != -1)
                {
                    Vector3D.Transform(ref billboard.Position0, ref worldToLocal, out billboard.Position0);
                    Vector3D.Transform(ref billboard.Position1, ref worldToLocal, out billboard.Position1);
                    Vector3D.Transform(ref billboard.Position2, ref worldToLocal, out billboard.Position2);
                    Vector3D.Transform(ref billboard.Position3, ref worldToLocal, out billboard.Position3);
                    billboard.ParentID = renderObjectID;
                }

                VRageRender.MyRenderProxy.AddBillboard(billboard);
            }
        }
예제 #26
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++;
        }
예제 #27
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));
    }
예제 #28
0
    // 处理有效数据
    public override void OnEventTCPSocketRead(int main, int sub, byte[] tmpBuf, int size)
    {
        MyDebug.Log("Main:" + (MainCmd)main);
        switch ((MainCmd)main)
        {
        case MainCmd.MDM_GP_LOGON:                    //1---
            OnSocketSubUpdateNotify(sub, tmpBuf, size);
            break;

        case MainCmd.MDM_MB_LOGON:     //登陆信息    //100---
            OnSocketMainLogon(sub, tmpBuf, size);
            break;

        case MainCmd.MDM_MB_SERVER_LIST:     //列表信息 //101---
            OnSocketMainServerList(sub, tmpBuf, size);
            break;

        case MainCmd.MDM_MB_PERSONAL_SERVICE:            //200---
            OnSocketPersonal_Service(sub, tmpBuf, size);
            break;
        }
    }
예제 #29
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);
        }
예제 #30
0
    /// <summary>
    /// 加载头像
    /// </summary>
    /// <returns>The image.</returns>
    private IEnumerator LoadImg()
    {
        //开始下载图片
        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));
            headerIcon.sprite = tempSp;
        }
        else
        {
            MyDebug.Log("没有加载到图片");
        }
    }