Exemplo n.º 1
0
        /// <summary>
        /// 本控制器接管
        /// </summary>
        public override void Enter(CameraContext context)
        {
            AnimCamContext _context = context as AnimCamContext;

            SetupDatas(_context);
            Animation anim = animGo.AddComponent <Animation>();

            if (anim != null)
            {
                anim.AddClip(_context.clip, _context.clip.name);
                anim.Play(_context.clip.name);
            }
            SendCameraFocusPosToLogic(0);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 判断Context是否存在且无误
        /// </summary>
        /// <param name="bEnabled"></param>
        public override bool CheckContext(CameraContext context)
        {
            AnimCamContext _context = context as AnimCamContext;

            if (_context != null && _context.clip != null)
            {
                return(true);
            }
            else
            {
                CameraUtil.LogError("_context.clip is null! : " + _context);
                return(false);
            }
        }
Exemplo n.º 3
0
        private void SetupDatas(AnimCamContext context)
        {
            GameObject camGo = new GameObject("CameraAnimRef");

            m_camRecTrans           = camGo.transform;
            animGo                  = new GameObject("Anim");
            animGo.transform.parent = m_camRecTrans;
            m_camAnimTrans          = animGo.transform;
            GameObject camFOVGo = new GameObject("camFOV");

            m_camFOVTrans        = camFOVGo.transform;
            m_camFOVTrans.parent = animGo.transform;

            m_camRecTrans.position   = Vector3.zero;
            m_cameraAminFollowHero   = false;
            m_cameraAnimProjectFloor = context.projectFloor;
            m_cameraAnimMainCamera   = context.animationMainCamera;

            if (context.animOrgType == CameraAnimOrgType.Hero || context.animOrgType == CameraAnimOrgType.FollowHero)
            {
                if (soldier != null && soldier.gameObject)
                {
                    m_camRecTrans.position    = soldier.gameObject.transform.position;
                    m_camRecTrans.eulerAngles = soldier.gameObject.transform.eulerAngles;

                    if (context.animOrgType == CameraAnimOrgType.FollowHero)
                    {
                        m_cameraAminFollowHero = true;
                    }
                }
            }
            else if (context.animOrgType == CameraAnimOrgType.TargetPos)
            {
                m_camRecTrans.position = context.targetPos;
                if (soldier != null)
                {
                    if (soldier.gameObject)
                    {
                        m_camRecTrans.eulerAngles = soldier.gameObject.transform.eulerAngles;
                    }
                }
            }
            else if (context.animOrgType == CameraAnimOrgType.SourceObject)
            {
                m_camRecTrans.position    = context.sourceTransform.position;
                m_camRecTrans.eulerAngles = context.sourceTransform.eulerAngles;
            }

            if (m_cameraAnimProjectFloor)
            {
                m_camRecTrans.position = CameraUtil.ProjectToFloor(m_camRecTrans.position);
            }

            m_cameraAminOrgPosition = m_camRecTrans.position;

            if (context.clip.legacy == false)
            {
                Debug.Log("Camera Animation clip " + context.clip.name + " need to be legacy!");
                context.clip.legacy = true;
            }

            m_cameraAnimStopTick = ((uint)(context.clip.length * 1000.0f)) + GameLogicAPI.getTickCount();
        }