Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions -Personal Coding Project-.gantter

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions Checkpoint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using UnityEngine;
using System.Collections;

public class Checkpoint : MonoBehaviour {

public LevelManager levelManager;

// Use this for initialization
void Start()
{
levelManager = FindObjectOfType<LevelManager>();
}

// Update is called once per frame
void Update () {

}

void OnTriggerEnter2D(Collider2D other)
{
if (other.name == "mario")
{
levelManager.currentCheckpoint = gameObject;
}
}
}
28 changes: 28 additions & 0 deletions Checkpoint2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using UnityEngine;
using System.Collections;

public class Checkpoint2 : MonoBehaviour
{

public LevelManager2 levelManager2;

// Use this for initialization
void Start()
{
levelManager2 = FindObjectOfType<LevelManager2>();
}

// Update is called once per frame
void Update()
{

}

void OnTriggerEnter2D(Collider2D other)
{
if (other.name == "MarioController")
{
levelManager2.currentCheckpoint2 = gameObject;
}
}
}
25 changes: 25 additions & 0 deletions KillPlayer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using UnityEngine;
using System.Collections;

public class KillPlayer : MonoBehaviour {

public LevelManager levelManager;

// Use this for initialization
void Start () {
levelManager = FindObjectOfType<LevelManager>();
}

// Update is called once per frame
void Update () {

}

void OnTriggerEnter2D(Collider2D other)
{
if (other.name == "mario")
{
levelManager.RespawnPlayer ();
}
}
}
28 changes: 28 additions & 0 deletions KillPlayer2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using UnityEngine;
using System.Collections;

public class KillPlayer2 : MonoBehaviour
{

public LevelManager2 levelManager2;

// Use this for initialization
void Start()
{
levelManager2 = FindObjectOfType<LevelManager2>();
}

// Update is called once per frame
void Update()
{

}

void OnTriggerEnter2D(Collider2D other)
{
if (other.name == "mario2")
{
levelManager2.RespawnPlayer();
}
}
}
27 changes: 27 additions & 0 deletions Kill_Player.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using UnityEngine;
using System.Collections;

public class Kill_Player : MonoBehaviour {

// call Level_manager script and set it to variable
public Level_manager level_manager;

// Use this for initialization
void Start () {
level_manager = FindObjectOfType<Level_manager>();
}

// Update is called once per frame
void Update () {

}

// check if the respawn collider meets player
void OnTriggerEnter2D(Collider2D collide)
{
if(collide.name == "Scorpion")
{
level_manager.Respawn_Player();
}
}
}
26 changes: 26 additions & 0 deletions LevelManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using UnityEngine;
using System.Collections;

public class LevelManager : MonoBehaviour {

public GameObject currentCheckpoint;

private mario player;

// Use this for initialization
void Start () {
player = FindObjectOfType<mario>();

}

// Update is called once per frame
void Update () {

}

public void RespawnPlayer()
{
Debug.Log ("Player Respawn");
player.transform.position = currentCheckpoint.transform.position;
}
}
31 changes: 31 additions & 0 deletions LevelManager2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using UnityEngine;
using System.Collections;

public class LevelManager2 : MonoBehaviour
{

public GameObject currentCheckpoint2;

private MarioController player;

// Use this for initialization
void Start()
{
player = FindObjectOfType<MarioController>();

}

// Update is called once per frame
void Update()
{

}

public void RespawnPlayer()
{
Debug.Log("Player Respawn");
//player.transform. = new Vector2(0, GetComponent<Rigidbody2D>().velocity.y);
player.transform.position = currentCheckpoint2.transform.position;
}
}

28 changes: 28 additions & 0 deletions Level_manager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using UnityEngine;
using System.Collections;

public class Level_manager : MonoBehaviour {

public GameObject current_respawnpoint;

// call player script and set it to variable
private NewBehaviourScript scorpion;

// Use this for initialization
void Start () {
scorpion = FindObjectOfType<NewBehaviourScript>();

}

// Update is called once per frame
void Update () {

}

// check to see if collider hits player and then have player respawn at specific spot
public void Respawn_Player()
{
Debug.Log("Player Respawn");
scorpion.transform.position = current_respawnpoint.transform.position;
}
}
74 changes: 74 additions & 0 deletions MarioController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using UnityEngine;
using System.Collections;

public class MarioController : MonoBehaviour {

public float moveSpeed;
public float jumpHeight;

public Transform groundCheck2;
public float groundCheckRadius;
public LayerMask whatIsGround;
private bool grounded;

private bool doubleJumped;

private Animator anim;

public Transform firePoint_right, firePoint_left;
public GameObject fireBall;

// Use this for initialization
void Start () {

}

void FixedUpdate()
{
grounded = Physics2D.OverlapCircle(groundCheck2.position, groundCheckRadius, whatIsGround);
}
// Update is called once per frame
void Update()
{
if (grounded)
doubleJumped = false;

if (Input.GetKeyDown(KeyCode.I) && grounded)
{
//GetComponent<Rigidbody2D>().velocity = new Vector2 (GetComponent<Rigidbody2D>().velocity.x, jumpHeight);
Jump();
}

if (Input.GetKeyDown(KeyCode.I) && !doubleJumped && !grounded)
{
//GetComponent<Rigidbody2D>().velocity = new Vector2 (GetComponent<Rigidbody2D>().velocity.x, jumpHeight);
Jump();
doubleJumped = true;
}

if (Input.GetKey(KeyCode.L))
{
GetComponent<Rigidbody2D>().velocity = new Vector2(moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
//anim.SetFloat("Speed Right", Mathf.Abs(GetComponent<Rigidbody2D> ().velocity.x));
}

if (Input.GetKey(KeyCode.J))
{
GetComponent<Rigidbody2D>().velocity = new Vector2(-moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
//anim.SetFloat("Speed Left", Mathf.Abs(GetComponent<Rigidbody2D> ().velocity.x));
}

if (Input.GetKeyDown(KeyCode.M))
{
if (GetComponent<Rigidbody2D>().velocity.x > 0)
Instantiate(fireBall, firePoint_right.position, firePoint_right.rotation);
else if (GetComponent<Rigidbody2D>().velocity.x < 0)
Instantiate(fireBall, firePoint_left.position, firePoint_left.rotation);
}
}

public void Jump()
{
GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, jumpHeight);
}
}
Loading