/// <summary>
        /// Restarts the tween
        /// </summary>
        /// <param name="fromHere">If TRUE, re-evaluates the tween's start and end values from its current position.
        /// Set it to TRUE when spawning the same DOTweenAnimation in different positions (like when using a pooling system)</param>
        public override void DORestart(bool fromHere = false)
        {
            _playCount = -1;
            if (tween == null)
            {
//                if (Debugger.logPriority > 1)
//					Debugger.LogNullTween(tween);
                DebugUtil.Error("tween is null");
                return;
            }
            if (fromHere && isRelative)
            {
                ReEvaluateRelativeTween();
            }
            DOTween.Restart(this.gameObject);
        }
Exemple #2
0
    public static FileStream GetFileStream(string fileName, string extname)
    {
        //FileStream stream;
        string path = GetResourceURL(fileName, extname, true);

        Debug.Log("Static Data Path: " + path);
        if (path != null)
        {
            //strip掉开始的file://
            string stripedpath = path.Substring(7);
            return(new FileStream(stripedpath, FileMode.Open, FileAccess.Read));
        }

        DebugUtil.Error("Load " + fileName + " failed");
        return(null);
    }
Exemple #3
0
        /// <summary>
        /// 从预加载中直接实例化游戏物体
        /// </summary>
        /// <returns>The and instance game object from preload.</returns>
        /// <param name="assetName">Asset name.</param>
        public GameObject LoadAndInstanceGameObjectFromPreload(string assetName)
        {
            //是否已加载成功
            if (_dicLoadedAsset.ContainsKey(assetName))
            {
                var asset = _dicLoadedAsset[assetName].Asset;
                if (asset != null)
                {
                    return(MonoBehaviour.Instantiate(asset as GameObject));
                }
            }

            //Debugger.LogError("not preload Gameobject:" + assetName);
            DebugUtil.Error("not preload Gameobject:" + assetName);
            return(null);
        }
Exemple #4
0
    /// <summary>
    /// 返回资源的路径。
    /// 在PC平台下,直接返回GetAssetBundlePath()路径下的资源路径
    /// 在iOS平台下先查询iOSAssetPath下,如果资源存在,则返回这个资源,否则再查询 /myapplication.app/目录下。
    /// 外部类应该使用这个接口来获取某一个资源的路径
    /// 如果updated为true,用以上逻辑,false的情况,只从.app路径里读取
    /// </summary>
    /// <param name="assetName">文件名</param>
    /// <param name="extname">文件后缀名</param>
    /// <returns>file://文件路径</returns>
    public static string GetResourceURL(string assetName, string extname, bool tryCacheFirst)
    {
        string cachedDataPath     = GamePath.GetCachedAssetBundlePath();
        string cachedDataPathFull = null;

        if (cachedDataPath != null)
        {
            cachedDataPath     = string.Format("{0}{1}.{2}", cachedDataPath, assetName, extname);
            cachedDataPathFull = "file:///" + cachedDataPath;
        }
        string dataPath     = string.Format("{0}{1}.{2}", GamePath.GetLocalAssetPath(), assetName, extname);
        string dataPathFull = string.Format("{0}{1}.{2}", GamePath.GetLocalAssetPathFullQualified(), assetName, extname);

        if (tryCacheFirst && cachedDataPath != null)
        {
            if (File.Exists(cachedDataPath))
            {
                Debug.Log("[GetResourceURL]dataPath = " + cachedDataPathFull);
                return(cachedDataPathFull);
            }
        }

        // #if !USE_FINAL_DATA
        //         if (GamePlatform.InEditor)
        //         {
        //             string editorDataPath = string.Format("{0}{1}.{2}", Application.dataPath + "/Binaries/", assetName, extname);
        //             //editor优先使用Binary中的数据
        //             if (File.Exists(editorDataPath))
        //             {
        //                 //DebugOutPut.Log("dataPath = " + editorDataPath, DebugLogLevel.LogLevel1);
        //                 return "file://" + editorDataPath;
        //             }
        //         }
        // #endif
        if (File.Exists(dataPath))
        {
            Debug.Log("[GetResourceURL]dataPath = " + dataPathFull);
            return(dataPathFull);
        }
        else
        {
            DebugUtil.Error("Can not find dataPath = " + dataPath + "!!!");
        }

        //DebugOutPut.Log("data not found : " + dataPath, DebugLogLevel.LogLevel5);
        return(null);
    }
Exemple #5
0
        public void AttackBoss()
        {
            int bossHp = 0;
            int bossId = 0;

            if (FightControl.Instance.EFightStatus == E_FightStatus.FightBoss1)
            {
                bossId = OpponentBossId[0];
            }
            else if (FightControl.Instance.EFightStatus == E_FightStatus.FightBoss2)
            {
                bossId = OpponentBossId[1];
            }
            else if (FightControl.Instance.EFightStatus == E_FightStatus.FightBoss3)
            {
                bossId = OpponentBossId[2];
            }
            else
            {
                DebugUtil.Error("状态不对,ModuleFight_AttackBoss():" + FightControl.Instance.EFightStatus);
                return;
            }

            bossHp = DicOpponentBoss[bossId];

            if (bossHp <= 0)
            {
                return;
            }

            bossHp -= CLEINT_DAMAGE;
            if (bossHp < 0)
            {
                bossHp = 0;
            }
            DicOpponentBoss[bossId] = bossHp;

            //通知服务端
            Util.CallMethod("Network", "ClientAttack", bossId, CLEINT_DAMAGE);
            //MyFrameWork.NetworkManager.Instance.ClientSendFightDataMsg(bossId,CLEINT_DAMAGE);

            //自己显示敌方扣血
            EventDispatcher.TriggerEvent <int, int>("CLIENT_ATTACK", bossId, bossHp);

            //播放动画
            FightControl.Instance.PlayBossAnim(bossId, bossHp > 0);
        }
Exemple #6
0
        /// <summary>
        /// 加载资源
        /// </summary>
        /// <param name="assetName">资源名称</param>
        /// <param name="listener">结果回调</param>
        /// <param name="isAsync">是否异步加载</param>
        /// <param name="isKeepInMemory">是否常驻内存</param>
        /// <param name="type">资源类型,默认GameObject</param>
        public void LoadAsset(string assetName, System.Action <object> listener, bool isAsync = true, bool isKeepInMemory = false, System.Type type = null)
        {
            //是否已加载成功
            if (_dicLoadedAsset.ContainsKey(assetName))
            {
                //已加载,直接返回
                listener(_dicLoadedAsset[assetName].Asset);
            }
            else
            {
                if (type == null)
                {
                    type = typeof(GameObject);
                }

                if (isAsync)
                {
                    LoadAsyncAsset(assetName, listener, isKeepInMemory, type);
                }
                else
                {
                    //直接加载资源
                    Object asset = Resources.Load(GetFileFullName(assetName), type);
                    if (asset != null)
                    {
                        AssetInfo assetInfo = new AssetInfo();
                        assetInfo.Asset          = asset;
                        assetInfo.IsKeepInMemory = isKeepInMemory;

                        _dicLoadedAsset.Add(assetName, assetInfo);
                        AddAssetToName(assetName);
                    }
                    else
                    {
                        //Debugger.LogError("LoadAsset failed!!! assetName:" + assetName);
                        DebugUtil.Error("LoadAsset failed!!! assetName:" + assetName);
                    }

                    if (listener != null)
                    {
                        listener(asset);
                    }
                }
            }
        }
Exemple #7
0
    public WWWRequestHandle RequestWWW(string url, Command cmd, MessageFunction completeCallback, MessageFunction errorCallback, int Id)
    {
        if (url == null)
        {
            DebugUtil.Error("ResourceManager::RequestWWW() url is null");
            return(null);
        }
        WWWRequestHandle ret = new WWWRequestHandle();

        ret.url = url;
        ret.cmd = cmd;
        ret.Id  = Id;
        ret.completeCallback = completeCallback;
        ret.errorCallback    = errorCallback;
        fetchingQueue.Add(ret);
        ret.m_LoadResTimeCost.Start();
        return(ret);
    }
Exemple #8
0
    public WWWRequestHandle RequestWWW(string url, Command cmd, MessageFunction completeCallback, MessageFunction errorCallback)
    {
        if (url == null)
        {
            DebugUtil.Error("ResourceManager::RequestWWW() url is null");
            return(null);
        }
        //DebugOutPut.Log("ResourceManager WWW at url: " + url, DebugLogLevel.LogLevel1);
        WWWRequestHandle ret = new WWWRequestHandle();

        ret.url = url;
        ret.cmd = cmd;
        ret.completeCallback = completeCallback;
        ret.errorCallback    = errorCallback;
        fetchingQueue.Add(ret);
        ret.m_LoadResTimeCost.Start();
        return(ret);
    }
Exemple #9
0
    /// <summary>
    /// 登录回调
    /// </summary>
    /// <param name="isSuccess">If set to <c>true</c> is success.</param>
    private void OnLoginCallback(bool isSuccess)
    {
        if (isSuccess)
        {
            //登录成功,连接游戏服务器
            DebugUtil.Info("连接游戏服务器,userId:" + SDKEMAController.Instance.UserId + ",channelId:" + SDKEMAController.ReceivedChanelId);

            _hasLoginSuccess = true;
            NetworkManager.Instance.SendReConnect();

//			Util.CallMethod("UILoginCtrl","SendLogin",SDKEMAController.Instance.UserId,SDKEMAController.ReceivedChanelId.ToString(),string.Empty);
        }
        else
        {
            //登录失败
            DebugUtil.Error("登录失败");
            _hasClickLogin = false;
        }
    }
Exemple #10
0
    /// <summary>
    /// 获取一个txt数据
    /// </summary>
    /// <param name="fileName"></param>
    /// <returns></returns>
    public static string GetTxt(string fileName, bool tryCacheFirst)
    {
        string path = GetResourceURL(fileName, "txt", tryCacheFirst);

        if (path != null)
        {
#if UNITY_WEBPLAYER
            //return GetWWWResource(path).text;
            TextAsset resource = Resources.Load(fileName) as TextAsset;
            return(resource.text);
#else
            //strip掉开始的file://
            string stripedpath = path.Substring(7);
            return(File.ReadAllText(stripedpath));
#endif
        }

        DebugUtil.Error("Load " + fileName + " failed");
        return(null);
    }
Exemple #11
0
    /// <summary>
    /// 获取一个2进制数据
    /// </summary>
    /// <param name="fileName"></param>
    /// <returns></returns>
    public static byte[] GetBytes(string fileName)
    {
#if UNITY_WEBPLAYER
        //return GetWWWResource(path).bytes;
        DebugOutPut.Log("filename=" + fileName, DebugLogLevel.LogLevel1);
        TextAsset resource = Resources.Load(fileName) as TextAsset;
        return(resource.bytes);
#else
        string path = GetResourceURL(fileName, "bytes", true);
        if (path != null)
        {
            //strip掉开始的file://
            string stripedpath = path.Substring(7);
            return(File.ReadAllBytes(stripedpath));
        }

        DebugUtil.Error("Load " + fileName + " failed");
        return(null);
#endif
    }
        public void TriggerSkill(int skillId)
        {
            SkillModule skill = SkillModuleMgr.Instance.GetSkill(skillId);

            if (skill == null)
            {
                DebugUtil.Error("未找到skill,id = " + skillId);
            }

            BossData bossData = ModuleFight.CurrentMyBoss;

            //暂时屏蔽
            if (skill.NeedEnergy > bossData.Energy)
            {
                ShowMsg(FightDefine.E_NoteMsgType.NotEnoughEnergy);
                return;
            }

            ModuleFight.UseEnergy(skill.NeedEnergy);
            ModuleFight.SkillAttackBoss(skill);
        }
Exemple #13
0
        private void _Create(Command cmd)
        {
            BaseUI ui = null;

            _dicUI.TryGetValue(cmd.UIType, out ui);
            if (ui != null)
            {
                //已加载
                if (cmd.Listener != null)
                {
                    cmd.Listener(ui);
                }

                if (cmd.lua_fun != null)
                {
                    cmd.lua_fun.Call(ui.gameObject);
                }

                return;
            }
            else
            {
                if (AppConst.PrefabBundleMode && cmd.UIType != E_UIType.Fight &&
                    cmd.UIType != E_UIType.UILoadingPanel &&
                    cmd.UIType != E_UIType.PanelMessageBox &&
                    cmd.UIType != E_UIType.UILoginPanel)
                {
                    string PrefabUrl = BundleResMgr.GetResourceURL(cmd.UIType.ToString(), "unity3d");
                    if (PrefabUrl == null)
                    {
                        DebugUtil.Error("Atlas [" + cmd.UIType.ToString() + "] is null!!!");
                    }
                    WWWRequestHandle handle = BundleResMgr.Instance.RequestWWW(PrefabUrl, cmd, OnLoadUIFinished, null);
                }
                else
                {
                    AppFacade.Instance.GetManager <ResourceMgr>(ManagerName.Resource).LoadAssetAndInstance(cmd.UIType.ToString(), (asset) => { OnLoadUIFinished(asset, cmd); });
                }
            }
        }
Exemple #14
0
    public void AddHistoryScore(HistoryScore hs)
    {
        if (hs == null)
        {
            DebugUtil.Warning("hs is NULL !!!");
            return;
        }

        _historyScores.Add(hs);
        try
        {
            using (StreamWriter sw = new StreamWriter(HistoryScoresFilePath, true))
            {
                string line = JsonUtility.ToJson(hs);
                sw.WriteLine(line);
            }
        }
        catch (Exception e)
        {
            DebugUtil.Error(e.Message);
        }
    }
Exemple #15
0
 void _InitHistoryScores()
 {
     _historyScores = new List <HistoryScore>();
     try
     {
         using (FileStream fs = new FileStream(HistoryScoresFilePath, FileMode.OpenOrCreate))
         {
             using (StreamReader sr = new StreamReader(fs))
             {
                 string line;
                 while ((line = sr.ReadLine()) != null)
                 {
                     HistoryScore hs = JsonUtility.FromJson <HistoryScore>(line);
                     _historyScores.Add(hs);
                 }
             }
         }
     }
     catch (Exception e)
     {
         DebugUtil.Error(e.Message);
     }
 }
Exemple #16
0
        /// <summary>
        /// 技能攻击对方
        /// </summary>
        public void SkillAttackBoss(SkillModule skill)
        {
            BossData boss    = CurrentMyBoss;
            BossData bossOpp = CurrentOppBoss;

            if (boss != null && bossOpp != null)
            {
                int bossHp = bossOpp.RealCurrentHp;

                if (bossHp <= 0)
                {
                    return;
                }

                                #if MinDamage
                int damage = 1;
                                #else
                int damage = (int)(boss.NormalAttack * skill.HarmPara);
                                #endif

                bossHp -= damage;
                if (bossHp < 0)
                {
                    bossHp = 0;
                }
//				bossOpp.CurrentHp = bossHp;
                bossOpp.RealCurrentHp = bossHp;

                //通知服务端
                Util.CallMethod("Network", "ClientAttack", CurrentOppBossId, damage, (int)AttackType.SKILL_1, skill.Id, 0, 0);

//				Debug.Log("<color=orange>boss :</color>" + CurrentOppBoss.CurrentHp.ToString() + " damage:" + (-damage).ToString());
                SkillData skillData = new SkillData();
                skillData.BossId       = CurrentOppBossId;
                skillData.CurrentHp    = bossOpp.RealCurrentHp;
                skillData.Damage       = damage;
                skillData.SkillType    = SkillTable.SkillType.GongZhuSkill;
                skillData.SkillId      = skill.Id;
                skillData.IsLastAttack = bossHp <= 0;

                FightMgr.Instance.CurrentMyBoss.AddAttackAction(skillData);

//				boss.AddEnergy(E_AddEnergyType.UseSkill);
            }
            else
            {
                DebugUtil.Error("技能攻击对方Boss,本方boss不存在");
            }



            //原来直接播放技能伤害逻辑
//			BossData boss = CurrentMyBoss;
//			BossData bossOpp = CurrentOppBoss;
//
//			if(boss != null && bossOpp != null && boss.IsCanUseSkill)
//			{
//
//				int bossHp = bossOpp.RealCurrentHp;
//
//				if(bossHp <= 0) return;
//
//				#if MinDamage
//				int damage = 1;
//				#else
//				int damage = boss.SkillAttack;
//				#endif
//
//				bossHp -= damage;
//				if(bossHp < 0) bossHp = 0;
////				bossOpp.CurrentHp = bossHp;
//				bossOpp.RealCurrentHp = bossHp;
//
//				//通知服务端
//				Util.CallMethod("Network", "ClientAttack",CurrentOppBossId, damage, (int)AttackType.SKILL_1);
//
////				Debug.Log("<color=orange>boss :</color>" + CurrentOppBoss.CurrentHp.ToString() + " damage:" + (-damage).ToString());
//				SkillData skillData = new SkillData();
//				skillData.BossId = CurrentOppBossId;
//				skillData.CurrentHp = bossOpp.RealCurrentHp;
//				skillData.Damage = damage;
//				skillData.SkillType = SkillTable.SkillType.GongZhuSkill;
//				skillData.IsLastAttack = bossHp <= 0;
//
//				FightMgr.Instance.CurrentMyBoss.AddAttackAction(skillData);
//
//				boss.AddEnergy(E_AddEnergyType.UseSkill);
//			}
//			else
//			{
//				DebugUtil.Error("技能攻击对方Boss,本方boss不存在");
//			}
        }
        /// <summary>
        /// 播放技能效果
        /// </summary>
        /// <param name="skill">Skill.</param>
        public void PlaySkillEffect(int skillId, bool isMyAttack)
        {
//			isMyAttack = !isMyAttack;

            SkillModule skill = SkillModuleMgr.Instance.GetSkill(skillId);

            if (skill == null)
            {
                DebugUtil.Error("未找到skill,id = " + skillId);
            }

            if (skill.SkillTypeDetail == E_SkillTypeDetail.AddMoves)
            {
                if (isMyAttack)
                {
                    //增加自己步数
                    int addMoves = int.Parse(skill.EffectNum);
                    EventDispatcher.TriggerEvent <int, bool>(UIFight.AddMoves, addMoves, true);
                }
                else
                {
                    ShowMsg(FightDefine.E_NoteMsgType.OppUseAddMoves);
                }
            }
            else if (skill.SkillTypeDetail == E_SkillTypeDetail.AddBlocks)
            {
                if (isMyAttack)
                {
                    //自己飞向对方
                    List <FlyingBezier> list = new List <FlyingBezier>();
                    int count = int.Parse(skill.EffectNum);
                    for (int i = 0; i < count; i++)
                    {
                        FlyingBezier         obj  = null;
                        Queue <FlyingBezier> pool = null;
                        bool isBlock = true;                        //Random.Range(1,1000) <= 750;
                        if (isBlock)
                        {
                            //木块
                            if (_poolsBlock.Count > 0)
                            {
                                obj = _poolsBlock.Dequeue();
                            }
                            else
                            {
                                obj = FightMgr.Instance.LoadAndInstantiate(FightDefine.Prefab_Flying_Block).GetComponent <BlockFlyToOpp>();                               // ResourceMgr.Instance.LoadAndInstanceGameObjectFromPreload(FightDefine.ParticleCardCrush);
                            }

                            pool = _poolsBlock;
                        }
//						else
//						{
//							//杂草
//							if(_poolsBlockWeed.Count > 0)
//							{
//								obj = _poolsBlockWeed.Dequeue();
//							}
//							else
//							{
//								obj = FightMgr.Instance.LoadAndInstantiate(FightDefine.Prefab_Flying_Weed).GetComponent<BlockFlyToOpp>();// ResourceMgr.Instance.LoadAndInstanceGameObjectFromPreload(FightDefine.ParticleCardCrush);
//							}
//
//							pool = _poolsBlockWeed;
//						}
                        list.Add(obj);

                        obj.transform.SetParent(_energyMgr.transform, false);
                        obj.transform.localPosition = new Vector3(Random.Range(-46f, 46f), Random.Range(-46f, 46f), 0);
                        obj.transform.SetParent(goBossOpp.transform);
                        obj.gameObject.SetActive(false);
                        obj.Speed = 0.8f;

                        (obj as BlockFlyToOpp).Play(i * 0.3f, pool, list, true, null, null, null);
                    }
                }
                else
                {
                    //对方往我棋盘飞
                    _FlyBlockToMyCnt = int.Parse(skill.EffectNum);
                }
            }
            else if (skill.SkillTypeDetail == E_SkillTypeDetail.ForbidAttack)
            {
                if (isMyAttack)
                {
                    //不管
                }
                else
                {
                    IsIceBlcok = true;
                    //获取冰封路径
                    var dicSlot = _filedMgr.FindIcePath();

                    //停止原来协程
                    if (_iceBlock != null)
                    {
                        StopCoroutine(_iceBlock);
                    }

                    //开始冰封
                    _iceBlock = StartCoroutine(ReIceBlockTimer(dicSlot, float.Parse(skill.EffectNum)));

                    //恢复冰封协程
                    StartCoroutine(IceSlot(dicSlot));

                    ShowMsg(FightDefine.E_NoteMsgType.ShowIceNotice, skill.Effect);
                }
            }
        }
Exemple #18
0
 public static void LogError(string str)
 {
     DebugUtil.Error(str);
 }
Exemple #19
0
 /// <summary>
 /// 登录流程
 /// </summary>
 /// <param name="o"></param>
 private void ReceiveSorketAuth()
 {
     try
     {
         if (srcTCP == null || !srcTCP.Connected)
         {
             Stop();
         }
         // 接收登录信息
         SrcRecvData();
         if (srcTCPSize == 0)
         {
             throw (new Exception("Src Link Shutdown!"));
         }
         ByteUtil.FlushBytes(srcRS, srcTCPBody, 0, srcTCPSize);
         version = ByteUtil.ReadUInt8(srcRS);
         methods = ByteUtil.Read1BUInt8s(srcRS);
         if (version != 5)
         {
             throw (new Exception("Version no supported!"));
         }
         // 回复登录信息
         if (server.useUPAuth)
         {
             var methodList = new List <int>(methods);
             if (methodList.Contains((int)Socks5AuthType.USERNAME_PASSWORD))
             {
                 SrcSendData(new byte[] { 0x05, (int)Socks5AuthType.USERNAME_PASSWORD });
                 SrcRecvData();
                 if (srcTCPSize == 0)
                 {
                     throw (new Exception("Src Link Shutdown!"));
                 }
                 ByteUtil.FlushBytes(srcRS, srcTCPBody, 0, srcTCPSize);
                 version = ByteUtil.ReadUInt8(srcRS);
                 if (version != 1)
                 {
                     throw (new Exception("Auth Version no supported!"));
                 }
                 var username = ByteUtil.Read1BString(srcRS);
                 var password = ByteUtil.Read1BString(srcRS);
                 // 暂时不校验
                 SrcSendData(new byte[] { 0x01, 0x00 });
                 //srcClient.Client.Send(new byte[] { 0x01, 0x01}); 校验失败返回非0
             }
             else
             {
                 SrcSendData(new byte[] { 0x05, (int)Socks5AuthType.NO_ACCEPTABLE_METHODS });
                 throw (new Exception("Auth failed!"));
             }
         }
         else
         {
             SrcSendData(new byte[] { 0x05, (int)Socks5AuthType.NO_AUTHENTICATION_REQUIRED });
         }
         // 接收代理请求
         SrcRecvData();
         if (srcTCPSize == 0)
         {
             throw (new Exception("Src Link Shutdown!"));
         }
         ByteUtil.FlushBytes(srcRS, srcTCPBody, 0, srcTCPSize);
         version = ByteUtil.ReadUInt8(srcRS);
         var cmd = (Socks5CMD)ByteUtil.ReadUInt8(srcRS);
         ByteUtil.ReadUInt8(srcRS);
         Socks5ATYP atyp;
         Socks5Util.ReadAddress(srcRS, out atyp, out tarIPA, out tarHost, out tarPort);
         if (version != 5)
         {
             throw (new Exception("Version no supported!"));
         }
         if (cmd == Socks5CMD.CONNECT)
         {
             tarTCP = new TcpClient();
             InitTCPClient(tarTCP);
             tarTCP.Connect(tarHost, tarPort);
             if (!tarTCP.Connected)
             {
                 throw (new Exception("Not connect!"));
             }
             // 回复连接结果
             ByteUtil.FlushBytes(srcSS);
             // Connect不关心返回ip和端口,这里都发0
             // ByteUtil.WriteBytes(srcSS, new byte[]{
             //     0x05, (int)Socks5Reply.Succeeded, 0x00, (int)Socks5ATYP.IPV4,
             //     0x00, 0x00, 0x00, 0x00, 0x00, 0x00
             // });
             ByteUtil.WriteBytes(srcSS, new byte[] { 0x05, (int)Socks5Reply.Succeeded, 0x00 });
             Socks5Util.WriteAddress(srcSS, server.ipep);
             SrcSendData(srcSS.ToArray());
             DebugUtil.LogFormat("TCP {0} => {1}", srcTCP.Client.RemoteEndPoint, tarTCP.Client.RemoteEndPoint);
             ReceiveSorketSrcTCPLoop();
             ReceiveSorketTarTCPLoop();
         }
         else if (cmd == Socks5CMD.BIND)
         {
             DebugUtil.LogFormat("ReceiveSorketAuth size:{0}  version:{1} cmd:{2} atyp:{3} tarHost:{4} tarPort:{5}", srcTCPSize, version, cmd, atyp, tarHost, tarPort);
             throw (new Exception("No suppered BIND!"));
         }
         else if (cmd == Socks5CMD.UDP_ASSOCIATE)
         {
             // ByteUtil.FlushBytes(srcSS);
             // ByteUtil.WriteBytes(srcSS, new byte[]{
             //     0x05, (int)Socks5Reply.CommandNotSupported, 0x00, (int)Socks5ATYP.IPV4,
             //     0x00, 0x00, 0x00, 0x00, 0x00, 0x00
             // });
             // SrcSendData(srcSS.ToArray());
             // Stop();
             // 使用UDP 第一次提交的地址和端口是,客户端的接收端口
             srcUDPREP = new IPEndPoint(((IPEndPoint)srcTCP.Client.RemoteEndPoint).Address, tarPort);
             udpID     = srcUDPREP.ToString();
             DebugUtil.LogFormat("UDP {0} => {1} {2}", srcUDPREP, server.ipep, srcTCP.Client.RemoteEndPoint);
             ByteUtil.FlushBytes(srcSS);
             ByteUtil.WriteBytes(srcSS, new byte[] { 0x05, (int)Socks5Reply.Succeeded, 0x00 });
             Socks5Util.WriteAddress(srcSS, server.ipep);
             SrcSendData(srcSS.ToArray());
             server.UDPJoin(this);
             ReceiveSorketSrcTCPLoop2(); // 空读取
         }
     }
     catch (Exception e)
     {
         DebugUtil.Error("Failed to ReceiveSorketAuth error." + e);
         Stop();
     }
 }
Exemple #20
0
 public void Update()
 {
     if (workingRequest == null) //not in downloading process
     {
         if (fetchingQueue.Count > 0)
         {
             //use tmp handle to clean status in resourcemanager first
             WWWRequestHandle tmp = fetchingQueue[0];
             if (HasResource(tmp.url))
             {
                 fetchingQueue.RemoveAt(0);
                 tmp.IsDone = true;
                 if (tmp.completeCallback != null)
                 {
                     tmp.completeCallback(tmp, tmp.cmd);
                 }
                 tmp.m_LoadResTimeCost.Stop();
                 System.TimeSpan cost           = tmp.m_LoadResTimeCost.Elapsed;
                 string          timecostdetial = string.Format("{0} Loaded,time cost: {1}", tmp.url, cost.TotalSeconds);
                 DebugUtil.Info(timecostdetial);
                 return;
             }
             workingRequest = tmp;
             workingWWW     = new WWW(workingRequest.url);
             //DebugOutPut.Log("ResourceManager new WWW at url: " + workingRequest.url, DebugLogLevel.LogLevel1);
         }
     }
     else //currently downloading
     {
         if (workingWWW.error != null)
         {
             if (workingWWW.error.Contains("WWW request was cancelled")) //not an error
             {
                 DebugUtil.Error("ResourceCanceled: " + workingWWW.url);
                 workingWWW     = null;
                 workingRequest = null;
                 fetchingQueue.RemoveAt(0);
             }
             else
             {
                 DebugUtil.Error("WWW download has error: " + workingWWW.error + " url: " + workingWWW.url);
                 //use tmp handle to clean status in resourcemanager first
                 WWWRequestHandle tmp = workingRequest;
                 workingWWW     = null;
                 workingRequest = null;
                 fetchingQueue.RemoveAt(0);
                 if (tmp.errorCallback != null)
                 {
                     tmp.errorCallback(tmp, tmp.cmd);
                 }
                 //throw new System.Exception(workingWWW.error + " : " + workingWWW.url);
                 tmp.m_LoadResTimeCost.Stop();
                 System.TimeSpan cost           = tmp.m_LoadResTimeCost.Elapsed;
                 string          timecostdetial = string.Format("{0} Loaded,time cost: {1}", tmp.url, cost.TotalSeconds);
                 DebugUtil.Info(timecostdetial);
             }
         }
         else
         {
             if (workingWWW.isDone)
             {
                 //DebugOutPut.Log("WWW download complete: " + workingWWW.url, DebugLogLevel.LogLevel1);
                 workingRequest.IsDone             = true;
                 fetchedWWWMap[workingRequest.url] = workingWWW;
                 workingWWW = null;
                 //use tmp handle to clean status in resourcemanager first
                 WWWRequestHandle tmp = workingRequest;
                 workingRequest = null;
                 fetchingQueue.RemoveAt(0);
                 if (tmp.completeCallback != null)
                 {
                     tmp.completeCallback(tmp, tmp.cmd);
                 }
                 tmp.m_LoadResTimeCost.Stop();
                 System.TimeSpan cost           = tmp.m_LoadResTimeCost.Elapsed;
                 string          timecostdetial = string.Format("{0} Loaded,time cost: {1}", tmp.url, cost.TotalSeconds);
                 DebugUtil.Info(timecostdetial);
             }
         }
     }
 }