예제 #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
        protected override void OnShow(object userData)
        {
            base.OnShow(userData);
            CachedTransform.rotation = Quaternion.identity;

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

            ActorType      actorType = m_EntityData.ActorType;
            BattleCampType campType  = m_EntityData.CampType;

            Actor = new ActorMount(this, actorType, campType, m_CharacterController,
                                   m_Animator);
            Actor.Init();

            if (m_EntityData.Host != null)
            {
                m_Host = m_EntityData.Host;
                Actor.SetHost(m_Host);
                m_Host.Vehicle = Actor;

                Transform ridePoint = ((ActorMount)Actor).GetRidePoint();

                if (ridePoint != null)
                {
                    m_Host.CachedTransform.parent        = ridePoint;
                    m_Host.CachedTransform.localPosition = Vector3.zero;
                    m_Host.CachedTransform.localRotation = Quaternion.identity;
                }
            }
        }
예제 #3
0
        public int AddPartner(ActorPlayer host, PartnerSortType sortPos, int typeId)
        {
            if (typeId <= 0)
            {
                return(0);
            }

            if (host == null)
            {
                return(0);
            }

            int entityId           = GameEntry.Entity.GenerateSerialId();
            PartnerEntityData data = new PartnerEntityData(entityId, typeId, ActorType.Partner, BattleCampType.Ally, host, sortPos);

            Vector3 pPos = host.GetPartnerPosBySort(sortPos);

            data.Position = pPos;
            data.Rotation = host.CachedTransform.rotation;
            data.Scale    = Vector3.one * 1.5f;

            AddRole <PartnerRole>(data);

            return(entityId);
        }
예제 #4
0
        protected override void OnHide(object userData)
        {
            base.OnHide(userData);

            RemoveEventListener();
            PlayerActor.Destory();
            PlayerActor = null;
        }
예제 #5
0
        public void CreatePlayerActor(ActorPlayer player)
        {
            if (player == null)
            {
                throw new GameFrameworkException("Create Player Fail!");
            }

            this.PlayerActor = player;
        }
예제 #6
0
        private void OnPlayerDead(object sender, GameEventArgs e)
        {
            List <RoleEntityBase> pList = GetRolesByActorType(ActorType.Monster);

            for (int i = 0; i < pList.Count; i++)
            {
                pList[i].Actor.SetTarget(null);
            }

            PlayerActor.CachedTransform.localPosition = Vector3.zero;
            this.PlayerActor = null;
            this.m_Victory   = false;
            this.LeaveCurrentLevel();
        }
예제 #7
0
        protected override void OnUpdate(IFsm <ActorBase> fsm, float elapseSeconds, float realElapseSeconds)
        {
            base.OnUpdate(fsm, elapseSeconds, realElapseSeconds);

            ActorPlayer host = m_Owner.Host as ActorPlayer;

            if (host == null)
            {
                return;
            }

            Vector3 pos = host.GetPartnerPosBySort(m_Owner.Sort);

            m_Owner.ExecuteCommand(new AutoMoveCommand(pos, OnFollowFinished));
        }
예제 #8
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();
        }