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


C# Collider2D.GetComponentInChildren方法代码示例

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


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

示例1: OnTriggerExit2D

 void OnTriggerExit2D(Collider2D collider)
 {
     if (this.actionsInRange.Contains (collider.GetComponentInChildren<IAction> ())) {
         collider.GetComponentInChildren<IAction> ().Finished ();
         this.actionsInRange.Remove (collider.GetComponentInChildren<IAction> ());
     }
 }
开发者ID:seanald,项目名称:2dShowcase,代码行数:7,代码来源:ExecuteAction.cs

示例2: OnTriggerEnter2D

 void OnTriggerEnter2D(Collider2D col)
 {
     Debug.Log ("当たった:" + col.GetComponentInChildren<Text>().text);
     if (NONE_PANEL == col.GetComponentInChildren<Text> ().text)
     {
         KeepPos = col.GetComponent<RectTransform>().position;
     }
 }
开发者ID:marv-Shimazug,项目名称:15Puzzle,代码行数:8,代码来源:PanelRule.cs

示例3: OnTriggerEnter2D

	void OnTriggerEnter2D(Collider2D other){
		if(other.CompareTag("Player")){
			other.GetComponentInChildren<Rigidbody2D>().velocity = new Vector2(0f,0f);
			other.GetComponent<CharacterControllerScript>().canMove(false);
			other.GetComponent<CharacterControllerScript>().fantasyArmorIdle.SetActive(true);
			other.GetComponent<CharacterControllerScript>().fantasyArmorWalking.SetActive(false);
			other.GetComponentInChildren<Animator>().Play("kidSmile");
			doppleganger.GetComponent<Animator>().Play ("kidSmile");
			credits.SetActive(true);
		}
}
开发者ID:BraveKids,项目名称:TheTrial,代码行数:11,代码来源:endGameScript.cs

示例4: OnTriggerEnter2D

 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.name == "Enemy"||other.gameObject.name=="Enemy(Clone)") {
         other.GetComponent<PlayerStats>().ChangeHealth(-(damage));
         other.GetComponentInChildren<ParticleSystem>().Emit (10);
     }
 }
开发者ID:alextat120,项目名称:zombie-game,代码行数:7,代码来源:MoveScript.cs

示例5: OnTriggerEnter2D

    private void OnTriggerEnter2D(Collider2D collider2d)
    {
        Rigidbody2D body = collider2d.GetComponent<Rigidbody2D>();
        if(!body)	body = collider2d.GetComponentInChildren<Rigidbody2D>();
        if(!body)	return;

        body.drag = drag;
        body.fixedAngle = true;
        body.gameObject.AddComponent<LateDestroyerComponent>();

        BoxCollider2D boxCollider2d = body.GetComponent<BoxCollider2D>();
        if(boxCollider2d)
            boxCollider2d.isTrigger = true;

        body.tag = "Untagged";

        foreach(Transform child in body.transform)
            GameObject.Destroy(child.gameObject);

        if(GameObject.FindGameObjectsWithTag("Crate").Length < 5)
            GameObject.FindObjectOfType<CrateSpawner>().spawnCrate();

        GameObject splash = GameObject.Instantiate(splashSystem);
        splash.transform.position = new Vector2(collider2d.transform.position.x, yPos);
        splash.AddComponent<TimedDestroyer>();
    }
开发者ID:Grenchorne,项目名称:LoadScreenSim,代码行数:26,代码来源:WaterComponent.cs

示例6: OnTriggerEnter2D

 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Player" && transform.parent == null) {
         Item playerItem = other.GetComponentInChildren<Item> ();
         if (playerItem == null) {
             transform.parent = other.gameObject.transform;
             transform.localPosition = new Vector3 (0, 0.8f, 0);
             transform.localScale /= 1.5f;
             if (item.itemType == ItemType.FAKEOBJECT) {
                 soundLauncher.CollectFake();
             } else {
                 soundLauncher.CollectTop();
                 if (other.gameObject.name == "Lux") MusicManager.Lux(); else MusicManager.Nox();
             }
         } else if (playerItem.itemType == ItemType.FAKEOBJECT && item.itemType == ItemType.TOPOBJECT) {
             playerItem.transform.parent = null;
             playerItem.transform.localScale *= 1.5f;
             transform.parent = other.gameObject.transform;
             transform.localPosition = new Vector3 (0, 0.8f, 0);
             transform.localScale /= 1.5f;
             soundLauncher.CollectTop();
             if (other.gameObject.name == "Lux") MusicManager.Lux(); else MusicManager.Nox();
         }
     }
     /*else if (other.gameObject.tag == "Player" && transform.parent != null)
         other.GetComponent<PlayerControl>().Collect(item);*/
 }
开发者ID:descorps,项目名称:Lux-Nox,代码行数:27,代码来源:Collect.cs

示例7: OnTriggerEnterOrExit2D

 public void OnTriggerEnterOrExit2D(Collider2D other)
 {
     if (transform.parent.GetComponent<PlayerControl>().isDashing && other.tag == "Player"){
         Item playerItem = transform.parent.GetComponentInChildren<Item> ();
         Item otherItem = other.GetComponentInChildren<Item> ();
         if(playerItem == null || otherItem == null) {
         }
         else if (playerItem.itemType == ItemType.FAKEOBJECT) {
             if(transform.parent.GetComponent<PlayerControl>().dashLeft)
                 otherItem.transform.parent.gameObject.GetComponent<Rigidbody2D>().AddForce(dashLeftForce);
             else
                 otherItem.transform.parent.gameObject.GetComponent<Rigidbody2D>().AddForce(dashRightForce);
             playerItem.transform.parent = null;
             playerItem.transform.localScale *= 1.5f;
             otherItem.transform.parent = transform.parent.transform;
             otherItem.transform.localPosition = new Vector3 (0, 0.8f, 0);
             if (otherItem.itemType == ItemType.TOPOBJECT) {
                 if (transform.parent.name == "Lux") MusicManager.Lux(); else MusicManager.Nox();
             }
         }
         else if (playerItem.itemType == ItemType.TOPOBJECT) {
             if(transform.parent.GetComponent<PlayerControl>().dashLeft)
                 otherItem.transform.parent.gameObject.GetComponent<Rigidbody2D>().AddForce(dashLeftForce);
             else
                 otherItem.transform.parent.gameObject.GetComponent<Rigidbody2D>().AddForce(dashRightForce);
             otherItem.transform.parent = null;
             otherItem.transform.localScale *= 1.5f;
         }
     }
 }
开发者ID:descorps,项目名称:Lux-Nox,代码行数:30,代码来源:collisionDash.cs

示例8: OnTriggerStay2D

 void OnTriggerStay2D(Collider2D otherObj)
 {
     if (otherObj.tag == "Player" && !otherObj.GetComponentInChildren<GroundCheckController>().touchingGround) {
         GetComponent<BoxCollider2D>().isTrigger = false;
         gameObject.tag = "Ground";
     }
 }
开发者ID:jcenriquez1123,项目名称:Project-Sol,代码行数:7,代码来源:EchoController.cs

示例9: OnTriggerEnter2D

 void OnTriggerEnter2D(Collider2D other)
 {
     CameraScript mainCamera = other.transform.parent.GetComponent(typeof(CameraScript)) as CameraScript;
     mainCamera.active = false;
     Player player = other.GetComponentInChildren(typeof(Player)) as Player;
     player.StopAllCoroutines();
     player.EndGame();
 }
开发者ID:TrentonPottruff,项目名称:Earth-Fall,代码行数:8,代码来源:Enemy.cs

示例10: OnTriggerStay2D

    public void OnTriggerStay2D(Collider2D target)
    {
        if (target.gameObject.tag == "Enemy")
        {
            target.GetComponentInChildren<PlayerHealth> ().TakeDamage (fireballBaseDamage);
            Destroy (gameObject);
        }

        if (target.gameObject.tag == "Ground")
        {
            Destroy (gameObject);
        }

        if(target.gameObject.tag== "Flammable")
        {
            target.GetComponentInChildren<Torch>().activateFlammable ();
            Destroy (gameObject);
        }
    }
开发者ID:MChen7209,项目名称:Yi-Ju-Chen,代码行数:19,代码来源:FireballScript.cs

示例11: OnTriggerEnter2D

 void OnTriggerEnter2D(Collider2D col)
 {
     //print(col);
     //checks to see if the collider belongs to a player
     if (col.GetComponentInParent<Health>() || col.GetComponent<GrappleScript>() || col.GetComponent<ParticleSystem>() || col.GetComponentInChildren<ParticleSystem>() || col.CompareTag("Grapple")) {
         if (col.GetComponent<Health>() && !respawning) SetInRespawnQueue(col.gameObject);
     } else {
         //print("Destroyyy");
         Destroy(col.gameObject);
     }
 }
开发者ID:PurdueSIGGD,项目名称:GrapplingHookFighters,代码行数:11,代码来源:Boundary.cs

示例12: compare

 // compares the current colour to the collider's colour
 // general tool
 public bool compare(Collider2D collider)
 {
     ModeChange mode = collider.GetComponentInChildren<ModeChange> ();
     if (mode == null) {
         mode = collider.GetComponentInParent<ModeChange> ();
         return compare (mode);
     }
     else {
         int colour = mode.currentColour;
         return currentColour == colour; // if they are the same, return true
     }
 }
开发者ID:Vylantze,项目名称:Chaos-Children,代码行数:14,代码来源:ModeChange.cs

示例13: OnTriggerEnter2D

 void OnTriggerEnter2D(Collider2D co)
 {
     Inventory inv = co.GetComponentInChildren<Inventory>() as Inventory;
     inv.AddItem (2);
     int r = Random.Range(2, 4);
     for (int i = 0; i < r; i++) {
         int item = Random.Range (3, 15);
            if(inv){
             inv.AddItem(item);  }
       }
     Destroy (this.gameObject);
 }
开发者ID:spacesnaill,项目名称:Summer-Seminar,代码行数:12,代码来源:Chest.cs

示例14: RespawnPlayerCo

    public IEnumerator RespawnPlayerCo(Collider2D player)
    {
        //Instantiate(deathParticle, player.transform.position, player.transform.rotation);

        player.enabled = false;
        player.GetComponentInChildren<Renderer>().enabled = false;
        player.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
        gravityStore = player.GetComponent<Rigidbody2D>().gravityScale;
        player.GetComponent<Rigidbody2D>().gravityScale = 0;

        ScoreManager.AddPoints(-pointPenaltOnDeath);

        yield return new WaitForSeconds(respawnDelay);

        player.transform.position = checkpoint[Random.Range(0, checkpoint.Length)].transform.position;
        //Instantiate(lifeParticle, currentCheckpoint.transform.position, currentCheckpoint.transform.rotation);

        player.enabled = true;
        player.GetComponentInChildren<Renderer>().enabled = true;
        player.GetComponent<Rigidbody2D>().gravityScale = gravityStore;
    }
开发者ID:DigaOSK8,项目名称:GravityProject,代码行数:21,代码来源:LevelManager.cs

示例15: OnTriggerEnter2D

 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Zombie" && PorteObjectif == true)
     {
         Main.GetComponent<Timer>().GiveZPoints();
     //	other.Destroy(other.gameObject.Find());
     }
     if (other.tag == "Human" && PorteObjectif == true)
     {
         other.GetComponentInChildren<Human_Handling>().FuckOffIncapacitated();
     }
     PorteObjectif = false;
 }
开发者ID:PhilippeRheaume,项目名称:World_War_H,代码行数:13,代码来源:Spawner_Objectif.cs


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