コード例 #1
0
    void OnTriggerEnter(Collider other)
    {
        if (_feeding || _movingToTarget)
        {
            return;
        }
        SkinArea skin = other.GetComponent <SkinArea>();

        if (skin != null)
        {
            if (skin._mosquitoCount < skin._supportedMosquitos)
            {
                skin._mosquitoCount++;
                if (skin._mosquitoCount >= skin._supportedMosquitos)
                {
                    skin.collider.enabled = false;
                }
                _movingToTarget = true;
                _manager.SetFeeding(this, true);
                _feedingSkin = skin;
                StartCoroutine(MoveToFeed(skin.transform.position + new Vector3(Random.Range(-30f, 30f), Random.Range(-30f, 30f), 0f)));
            }
        }
        else
        {
            GiantArm arm = other.GetComponent <GiantArm>();
            if (arm != null)
            {
                StartCoroutine(Die());
            }
        }
    }