コード例 #1
0
    public void Block2Axis(EnumFreeAxis _axis, float _snapPointX = 0, float _snapPointY = 0, float _snapPointZ = 0)
    {
        state         = CameraManagerState.moving;
        lookingTarget = false;
        freeAxis      = _axis;

        snapPoint = new Vector3(_snapPointX, _snapPointY, _snapPointZ);

        if (snapPoint == Vector3.zero)
        {
            snap = false;
        }
        else
        {
            snap = true;
        }
    }
コード例 #2
0
 public void UnBlockAllAxis()
 {
     freeAxis      = EnumFreeAxis.none;
     state         = CameraManagerState.idle;
     lookingTarget = true;
 }
コード例 #3
0
    new void Update()
    {
        if (lookingTarget)
        {
            currentTarget_A = (target == null) ? this.gameObject : target;
        }
        else
        {
            currentTarget_A = this.gameObject;
        }

        iTween.MoveUpdate(this.gameObject, iTween.Hash("position", destination, "lookTarget", currentTarget_A, "time", timeToTarget));

        //this.transform.position = Vector3.Lerp(this.transform.position, destination, 0.25f);
//		if (pivotY != null)
//		iTween.RotateUpdate (pivotY, iTween.Hash ("rotation", Vector3.up * rotY, "time", timeRotY, "islocal", true));
        if (pivotY != null)
        {
            //dT.text += "\n   >>>: pivoyy != null";
            //			if (y < targetY) {
            //				y += speedRotY * Time.deltaTime;
            //				if (y > targetY) {
            //					y = targetY;
            //				}
            //				pivotY.transform.rotation = Quaternion.Euler (new Vector3 (0, y, 0));
            //			}
            //			if (y > targetY) {
            //				y -= speedRotY * Time.deltaTime;
            //				if (y < targetY) {
            //					y = targetY;
            //				}
            //				pivotY.transform.rotation = Quaternion.Euler (new Vector3 (0, y, 0));
            //			}
            //			float yChangeSpeed = (targetY - y);
            //			if (yChangeSpeed > 8.0f)
            //				yChangeSpeed = 8.0f;
            //			if (yChangeSpeed < -8.0f)
            //				yChangeSpeed = -8.0f;
            //			y += yChangeSpeed * speedRotY * Time.deltaTime;
            //			pivotY.transform.rotation = Quaternion.Euler (new Vector3 (0, y, 0));
            softY.update();
            y = softY.getValue();
            pivotY.transform.rotation = Quaternion.Euler(new Vector3(0, softY.getValue(), 0));
        }
        if (pivotX != null)
        {
            iTween.RotateUpdate(pivotX, iTween.Hash("rotation", Vector3.right * rotX, "time", timeRotX, "islocal", true));
        }
        if (pivotZ != null)
        {
            iTween.MoveUpdate(pivotZ, iTween.Hash("position", Vector3.back * movZ, "time", timeMoveZ, "islocal", true));
        }
        if (mainCamera != null)
        {
            iTween.MoveUpdate(mainCamera, iTween.Hash("position", Vector3.forward * movM, "time", timeMoveM, "islocal", true));
        }

        if (state == CameraManagerState.idle)
        {
            timeToTarget = 2;
            destination  = player_A.transform.position + offset;
            posBase      = this.transform.position;
        }

        if (state == CameraManagerState.moving)
        {
            if (!snap)
            {
                switch (freeAxis)
                {
                case EnumFreeAxis.none:
                    //destination = player.transform.position;
                    break;

                case EnumFreeAxis.x:
                    destination = new Vector3(player_A.transform.position.x, this.transform.position.y, this.transform.position.z) + offset;
                    break;

                case EnumFreeAxis.y:
                    destination = new Vector3(this.transform.position.x, player_A.transform.position.y, this.transform.position.z) + offset;
                    break;

                case EnumFreeAxis.z:
                    destination = new Vector3(this.transform.position.x, this.transform.position.y, player_A.transform.position.z) + offset;
                    break;
                }
            }
            else
            {
                switch (freeAxis)
                {
                case EnumFreeAxis.none:
                    //destination = player.transform.position;
                    break;

                case EnumFreeAxis.x:
                    destination = new Vector3(player_A.transform.position.x, player_A.transform.position.y, snapPoint.z) + offset;
                    break;

                case EnumFreeAxis.y:
                    destination = new Vector3(snapPoint.x, player_A.transform.position.y, snapPoint.z) + offset;
                    break;

                case EnumFreeAxis.z:
                    destination = new Vector3(snapPoint.x, player_A.transform.position.y, player_A.transform.position.z) + offset;
                    break;
                }
            }

            if (estado == "ir")
            {
                if (Mathf.Abs((this.transform.position - destination).magnitude) < 1)
                {
                    notifyFinishAction();
                }
            }

            if (estado == "volver")
            {
                if (Mathf.Abs((this.transform.position - destination).magnitude) < 1)
                {
                    state = CameraManagerState.idle;
                    notifyFinishAction();
                    estado = "ir";
                }
            }
        }
    }