Exemple #1
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;
                }
            }
        }
        private void LoadMount()
        {
            int mountId = UnityEngine.Random.Range(100001, 100003);

            TransformParam param = TransformParam.Create(CachedTransform.position, CachedTransform.eulerAngles);

            int             entityId = GameEntry.Entity.GenerateSerialId();
            MountEntityData data     = new MountEntityData(entityId, mountId, ActorType.Mount, BattleCampType.Ally, this)
            {
                Position = param.Position,
                Rotation = Quaternion.Euler(param.EulerAngles),
                Scale    = param.Scale
            };

            GameEntry.Level.AddRole <MountRole>(data);
            this.Mount = entityId;
        }