Exemple #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        Bubble _otherBubble = other.gameObject.GetComponent <Bubble>();

        if (other.gameObject.CompareTag("Player"))
        {
            ActivateBubble();
        }
        else if (other.gameObject.CompareTag("Bubble") && _otherBubble.CanBePicked)
        {
            DesactivateBubble();

            _otherBubble.ActivateBubble();
        }
    }
    IEnumerator SeekoutSeparatedBubbles(Action onSeparatedIslandsFound)
    {
        GridBubble mainlandOrigin = null;

        mainlandOrigin = gridSpawner.ToplineBubbles.Find(b => b.IsActive == true);

        if (mainlandOrigin == null)
        {
            onSeparatedIslandsFound.Invoke();
            yield break;
        }

        IEnumerable <GridBubble> separatedBubbles = FindSeparatedBubbles(mainlandOrigin);

        float gridY = gridSpawner.transform.position.y;

        Sequence mySequence = DOTween.Sequence();

        for (int i = 0; i < separatedBubbles.Count(); i++)
        {
            Bubble  bubble           = separatedBubbles.ElementAt(i).Bubble;
            Vector3 originalPosition = bubble.transform.localPosition;

            mySequence.Insert(0f, bubble.transform
                              .DOLocalMoveY(
                                  bubble.transform.localPosition.y - gridY,
                                  0.5f)
                              .SetEase(Ease.OutBounce)
                              .OnComplete(() =>
            {
                bubble.ActivateBubble(false);
                bubble.transform.localPosition = originalPosition;
            }));

            mySequence.Insert(0f, bubble.transform
                              .DOScale(
                                  0.2f,
                                  0.5f)
                              .SetEase(Ease.OutBounce))
            .OnComplete(() =>
            {
                bubble.transform.localScale = Vector3.one;
            });
        }

        mySequence.AppendCallback(() => onSeparatedIslandsFound.Invoke());
    }
Exemple #3
0
    public GridBubble PutPlayerBubbleInAGrid(Bubble playerBubble)
    {
        Vector3 bubblePos = playerBubble.GetBubblePosition();

        for (int i = 0; i < BubbleGrid.Length; i++)
        {
            if (BubbleGrid[i].IsActive == false)
            {
                Vector3 otherBubblePos = BubbleGrid[i].Bubble.GetBubblePosition();

                if ((otherBubblePos - bubblePos).magnitude < 0.02)
                {
                    BubbleGrid[i].Bubble.UpdateBubbleValue(playerBubble.Value);
                    BubbleGrid[i].ActivateBubble(true);
                    playerBubble.ActivateBubble(false);
                    return(BubbleGrid[i]);
                }
            }
        }

        Debug.LogError("Failed to find a slot for player bubble");

        return(null);
    }
    void GameOverSequence()
    {
        Sequence mySequence = DOTween.Sequence();

        float gridY = gridSpawner.transform.position.y;

        for (int i = 0; i < gridSpawner.BubbleGrid.Length; i++)
        {
            Bubble  bubble           = gridSpawner.BubbleGrid[i].Bubble;
            Vector3 originalPosition = bubble.transform.localPosition;

            mySequence.Insert(0f, bubble.transform
                              .DOLocalMoveY(
                                  bubble.transform.localPosition.y - gridY,
                                  0.5f)
                              .SetEase(Ease.OutBounce)
                              .OnComplete(() =>
            {
                bubble.ActivateBubble(false);
                bubble.transform.localPosition = originalPosition;
            }));

            mySequence.Insert(0f, bubble.transform
                              .DOScale(
                                  0.2f,
                                  0.5f)
                              .SetEase(Ease.OutBounce))
            .OnComplete(() =>
            {
                bubble.transform.localScale = Vector3.one;
            });
        }

        mySequence.AppendCallback(() => playLoop.GridSpawner.ClearGrid());
        mySequence.SetAutoKill(true);
    }
Exemple #5
0
 public void ActivateBubble(bool activate)
 {
     bubble.ActivateBubble(activate);
 }
Exemple #6
0
 public void CreatePlayerBubble()
 {
     bubble.transform.position = transform.position; // todo change for the secondary shoot bubble
     bubble.RandomizeBubbleValue();
     bubble.ActivateBubble(true);
 }