lots of small changes lol
worked on tambourine level layout, improved tambourine throwing, created enemy respawn system
This commit is contained in:
		@@ -41,8 +41,8 @@ public class CameraMovement : MonoBehaviour {
 | 
			
		||||
 | 
			
		||||
    public void FindPlayer() {
 | 
			
		||||
        player = GameObject.FindGameObjectWithTag("Player");
 | 
			
		||||
        if (player == null) {
 | 
			
		||||
            print("null player!");
 | 
			
		||||
        }
 | 
			
		||||
        // if (player == null) {
 | 
			
		||||
        //     print("null player!");
 | 
			
		||||
        // }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -68,6 +68,10 @@ public class EnemyPatrol : MonoBehaviour {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void DefeatEnemy() {
 | 
			
		||||
        this.gameObject.SetActive(false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void OnDrawGizmos() {
 | 
			
		||||
        Gizmos.color = Color.green;
 | 
			
		||||
        if (isHorizontal){
 | 
			
		||||
 
 | 
			
		||||
@@ -179,7 +179,7 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
    void OnCollisionEnter2D(Collision2D collision) {
 | 
			
		||||
        if (collision.gameObject.tag == "Enemy") {
 | 
			
		||||
            if (collision.transform.position.y < transform.position.y) {
 | 
			
		||||
                Destroy(collision.gameObject);
 | 
			
		||||
                collision.gameObject.GetComponent<EnemyPatrol>().DefeatEnemy();
 | 
			
		||||
            } else {
 | 
			
		||||
                DestroyPlayer();
 | 
			
		||||
            }
 | 
			
		||||
@@ -192,6 +192,13 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
 | 
			
		||||
    public void DestroyPlayer() {
 | 
			
		||||
        this.stateController.SetDeathCanvasActive(true);
 | 
			
		||||
 | 
			
		||||
        // destroy all tambourines
 | 
			
		||||
        GameObject[] currentTambourines = GameObject.FindGameObjectsWithTag("tambourine");
 | 
			
		||||
        foreach (GameObject tambourine in currentTambourines) {
 | 
			
		||||
            tambourine.GetComponent<TambourineBehavior>().DestroySelf();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Destroy(this.gameObject);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -97,14 +97,14 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
            CheckDirectionToFace(_moveInput.x > 0);
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        if (!IsJumping)
 | 
			
		||||
        {
 | 
			
		||||
            print("not jumping");
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            print("jumping, " + RB.velocity.y);
 | 
			
		||||
        }
 | 
			
		||||
        // if (!IsJumping)
 | 
			
		||||
        // {
 | 
			
		||||
        //     print("not jumping");
 | 
			
		||||
        // }
 | 
			
		||||
        // else
 | 
			
		||||
        // {
 | 
			
		||||
        //     print("jumping, " + RB.velocity.y);
 | 
			
		||||
        // }
 | 
			
		||||
 | 
			
		||||
        #region COLLISION CHECKS
 | 
			
		||||
        if (!IsJumping)
 | 
			
		||||
@@ -164,7 +164,7 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
            Jump();
 | 
			
		||||
            if (!IsGrounded() && in_range && trumpet > 0)
 | 
			
		||||
            {
 | 
			
		||||
                Destroy(enemy.gameObject);
 | 
			
		||||
                enemy.GetComponent<EnemyPatrol>().DefeatEnemy();
 | 
			
		||||
                enemy = null;
 | 
			
		||||
                in_range = false;
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,9 @@ public class StateController : MonoBehaviour {
 | 
			
		||||
    public bool inDebugMode;
 | 
			
		||||
    GameObject debugCanvas;
 | 
			
		||||
 | 
			
		||||
    [Header("Enemies")]
 | 
			
		||||
    GameObject[] enemiesInScene;
 | 
			
		||||
 | 
			
		||||
    void Awake() {
 | 
			
		||||
        // check to see if a state controller already exists
 | 
			
		||||
        if (GameObject.FindGameObjectWithTag("StateController") != null) {
 | 
			
		||||
@@ -50,6 +53,10 @@ public class StateController : MonoBehaviour {
 | 
			
		||||
            TogglePauseMenu(false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // keep track of all enemies
 | 
			
		||||
        enemiesInScene = GameObject.FindGameObjectsWithTag("Enemy");
 | 
			
		||||
        // print(enemiesInScene);
 | 
			
		||||
 | 
			
		||||
        if (isPaused) {
 | 
			
		||||
            Unpause();
 | 
			
		||||
        }
 | 
			
		||||
@@ -87,9 +94,16 @@ public class StateController : MonoBehaviour {
 | 
			
		||||
    public void RespawnPlayer() {
 | 
			
		||||
        SetDeathCanvasActive(false);
 | 
			
		||||
        GameObject.Find("Main Camera").GetComponent<CameraMovement>().FindPlayer();
 | 
			
		||||
        RespawnEnemies();
 | 
			
		||||
        Instantiate(player, spawnPoint.transform.position, player.transform.rotation);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void RespawnEnemies() {
 | 
			
		||||
        foreach (GameObject enemy in enemiesInScene) {
 | 
			
		||||
            enemy.SetActive(true);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void SetDeathCanvasActive(bool activeState) {
 | 
			
		||||
        deathCanvas.SetActive(activeState);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ public class TambourineBehavior : MonoBehaviour {
 | 
			
		||||
    
 | 
			
		||||
    private GameObject collidedObject;
 | 
			
		||||
    private float timeLerped = 0.0f;
 | 
			
		||||
    private float timeToLerp = 0.5f;
 | 
			
		||||
    private float timeToLerp = 0.2f;
 | 
			
		||||
 | 
			
		||||
    private GameObject player;
 | 
			
		||||
 | 
			
		||||
@@ -52,7 +52,7 @@ public class TambourineBehavior : MonoBehaviour {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void OnTriggerEnter2D(Collider2D col) {
 | 
			
		||||
        print(col.tag);
 | 
			
		||||
        // print(col.tag);
 | 
			
		||||
        if (col.tag == "Enemy") {
 | 
			
		||||
            collidedObject = col.gameObject;
 | 
			
		||||
            print("Pinning to enemy");
 | 
			
		||||
@@ -74,7 +74,7 @@ public class TambourineBehavior : MonoBehaviour {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    IEnumerator CheckToDestroy() {
 | 
			
		||||
        yield return new WaitForSeconds(5f);
 | 
			
		||||
        yield return new WaitForSeconds(3f);
 | 
			
		||||
        // print("waited 5");
 | 
			
		||||
        if (!player.GetComponent<PlayerBehavior>().grapplingRope.isGrappling) {
 | 
			
		||||
            DestroySelf();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user