Ejemplo n.º 1
0
    public void OnTouchedBarrier(GameObject colliderObj)
    {
        _touchedBarrier = true;
        Barrier barrier = colliderObj.GetComponentInParent <Barrier>();

        if (barrier != null)
        {
            barrier.OnProjectileCollision();

            Vector3    posWithOffset = colliderObj.transform.position + new Vector3(-1.5f, -2f, 0);
            Vector2    pos           = WorldToCanvasPosition(_canvas, _canvasRect, Camera.main, posWithOffset);
            GameObject msg           = UIMessageSpawner.SpawnMessageOnPositionUsingPrefab(pos, _barrierMsgPrefab, _canvasRect);
            UIMessage  uiMsg         = msg.GetComponent <UIMessage>();
            uiMsg.SetupWithMessage(barrier.barrierMsg);
        }
    }
Ejemplo n.º 2
0
    public void WentThroughRing(GameObject ring)
    {
        //Don't take into account further touches after having touched a barrier
        if (_touchedBarrier)
        {
            return;
        }

        int    pointsAwarded  = 0;
        string powerUpMessage = "";

        if (ring.name.Contains("ring1"))
        {
            //Avoid double triggers
            if (_wentThroughRing1)
            {
                return;
            }
            _currentAttempt.caughtRing1 = true;
            pointsAwarded     = scoreFromRing1;
            powerUpMessage    = "81% Power-Up";
            _wentThroughRing1 = true;
            _currentScore    += pointsAwarded;
            GetUIManager().UpdateScore(_currentScore);
        }
        else if (ring.name.Contains("ring2"))
        {
            //Avoid double triggers
            if (_wentThroughRing2)
            {
                return;
            }
            _currentAttempt.caughtRing2 = true;
            pointsAwarded     = scoreFromRing2;
            powerUpMessage    = "POA Power-Up";
            _wentThroughRing2 = true;
            _currentScore    += pointsAwarded;
            GetUIManager().UpdateScore(_currentScore);
        }
        else if (ring.name.Contains("ring3"))
        {
            //Avoid double triggers
            if (_wentThroughRing3)
            {
                return;
            }
            _currentAttempt.caughtRing3 = true;
            pointsAwarded     = scoreFromRing3;
            powerUpMessage    = "Unity Power-Up";
            _wentThroughRing3 = true;
            _currentScore    += pointsAwarded;
            GetUIManager().UpdateScore(_currentScore);
        }

        //FIX ME The offset is not working!
        Vector3    posWithOffset = ring.transform.position + new Vector3(0, 0f, 0);
        Vector2    pos           = WorldToCanvasPosition(_canvas, _canvasRect, Camera.main, posWithOffset);
        GameObject msg           = UIMessageSpawner.SpawnMessageOnPositionUsingPrefab(pos, _ringMsgPrefab, _canvasRect);

        RingUIMessage ringMsg = msg.GetComponent <RingUIMessage>();

        ringMsg.SetupWithMessageAndAdvantage("x " + pointsAwarded.ToString(), powerUpMessage);

        //TODO update score label
    }