Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Lachness900 authored Jan 18, 2023
0 parents commit abcbf18
Show file tree
Hide file tree
Showing 12 changed files with 559 additions and 0 deletions.
60 changes: 60 additions & 0 deletions CatapillerMovement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CatapillerMovement : MonoBehaviour {
[SerializeField]private Transform Cylinder;
public float Speed;
private bool faceingRight = false;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void FixedUpdate () {
if (Cylinder.transform.position.y > 0) {

if (Cylinder.transform.position.x - transform.position.x > 0 && Cylinder.transform.position.x - transform.position.x < 10) {
Vector3 temp = transform.position;
temp.x += Speed;
transform.position = temp;
}
if (Cylinder.transform.position.x - transform.position.x < 0 && Cylinder.transform.position.x - transform.position.x > -10) {
Vector3 temp = transform.position;
temp.x -= Speed;
transform.position = temp;

}
if (faceingRight == false && Cylinder.transform.position.x - transform.position.x > 0) {
Flip();
} else if (faceingRight == true && Cylinder.transform.position.x - transform.position.x < 0) {
Flip();
}

}
}
void Flip(){
Vector3 Scaler = transform.localScale;
Vector3 position = transform.position;
Scaler.x *= -1;
if (faceingRight == true) {
position.x -= -4f;
}
if (faceingRight == false) {
position.x -= 4f;
}
transform.position = position;
transform.localScale = Scaler;
faceingRight = !faceingRight;
}
void OnTriggerEnter2D(Collider2D other){
if (other.tag == "goodBullet") {
Destroy (other);
Destroy (gameObject);

}

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

public class EnermyBullet : MonoBehaviour {
public TurretShoot shoot;
public bool isfirst = true;

void Awake(){
shoot = gameObject.GetComponentInParent<TurretShoot> ();

}
void OnTriggerStay2D(Collider2D col){
if (col.CompareTag ("Player")) {
shoot.Attack ();
}

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

public class GoodBullet : MonoBehaviour {

void OnTriggerEnter2D(Collider2D other){
if (other.tag == "Enermy1") {
DestroyObject(gameObject);
}
if (other.tag == "Enermy2") {
DestroyObject (gameObject);
}
if (other.tag == "Enermy3") {
DestroyObject(gameObject);
}
}
}
173 changes: 173 additions & 0 deletions NewBehaviourScript1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class NewBehaviourScript1 : MonoBehaviour {


private Rigidbody2D myRigidbody;
public float Speed;
public float jumpForce;
private float moveInput;
private bool faceingRight = true;
private bool Grounded;
public Transform groundCheck;
public float checkRadius;
public LayerMask WIGround;
private int extraJumps;
public int health=5;
public int maxHealth = 5;
public int healthAfterLevel = 2;
public Text healthText;
public float bulletSpeed;
public float interval;
public GameObject bullet;
public int magic = 2;
public Text magicText;
// Use this for initialization
void Start () {
health = maxHealth;
myRigidbody = GetComponent<Rigidbody2D>();

}

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

Grounded = Physics2D.OverlapCircle(groundCheck.position,checkRadius, WIGround);
moveInput = Input.GetAxis("Horizontal");
myRigidbody.velocity = new Vector2(moveInput * Speed, myRigidbody.velocity.y);

if (faceingRight == false && moveInput > 0) {
Flip();
} else if (faceingRight == true && moveInput < 0) {
Flip();
}
}

void Update(){

if (Grounded == true) {
extraJumps = 1;
}
if (Input.GetKeyDown (KeyCode.UpArrow) && extraJumps > 0) {
myRigidbody.velocity = Vector2.up * jumpForce;
extraJumps--;
} else if (Input.GetKeyDown (KeyCode.UpArrow) && extraJumps == 0 && Grounded == true) {
extraJumps = 1;
}
if (transform.position.y <= 30) {
magicText.text = "Magic:" + magic;
}
healthText.text = "Lives:" + health;
if (health == 0) {
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
health = health + 5;
}
if(magic > 0 && Input.GetKeyDown(KeyCode.Space)){

GameObject lightningbulletG;
lightningbulletG = Instantiate (bullet, transform.position, transform.rotation)as GameObject;
lightningbulletG.GetComponent<Rigidbody2D> ().velocity = Vector2.right * bulletSpeed;
magic--;

}
}

void Flip(){

faceingRight = !faceingRight;
Vector3 Scaler = transform.localScale;
Scaler.x *= -1;
transform.localScale = Scaler;
}

[SerializeField]private Transform level3Respawn;
[SerializeField]private Transform level1Respawn;
[SerializeField]private Transform level2Respawn;
[SerializeField]private Transform bossRespawn;
void OnTriggerEnter2D(Collider2D other){
if (other.tag == "death3") {
health--;
transform.position = level3Respawn.position;
Vector3 playerPos = level3Respawn.transform.position;
playerPos.z = 0f;
transform.position = playerPos;
}
if (other.tag == "death") {
health--;
transform.position = level1Respawn.position;
Vector3 playerPos = level1Respawn.transform.position;
playerPos.z = 0f;
transform.position = playerPos;
}
if (other.tag == "death2") {
health--;
transform.position = level2Respawn.position;
Vector3 playerPos = level2Respawn.transform.position;
playerPos.z += 0f;
transform.position = playerPos;
}
if (other.tag == "deathboss") {
health--;
transform.position = bossRespawn.position;
Vector3 playerPos = bossRespawn.transform.position;
playerPos.z = 0f;
transform.position = playerPos;
}
if (other.tag == "portal1") {
health++;
magic++;
magic++;
transform.position = level2Respawn.transform.position;
Vector3 playerPos = level2Respawn.transform.position;
playerPos.z = 0f;
transform.position = playerPos;
}
if (other.tag == "portal2") {
health++;
transform.position = level3Respawn.transform.position;
Vector3 playerPos = level3Respawn.transform.position;
playerPos.z = 0f;
transform.position = playerPos;
}
if (other.tag == "portal3") {
health++;
magic++;
magic++;
transform.position = bossRespawn.transform.position;
Vector3 playerPos = bossRespawn.transform.position;
playerPos.z = 0f;
transform.position = playerPos;
}
if (other.tag == "portal4") {
health++;
magic++;
magic++;
transform.position = bossRespawn.transform.position;
Vector3 playerPos = bossRespawn.transform.position;
playerPos.z = 0f;
transform.position = playerPos;
}
if (other.tag == "Enermy1") {
health--;
transform.position = level1Respawn.transform.position;
}
if (other.tag == "Enermy2") {
health--;
transform.position = level2Respawn.transform.position;
}
if (other.tag == "Enermy3") {
health--;
transform.position = level3Respawn.transform.position;
}




}

}

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

public class Tristanatan : MonoBehaviour {
[SerializeField]public Transform Tritanatan;
public float speed;
public float bulletSpeed;
public float bulletTime;
public float interval;
// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
if (transform.position.x > 5) {
Vector3 Temp = transform.position;
Temp.x += speed;
transform.position = Temp;
}
if (transform.position.x < 3) {
Vector3 Temp = transform.position;
Temp.x -= speed;
transform.position = Temp;
}
}
}
53 changes: 53 additions & 0 deletions TurretShoot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TurretShoot : MonoBehaviour {
[SerializeField]private Transform Player;
public float bulletSpeed;
public float bulletTime;
public float interval;
public GameObject bullet;
public float distance;
[SerializeField]private Transform magicTurret1B;
[SerializeField]private Transform magicTurretB;
[SerializeField]private Transform magicTurret1;
[SerializeField]private Transform magicTurret;
// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
distance = Vector3.Distance (transform.position, Player.transform.position);

}
public void Attack (){
bulletTime += Time.deltaTime;
if (bulletTime >= interval && (magicTurret)) {

GameObject lightningbullet;
lightningbullet = Instantiate (bullet, magicTurretB.transform.position, magicTurretB.transform.rotation)as GameObject;
lightningbullet.GetComponent<Rigidbody2D> ().velocity = Vector2.left * bulletSpeed;
bulletTime = 0;
}
if (bulletTime >= interval && (magicTurret1)) {

GameObject lightningbullet1;
lightningbullet1 = Instantiate (bullet, magicTurret1B.transform.position, magicTurret1B.transform.rotation)as GameObject;
lightningbullet1.GetComponent<Rigidbody2D> ().velocity = Vector2.left * bulletSpeed;
bulletTime = 0;
}

}
void OnTriggerEnter2D(Collider2D other){
if (other.tag == "goodBullet") {
Destroy (other);
Destroy (gameObject);

}
}
}


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

public class bullet : MonoBehaviour {

void OnTriggerEnter2D(Collider2D col){

if (col.isTrigger != true) {
if (col.CompareTag ("PLayer")) {
Destroy (gameObject);

}

}

}}
1 change: 1 addition & 0 deletions bunny Movement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading

0 comments on commit abcbf18

Please sign in to comment.