Ejemplo n.º 1
0
    //收到玩家进入场景
    public void ParseEnterBattle(BPEnter bp)
    {
        SceneEvent.GetInstance().dispatchEvent(SCENE_EVENT.ADD_PLAYER, new Notification(bp));

        //通知其他玩家自己位置
        if (bp.BattleId != PlayerModule.GetInstance().RoleID&& !_sendList.Contains(bp.BattleId))
        {
            _sendList.Add(bp.BattleId);
            BattleProtocol.GetInstance().SendEnterBattle(PlayerModule.GetInstance().RoleID, PlayerModule.GetInstance().RoleJob);
        }
    }
Ejemplo n.º 2
0
    private void CreatePlayer(BPEnter bp)
    {
        if (_charaDic.ContainsKey(bp.BattleId))
        {
            return;
        }

        //test
        PlayerBattleInfo playerInfo = new PlayerBattleInfo(1, CHARA_TYPE.PLAYER);

        playerInfo.SetFightInfo(100);
        playerInfo.SetPlayerInfo();
        playerInfo.SetBattleInfo(bp.BattleId, (int)bp.BattleId, bp.Pos);

        playerInfo.CareerType = bp.CareerType;
        //test
        _charaDic.Add(bp.BattleId, playerInfo);
        _charaList.Add(playerInfo);


        if (playerInfo.BattleId == PlayerModule.GetInstance().RoleID)
        {
            MyPlayer = playerInfo;
            MapManager.GetInstance().Update(playerInfo.MovePos);
        }

        if (_playerPrefab.ContainsKey(playerInfo.CareerType))
        {
            //资源加载中 等待回调
            if (null == _playerPrefab[playerInfo.CareerType])
            {
                return;
            }
            CreatePlayerView(playerInfo);
        }
        else
        {
            //占位 启动加载
            _playerPrefab.Add(playerInfo.CareerType, null);
            AssetManager.LoadAsset("Assets/Models/TmpCharacter/" + modelNames[(int)playerInfo.CareerType], (Object target, string path) =>
            {
                _playerPrefab[playerInfo.CareerType] = target as GameObject;
                LaterCreatePlayer();
            });
        }
    }
Ejemplo n.º 3
0
    private void OnAddPlayer(Notification note)
    {
        BPEnter bp = (BPEnter)note.param;

        CreatePlayer(bp);
    }
Ejemplo n.º 4
0
    //进入场景
    public void SendEnterBattle(uint battleId, uint careerType)
    {
        BPEnter bp = new BPEnter(battleId, careerType);

        SendMsg(bp);
    }