Exemplo n.º 1
0
 virtual public void     Tick()
 {
     if (current_command_ != null && current_command_.Tick())
     {
         current_command_.OnDestroy();
         current_command_ = null;
     }
 }
Exemplo n.º 2
0
        public void AddCommand(int logic_frame, BLCommandBase command)
        {
            if (!command_list.ContainsKey(logic_frame))
            {
                command_list.Add(logic_frame, new List <BLCommandBase>());
            }

            //Debug.Log("logic_frame  " + logic_frame + " add command");

            command_list[logic_frame].Add(command);
        }
Exemplo n.º 3
0
        public void DoCommand(BLCommandBase command)
        {
            if (current_command_ != null)
            {
                current_command_.OnDestroy();

                current_command_ = null;
            }

            current_command_ = command;
            current_command_.OnInit();
        }
Exemplo n.º 4
0
    public void MainThreadFunc(float delta_time)
    {
        // called every frame
        ProtoData proto_data = receiveBuffer.DequeueProtoData();

        while (proto_data != null)
        {
            //Debug.Log("收到消息包 id : " + proto_data.id);

            switch (proto_data.id)
            {
            case ResponseId.JoinRoomResult:
            {
                JoinRoomResult result = proto_data.proto as JoinRoomResult;

                // 逻辑层更新
                BL.BLTimelineController.Instance().OnJoinRoom(result.team_id);
                // 表现层更新
                BattleField.battle_field.OnJoinRoom(result.team_id, result.team_id);
            }
            break;

            case ResponseId.BattleStart:
            {
                BattleStart result = proto_data.proto as BattleStart;

                BL.BLTimelineController.Instance().Start();
                BattleFieldInputHandle.Instance().enabled = true;
            }
            break;

            case ResponseId.Tick:
            {
                TickList tick_list = proto_data.proto as TickList;
                //Debug.Log("收到同步帧 " + tick_list.frame);

                // 先把指令放入队列
                for (int i = 0; i < tick_list.list.Count; ++i)
                {
                    Tick tick = tick_list.list[i];

                    switch (tick.command_type)
                    {
                    case BL.TickCommandType.Move:
                    {
                        BL.BLIntVector3 dest_position;
                        dest_position.x = tick.x;
                        dest_position.y = 0;
                        dest_position.z = tick.y;

                        BL.BLCommandBase command = BL.BLCommandManager.Instance().CreateMove2PositionCommand(tick.cast_id, tick_list.frame, dest_position);

                        BL.BLCommandManager.Instance().AddCommand(command.cast_frame, command);
                    }
                    break;

                    case BL.TickCommandType.PUT_HERO:
                    {
                        BL.BLCommandBase command = BL.BLCommandManager.Instance().CreatePutHeroCommand(tick.team_id, tick_list.frame, tick.hero_index);

                        BL.BLCommandManager.Instance().AddCommand(command.cast_frame, command);
                    }
                    break;

                    case BL.TickCommandType.PURSUE_TARGET:
                    {
                    }
                    break;
                    }
                    ;
                }

                // 时间轴控制进行一帧, 分发指令
                BL.BLTimelineController.Instance().frame_received++;
            }
            break;

            default:
                break;
            }
            ;

            proto_data = receiveBuffer.DequeueProtoData();
        }
    }