Exemplo n.º 1
0
    public void Init()
    {
        //EasyTouchSimpleEvent.SwipeAction += OnSwipe;
        //EasyTouchSimpleEvent.Swipe2FingerAction += OnSwipe2Finger;
        //EasyTouchSimpleEvent.SwipeEnd2FingerAction += OnSwipeEnd2Finger;
        //InputManager.MouseScrollWheelAction += OnMouseScrollWheel;
        if (initialized)
        {
            return;
        }
        initialized = true;
        if (followCamera == null)
        {
            followCamera = Camera.main;
        }
        if (followCamera == null)//再次确认是否存在,场景里不拖拽相机到这脚本上,就需要代码赋值,但存在camera被隐藏的情况,因此通过名字查找
        {
            Transform obj = transform.parent.Find("Main Camera");
            if (obj != null)
            {
                followCamera = obj.GetComponent <Camera>();
            }
            else
            {
                EB.Debug.LogError("Can't find Main Camera!!!");
            }
        }
        cc = followCamera.GetComponent <CombatCamera>();

        if (isActive)
        {
            //followOffset = new Vector3(0, followOffsetY, 0);
            Transform buffParent = transform.parent;
            followCamera.transform.LookAt(this.transform);
            transform.SetParent(followCamera.transform);
            transform.localEulerAngles = Vector3.zero;
            transform.SetParent(buffParent);
            followCamera.transform.SetParent(this.transform);
            if (cc != null)
            {
                cc.State = CombatCamera.MotionState.Freedom;
            }
        }

        if (_rotationTarget == null)
        {
            _rotationTarget          = new GameObject("RotationTarget").transform;
            _rotationTarget.rotation = transform.rotation;
        }

        delTouchCharacter  += OnTouchCharacter;
        delTouchDownInView += OnTouchDownInView;

        if (GameEngine.Instance == null)
        {
            isOpenTouchView = false;
        }

        CameraRotationalSpeed = CAMERA_ROTATIONAL_SPEED;
    }
Exemplo n.º 2
0
    void OnDestroy()
    {
        //EasyTouchSimpleEvent.SwipeAction -= OnSwipe;
        //EasyTouchSimpleEvent.Swipe2FingerAction -= OnSwipe2Finger;
        //EasyTouchSimpleEvent.SwipeEnd2FingerAction -= OnSwipeEnd2Finger;
        //InputManager.MouseScrollWheelAction -= OnMouseScrollWheel;

        Instance = null;

        delTouchCharacter  -= OnTouchCharacter;
        delTouchDownInView -= OnTouchDownInView;

        if (_rotationTarget != null)
        {
            Destroy(_rotationTarget.gameObject);
        }
    }