示例#1
0
        protected override void OnInit(object userData)
        {
            base.OnInit(userData);

            m_PlayerEntityData = userData as PlayerEntityData;
            if (m_PlayerEntityData == null)
            {
                Log.Error("playerEntityData is null");
                return;
            }

            m_Animator            = gameObject.GetComponent <Animator>();
            m_CharacterController = gameObject.GetOrAddComponent <CharacterController>();

            PlayerActor = new ActorPlayer(m_PlayerEntityData.Id, m_PlayerEntityData.TypeId, gameObject, ActorType.Player, ActorBattleCampType.Ally, m_CharacterController, m_Animator);
            PlayerActor.Init();

            //设置自身,与跟随相机到场景出身点
            Vector3 spawnPos = GameEntry.Scene.GetCurSceneSpawnPos();

            CachedTransform.position = spawnPos;
            GameEntry.Camera.SetCameraRigPos(spawnPos);

            AddEventListener();
        }
示例#2
0
        private void InitPlayer(int playerId)
        {
            if (Config.Ally == null)
            {
                return;
            }

            DBPlayer dbPlayer = GameEntry.Database.GetDBRow <DBPlayer>(playerId);

            int              entityId    = GameEntry.Entity.GenerateSerialId();
            bool             battleState = CurSceneType == SceneType.Battle;
            PlayerEntityData data        = new PlayerEntityData(entityId, dbPlayer.Id, ActorType.Player, BattleCampType.Ally, battleState)
            {
                Position = Config.Ally.TransParam.Position,
                Rotation = Quaternion.Euler(Config.Ally.TransParam.EulerAngles),
                Scale    = Config.Ally.TransParam.Scale
            };

            AddRole <PlayerRole>(data);
        }
示例#3
0
        protected override void OnShow(object userData)
        {
            base.OnShow(userData);

            m_EntityData = userData as PlayerEntityData;
            if (m_EntityData == null)
            {
                Log.Error("playerEntityData is null");
                return;
            }

            //创建Actor
            ActorType      actorType = m_EntityData.ActorType;
            BattleCampType campType  = m_EntityData.CampType;

            Actor = new ActorPlayer(this, actorType, campType, m_CharacterController,
                                    m_Animator);
            Actor.Init();
            ((ActorPlayer)Actor).BattleState = m_EntityData.BattleState;

            GameEntry.Camera.SwitchCameraBehaviour(CameraBehaviourType.LockLook);

            AddEventListener();
        }
示例#4
0
 public static void ShowPlayer(this EntityComponent entityComponent, PlayerEntityData data)
 {
     entityComponent.ShowActorEntity(typeof(PlayerRole), data);
 }