mirror of
https://github.com/frizbee19/FebGameJam.git
synced 2026-09-11 08:17:01 +00:00
Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
commit
6d43681db6
73 files changed
+12035
-4299
No files matched your search
@@ -15,11 +15,11 @@ public class Movement : MonoBehaviour
|
||||
[SerializeField] private Collider2D m_CrouchDisableCollider; // A collider that will be disabled when crouching
|
||||
|
||||
const float k_GroundedRadius = .2f; // Radius of the overlap circle to determine if grounded
|
||||
private bool m_Grounded; // Whether or not the player is grounded.
|
||||
public bool m_Grounded; // Whether or not the player is grounded.
|
||||
const float k_CeilingRadius = .2f; // Radius of the overlap circle to determine if the player can stand up
|
||||
private Rigidbody2D m_Rigidbody2D;
|
||||
private bool m_FacingRight = true; // For determining which way the player is currently facing.
|
||||
private Vector3 m_Velocity = Vector3.zero;
|
||||
public Vector3 m_Velocity = Vector3.zero;
|
||||
public static bool pause = false;
|
||||
private bool dj = false;
|
||||
|
||||
@@ -36,6 +36,7 @@ public class Movement : MonoBehaviour
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
pause = false;
|
||||
m_Rigidbody2D = GetComponent<Rigidbody2D>();
|
||||
|
||||
if (OnLandEvent == null)
|
||||
@@ -162,4 +163,3 @@ public class Movement : MonoBehaviour
|
||||
transform.localScale = theScale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,27 +8,46 @@ public class NPC : MonoBehaviour
|
||||
{
|
||||
|
||||
public Movement controller;
|
||||
float horizontalMove = 0f;
|
||||
public float runSpeed = 40f;
|
||||
public string title = "";
|
||||
public Animator animator;
|
||||
float horizontalMove = 1f;
|
||||
public float runSpeed = 20f;
|
||||
public float leftBound;
|
||||
public float rightBound;
|
||||
float elapsed;
|
||||
public float minDelay;
|
||||
public float maxDelay;
|
||||
float delay;
|
||||
|
||||
//constructs an NPC using parameters
|
||||
public NPC(string name, float run, float hor)
|
||||
{
|
||||
title = name;
|
||||
runSpeed = run;
|
||||
horizontalMove = hor;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
delay = Random.Range(minDelay, maxDelay);
|
||||
horizontalMove = horizontalMove * runSpeed;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
if(elapsed > delay) {
|
||||
horizontalMove = -1 * (horizontalMove/Mathf.Abs(horizontalMove)) * runSpeed;
|
||||
elapsed = 0f;
|
||||
delay = Random.Range(minDelay, maxDelay);
|
||||
}
|
||||
if(Movement.pause) {
|
||||
animator.SetFloat("Horizontal", 0);
|
||||
}
|
||||
if (animator != null && !Movement.pause) {
|
||||
animator.SetFloat("Horizontal", (horizontalMove/Mathf.Abs(horizontalMove)));
|
||||
animator.SetBool("Airborne", !controller.m_Grounded);
|
||||
}
|
||||
elapsed += Time.deltaTime;
|
||||
if(transform.position.x > rightBound) {
|
||||
horizontalMove = -1 * runSpeed;
|
||||
}
|
||||
if(transform.position.x < leftBound) {
|
||||
horizontalMove = runSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
//NPC movement determined by script in subclasses
|
||||
|
||||
@@ -5,7 +5,7 @@ using UnityEngine;
|
||||
public class PlayerMovement : MonoBehaviour
|
||||
{
|
||||
public Movement controller;
|
||||
//public Animator animator;
|
||||
public Animator animator;
|
||||
public float runSpeed = 40f;
|
||||
float horizontalMove = 0f;
|
||||
bool jump = false;
|
||||
@@ -13,9 +13,6 @@ public class PlayerMovement : MonoBehaviour
|
||||
|
||||
// Update is called once per frame
|
||||
void Update() {
|
||||
// Horizontal value is for the animation state machine. No code required, wow!
|
||||
//animator.SetFloat("Horizontal", Input.GetAxis("Horizontal"));
|
||||
|
||||
horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
|
||||
|
||||
if (Input.GetButtonDown("Jump")) {
|
||||
@@ -27,8 +24,15 @@ public class PlayerMovement : MonoBehaviour
|
||||
} else if (Input.GetKeyUp(KeyCode.LeftShift)) {
|
||||
crouch = false;
|
||||
}
|
||||
|
||||
if(Movement.pause) {
|
||||
animator.SetFloat("Horizontal", 0);
|
||||
}
|
||||
if (animator != null && !Movement.pause) {
|
||||
animator.SetFloat("Horizontal", Input.GetAxis("Horizontal"));
|
||||
animator.SetBool("Airborne", !controller.m_Grounded);
|
||||
}
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
controller.Move(horizontalMove * Time.fixedDeltaTime, crouch, jump);
|
||||
|
||||
@@ -4,13 +4,18 @@ using UnityEngine;
|
||||
|
||||
public class Platform : MonoBehaviour
|
||||
{
|
||||
public bool isMoving;
|
||||
public Vector3 positionToMoveTo;
|
||||
public float length;
|
||||
float prevY;
|
||||
Vector3 startPos;
|
||||
void Start()
|
||||
{
|
||||
startPos = transform.position;
|
||||
StartCoroutine(LerpPosition(positionToMoveTo, length));
|
||||
if(isMoving)
|
||||
{
|
||||
startPos = transform.position;
|
||||
StartCoroutine(LerpPosition(positionToMoveTo, length));
|
||||
}
|
||||
}
|
||||
IEnumerator LerpPosition(Vector3 targetPosition, float duration)
|
||||
{
|
||||
@@ -35,11 +40,27 @@ public class Platform : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(transform.position == positionToMoveTo) {
|
||||
Switch();
|
||||
StartCoroutine(LerpPosition(positionToMoveTo, length));
|
||||
|
||||
if(isMoving) {
|
||||
if(transform.position == positionToMoveTo) {
|
||||
Switch();
|
||||
StartCoroutine(LerpPosition(positionToMoveTo, length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// void OnCollisionEnter2D (Collision2D other) {
|
||||
|
||||
// if (other.gameObject.tag == "Player") {
|
||||
// if(goThrough) {
|
||||
// if(other.gameObject.GetComponent<Movement>().m_Velocity.y > 0.01f) {
|
||||
// GetComponent<Collider2D>().isTrigger = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// GetComponent<Collider2D>().isTrigger = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
Reference in new issue
Block a user