public void SetPlayer(MapRole playerRoleView) { playerRoleView.BindRoleInstance(runtime.Player, () => { //由于这里是异步加载模型,所以必须加载完后才初始化出生点,因为初始化出生点里有描述玩家是否在船上,需要调用子节点的renderer //初始化出生点 LoadSpawnPosition(); }); _playerView = playerRoleView; _player = playerRoleView.transform; _playerNavAgent = playerRoleView.GetComponent <NavMeshAgent>(); SetPlayerSpeed(0); var gameMap = GetCurrentGameMap(); if (gameMap != null && gameMap.Tags.Contains("WORLDMAP")) { _playerNavAgent.speed = 10; //大地图上放大一倍 } else { _playerNavAgent.speed = MapRuntimeData.Instance.ExploreSpeed; } _playerNavAgent.angularSpeed = MapRuntimeData.Instance.ExploreAngularSpeed; _playerNavAgent.acceleration = MapRuntimeData.Instance.ExploreAcceleration; var playerCom = _player.GetComponent <Jyx2Player>(); if (playerCom == null) { var player = _player.gameObject.AddComponent <Jyx2Player>(); player.Init(); } }
void DoSwitchRoleModel() { var role = new RoleInstance(PlayerRoleId.ToString()); player.BindRoleInstance(role, () => { var animator = player.GetAnimator(); animator.runtimeAnimatorController = player.GetComponent <Animator>().runtimeAnimatorController; //force set animator SwitchSkillPose(); }); }
/// <summary> /// 地图角色绑定新的数据实例 /// </summary> /// <param name="roleKey"></param> /// <param name="roleView"></param> public static void CreateRoleInstance(this MapRole roleView, string roleKey) { roleView.BindRoleInstance(new RoleInstance(roleKey)); roleView.DataInstance.Hp = roleView.DataInstance.MaxHp; //默认满血 }