Log() 공개 정적인 메소드

public static Log ( object message ) : void
message object
리턴 void
예제 #1
0
    public void Analysis(Client pClient)
    {
        int Count = pClient.bufferCount;

        try
        {
            pClient.msgLength = pClient.readBuffer.Length;

            object  cmdmsgs = ProtocolByt.ByteToStruct(pClient.readBuffer, typeof(MsgHead));
            MsgHead head    = (MsgHead)cmdmsgs;
            pClient.bufferCount -= Marshal.SizeOf(head);
            string msg = "";
            if (pClient.bufferCount > 0)
            {
                msg         = System.Text.Encoding.UTF8.GetString(pClient.readBuffer, Count - pClient.bufferCount, head.len);
                bufferCount = 0;
            }

            EDebug.LogFormat("Analysis {0} {1}", head.cmd_id, msg);

            ServerMsgObj serverMsgPair = new ServerMsgObj
            {
                MsgId = (int)head.cmd_id,
                SubId = (int)head.sub_id,
                Msg   = msg
            };
            _msgReceived.AddLast(serverMsgPair);
        }
        catch (Exception e)
        {
            EDebug.Log(e.ToString());
            OnDisconnect();
            //throw;
        }
    }
예제 #2
0
    public void Connect()
    {
        if (status == NetStatus.Connected)
        {
            EDebug.Log("服务器已连接!");
            OnConnectOver();
            return;
        }
        string gateHost = "47.104.82.214";
        int    gatePort = 3101;

        client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        try
        {
            client.Connect(gateHost, gatePort);
            status = NetStatus.Connected;
            client.BeginReceive(readBuffer, 0, MAX_BUFFER - bufferCount, SocketFlags.None, OnReceiveCb, readBuffer);
            OnConnectOver();
            EDebug.Log("连接上服务器了");
        }
        catch (System.Exception e)
        {
            EDebug.Log(string.Format("服务器连接失败:\n", e.ToString()));
            OnDisconnect(true);
            throw;
        }
    }
예제 #3
0
 /// <summary>
 /// 召唤怪物
 /// </summary>
 /// <param name="monsterId"></param>
 /// <param name="isEnemy"></param>
 /// <param name="ambush"></param>
 public void Summon(int monsterId, int level, bool isEnemy, int num, bool ambush = false)
 {
     if (num <= 0)
     {
         EDebug.LogErrorFormat("FightLogic.Summon failed, invalid monster num : {0}", num);
         return;
     }
     monsterId += (level - 1);
     for (int idx = AllFighters.Count - 1; idx > 0; --idx)
     {
         FightUnit unit = AllFighters[idx];
         if (unit.IsDead || !unit.IsSummon)
         {
             continue;
         }
         if (unit.HeroId == monsterId)
         {
             ZEventSystem.Dispatch(EventConst.ForceDestroyView, unit);
             AllFighters.RemoveAt(idx);
         }
     }
     for (int idx = 0; idx < num; ++idx)
     {
         int summonPos = -1;
         for (int stubX = 0; stubX < PathFinder.H_GRID; ++stubX)
         {
             for (int stubY = 0; stubY < PathFinder.V_GRID; ++stubY)
             {
                 int fightPos = PathFinder.Stub2InitPos(CurRound, (ambush ? !isEnemy : isEnemy), (stubX + 1) * 10 + (stubY + 1));
                 if (!CheckGridPosOccupy(fightPos))
                 {
                     summonPos = fightPos;
                     break;
                 }
             }
         }
         if (summonPos >= 0)
         {
             Monster monster = JsonMgr.GetSingleton().GetMonsterByID(monsterId);
             if (monster == null)
             {
                 EDebug.LogErrorFormat("Summon failed, could not find monster {0} from json", monsterId);
                 return;
             }
             FightUnit summon = new FightUnit(monster, 0, isEnemy, true);
             summon.UID = ++UID;
             _createFightUnitView(summon);
             summon.PathFinderObj.SetPos(summonPos);
             AllFighters.Add(summon);
             ZEventSystem.Dispatch(EventConst.OnCreateSummon, summon);
         }
         else
         {
             EDebug.Log("Summon failed, could not find summonPos");
         }
     }
 }
예제 #4
0
    IEnumerator FirstLogin()
    {
        EDebug.Log("firstLogin");
        yield return(StartCoroutine(CopyVersionFileFromStreamingAssetsToPersistentDataPath()));

        EDebug.Log("unzip");
        // yield return StartCoroutine(CopyUnZipBundle());
        GameStart();
    }
예제 #5
0
    IEnumerator CopyVersionFileFromStreamingAssetsToPersistentDataPath()
    {
        string url = BundleConfig.StreamingAssetPath + BundleConfig.resourceVersionFileName;
        WWW    www = new WWW(url);

        yield return(www);

        if (string.IsNullOrEmpty(www.error) == false)
        {
            EDebug.Log("copy versionfile from streamingasset to persistentdatapath error:" + www.error);
            yield break;
        }
        string destUrl = BundleConfig.PersistentDataPath + BundleConfig.resourceOldVersionFileName;

        File.WriteAllBytes(destUrl, www.bytes);
        StreamReader sr = new StreamReader(destUrl);

        version = sr.ReadLine();
        while (!sr.EndOfStream)
        {
            string   str      = sr.ReadLine();
            string[] strList  = str.Split('\t');
            string   fileName = strList[0].ToLower();

            if (fileName.EndsWith(".zip"))
            {
                continue;
            }
            string downloadUrl = BundleConfig.localDownloadPathRoot + fileName;
            EDebug.Log(downloadUrl);
            WWW wwwRes = new WWW(downloadUrl);
            yield return(wwwRes);

            if (string.IsNullOrEmpty(wwwRes.error) == false)
            {
                EDebug.Log("download error:" + www.error);
                continue;
            }

            string dir = BundleConfig.PersistentDataPath + fileName.Substring(0, fileName.LastIndexOf('/') + 1);
            EDebug.Log("download:" + downloadUrl);
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            File.WriteAllBytes(BundleConfig.PersistentDataPath + fileName, wwwRes.bytes);
        }
        EDebug.Log(version);
        sr.Close();
        sr.Dispose();
    }
예제 #6
0
 public void OnLoginResult(bool success)
 {
     if (success)
     {
         EDebug.Log("LoginSuccess");
         _login = true;
         lastKeepAliveReceive = Time.time;
         //CanvasView.Instance.OpenConnect(false);
     }
     else
     {
         Reset();
     }
 }
예제 #7
0
    IEnumerator CopyUnZipBundle()
    {
        string filename = "bundleassets_" + version + ".zip";

        string url = BundleConfig.StreamingAssetPath + filename;
        WWW    www = new WWW(url);

        yield return(www);

        if (string.IsNullOrEmpty(www.error) == false)
        {
            EDebug.Log("copy versionfile from streamingasset to persistentdatapath error:" + www.error);
            yield break;
        }
        string destUrl = BundleConfig.PersistentDataPath + filename;

        File.WriteAllBytes(destUrl, www.bytes);
        ZipHelper.Decompress(destUrl, BundleConfig.PersistentDataPath, null);
        yield return(null);
    }
예제 #8
0
    public void Send(ServerMsgId pMsgId, object o, short sub_id = 0, uint arg1 = 0, uint arg2 = 0)
    {
        EDebug.Log("Send " + pMsgId.ToString());
        //if (NetStatus.Disconnected == status)
        //    Connect();
        MsgHead head = new MsgHead
        {
            cmd_id = (short)pMsgId,
            sub_id = sub_id,
            param1 = (int)arg1,
            param2 = (int)arg2
        };
        string msg = JsonUtility.ToJson(o);

        byte[] bMsg = System.Text.Encoding.UTF8.GetBytes(msg);
        head.len = bMsg.Length;
        byte[] bHead  = ProtocolByt.StructToBytes(head, 16);
        byte[] buffer = new byte[bHead.Length + bMsg.Length];
        System.Array.Copy(bHead, buffer, bHead.Length);
        System.Array.Copy(bMsg, 0, buffer, bHead.Length, bMsg.Length);
        _msgSend.AddLast(buffer);
    }
예제 #9
0
    /// <summary>
    /// 通过id获取数量
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public int GetItemNum(int itemId)
    {
        int num = 0;

        if (itemList == null)
        {
            num = 0;
        }
        else
        {
            for (int i = 0; i < itemList.Count; i++)
            {
                if (itemList[i].itemId == itemId)
                {
                    EDebug.Log(itemList[i].itemNum);
                    num = itemList[i].itemNum;
                    break;
                }
            }
        }
        return(999);
    }
예제 #10
0
    /// <summary>
    /// 战斗状态改变
    /// </summary>
    /// <param name="state"></param>
    public void OnFightStateChange(FightState state)
    {
        switch (state)
        {
        case FightState.Init:
            break;

        case FightState.Prepare:
            //设置所有单位初始站位,目标站位
            for (int idx = 0; idx < AllFighters.Count; ++idx)
            {
                AllFighters[idx].SystemProtect = false;
                AllFighters[idx].InitPassiveSkill();
            }
            ZEventSystem.Register(EventConst.OnUnitMoveOver, this, "OnUnitMoveOver");
            EnterBattileField();
            break;

        case FightState.Fight:
            EDebug.Log("战斗开始");
            CamMgrObj.ChangeCam(true);
            //使用被动技能
            for (int idx = 0; idx < AllFighters.Count; ++idx)
            {
                FightUnit u = AllFighters[idx];
                if (u.IsDead)
                {
                    continue;
                }
                AllFighters[idx].FightIntervalAcc = 0;
                AllFighters[idx].FightInterval    = 0;
            }
            break;

        case FightState.Continue:
            CamMgrObj.ChangeCam(false);

            clearFightState(false);

            for (int idx = 0; idx < Fighters.Count; ++idx)
            {
                FightUnit u = Fighters[idx];
                if (u.IsDead)
                {
                    continue;
                }
                u.RoundOver();
                u.NewRound();
            }
            ExitBattleField();
            break;

        case FightState.Over:
            EDebug.Log("战斗结束, 是否胜利:" + HasWin);
            clearFightState(true);
            break;

        default:
            break;
        }
    }
예제 #11
0
 void CheckVersion()
 {
     EDebug.Log("check version");
     GameStart();
 }