Esempio n. 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();
        }
Esempio n. 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);
        }
Esempio n. 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();
        }
Esempio n. 4
0
 public static void ShowPlayer(this EntityComponent entityComponent, PlayerEntityData data)
 {
     entityComponent.ShowActorEntity(typeof(PlayerRole), data);
 }