Beispiel #1
0
 private void MoveHandler(byte[] message)
 {
     try
     {
         ServerMoveDTO serverMove = ServerMoveDTO.Parser.ParseFrom(message);
         FightScene.instance.Refresh(serverMove);
     }
     catch (InvalidProtocolBufferException)
     {
         Debug.Log("InvalidProtocolBufferException");
     }
     FrameActions.instance.Clear();
 }
Beispiel #2
0
    public void Refresh(ServerMoveDTO move)
    {
        for (int i = 0; i < FrameActions.instance.FrameCount; ++i)
        {
            int   count     = 0;
            float deltaTime = 0;
            for (int j = 0; j < move.ClientInfo.Count; ++j)
            {
                if (move.ClientInfo[j].Seat != -1 && !isInDeath(move.ClientInfo[j].Seat))
                {
                    ++count;
                    deltaTime += move.ClientInfo[j].Msg[i].DeltaTime;
                }
            }
            if (count == 0)
            {
                continue;
            }
            deltaTime /= count;
            gameTime  += deltaTime;
            for (int k = 0; k < lights.Count; ++k)
            {
                LightManager lightManager = lights[k].GetComponent <LightManager>();
                lightManager.Move(deltaTime);
            }

            for (int p = 0; p < players.Count; ++p)
            {
                // 是否丢包
                int           index         = -1;
                PlayerControl playerControl = players[p].GetComponent <PlayerControl>();
                playerControl.UpdateState(deltaTime);
                if (playerControl.attr.isEnd)
                {
                    continue;
                }
                for (int q = 0; q < move.ClientInfo.Count; ++q)
                {
                    if (move.ClientInfo[q].Seat == playerControl.attr.seat)
                    {
                        index = q;
                        break;
                    }
                }
                if (index != -1 && !playerControl.attr.isDied)
                {
                    playerControl.onMsgHandler(move.ClientInfo[index].Msg[i], deltaTime);
                }
            }
        }
    }
Beispiel #3
0
 public void AddCache(ServerMoveDTO moveDTO)
 {
     caches.Add(moveDTO);
     caches.Sort((a, b) => a.Bagid.CompareTo(b.Bagid));
     PlayCache();
 }