init
This commit is contained in:
commit
001bb14f16
951 changed files with 270074 additions and 0 deletions
17
Assets/Scripts/Enemies/EnemyAim.cs
Normal file
17
Assets/Scripts/Enemies/EnemyAim.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EnemyAim : MonoBehaviour{
|
||||
|
||||
Transform player;
|
||||
|
||||
void Start(){
|
||||
player = GameObject.FindGameObjectWithTag("Player").transform;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void LateUpdate(){
|
||||
transform.LookAt(player.position, Vector3.back);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Enemies/EnemyAim.cs.meta
Normal file
11
Assets/Scripts/Enemies/EnemyAim.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 02fb908107453d54cab95cd1923504e6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
69
Assets/Scripts/Enemies/EnemyController.cs
Normal file
69
Assets/Scripts/Enemies/EnemyController.cs
Normal file
|
@ -0,0 +1,69 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EnemyController : MonoBehaviour, IPooledObject{
|
||||
|
||||
public float speed;
|
||||
public float maxSpeed;
|
||||
public Material red;
|
||||
public GameObject[] materialsApplied;
|
||||
public LayerMask whatStops;
|
||||
public Transform circlePos;
|
||||
|
||||
bool canDisappear;
|
||||
|
||||
Transform target;
|
||||
Rigidbody2D rb2d;
|
||||
Vector2 mov;
|
||||
Animator anim;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
rb2d = GetComponent<Rigidbody2D>();
|
||||
target = GameObject.FindGameObjectWithTag("Player").transform;
|
||||
anim = GetComponentInChildren<Animator>();
|
||||
anim.SetBool("Walking", true);
|
||||
}
|
||||
|
||||
public void OnObjectSpawn(){
|
||||
canDisappear = false;
|
||||
}
|
||||
|
||||
void FixedUpdate(){
|
||||
/*if (target.position.x < transform.position.x){
|
||||
rb2d.AddForce(Vector2.left * speed * Time.deltaTime);
|
||||
}else{
|
||||
rb2d.AddForce(Vector2.right * speed * Time.deltaTime);
|
||||
}
|
||||
if (target.position.y < transform.position.y){
|
||||
rb2d.AddForce(Vector2.down * speed * Time.deltaTime);
|
||||
}else{
|
||||
rb2d.AddForce(Vector2.up * speed * Time.deltaTime);
|
||||
}
|
||||
float limitedSpeed = Mathf.Clamp(rb2d.velocity.x, -maxSpeed, maxSpeed);
|
||||
float yLimitedSpeed = Mathf.Clamp(rb2d.velocity.y, -maxSpeed, maxSpeed);
|
||||
rb2d.velocity = new Vector2(limitedSpeed, yLimitedSpeed);*/
|
||||
mov = transform.position;
|
||||
mov = Vector2.MoveTowards(rb2d.position, target.position, speed * Time.fixedDeltaTime);
|
||||
rb2d.MovePosition(mov);
|
||||
//print(rb2d.velocity.magnitude);
|
||||
}
|
||||
void OnTriggerEnter2D(Collider2D col){
|
||||
if(col.gameObject.tag == "Attack"){
|
||||
anim.SetBool("Attacking", true);
|
||||
for (int i = 0; i < materialsApplied.Length; i++){
|
||||
materialsApplied[i].GetComponent<SkinnedMeshRenderer>().material = red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnBecameVisible(){
|
||||
canDisappear = true;
|
||||
}
|
||||
void OnBecameInvisible(){
|
||||
if (canDisappear){
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Enemies/EnemyController.cs.meta
Normal file
11
Assets/Scripts/Enemies/EnemyController.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6e05f835678ca1f4f8b0df2fee8eb5ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue