Levels fixed

This commit is contained in:
2023-02-08 14:56:59 +05:30
parent 49837acabc
commit 59f01f98c6
18 changed files with 782 additions and 840 deletions

View File

@@ -11,9 +11,11 @@ public class Enemy : MonoBehaviour
public float dodgeTime = 0.2f;
float dodgeTimer = 0;
public LayerMask linecastLayer;
float offset;
private void Awake()
{
dodgeTimer = dodgeTime;
offset = Random.Range(-0.5f,0.5f);
}
@@ -53,7 +55,7 @@ public class Enemy : MonoBehaviour
}
}
Vector3 direction = (GameManager.Player.position - new Vector3(0,0.5f,0) - transform.position).normalized;
Vector3 direction = (GameManager.Player.position - new Vector3(-offset/2f,offset,0) - transform.position).normalized;
float rot_z = Mathf.Atan2(direction.y,direction.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0,0,rot_z+180);
if (dodgeTimer < dodgeTime)
@@ -63,7 +65,8 @@ public class Enemy : MonoBehaviour
if (dodgeTimer > dodgeTime/100f || true)
{
debugColor = Color.red;
transform.Translate(new Vector3(-direction.x, direction.y) * moveSpeed * 1.2f, Space.World);
Vector3 new_direction = (hit.point - (Vector2)transform.position).normalized;
transform.Translate(-new_direction * moveSpeed * 1.2f, Space.World);
return;
}
}

View File

@@ -116,6 +116,10 @@ public class GameManager : MonoBehaviour
public void Restart()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
public void BackToMenu(){
SceneManager.LoadScene(0);
}
}

View File

@@ -97,6 +97,7 @@ public class LevelSelect : MonoBehaviour
}
}else{
newLevel.transform.GetChild(1).GetComponent<Image>().sprite = locked;
newLevel.GetComponent<Button>().interactable=false;
newLevel.transform.GetChild(2).gameObject.SetActive(false);
}
}

13
Assets/Scripts/Water.cs Normal file
View File

@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Water : MonoBehaviour
{
void OnTriggerEnter2D(Collider2D other){
Debug.Log("Fell into water : " + other.name);
if(other.tag == "Player"){
GameManager.GameOver();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 62a860876ed5bff4c8bd406d15191ab7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: