big refactor
This commit is contained in:
		@@ -21,10 +21,4 @@ public class CirclePlatformGenerator : MonoBehaviour
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Update is called once per frame
 | 
					 | 
				
			||||||
    void Update()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,11 +8,6 @@ public class PlatformManager : MonoBehaviour
 | 
				
			|||||||
    public PlatformType type = PlatformType.Pull;
 | 
					    public PlatformType type = PlatformType.Pull;
 | 
				
			||||||
    public float speed = 5;
 | 
					    public float speed = 5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void Start()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void FixedUpdate()
 | 
					    void FixedUpdate()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (type == PlatformType.RotateZ)
 | 
					        if (type == PlatformType.RotateZ)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,7 @@ public class PlayerController : MonoBehaviour
 | 
				
			|||||||
    public float minSpeed = 5.0f;
 | 
					    public float minSpeed = 5.0f;
 | 
				
			||||||
    [HideInInspector]
 | 
					    [HideInInspector]
 | 
				
			||||||
    public float currentSpeed = 0f;
 | 
					    public float currentSpeed = 0f;
 | 
				
			||||||
    private float modifier = 0.0f;
 | 
					    private float speedModifier = 0.0f;
 | 
				
			||||||
    Vector3 moveDirection = Vector3.zero;
 | 
					    Vector3 moveDirection = Vector3.zero;
 | 
				
			||||||
    bool canMove = false;
 | 
					    bool canMove = false;
 | 
				
			||||||
    Rigidbody rb;
 | 
					    Rigidbody rb;
 | 
				
			||||||
@@ -22,7 +22,7 @@ public class PlayerController : MonoBehaviour
 | 
				
			|||||||
    [Header("Jump")]
 | 
					    [Header("Jump")]
 | 
				
			||||||
    public float jumpSpeed = 7.5f;
 | 
					    public float jumpSpeed = 7.5f;
 | 
				
			||||||
    [HideInInspector]
 | 
					    [HideInInspector]
 | 
				
			||||||
    public bool jump = false;
 | 
					    public bool inAir = false;
 | 
				
			||||||
    private bool isGrounded = false;
 | 
					    private bool isGrounded = false;
 | 
				
			||||||
    [Header("Camera")]
 | 
					    [Header("Camera")]
 | 
				
			||||||
    public float lookSpeed = 7.5f;
 | 
					    public float lookSpeed = 7.5f;
 | 
				
			||||||
@@ -84,41 +84,41 @@ public class PlayerController : MonoBehaviour
 | 
				
			|||||||
            currentSpeed -= 0.01f;
 | 
					            currentSpeed -= 0.01f;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        float curSpeedX = canMove ? (currentSpeed + modifier) : 0;
 | 
					        float curSpeedX = canMove ? (currentSpeed + speedModifier) : 0;
 | 
				
			||||||
        float curSpeedY = canMove ? (currentSpeed + 3.5f + modifier) * Input.GetAxis("Horizontal") : 0;
 | 
					        float curSpeedY = canMove ? (currentSpeed + 3.5f + speedModifier) * Input.GetAxis("Horizontal") : 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        moveDirection = (platformForward * curSpeedX * Time.deltaTime) + (transform.right * curSpeedY * Time.deltaTime);
 | 
					        moveDirection = (platformForward * curSpeedX * Time.deltaTime) + (transform.right * curSpeedY * Time.deltaTime);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ((currentSpeed + modifier) >= maxSpeed && !runningParticles.isPlaying)
 | 
					        if ((currentSpeed + speedModifier) >= maxSpeed && !runningParticles.isPlaying)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            runningParticles.Play(true);
 | 
					            runningParticles.Play(true);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else if ((currentSpeed + modifier) < maxSpeed && runningParticles.isPlaying)
 | 
					        else if ((currentSpeed + speedModifier) < maxSpeed && runningParticles.isPlaying)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            runningParticles.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
 | 
					            runningParticles.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
 | 
					        if (Input.GetKeyDown(KeyCode.Space) && isGrounded)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            jump = true;
 | 
					            inAir = true;
 | 
				
			||||||
            isGrounded = false;
 | 
					            isGrounded = false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (audioSource != null && audioClips.Count > 0) {
 | 
					        if (audioSource != null && audioClips.Count > 0) {
 | 
				
			||||||
            if ((currentSpeed + modifier) > speed * 3f && (currentSpeed + modifier) < speed * 7f)
 | 
					            if ((currentSpeed + speedModifier) > speed * 3f && (currentSpeed + speedModifier) < speed * 7f)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (audioClips.Count > 1 && audioSource.clip != audioClips[1]) {
 | 
					                if (audioClips.Count > 1 && audioSource.clip != audioClips[1]) {
 | 
				
			||||||
                    audioSource.Stop();
 | 
					                    audioSource.Stop();
 | 
				
			||||||
                    audioSource.clip = audioClips[1];
 | 
					                    audioSource.clip = audioClips[1];
 | 
				
			||||||
                    audioSource.Play();
 | 
					                    audioSource.Play();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } else if ((currentSpeed + modifier) <= speed * 3f) {
 | 
					            } else if ((currentSpeed + speedModifier) <= speed * 3f) {
 | 
				
			||||||
                if (audioSource.clip != audioClips[0]) {
 | 
					                if (audioSource.clip != audioClips[0]) {
 | 
				
			||||||
                    audioSource.Stop();
 | 
					                    audioSource.Stop();
 | 
				
			||||||
                    audioSource.clip = audioClips[0];
 | 
					                    audioSource.clip = audioClips[0];
 | 
				
			||||||
                    audioSource.Play();
 | 
					                    audioSource.Play();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } else if ((currentSpeed + modifier) >= speed * 7f) {
 | 
					            } else if ((currentSpeed + speedModifier) >= speed * 7f) {
 | 
				
			||||||
                if (audioClips.Count > 2 && audioSource.clip != audioClips[2])
 | 
					                if (audioClips.Count > 2 && audioSource.clip != audioClips[2])
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    audioSource.Stop();
 | 
					                    audioSource.Stop();
 | 
				
			||||||
@@ -133,11 +133,11 @@ public class PlayerController : MonoBehaviour
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private void FixedUpdate()
 | 
					    private void FixedUpdate()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (jump)
 | 
					        if (inAir)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            // Debug.Log("Jump");
 | 
					            // Debug.Log("Jump");
 | 
				
			||||||
            rb.AddForce(transform.up * jumpSpeed * 100 * Time.deltaTime, ForceMode.Impulse);
 | 
					            rb.AddForce(transform.up * jumpSpeed * 100 * Time.deltaTime, ForceMode.Impulse);
 | 
				
			||||||
            jump = false;
 | 
					            inAir = false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (rb.velocity.magnitude != 0 && Vector3.Dot(rb.velocity.normalized, Physics.gravity.normalized) > 0)
 | 
					        if (rb.velocity.magnitude != 0 && Vector3.Dot(rb.velocity.normalized, Physics.gravity.normalized) > 0)
 | 
				
			||||||
@@ -273,16 +273,16 @@ public class PlayerController : MonoBehaviour
 | 
				
			|||||||
                    case PlatformManager.PlatformType.RotateZ:
 | 
					                    case PlatformManager.PlatformType.RotateZ:
 | 
				
			||||||
                        break;
 | 
					                        break;
 | 
				
			||||||
                    case PlatformManager.PlatformType.SpeedUp:
 | 
					                    case PlatformManager.PlatformType.SpeedUp:
 | 
				
			||||||
                        modifier += platform.speed;
 | 
					                        speedModifier += platform.speed;
 | 
				
			||||||
                        break;
 | 
					                        break;
 | 
				
			||||||
                    case PlatformManager.PlatformType.SpeedDown:
 | 
					                    case PlatformManager.PlatformType.SpeedDown:
 | 
				
			||||||
                        if (modifier - platform.speed >= 0)
 | 
					                        if (speedModifier - platform.speed >= 0)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            modifier -= platform.speed;
 | 
					                            speedModifier -= platform.speed;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        else
 | 
					                        else
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            modifier = 0.0f;
 | 
					                            speedModifier = 0.0f;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        break;
 | 
					                        break;
 | 
				
			||||||
                    default:
 | 
					                    default:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,11 +4,6 @@ using UnityEngine;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public class gizmoManager : MonoBehaviour
 | 
					public class gizmoManager : MonoBehaviour
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    // Start is called before the first frame update
 | 
					 | 
				
			||||||
    void Start()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void OnDrawGizmos()
 | 
					    void OnDrawGizmos()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -33,9 +28,4 @@ public class gizmoManager : MonoBehaviour
 | 
				
			|||||||
            return new Bounds();
 | 
					            return new Bounds();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // Update is called once per frame
 | 
					 | 
				
			||||||
    void Update()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user