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()); } } }
IEnumerator SpawnArm(Vector3 pos) { while (_armSpawned) { yield return(1); } _armSpawned = true; GiantArm arm = Instantiate(_armPrefab) as GiantArm; pos.z = 500f; pos.x += Random.Range(-300f, 300f); pos.y += Random.Range(-300f, 300f); arm._t.position = pos; }