Exemplo n.º 1
0
    public static void SendAiStateHigh(long playerId, long actorId, StateEnum aiState, int targetCellIndex = 0, long targetId = 0, float durationTime = 0f, float totalTime = 0f)
    {
        ActorAiStateHigh output = new ActorAiStateHigh()
        {
            RoomId             = GameRoomManager.Instance.RoomId, // 肯定是在同一个房间里
            OwnerId            = playerId,
            ActorId            = actorId,
            HighAiState        = (int)aiState,
            HighAiCellIndexTo  = targetCellIndex,
            HighAiTargetId     = targetId,
            HighAiDurationTime = durationTime,
            HighAiTotalTime    = totalTime,
        };

        GameRoomManager.Instance.SendMsg(ROOM.ActorAiStateHigh, output.ToByteArray());
    }
Exemplo n.º 2
0
    private void OnActorAiStateHigh(SocketAsyncEventArgs args, byte[] bytes)
    {
        ActorAiStateHigh input = ActorAiStateHigh.Parser.ParseFrom(bytes);

        if (input.RoomId != RoomId)
        {
            return; // 不是自己房间的消息,略过
        }
        // 更新单元Ai信息,在服务器的ActorBehaviour里保存一份
        var ab = ActorManager.GetActor(input.ActorId);

        if (ab != null)
        {
            ab.HighAiState        = input.HighAiState;
            ab.HighAiTargetId     = input.HighAiTargetId;
            ab.HighAiCellIndexTo  = input.HighAiCellIndexTo;
            ab.HighAiDurationTime = input.HighAiDurationTime;
            ab.HighAiTotalTime    = input.HighAiTotalTime;
            ab.HighAiStartTime    = DateTime.Now; // 记录得到当前状态的时间, 在存盘的时候再记录一下时间, 把剩余时间保存起来
        }

        ActorAiStateHighReply output2 = new ActorAiStateHighReply()
        {
            RoomId             = input.RoomId,
            OwnerId            = input.OwnerId,
            ActorId            = input.ActorId,
            HighAiState        = input.HighAiState,
            HighAiTargetId     = input.HighAiTargetId,
            HighAiCellIndexTo  = input.HighAiCellIndexTo,
            HighAiDurationTime = input.HighAiDurationTime,
            HighAiTotalTime    = input.HighAiTotalTime,
            Ret = true,
        };

        BroadcastMsg(ROOM_REPLY.ActorAiStateHighReply, output2.ToByteArray());
    }