コード例 #1
0
        public void OnTriggerExit(Collider col)
        {
            PointOfInterestDirector pointOfInterestDirectorForCollider = getPointOfInterestDirectorForCollider(col);

            if (pointOfInterestDirectorForCollider != null)
            {
                pointOfInterestDirectorForCollider.Deactivate(this);
            }
        }
コード例 #2
0
        public void OnTriggerStay(Collider col)
        {
            PointOfInterestDirector pointOfInterestDirectorForCollider = getPointOfInterestDirectorForCollider(col);

            if (pointOfInterestDirectorForCollider != null)
            {
                Vector3 vector = base.transform.position - col.transform.position;
                if (Vector3.Dot(rhs: col.transform.TransformDirection(Vector3.forward).normalized, lhs: vector.normalized) > 0f)
                {
                    pointOfInterestDirectorForCollider.Activate(this);
                }
                else
                {
                    pointOfInterestDirectorForCollider.Deactivate(this);
                }
            }
        }
コード例 #3
0
        public override bool Aim(ref Setup setup)
        {
            bool result = false;

            if (pointOfInterestDirector == null)
            {
                pointOfInterestDirector = setup.Focus.GetComponent <PointOfInterestDirector>();
                startNewBlend           = true;
                Debug.Assert(pointOfInterestDirector != null, "Camera focus object does not have Point of Interest Director component on it.  The PointOfInterestGlancer will not work.");
            }
            if (pointOfInterestDirector != null && pointOfInterestDirector.HasActivePointOfInterest)
            {
                Vector3 weightedPointOfInterest = pointOfInterestDirector.GetWeightedPointOfInterest();
                if (isBlendingOut || weightedPointOfInterest != prevPOIPos)
                {
                    startNewBlend = true;
                    prevPOIPos    = weightedPointOfInterest;
                }
                if (startNewBlend)
                {
                    if (!isBlendingOut)
                    {
                        blendInStartGlance = setup.Glance;
                    }
                    restartBlend(ref setup);
                }
                Vector3 vector  = setup.LookAt - setup.Goal;
                Vector3 vector2 = weightedPointOfInterest - setup.Goal;
                Debug.DrawLine(setup.LookAt, setup.Goal, Color.green, 1f);
                Debug.DrawLine(weightedPointOfInterest, setup.Goal, Color.yellow, 1f);
                float num = Vector3.Angle(vector, vector2);
                if (num < MaxGlanceAngle)
                {
                    Vector3 axis = Vector3.Cross(vector, vector2);
                    axis.z = 0f;
                    axis.Normalize();
                    Quaternion quaternion = Quaternion.AngleAxis(num * GlancePercent, axis);
                    if (UseBlendCurve && BlendDuration > 0f)
                    {
                        elapsedTime += Time.deltaTime;
                        if (elapsedTime > BlendDuration)
                        {
                            elapsedTime = BlendDuration;
                        }
                        setup.Glance        = Quaternion.Slerp(blendInStartGlance, quaternion, BlendCurve.Evaluate(elapsedTime / BlendDuration));
                        blendOutStartGlance = setup.Glance;
                        isBlendingIn        = true;
                    }
                    else
                    {
                        setup.Glance = quaternion;
                    }
                    result = true;
                }
                else if (isBlendingIn)
                {
                    isBlendingIn  = false;
                    isBlendingOut = true;
                    elapsedTime   = 0f;
                }
            }
            else
            {
                if (isBlendingIn)
                {
                    isBlendingIn  = false;
                    isBlendingOut = true;
                    elapsedTime   = 0f;
                }
                if (isBlendingOut)
                {
                    elapsedTime += Time.deltaTime;
                    if (elapsedTime > BlendDuration)
                    {
                        restartBlend(ref setup);
                    }
                    else
                    {
                        setup.Glance       = Quaternion.Slerp(blendOutStartGlance, Quaternion.identity, BlendCurve.Evaluate(elapsedTime / BlendDuration));
                        blendInStartGlance = setup.Glance;
                        result             = true;
                    }
                }
                else
                {
                    restartBlend(ref setup);
                }
            }
            return(result);
        }