Beispiel #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        ObjectLifeSystem comp = collision.gameObject.GetComponent <ObjectLifeSystem>();

        comp.Damage(Damage);
        Destroy(this.gameObject);
    }
    private void OnCollisionStay2D(Collision2D collision)
    {
        bool isEnemy = collision.gameObject.tag == "Enemy";
        bool isNest  = collision.gameObject.tag == "Nest";

        if (!isEnemy && !isNest)
        {
            ObjectLifeSystem comp = collision.gameObject.GetComponent <ObjectLifeSystem>();
            comp.Damage(Damage);
        }
    }
Beispiel #3
0
    void DestroyObject()
    {
        // 左クリックされた場所のオブジェクトを取得
        Vector2    tapPoint    = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Collider2D collition2d = Physics2D.OverlapPoint(tapPoint);

        if (collition2d)
        {
            GameObject selectObj = collition2d.transform.gameObject;
            if (selectObj.tag != "Base" && selectObj.tag != "Nest" && selectObj.tag != "Enemy")
            {
                ObjectLifeSystem comp = selectObj.gameObject.GetComponent <ObjectLifeSystem>();
                Destroy(comp.HP_Bar);
                Destroy(selectObj.gameObject);
            }
        }
    }
Beispiel #4
0
 // Start is called before the first frame update
 void Start()
 {
     energy     = isBase;
     lifeSystem = this.GetComponent <ObjectLifeSystem>();
 }
Beispiel #5
0
 // Start is called before the first frame update
 void Start()
 {
     Base   = GameObject.Find("Base");
     Script = Base.GetComponent <ObjectLifeSystem>();
 }