コード例 #1
0
ファイル: Fishing.cs プロジェクト: request-time-out/A-Scripts
        private void UpdateRodAngle()
        {
            Transform transform1 = ((Component)this.fishingSystem.lure).get_transform();
            Transform transform2 = this.fishingSystem.playerInfo.fishingRod.get_transform();
            Transform transform3 = ((Component)this.player.Controller).get_transform();

            if (Object.op_Equality((Object)transform2, (Object)null) || Object.op_Equality((Object)transform1, (Object)null) || Object.op_Equality((Object)transform3, (Object)null))
            {
                return;
            }
            switch (this.fishingSystem.scene)
            {
            case FishingManager.FishingScene.WaitHit:
                Vector3 localEulerAngles = transform2.get_localEulerAngles();
                localEulerAngles.x = (__Null)(double)(localEulerAngles.z = (__Null)0.0f);
                if (this.inputFlag)
                {
                    Vector2 vector2_1;
                    ((Vector2) ref vector2_1).\u002Ector((float)transform3.get_forward().x, (float)transform3.get_forward().z);
                    Vector2 normalized1 = ((Vector2) ref vector2_1).get_normalized();
                    Vector2 vector2_2;
                    ((Vector2) ref vector2_2).\u002Ector((float)(transform1.get_position().x - transform3.get_position().x), (float)(transform1.get_position().z - transform3.get_position().z));
                    Vector2 normalized2 = ((Vector2) ref vector2_2).get_normalized();
                    float   time        = Mathf.Acos(Mathf.Clamp(Vector2.Dot(normalized1, normalized2), -1f, 1f)) * 57.29578f;
                    float   num1        = Mathf.Sign((float)Vector3.Cross(new Vector3((float)normalized1.x, 0.0f, (float)normalized1.y), new Vector3((float)normalized2.x, 0.0f, (float)normalized2.y)).y);
                    float   num2        = EasingFunctions.EaseOutExpo(time, 90f);
                    float   num3        = time * num2 * num1 * this.PlayerParam.RodAngleScale;
                    localEulerAngles.y = (__Null)(double)this.Angle360To180((float)localEulerAngles.y);
                    float num4 = this.PlayerParam.RodHitWaitAngleSpeed * Time.get_deltaTime() * num1;
                    localEulerAngles.y = (localEulerAngles.y + (double)num4) * (double)num1 >= (double)num3 * (double)num1 ? (__Null)(double)num3 : (__Null)(localEulerAngles.y + (double)num4);
                    localEulerAngles.y = (__Null)(double)this.AngleAbs((float)localEulerAngles.y);
                    transform2.set_localEulerAngles(localEulerAngles);
                    break;
                }
                if (localEulerAngles.y == 0.0)
                {
                    break;
                }
                localEulerAngles.y = (__Null)(double)this.Angle360To180((float)localEulerAngles.y);
                float       num5  = Mathf.Sign((float)localEulerAngles.y);
                ref Vector3 local = ref localEulerAngles;
                local.y = (__Null)(local.y - (double)this.PlayerParam.RodHitWaitAngleSpeed * (double)Time.get_deltaTime() * (double)num5);
                if (localEulerAngles.y * (double)num5 < 0.0)
                {
                    localEulerAngles.y = (__Null)0.0;
                }
                localEulerAngles.y = (__Null)(double)this.AngleAbs((float)localEulerAngles.y);
                transform2.set_localEulerAngles(localEulerAngles);
                break;
コード例 #2
0
        private IEnumerator AnimDragBack()
        {
            Vector3 currentPosition      = transform.position;
            Vector3 interpolatedPosition = Vector3.zero;

            animTime = 0.0f;

            while (!isDragging && animTime < 1.0f)
            {
                yield return(new WaitForEndOfFrame());

                interpolatedPosition.x = EasingFunctions.EaseOutExpo(currentPosition.x, startPosition.Value.x, animTime);
                interpolatedPosition.y = EasingFunctions.EaseOutExpo(currentPosition.y, startPosition.Value.y, animTime);
                //interpolatedPosition.z = EasingFunctions.EaseOutExpo(currentPosition.z, startPosition.Value.z, animTime); No need because it's 2D

                transform.position = interpolatedPosition;

                //Debug.Log($"Object pos = ({interpolatedPosition.x}, {interpolatedPosition.y} animTime = {animTime}");

                animTime += Time.deltaTime * pullBackSpeed;
            }
        }