mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
45 lines
949 B
C#
45 lines
949 B
C#
using GameLogic;
|
|
using TEngine;
|
|
using UnityEngine;
|
|
using UniFramework.Pooling;
|
|
|
|
public class EntityAsteroid : MonoBehaviour
|
|
{
|
|
public float MoveSpeed = -5f;
|
|
public float Tumble = 5f;
|
|
|
|
private SpawnHandle _handle;
|
|
private Rigidbody _rigidbody;
|
|
|
|
public void InitEntity(SpawnHandle handle)
|
|
{
|
|
_handle = handle;
|
|
|
|
_rigidbody.velocity = this.transform.forward * MoveSpeed;
|
|
_rigidbody.angularVelocity = Random.insideUnitSphere * Tumble;
|
|
}
|
|
|
|
void Awake()
|
|
{
|
|
_rigidbody = this.transform.GetComponent<Rigidbody>();
|
|
}
|
|
void OnTriggerEnter(Collider other)
|
|
{
|
|
var name = other.gameObject.name;
|
|
if (name.StartsWith("player"))
|
|
{
|
|
GameEvent.Send(ActorEventDefine.AsteroidExplosion,this.transform.position, this.transform.rotation);
|
|
_handle.Restore();
|
|
_handle = null;
|
|
}
|
|
}
|
|
void OnTriggerExit(Collider other)
|
|
{
|
|
var name = other.gameObject.name;
|
|
if (name.StartsWith("Boundary"))
|
|
{
|
|
_handle.Restore();
|
|
_handle = null;
|
|
}
|
|
}
|
|
} |