Пример #1
0
        /// <summary>
        /// 设置玩家
        /// </summary>
        /// <param name="unit"></param>
        public void SetPlayer(TUnit unit)
        {
            PrePlayer       = LocalPlayer;
            BasePrePlayer   = LocalPlayer;
            LocalPlayer     = unit as TUnit;
            BaseLocalPlayer = unit;
            Callback_OnSetPlayer?.Invoke(PrePlayer, LocalPlayer);
            Callback_OnSetPlayerBase?.Invoke(PrePlayer, LocalPlayer);

            if (PrePlayer != null)
            {
                PrePlayer.Callback_OnRealDeath -= OnPlayerRealDeath;
            }
            if (LocalPlayer != null)
            {
                LocalPlayer.Callback_OnRealDeath += OnPlayerRealDeath;
            }
        }
Пример #2
0
        // 设置玩家
        // 默认会在OnBattleLoaded设置Player
        public virtual void SetPlayer(TUnit unit, bool isSystem = false)
        {
            Player?.OnUnBeSetPlayer();
            PrePlayer       = Player;
            BasePrePlayer   = Player;
            Player          = unit;
            BaseLocalPlayer = unit;
            Callback_OnSetPlayer?.Invoke(PrePlayer, Player);
            Callback_OnSetPlayerBase?.Invoke(PrePlayer, Player);

            if (PrePlayer != null)
            {
                PrePlayer.Callback_OnRealDeath -= OnPlayerRealDeath;
            }
            if (Player != null)
            {
                Player.Callback_OnRealDeath += OnPlayerRealDeath;
            }

            Player?.OnBeSetPlayer();
        }