本文整理汇总了C#中UnityEngine.Collider2D.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Collider2D.GetType方法的具体用法?C# Collider2D.GetType怎么用?C# Collider2D.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Collider2D
的用法示例。
在下文中一共展示了Collider2D.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if((other.CompareTag("Cell") && other.GetType() == typeof(BoxCollider2D)) || (other.CompareTag("Enemy") && other.GetType() == typeof(BoxCollider2D)) || (other.CompareTag("LTAux") && other.GetType() == typeof(BoxCollider2D))){
Vector3 reflect = Vector3.Reflect(other.transform.right, normal);
Vector3 direction = new Vector3(reflect.x, reflect.y, 0);
Vector3 diff = (other.transform.position + direction) - other.transform.position;
/*if((normal.x*diff.x > 0) || (normal.y*diff.y > 0))
return;*/
float rot_z = Mathf.Atan2(diff.y, diff.x) * Mathf.Rad2Deg;
AgentMovement agentMovement = other.gameObject.GetComponent<AgentMovement>();
agentMovement.agentRigidbody.rotation = rot_z;
//other.gameObject.GetComponent<Rigidbody2D>().AddForce(normal * 10);
/*AgentMovement agentMovement = other.gameObject.GetComponent<AgentMovement>();
if(normal.x == 0f){
if(agentMovement.agentRigidbody.position.y >= transform.position.y + offset){
agentMovement.agentRigidbody.position = new Vector2(agentMovement.agentRigidbody.position.x, transform.position.y + offset);
}
}else{
if(agentMovement.agentRigidbody.position.x >= transform.position.x + offset){
agentMovement.agentRigidbody.position = new Vector2(transform.position.x + offset, agentMovement.agentRigidbody.position.y);
}
}*/
}
}
示例2: OnTriggerExit2D
void OnTriggerExit2D(Collider2D collider){
if(collider.GetType() == typeof(BoxCollider2D)||
collider.GetType() == typeof(EdgeCollider2D)){
colliding = false;
}
}
示例3: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D coll)
{
Debug.Log ("Animal coll:" + coll.gameObject.name + " class:" + coll.GetType().FullName);
if(coll.gameObject.name.CompareTo("firewall(Clone)") == 0) {
GameRuleManager _manager = (GameRuleManager)GameObject.Find("_GameRuleManager(Clone)").GetComponent("GameRuleManager");
_manager.gameOver();
}
else if(coll.gameObject.name.StartsWith ("cola_tsubu")) {
//cola mituketa!
mCount = 50;
mTarget = coll.transform;
Vector2 heading = mTarget.position - gameObject.transform.position;
float distance = heading.magnitude;
float force = 0.75f;
Vector2 direction = heading / distance * force;
rigidbody2D.velocity = direction;
//
LookAt2D(transform, mTarget, Vector2.up);
//cola destroy
coll.gameObject.SetActive(false);
}
else if(coll.gameObject.name.StartsWith ("exit")) {
gameObject.SetActive(false);
}
//
}
示例4: OnTriggerExit2D
void OnTriggerExit2D(Collider2D c)
{
// Debug.Log("an Object collided");
if(objsToRemove.Length > 0){
foreach (GameObject o in objsToRemove){
if(c.GetType() == typeof(BoxCollider2D)){
o.GetComponent<MeshRenderer>().enabled = !o.GetComponent<MeshRenderer>().enabled;
}
}
}else{
if(c.GetType() == typeof(BoxCollider2D)){
objToRemove.GetComponent<MeshRenderer>().enabled = !objToRemove.GetComponent<MeshRenderer>().enabled;
}
}
}
示例5: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D collider){
if(collider.GetType() == typeof(BoxCollider2D)){
LureEnteredMessage message = new LureEnteredMessage (this, collider.gameObject);
MessageCenter.Instance.Broadcast (message);
npcCaught = true;
caughtTime = Time.time;
caughtNPC = collider.gameObject;
}
}
示例6: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D collision)
{
if(collision.gameObject.layer == playerLayer && collision.gameObject.GetComponent<Rigidbody2D>().velocity.y < -fallthreshold && collision.GetType() == typeof(CircleCollider2D))
{
PlatformerCharacter2D playerScript = collision.gameObject.GetComponent<PlatformerCharacter2D>();
playerScript.AdjustHP(-damage);
Debug.Log("hit");
}
}
示例7: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if(other.CompareTag("Cell") && other.GetType() == typeof(BoxCollider2D) && color.a > 0.05f){
AgentLife agentLife = other.GetComponent<AgentLife>();
agentLife.TakeDamage(amountDamage);
StopCoroutine(agentLife.IsHit(new Color(color.r, color.g, color.b)));
StartCoroutine(agentLife.IsHit(new Color(color.r, color.g, color.b)));
}
}
示例8: OnTriggerExit2D
/// <summary>
/// Vérifie ce qui sort dans le percepts de l'agent.
/// </summary>
/// <param name="other">Other.</param>
protected override void OnTriggerExit2D(Collider2D other)
{
base.OnTriggerExit2D(other);
if(other.CompareTag(gameObject.tag) && other.GetType() == typeof(BoxCollider2D)){
if(Vector3.Distance(transform.position, other.transform.position) > GetComponent<CircleCollider2D>().radius){
bacterias.Remove(other.gameObject);
}
}
}
示例9: OnTriggerEnter2D
float wallVelocity = 0.0f; //1.2f
#endregion Fields
#region Methods
void OnTriggerEnter2D(Collider2D coll)
{
Debug.Log ("FireWall coll:" + coll.gameObject.name + " class:" + coll.GetType().FullName);
if(coll.gameObject.name.StartsWith ("cola_tsubu")) {
wallVelocity = wallUP;
//cola destroy
coll.gameObject.SetActive(false);
}
}
示例10: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D col)
{
Debug.Log ("OutCircle");
if (col.GetType() == typeof(CircleCollider2D))
{
rb.velocity = new Vector2(-0.0001f,-0.0001f);
rb.angularVelocity = 0;
print("circle");
Orc.transform.position=oldPos;
// newPos=Vector2.zero;
}
}
示例11: OnTriggerStay2D
/// <summary>
/// Permet de ce diriger vers un macrophage lorsque celui-ci est détecté
/// dans le percept du lymphocyte T Auxiliaire et qu'il apporte un résidu.
/// </summary>
/// <param name="other">Other.</param>
protected void OnTriggerStay2D(Collider2D other)
{
if(other.CompareTag("Cell") && other.GetType() == typeof(BoxCollider2D)){
if(other.name.Contains("Macrophage") && MacrophageAttack.bringResidues){
if(other.GetComponent<Agent>().state == MacrophageAgent.BRING_RESIDUS){
Vector3 diff = other.transform.position - transform.position;
float rot_z = Mathf.Atan2(diff.y, diff.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, 0f, rot_z);
agentRigidbody.velocity = new Vector2(transform.right.x, transform.right.y) * speed * Time.deltaTime;
}
}
}
}
示例12: OnTriggerEnter2D
/// <summary>
/// Vérifie ce qui entre dans le percepts de l'agent.
/// </summary>
/// <param name="other">Other.</param>
protected override void OnTriggerEnter2D(Collider2D other)
{
base.OnTriggerEnter2D(other);
/*if (other.CompareTag ("LTAux") && other.GetType () == typeof(BoxCollider2D)) {
if (!targets.Contains (other.gameObject)) {
targets.Add (other.gameObject);
}
}*/
if(other.CompareTag(gameObject.tag) && other.GetType() == typeof(BoxCollider2D)){
if(!bacterias.Contains(other.gameObject)){
bacterias.Add(other.gameObject);
}
}
}
示例13: OnTriggerStay2D
void OnTriggerStay2D(Collider2D col)
{
if (col.tag == "Player" && col.GetType () == typeof(CircleCollider2D)) {
if (upIsStraight) {
if (CrossPlatformInputManager.GetAxis("Vertical") < -0.5f) {
Active = false;
} else {
Active = true;
}
} else {
if (CrossPlatformInputManager.GetAxis ("Vertical") > 0.5f) {
Active = true;
} else {
Active = false;
}
}
}
}
示例14: triggered
//.........这里部分代码省略.........
{
if(mIsAwake)
{
if(!mIsKinematic) //TODO think about using the collision relative velocity in order to wake a body up?
{
if(velocity.sqrMagnitude > World.wakeVelocity * World.wakeVelocity || Mathf.Abs( angularVelocity ) > World.wakeAngularVelocity)
{
otherBody.IsAwake = true; otherBody.sleepCount = 0;
}
}
else
{
otherBody.IsAwake = true; otherBody.sleepCount = 0;
}
}
}
// Benchy.End("Wakeup");
SupplementaryColliderInfo Info;
bool alreadyTracked = World.StartTrackingCollider(polyCollider, out Info, this);
if(alreadyTracked)
Info.Update();
SupplementaryColliderInfo otherInfo;
alreadyTracked = World.StartTrackingCollider(coll, out otherInfo, otherBody);
if(alreadyTracked)
otherInfo.Update();
// Benchy.Begin("BodyCollide");
//find fine detail of collision.
List<JelloContact> contacts = new List<JelloContact>();
Type t2 = coll.GetType();
if(t2 == typeof(CircleCollider2D))
{
World.BodyCollide((CircleCollider2D)coll, Info, ref contacts);
}
else //polygon and box collisions handled here.
{
World.BodyCollide (Info, otherInfo, ref contacts);
}
if(contacts.Count <= 0)
return;
// Benchy.End("BodyCollide");
// Benchy.Begin("CollisionEvent");
collisions.Add (new JelloCollision(contacts.ToArray()));
if(collisions[collisions.Count - 1].GetOtherBody(this) != null)
{
collisions[collisions.Count - 1].GetOtherBody(this).collisions.Add(collisions[collisions.Count - 1]);
collisions[collisions.Count - 1].GetOtherBody(this).OnJelloCollision(collisions[collisions.Count - 1]);
}
OnJelloCollision(collisions[collisions.Count - 1]);
if(collisions[collisions.Count - 1].ignore)
return;
// Benchy.End("CollisionEvent");
//handle the collision
// Benchy.Begin("Resolve");
int numContacts = 0;
for(int i = 0; i < collisions[collisions.Count - 1].contacts.Length; i++)
{
示例15: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D collider){
if(collider.GetType() == typeof(BoxCollider2D)||
collider.GetType() == typeof(EdgeCollider2D)){
colliding = true;
}
}