当前位置: 首页>>代码示例>>C#>>正文


C# Collider.GetType方法代码示例

本文整理汇总了C#中Collider.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Collider.GetType方法的具体用法?C# Collider.GetType怎么用?C# Collider.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Collider的用法示例。


在下文中一共展示了Collider.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMass

	public static float GetMass(Collider collider,float density = 1){
		float volume = 0;
		float mass = 0;
		if(collider.GetType() == typeof(SphereCollider)){
			volume = (collider.bounds.size.x * Mathf.PI)/6;
		}else if(collider.GetType() == typeof(CapsuleCollider)){
			volume = ((Mathf.PI * collider.bounds.size.x * collider.bounds.size.y) * collider.bounds.size.z)/4;
		}else{
			volume = collider.bounds.size.x * collider.bounds.size.y * collider.bounds.size.z;
		}
		mass = (density * volume)/10;
		return mass;
	}
开发者ID:Xananax,项目名称:unity-manipulateObjectsTest,代码行数:13,代码来源:SimpleDraggable.cs

示例2: OnTriggerStay

 void OnTriggerStay(Collider col)
 {
     if (col.GetType() != typeof(SphereCollider) && !col.CompareTag("Terrain"))
     {
         isColliding = true;
     }
 }
开发者ID:KennyDBacon,项目名称:FYP-Personal,代码行数:7,代码来源:BuildCheck.cs

示例3: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if (other.GetType() == typeof(CapsuleCollider)) {
         charactersEnding[other.name] = true;
         CheckEndOfAllCharacters();
     }
 }
开发者ID:5thFloorGames,项目名称:FollowTheLight,代码行数:7,代码来源:LevelEnd.cs

示例4: OnTriggerEnter

    void OnTriggerEnter(Collider projectile)
    {
        if(projectile.GetType() == typeof(SphereCollider))
        {
            //bomb!!!
            Vector3 houseTransform = thisHouse.transform.position;
            Quaternion houseRotatoin = thisHouse.transform.rotation;
            switch(targetType)
            {
            case TargetType.present:
                //present was wanted

                //lose points!
                scoreController.addScore(-30);

                //destroy house!!
                GameObject.Destroy(thisHouse);
                Instantiate(houseExplosion, houseTransform, houseRotatoin);
                break;
            case TargetType.bomb:
                //bomb was wanted

                //get points!
                scoreController.addScore(10);

                //destroy house
                GameObject.Destroy(thisHouse);
                Instantiate(houseExplosion, houseTransform, houseRotatoin);
                break;
            }
        }
    }
开发者ID:graemebr,项目名称:SantaSlay,代码行数:32,代码来源:TriggerHandler.cs

示例5: OnTriggerExit

 void OnTriggerExit(Collider hitObject)
 {
     if (hitObject.GetType() == typeof(BoxCollider) && hitObject.CompareTag("Enemy"))
     {
         enemiesInMeleeRange.Remove(hitObject.gameObject);
     }
 }
开发者ID:eaho1,项目名称:Shut-Up-and-Escape-With-Me,代码行数:7,代码来源:PlayerMeleeManager.cs

示例6: OnTriggerEnter

 void OnTriggerEnter(Collider obj)
 {
     if(obj.gameObject.tag == "Enemy" && obj.GetComponent<BossAI>() == bossAI && (typeof(SphereCollider) != obj.GetType ()) && isCollectableByBoss)
     {
         Debug.Log("Collision entre la Flesh et le boss");
         Destroy(this.gameObject);
     }
 }
开发者ID:Defsv,项目名称:UJelly-ProtoType1,代码行数:8,代码来源:Flesh.cs

示例7: OnTriggerEnter

 void OnTriggerEnter(Collider obj)
 {
     if(obj.gameObject.tag == "Enemy" && (typeof(SphereCollider) != obj.GetType ()))
     {
         Destroy(this.gameObject);
         obj.GetComponentInParent<EnemyObject>().enemy.removeHP(player.attack/2);
         obj.gameObject.GetComponent<EnemyObject>().afficherVie = true;
     }
 }
开发者ID:Defsv,项目名称:UJelly-ProtoType1,代码行数:9,代码来源:DamageEnemy.cs

示例8: OnTriggerEnter

	void OnTriggerEnter (Collider other){
		if (other.transform.parent) {
			if (other.transform.parent.GetComponent<CharacterStats>() && other.gameObject.transform.parent.tag != transform.parent.tag && !enemies.Contains (other)) {
				if (other.GetType () == typeof(BoxCollider)) {
					enemies.Add (other);
				}
			}
		}
	}
开发者ID:diogo92,项目名称:Project.EXE,代码行数:9,代码来源:FightObjectScript.cs

示例9: OnTriggerEnter

	void OnTriggerEnter (Collider coll)
	{
		if (coll.name == "Zombie" && coll.GetType() == typeof(CapsuleCollider))
		{
			GameObject go = coll.collider.gameObject;
			mAI other = (mAI)go.GetComponent (typeof(mAI));
			other.hurt();
		}
		//Destroy (gameObject, 0.3f);
	}
开发者ID:sybiload,项目名称:0xyde,代码行数:10,代码来源:BlastKill.cs

示例10: ClosestPointOnSurface

    public static bool ClosestPointOnSurface(Collider collider, Vector3 to, float radius, out Vector3 closestPointOnSurface)
    {
        if (collider is BoxCollider)
        {
            closestPointOnSurface = SuperCollider.ClosestPointOnSurface((BoxCollider)collider, to);
            return true;
        }
        else if (collider is SphereCollider)
        {
            closestPointOnSurface = SuperCollider.ClosestPointOnSurface((SphereCollider)collider, to);
            return true;
        }
        else if (collider is CapsuleCollider)
        {
            closestPointOnSurface = SuperCollider.ClosestPointOnSurface((CapsuleCollider)collider, to);
            return true;
        }
        else if (collider is MeshCollider)
        {
            RPGMesh rpgMesh = collider.GetComponent<RPGMesh>();

            if (rpgMesh != null)
            {
                closestPointOnSurface = rpgMesh.ClosestPointOn(to, radius, false, false);
                return true;
            }

            BSPTree bsp = collider.GetComponent<BSPTree>();

            if (bsp != null)
            {
                closestPointOnSurface = bsp.ClosestPointOn(to, radius);
                return true;
            }

            BruteForceMesh bfm = collider.GetComponent<BruteForceMesh>();

            if (bfm != null)
            {
                closestPointOnSurface = bfm.ClosestPointOn(to);
                return true;
            }
        }
        else if (collider is TerrainCollider)
        {
            closestPointOnSurface = SuperCollider.ClosestPointOnSurface((TerrainCollider)collider, to, radius, false);
            return true;
        }

        Debug.LogError(string.Format("{0} does not have an implementation for ClosestPointOnSurface; GameObject.Name='{1}'", collider.GetType(), collider.gameObject.name));
        closestPointOnSurface = Vector3.zero;
        return false;
    }
开发者ID:IronWarrior,项目名称:SuperCharacterController,代码行数:53,代码来源:SuperCollider.cs

示例11: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player" && (other.GetType() == typeof(CapsuleCollider))) {
         if (CheckIfCharacterInSight(other.gameObject)) {
             List <object> info = new List<object>();
             object dmgObject = damage;
             info.Add(dmgObject);
             info.Add(caster);
             other.gameObject.SendMessageUpwards("TakeDamage", info);
         }
     }
 }
开发者ID:5thFloorGames,项目名称:FollowTheLight,代码行数:12,代码来源:AreaDamageBehavior.cs

示例12: OnTriggerEnter

    void OnTriggerEnter(Collider other)
    {
        if (other is CharacterController) {

            CharacterController A = (CharacterController)other;

            A.transform.forward = - this.transform.forward;

            //A.Move(new Vector3(0,20,-10));
            print ("Collision by: "+other.GetType().ToString()+"  ... End of text");

        }
    }
开发者ID:ArcaneSaint,项目名称:iTalent-Workshop,代码行数:13,代码来源:jumppad.cs

示例13: OnTriggerStay

 void OnTriggerStay(Collider projectile)
 {
     if(!triggered && projectile.rigidbody.velocity.magnitude <= 0.01)
     {
         if(projectile.GetType() == typeof(BoxCollider) && targetType == TargetType.present)
         {
             //present was correctly received!
             triggered = true;
             //add points
             scoreController.addScore(10);
             //remove trigger
             GameObject.Destroy(gameObject);
         }
         else if(projectile.GetType() == typeof(BoxCollider) && targetType == TargetType.bomb)
         {
             //present was incorrectly recieved!
             triggered = true;
             //add points
             scoreController.addScore(-10);
             //remove trigger
             GameObject.Destroy(gameObject);
         }
     }
 }
开发者ID:graemebr,项目名称:SantaSlay,代码行数:24,代码来源:TriggerHandler.cs

示例14: OnTriggerEnter

    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Tower" && !other.GetType().ToString().Equals("UnityEngine.SphereCollider"))
        {

            var tower = GameObject.FindGameObjectWithTag("Player").GetComponent<TowerControl>();
            tower.Placeable = false;
            tower.collided.Add(this.gameObject);
            var renderers = other.gameObject.GetComponentsInChildren<Renderer>();
            foreach (var render in renderers)
            {
                render.material.color = Color.red;
            }
        }
    }
开发者ID:camotts,项目名称:Tower-Defense,代码行数:15,代码来源:Terrain.cs

示例15: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if (!triggered) {
         if (other.tag == "Player" && other.GetType() == typeof(CapsuleCollider)) {
             StartCoroutine(GiveTextToHandler());
             if (uiEventSendMessage != "") {
                 GameObject.Find("TutorialUIEvents").SendMessage(uiEventSendMessage);
             }
             if (flashMessage == "FlashHealth" ) {
                 GameObject.Find("UserInterface").GetComponent<UserInterfaceManager>().FlashHealth("Character1", 3);
             } else if (flashMessage == "FlashMovement") {
                 GameObject.Find("UserInterface").GetComponent<UserInterfaceManager>().FlashMovement("Character1", 3);
             } else if (flashMessage == "FlashActionPoints") {
                 GameObject.Find("UserInterface").GetComponent<UserInterfaceManager>().FlashActionPoints("Character1", 3);
             }
             triggered = true;
         }
     }
 }
开发者ID:5thFloorGames,项目名称:FollowTheLight,代码行数:19,代码来源:TutorialTrigger.cs


注:本文中的Collider.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。