示例#1
0
 // Use this for initialization
 void Start()
 {
     playerData  = GameObject.FindGameObjectsWithTag("backgroundScipt")[0].GetComponent <playerDataClass>(); //
     rigidbody2d = GetComponent <Rigidbody2D>();
     npcclass    = GetComponent <npcClass>();
     playermove  = GetComponent <playerMove>();
     npcmove     = GetComponent <npcMove>();
     npcclass.npcClassSetUp();
     ignoreCollisionSetUp();//無視其他enemy碰撞
     thisAnimation.state.Complete += MyCompleteListener;
     DelegateSetUp();
 }
示例#2
0
    // Use this for initialization
    void Start()
    {
        playerData  = GameObject.FindGameObjectsWithTag("backgroundScipt")[0].GetComponent <playerDataClass>(); //
        rigidbody2d = GetComponent <Rigidbody2D>();
        npcclass    = GetComponent <npcClass>();
        npcclass.npcClassSetUp();

        GameObject[] gameObj = GameObject.FindGameObjectsWithTag("enemy");  //無視其他enemy碰撞
        foreach (GameObject each in gameObj)
        {
            Physics2D.IgnoreCollision(each.GetComponent <BoxCollider2D>(), GetComponent <BoxCollider2D>());
            Physics2D.IgnoreCollision(each.GetComponent <BoxCollider2D>(), GetComponent <CircleCollider2D>());
            Physics2D.IgnoreCollision(each.GetComponent <CircleCollider2D>(), GetComponent <BoxCollider2D>());
            Physics2D.IgnoreCollision(each.GetComponent <CircleCollider2D>(), GetComponent <CircleCollider2D>());
        }

        GameObject[] HPpartaclegameObj = GameObject.FindGameObjectsWithTag("HPpartacle");  //無視其他enemy碰撞
        foreach (GameObject each in HPpartaclegameObj)
        {
            Physics2D.IgnoreCollision(each.GetComponent <Collider2D>(), GetComponent <BoxCollider2D>());
            Physics2D.IgnoreCollision(each.GetComponent <Collider2D>(), GetComponent <CircleCollider2D>());
        }
    }