string GetInstructionLogInfo(RpBattleInstructionList rpMessage)
        {
            System.Text.StringBuilder logSb = new System.Text.StringBuilder();
            logSb.Append("收到数据 " + rpMessage.FrameCount + "\t\t");
            for (int i = 0; i < rpMessage.BattleInstructionList.Count; ++i)
            {
                var item = rpMessage.BattleInstructionList [i];
                logSb.Append(item.SceneUnitId.ToString() + "\t");
                logSb.Append(item.InstructionType.ToString() + "\t");
                switch (item.InstructionType)
                {
                case BattleInstructionType.Move:
                    BattleMove moveInstruct = item as BattleMove;
                    logSb.Append(moveInstruct.MoveAngle);
                    break;

                case BattleInstructionType.StopMove:
                    break;

                default:
                    break;
                }
            }
            return(logSb.ToString());
        }
Esempio n. 2
0
        void SynchronizeBattleEvent()
        {
            mCurFrameCount++;
            //LBLogger.Info(LogTag, "向前端发送战斗数据,帧数为:" + mCurFrameCount);
            if (0 == mPlayerBattleInstructionList.Count)
            {
                BroadcastEvent(RpId.BattleInstruction, RpBattleInstructionList.Serialization(mCurFrameCount, new List <BattleInstructionBase> (0), true));
                return;
            }
            int i = 0;
            List <BattleInstructionBase> instructionList = null;

            while (i < mPlayerBattleInstructionList.Count)
            {
                if (null == instructionList)
                {
                    int capacity = i + RpBattleInstructionList.MaxInstructionCount > mPlayerBattleInstructionList.Count ? mPlayerBattleInstructionList.Count - i : RpBattleInstructionList.MaxInstructionCount;
                    instructionList = new List <BattleInstructionBase>(capacity);
                }
                instructionList.Add(mPlayerBattleInstructionList[i]);
                if (instructionList.Count >= RpBattleInstructionList.MaxInstructionCount || i == mPlayerBattleInstructionList.Count - 1)
                {
                    bool isFinish = i == mPlayerBattleInstructionList.Count - 1;
                    BroadcastEvent(RpId.BattleInstruction, RpBattleInstructionList.Serialization(mCurFrameCount, instructionList, isFinish));
                }
                ++i;
            }
            mPlayerBattleInstructionList.Clear();
        }
 public void AddInstruction(RpBattleInstructionList rpMessage)
 {
     BattleLogManager.Instance.Log("ReceIns", GetInstructionLogInfo(rpMessage));
     //Logger.LogWarning ("添加指令: " + rpMessage.FrameCount);
     if (null != mCurNotAllReceiveInstructions)
     {
         if (rpMessage.FrameCount != mCurNotAllReceiveInstructions.frameCount)
         {
             Logger.LogError("等待接受战斗指令,但是确收到了下一帧的数据,为什么呢?新的帧号是:" + rpMessage.FrameCount);
             mInstructionQueue.Enqueue(mCurNotAllReceiveInstructions);
             mCurNotAllReceiveInstructions = null;
         }
         else
         {
             mCurNotAllReceiveInstructions.instructionList.AddRange(rpMessage.BattleInstructionList);
             if (rpMessage.IsFrameFinish)
             {
                 mInstructionQueue.Enqueue(mCurNotAllReceiveInstructions);
                 mCurNotAllReceiveInstructions = null;
                 mLastInstructionFrameCount    = rpMessage.FrameCount;
             }
             else
             {
             }
         }
     }
     else
     {
         if (rpMessage.IsFrameFinish)
         {
             OneFrameInstructions newFrameInfo = new OneFrameInstructions();
             newFrameInfo.frameCount      = rpMessage.FrameCount;
             newFrameInfo.instructionList = rpMessage.BattleInstructionList;
             mInstructionQueue.Enqueue(newFrameInfo);
             mLastInstructionFrameCount = rpMessage.FrameCount;
         }
         else
         {
             mCurNotAllReceiveInstructions                 = new OneFrameInstructions();
             mCurNotAllReceiveInstructions.frameCount      = rpMessage.FrameCount;
             mCurNotAllReceiveInstructions.instructionList = rpMessage.BattleInstructionList;
         }
     }
 }