void OnTriggerEnter2D(Collider2D col)
    {
        if (isActivated)
        {
            return;
        }

        if (col.gameObject.CompareTag("Chip"))
        {
            isActivated = true;
            _Manager.audioFinish.Play();
            Invoke("ResetIsActivated", 0.1f);
            // Tell chip to despawn
            col.gameObject.SendMessage("FinishedDespawn", SendMessageOptions.DontRequireReceiver);
            // Reduce _Manager.currentChipsNeededCount count by 1
            _Manager.currentChipsNeededCount -= 1;
            if (_Manager.currentChipsNeededCount == 0)
            {
                Messenger.Invoke("levelComplete");                                              // tell the world the level is complete
            }
            else
            {
                textEffect.TextToShow = "need " + _Manager.currentChipsNeededCount + " more";
                textEffect.RemoveText(true);
            }
        }
    }
Esempio n. 2
0
    void Update()
    {
        if (isActivated)
        {
            return;
        }
        if (Input.GetMouseButtonDown(0))
        {
            Ray          ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit2D hit = Physics2D.GetRayIntersection(ray, Mathf.Infinity);

            if (hit.collider != null && hit.collider.transform == transform)
            {
                isActivated = true;
                if (music.mute)
                {
                    music.mute = false;
                    _Manager.UnMute();
                    textEffect.RemoveText();
                    textEffect.ShowTextDelayed("mute", 1f);
                }
                else
                {
                    music.mute = true;
                    _Manager.Mute();
                    textEffect.RemoveText();
                    textEffect.ShowTextDelayed("unmute", 1f);
                }
                Invoke("ResetIsActivated", 0.5f);
            }
        }
    }
Esempio n. 3
0
    void OnChipSpawned()
    {
        // This method is called by the Chip_Spawner when they spawn a chip
        // Reduce our spawn count by 1.
        if (_Manager.currentSpawnChipCount != 0)
        {
            _Manager.currentSpawnChipCount -= 1;
        }
        // figure out which child we need to move in next.
        int spawnerToMove = childrenArray.Length - _Manager.currentSpawnChipCount;

        // move em in (making sure the spawnerToMove is within the childrenArray size)
        if (spawnerToMove < childrenArray.Length)
        {
            MoveChipSpawnerToScreen(spawnerToMove);
        }
        if (_Manager.currentSpawnChipCount >= 1)
        {
            // update spawn count text
            textEffect.TextToShow = "x" + (_Manager.currentSpawnChipCount - 1);
            textEffect.RemoveText(true);
        }
    }
Esempio n. 4
0
 void OnReset()
 {
     textEffect.RemoveText(true);
 }