public List<GameObject> zombieArray = new List<GameObject>();
public List<GameObject> ZombieMaxArrayList = new List<GameObject>();
public List<GameObject> zombieArrayNew = new List<GameObject>();
public Rigidbody2D bullet;
public int ZombieArrayGivePosition;
public int thisAtackTower;
void OnTriggerEnter2D(Collider2D collider)
{
if (collider.gameObject.tag == "Zombie")
{
zombieArray.Add(collider.gameObject);
}
}
private void OnTriggerEnter2D(Collider2D collider)
{
if (collider.TryGetComponent<ZombieStandart>(out ZombieStandart zombie)
{
zombieArray.Add(zombie);
}
}
transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, Mathf.Atan2(target.transform.position.y - transform.position.y, target.transform.position.x - transform.position.x) * Mathf.Rad2Deg + 90);
private void ChekDistante()
Rigidbody2D clone = Instantiate(bullet, gunPoint.position, Quaternion.identity) as Rigidbody2D;
clone.GetComponent<BulletEnter>().atack = thisAtackTower;
clone.transform.up = gunPoint.up;
clone.velocity = clone.transform.up * speed;
var bullet = Instantiate<Bullet>(bullet, gunPoint.position, Quaternion.identity);
bullet.Shot(direction);
using System;
using UnityEngine;
namespace Assets.Scripts
{
public class ObjectDisabler : MonoBehaviour, IDeactivatable
{
public event Action Deactivated;
public event Action Activated;
public void Activate()
{
gameObject.SetActive(true);
Activated?.Invoke();
}
public void Deactivate()
{
gameObject.SetActive(false);
Deactivated?.Invoke();
}
}
public interface IDeactivatable
{
event Action Deactivated;
event Action Activated;
void Activate();
void Deactivate();
}
}
using UnityEngine;
namespace Assets.Scripts
{
public class TriggerTest : MonoBehaviour
{
private IDeactivatable _deactivatable;
private void OnTriggerEnter(Collider other)
{
if (other.TryGetComponent(out IDeactivatable deactivatable))
{
_deactivatable = deactivatable;
_deactivatable.Deactivated += ExitTrigger;
}
}
private void OnTriggerStay(Collider other)
{
Debug.Log("TriggerStay");
}
private void OnTriggerExit(Collider other)
{
ExitTrigger();
}
private void ExitTrigger()
{
Debug.Log("TriggerExit");
_deactivatable.Deactivated -= ExitTrigger;
}
}
}
var position = Camera.main.ScreenToWorldPoint(Input.mousePosition);
position.z = transform.position.z;
transform.position = position;