Ejemplo n.º 1
0
    //-------------------------------------------------------------------------------------------------------
    protected void updateInfo()
    {
        if (mGameCamera == null)
        {
            return;
        }
        CameraLinker linker = mGameCamera.getCurLinker();

        if (linker != null)
        {
            mCurLinkerName    = linker.getName();
            mLinkedObject     = linker.getLinkObject().getObject();
            mLinkedObjectName = linker.getLinkObject().getName();
            mRelative         = linker.getRelativePosition();
            if (mLinkedObject != null)
            {
                mCurRelative = mGameCamera.getWorldPosition() - mLinkedObject.transform.position;
            }
            else
            {
                mCurRelative = Vector3.zero;
            }
        }
        else
        {
            mCurLinkerName    = "";
            mLinkedObjectName = "";
            mLinkedObject     = null;
            mRelative         = Vector3.zero;
            mCurRelative      = Vector3.zero;
        }
    }
Ejemplo n.º 2
0
    public void linkTarget(string linkerName, MovableObject target)
    {
        GameComponent com = null;

        if (mAllComponentList.ContainsKey(linkerName))
        {
            com = mAllComponentList[linkerName];
        }
        // 如果不是连接器则直接返回
        if (com != null && com.getBaseType() != typeof(CameraLinker))
        {
            return;
        }
        foreach (var item in mLinkerList)
        {
            // 如果使用了该连接器,则激活该连接器
            item.Value.setLinkObject(item.Value == com ? target : null);
            item.Value.setActive(item.Value == com && target != null);
        }
        // 如果是要断开当前连接器,则将连接器名字清空,否则记录当前连接器
        if (target != null && com != null)
        {
            mCurLinker = com as CameraLinker;
        }
        else
        {
            mCurLinker = null;
        }
    }
Ejemplo n.º 3
0
    public override void execute()
    {
        GameCamera camera = (mReceiver) as GameCamera;

        camera.linkTarget(mLinkerName, mTarget);
        if (mTarget != null)
        {
            CameraLinker linker = camera.getComponent(mLinkerName) as CameraLinker;
            if (linker != null)
            {
                linker.setLookAtTarget(mLookAtTarget);
                linker.setLookAtOffset(mLookatOffset);
                // 不使用原来的相对位置,则设置新的相对位置
                if (!mUseOriginRelative)
                {
                    linker.setRelativePosition(mRelativePosition, mSwitchType, mUseLastSwitchSpeed, mSwitchSpeed);
                }
                if (mImmediately)
                {
                    linker.applyRelativePosition(linker.getNormalRelativePosition());
                }
            }
            else if (mLinkerName != "")
            {
                UnityUtility.logError("linker name is not empty, but can not find linker, name : " + mLinkerName);
            }
        }
    }
Ejemplo n.º 4
0
 public CameraLinkerSwitch(CAMERA_LINKER_SWITCH type, CameraLinker parentLinker)
 {
     mType           = type;
     mParentLinker   = parentLinker;
     mOriginRelative = Vector3.zero;
     mTargetRelative = Vector3.zero;
 }
Ejemplo n.º 5
0
    public void linkTarget(CameraLinker linker, MovableObject target)
    {
        if (!mAllComponentTypeList.containsValue(linker))
        {
            return;
        }
        // 如果不是连接器则直接返回
        if (linker != null)
        {
            return;
        }
        int count = mLinkerList.Count;

        for (int i = 0; i < count; ++i)
        {
            CameraLinker item = mLinkerList[i];
            // 如果使用了该连接器,则激活该连接器
            item.setLinkObject(item == linker ? target : null);
            item.setActive(item == linker && target != null);
        }
        // 如果是要断开当前连接器,则将连接器名字清空,否则记录当前连接器
        if (target != null && linker != null)
        {
            mCurLinker = linker;
        }
        else
        {
            mCurLinker = null;
        }
    }
Ejemplo n.º 6
0
 public void linkTarget(CameraLinker linker, MovableObject target)
 {
     if (!mAllComponentTypeList.ContainsValue(linker))
     {
         return;
     }
     // 如果不是连接器则直接返回
     if (linker != null)
     {
         return;
     }
     foreach (var item in mLinkerList)
     {
         // 如果使用了该连接器,则激活该连接器
         item.setLinkObject(item == linker ? target : null);
         item.setActive(item == linker && target != null);
     }
     // 如果是要断开当前连接器,则将连接器名字清空,否则记录当前连接器
     if (target != null && linker != null)
     {
         mCurLinker = linker;
     }
     else
     {
         mCurLinker = null;
     }
 }
Ejemplo n.º 7
0
 public CameraLinkerSwitchCircle(CAMERA_LINKER_SWITCH type, CameraLinker parentLinker)
     :
     base(type, parentLinker)
 {
     mRotatedAngle = 0.0f;
     mTotalAngle   = Mathf.PI;
     mSpeed        = Mathf.PI;
 }
Ejemplo n.º 8
0
 public Vector3 mDirection;  // 此次转换的方向,用于避免不必要的向量重复计算
 public CameraLinkerSwitchLinear(CAMERA_LINKER_SWITCH type, CameraLinker parentLinker)
     :
     base(type, parentLinker)
 {
     mMovedDistance = 0.0f;
     mDirection     = Vector3.zero;
     mSpeed         = 7.0f;
 }
Ejemplo n.º 9
0
 public override void notifyComponentDestroied(GameComponent component)
 {
     base.notifyComponentDestroied(component);
     // 如果是销毁的当前正在使用的连接器,则将记录的连接器清空
     if (mCurLinker == component)
     {
         mCurLinker = null;
     }
     mLinkerList.Remove(component as CameraLinker);
 }
Ejemplo n.º 10
0
 public CameraLinkerSwitchAroundTarget(CAMERA_LINKER_SWITCH type, CameraLinker parentLinker)
     :
     base(type, parentLinker)
 {
     mTotalAngle      = 0.0f;
     mRotatedAngle    = 0.0f;
     mClockwise       = true;
     mDistanceDelta   = 0.0f;
     mDistanceCurrent = 0.0f;
     mSpeed           = Mathf.PI / 2.0f;
 }
Ejemplo n.º 11
0
 public override void resetProperty()
 {
     base.resetProperty();
     mCamera    = null;
     mCurLinker = null;
     mLinkerList.Clear();
     mCameraMoveSpeed  = 30.0f;
     mMouseSpeed       = 0.1f;
     mProcessKey       = false;
     mPositionOffset   = Vector3.zero;
     mLastVisibleLayer = 0;
 }
Ejemplo n.º 12
0
 protected bool mKeyProcess;                              // 锁定摄像机的按键控制
 // 如果要实现摄像机震动,则需要将摄像机挂接到一个节点上,一般操作的是父节点的Transform,震动时是操作摄像机自身节点的Transform
 public GameCamera(string name)
     :
     base(name)
 {
     mUsePreLateUpdate = true;
     mCurLinker        = null;
     mMoveSpeed        = 30.0f;
     mMouseSpeed       = 0.1f;
     mKeyProcess       = false;
     mLinkerList       = new Dictionary <string, CameraLinker>();
     mDestroyObject    = false;
 }
Ejemplo n.º 13
0
 public override void notifyComponentDestroied(GameComponent component)
 {
     base.notifyComponentDestroied(component);
     // 如果是销毁的当前正在使用的连接器,则将记录的连接器清空
     if (mCurLinker == component)
     {
         mCurLinker = null;
     }
     if (mLinkerList.ContainsKey(component.getName()))
     {
         mLinkerList.Remove(component.getName());
     }
 }
 public bool mImmediately;                   // 是否直接将摄像机设置到当前连接器的正常位置
 public override void resetProperty()
 {
     base.resetProperty();
     mTarget             = null;
     mSwitchType         = null;
     mLinker             = null;
     mLookAtTarget       = true;
     mLookatOffset       = Vector3.zero;
     mUseOriginRelative  = true;
     mRelativePosition   = Vector3.zero;
     mUseLastSwitchSpeed = true;
     mSwitchSpeed        = 10.0f;
     mAutoProcessKey     = false;
     mImmediately        = false;
 }
 public bool mImmediately;                   // 是否直接将摄像机设置到当前连接器的正常位置
 public override void init()
 {
     base.init();
     mTarget             = null;
     mSwitchType         = CAMERA_LINKER_SWITCH.CLS_NONE;
     mLinker             = null;
     mLookAtTarget       = true;
     mLookatOffset       = Vector3.zero;
     mUseOriginRelative  = true;
     mRelativePosition   = Vector3.zero;
     mUseLastSwitchSpeed = true;
     mSwitchSpeed        = 10.0f;
     mAutoProcessKey     = false;
     mImmediately        = false;
 }
Ejemplo n.º 16
0
    public void Update()
    {
        if (!FrameBase.mGameFramework.isEnableScriptDebug())
        {
            return;
        }
        if (mGameCamera == null)
        {
            return;
        }
        CameraLinker linker = mGameCamera.getCurLinker();

        if (linker != null)
        {
            CurLinkerName    = UnityUtility.Typeof(linker).ToString();
            LinkedObject     = linker.getLinkObject().getObject();
            LinkedObjectName = linker.getLinkObject().getName();
            Relative         = linker.getRelativePosition();
            if (LinkedObject != null)
            {
                CurRelative = mGameCamera.getWorldPosition() - LinkedObject.transform.position;
            }
            else
            {
                CurRelative = Vector3.zero;
            }
        }
        else
        {
            CurLinkerName    = StringUtility.EMPTY;
            LinkedObjectName = StringUtility.EMPTY;
            LinkedObject     = null;
            Relative         = Vector3.zero;
            CurRelative      = Vector3.zero;
        }
        ActiveComponent.Clear();
        var allComponents = mGameCamera.getAllComponent().getUpdateList();

        foreach (var item in allComponents)
        {
            if (item.Value.isActive())
            {
                ActiveComponent.Add(item.Key.ToString());
            }
        }
    }
Ejemplo n.º 17
0
    public override void execute()
    {
        GameCamera camera = (mReceiver) as GameCamera;

        camera.linkTarget(mLinkerName, mTarget);
        if (mTarget != null)
        {
            CameraLinker linker = camera.getComponent(mLinkerName) as CameraLinker;
            if (linker != null)
            {
                linker.setLookAtTarget(mLookAtTarget);
                linker.setUseTargetYaw(mUseTargetYaw);
                linker.setLookAtOffset(mLookatOffset);
                // 不使用原来的相对位置,则设置新的相对位置
                if (!mUseOriginRelative)
                {
                    linker.setRelativePosition(mRelativePosition, mSwitchType, mUseLastSwitchSpeed, mSwitchSpeed);
                }
            }
        }
    }
Ejemplo n.º 18
0
 public void initType(CameraLinker parentLinker)
 {
     mParentLinker = parentLinker;
 }
Ejemplo n.º 19
0
 public virtual void destroy()
 {
     mParentLinker = null;
 }
Ejemplo n.º 20
0
 public void initType(CAMERA_LINKER_SWITCH type, CameraLinker parentLinker)
 {
     mType         = type;
     mParentLinker = parentLinker;
 }