Пример #1
0
    void Start()
    {
        BeeCountStore store      = BeeCountStore.GetInstance();
        Transform     beesParent = GameObject.Find("bees").transform;

        for (int i = 0; i < store.beesAtStartOfLevel; i++)
        {
            Vector3    beePosition = new Vector3(transform.position.x + (Random.value * 2 - 1), transform.position.y + (Random.value * 2 - 1), 0f);
            GameObject bee         = (GameObject)Instantiate(beePrefab, beePosition, Quaternion.identity);
            bee.transform.parent = beesParent;
            bee.GetComponent <AudioSource>().clip = beeHitSounds[Random.Range(0, beeHitSounds.Length)];
        }

        BeeCountUpdater.GetInstance().UpdateBeeCount();
    }
Пример #2
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (!col.CompareTag("Player"))
        {
            return;
        }

        GameObject bee = (GameObject)Instantiate(beePrefab, transform.position, Quaternion.identity);

        bee.transform.parent = beesParent;
        BeeCountUpdater.GetInstance().UpdateBeeCount();

        audioSource.Play();
        audioPlayer.transform.parent = null;
        Destroy(audioPlayer, audioSource.clip.length);
        Destroy(gameObject);
    }
Пример #3
0
 void Awake()
 {
     instance = this;
     beesParent = GameObject.Find("bees").transform;
     beeCountText = GetComponent<Text>();
 }
Пример #4
0
 void Awake()
 {
     instance     = this;
     beesParent   = GameObject.Find("bees").transform;
     beeCountText = GetComponent <Text>();
 }