private void OnFightStart(SocketAsyncEventArgs args, byte[] bytes) { FightStart input = FightStart.Parser.ParseFrom(bytes); if (input.RoomId != RoomId) { return; // 不是自己房间的消息,略过 } var attacker = ActorManager.GetActor(input.ActorId); if (attacker == null) { FightStartReply output = new FightStartReply() { RoomId = input.RoomId, OwnerId = input.OwnerId, ActorId = input.ActorId, Ret = false, ErrMsg = "Attacker not found!", }; ServerRoomManager.Instance.SendMsg(args, ROOM_REPLY.FightStartReply, output.ToByteArray()); return; } if (attacker.AmmoBase <= 0) { // 3.1-弹药基数不足, 无法攻击 attacker.AmmoBase = 0; FightStartReply output = new FightStartReply() { RoomId = input.RoomId, OwnerId = input.OwnerId, ActorId = input.ActorId, Ret = false, ErrMsg = "弹药基数不足, 无法攻击!", }; ServerRoomManager.Instance.SendMsg(args, ROOM_REPLY.FightStartReply, output.ToByteArray()); return; } { FightStartReply output = new FightStartReply() { RoomId = input.RoomId, OwnerId = input.OwnerId, ActorId = input.ActorId, TargetId = input.TargetId, SkillId = input.SkillId, Ret = true, }; // 广播 BroadcastMsg(ROOM_REPLY.FightStartReply, output.ToByteArray()); } }
private void OnFightStartReply(byte[] bytes) { FightStartReply input = FightStartReply.Parser.ParseFrom(bytes); if (input.ActorId != ActorId) { return; // 不是自己,略过 } if (!input.Ret) { GameRoomManager.Instance.Log($"ActorBehaviour OnFightStartReply Error - {input.ErrMsg}"); StateMachine.TriggerTransition(StateEnum.IDLE); return; } GameRoomManager.Instance.Log("ActorBehaviour OnFightStartReply OK ..."); }
private void OnFightStartReply(byte[] bytes) { FightStartReply input = FightStartReply.Parser.ParseFrom(bytes); if (input.ActorId != ActorId) { return; // 不是自己,略过 } if (!input.Ret) { PanelSprayMessage spray = GameRoomManager.Instance.FightManager.SprayMessage.Spawn(_inner, Vector3.zero); if (spray == null) { return; } spray.Play(this, input.ErrMsg, PanelSystemTips.MessageType.Error); GameRoomManager.Instance.Log($"ActorVisualizer OnFightStartReply Error - {input.ErrMsg}"); return; } // 显示自己的血条 ShowSliderBlood(); GameRoomManager.Instance.Log("ActorVisualizer OnFightStartReply OK ..."); // 显示对方的血条 var avTarget = GameRoomManager.Instance.GetActorVisualizer(input.TargetId); if (!avTarget) { return; } if (avTarget.IsDead) { return; } avTarget.ShowSliderBlood(); }