コード例 #1
0
    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());
    }
コード例 #2
0
        //---readers

        void StartFightMessage_Reader(ReceivedMsg receivedMsg, StartFightMessage msg)
        {
            if (FightStart != null)
            {
                FightStart.Invoke();
            }
        }
コード例 #3
0
    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());
        }
    }
コード例 #4
0
ファイル: Fight.cs プロジェクト: yabloko9393/FlipTheKnife
        void StartFight()
        {
            timeEndFight = DateTime.Now + _fightLength;

            foreach (var gaemLoop in games)
            {
                gaemLoop.TimeEndFight = timeEndFight;
            }

            Timer.AddTimer(FightEnd_Timer, timeEndFight);

            FightStart?.Invoke(this);
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
ファイル: NewCharacter.cs プロジェクト: geokufer/steppatterns
 public void InitializeStartBattle(FightStart _fightStart) => fightStart = _fightStart;
コード例 #7
0
 private void ShowFightMessage(FightStart fightStart)
 {
     anim.SetTrigger("Fight");
 }