private void SpawnPlayers(FightStart fightStart) { this.Player1Prefab.transform.position = this.PLAYER_1_START_POS; this.Player2Prefab.transform.position = this.PLAYER_2_START_POS; PubSub.Publish(new PlayersSpawned()); }
//---readers void StartFightMessage_Reader(ReceivedMsg receivedMsg, StartFightMessage msg) { if (FightStart != null) { FightStart.Invoke(); } }
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()); } }
void StartFight() { timeEndFight = DateTime.Now + _fightLength; foreach (var gaemLoop in games) { gaemLoop.TimeEndFight = timeEndFight; } Timer.AddTimer(FightEnd_Timer, timeEndFight); FightStart?.Invoke(this); }
public override void Enter() { _enemyActorId = 0; isRest = false; ActorBehaviour abEnemy = GameRoomManager.Instance.RoomLogic.ActorManager.GetActor(Owner.TargetActorId); if (abEnemy != null && _actorBehaviour.IsEnemyInRange(abEnemy)) { _enemyActorId = abEnemy.ActorId; FightStart output = new FightStart() { RoomId = GameRoomManager.Instance.RoomId, OwnerId = _actorBehaviour.OwnerId, ActorId = _actorBehaviour.ActorId, TargetId = abEnemy.ActorId, // SkillId }; GameRoomManager.Instance.SendMsg(ROOM.FightStart, output.ToByteArray()); } else { // 如果没有找到敌人, 休息 Owner.TriggerTransition(StateEnum.IDLE); } }
public void InitializeStartBattle(FightStart _fightStart) => fightStart = _fightStart;
private void ShowFightMessage(FightStart fightStart) { anim.SetTrigger("Fight"); }