Beispiel #1
0
 void Update()
 {
     if (string.IsNullOrEmpty(txtPlayerName.text))
     {
         txtPlayerName.text = PlayerModule.GetInstance().RoleName;
     }
 }
Beispiel #2
0
 private void UpdateMap()
 {
     if (_charaViewDic != null)
     {
         GameObject tempPlayer;
         if (_charaViewDic.TryGetValue(PlayerModule.GetInstance().RoleID, out tempPlayer))
         {
             MapManager.GetInstance().Update(tempPlayer.transform.position);
         }
     }
 }
Beispiel #3
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);
        }
    }
Beispiel #4
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();
            });
        }
    }
Beispiel #5
0
 private void Test()
 {
     BattleProtocol.GetInstance().Init();
     //SceneEvent.GetInstance().dispatchEvent(SCENE_EVENT.ADD_PLAYER, new Notification(1, this.gameObject));
     //SceneEvent.GetInstance().dispatchEvent(SCENE_EVENT.ADD_PLAYER, new Notification(2, this.gameObject));
     if (NetWorkConst.IsOpenNetWork)
     {
         BattleProtocol.GetInstance().SendEnterBattle(PlayerModule.GetInstance().RoleID, PlayerModule.GetInstance().RoleJob);
     }
     else
     {
         /*
          * PlayerModule.GetInstance().SetRoleInfo(new gprotocol.p_role()
          * {
          * id = 1,
          * job = 1
          * });
          */
         BattleProtocol.GetInstance().SendEnterBattle(1, 1);
         BattleProtocol.GetInstance().SendEnterBattle(2, 1);
     }
 }
Beispiel #6
0
    private void CreatePlayerView(PlayerBattleInfo playerInfo)
    {
        if (null == playerInfo)
        {
            return;
        }

        GameObject gameObject = GameObject.Instantiate(_playerPrefab[playerInfo.CareerType]);

        gameObject.transform.localPosition = playerInfo.MovePos;
        gameObject.transform.parent        = _playerLayer;
        _charaViewDic.Add(playerInfo.BattleId, gameObject);
        gameObject.AddComponent <PlayerBattleActor>();
        gameObject.GetComponent <PlayerBattleActor>().SetInfo(playerInfo);
        //通知ui管理器 添加头像
        SceneEvent.GetInstance().dispatchEvent(SCENE_EVENT.ADD_UI_HEAD, new Notification(playerInfo));

        if (playerInfo.BattleId == PlayerModule.GetInstance().RoleID)
        {
            GameObject.Find("Main Camera").GetComponent <CameraFollow>().target = gameObject.transform;
            GameObject.Find("SkillJoystick").GetComponent <SkillArea>().player  = gameObject;
        }
    }