private void checkForPlayerBubbleAndBacteriaCollision()
    {
        // check if any of the bubbles have collided with any of the bacteria
        // TODO: Make this algorithm more efficient
        for (int b = bubbles_.Count - 1; b >= 0; b--)
        {
            PlayerBubble bubble = bubbles_[b];

            Rect bubbleRect = bubble.localRect.CloneAndScaleThenOffset(.2f, .2f, bubble.x, bubble.y);             //bubble.scale, bubble.scale, bubble.x, bubble.y);
            for (int j = bacterias_.Count - 1; j >= 0; j--)
            {
                BacteriaBubble bacteria = bacterias_[j];

                Rect bacteriaRect = bacteria.localRect.CloneAndScaleThenOffset(Math.Abs(bacteria.scaleX), bacteria.scaleY, bacteria.x, bacteria.y);

                if (bubbleRect.CheckIntersect(bacteriaRect))
                {
                    HandleGotBacteria(bacteria);
                    bubbles_.Remove(bubble);
                    bubbleContainer_.RemoveChild(bubble);
                    break;
                }
            }
        }
    }
Example #2
0
    void Launch()
    {
        GameObject Bubble1 = Instantiate(bubble, (proPlaceL.transform.position) + Vector3.up * 0.5f, Quaternion.identity);
        GameObject Bubble2 = Instantiate(bubble, (proPlaceR.transform.position) + Vector3.up * 0.5f, Quaternion.identity);

        PlayerBubble bub1 = Bubble1.GetComponent <PlayerBubble>();

        bub1.Launch(transform.up, 300);

        PlayerBubble bub2 = Bubble2.GetComponent <PlayerBubble>();

        bub2.Launch(transform.up, 300);
    }
    public void CreateBubble(Vector2 direction)
    {
        if (bubbles_.Count >= 3)
        {
            return;
        }
        PlayerBubble bubble = new PlayerBubble(direction);

        bubbleContainer_.AddChild(bubble);
        bubble.x = player_.x;
        bubble.y = player_.y;
        bubble.play("idle");
        bubbles_.Add(bubble);
    }
Example #4
0
 // Use this for initialization
 void Start()
 {
     rb   = this.GetComponentInParent <Rigidbody>();
     cam  = Camera.main.gameObject;
     anim = this.GetComponent <Animator>();
     gm   = GameObject.Find("GameManager").GetComponent <GameManager>();
     gm.EventMan.movePlayerToPosition.AddListener(StartMoveToPosition);
     bubble = this.GetComponentInChildren <PlayerBubble>();
     if (bubble != null)
     {
         bubble.Deactivate();
     }
     previousPos = this.transform.position;
     skinnedMesh = this.GetComponentInChildren <SkinnedMeshRenderer>();
 }
    private void checkForPlayerBubbleOffScreen()
    {
        for (int b = bubbles_.Count - 1; b >= 0; b--)
        {
            PlayerBubble bubble = bubbles_[b];

            // remove a bubble if it falls off screen
            if (bubble.y < -Futile.screen.halfHeight - 50 ||
                bubble.y > Futile.screen.halfHeight + 50)
            {
                if (bubble.x < -Futile.screen.halfWidth - 50 ||
                    bubble.x > Futile.screen.halfWidth + 50)
                {
                    bubbles_.Remove(bubble);
                    bubbleContainer_.RemoveChild(bubble);
                }
            }
        }
    }
    void checkForPlayerBubbleAndEnemyCollision()
    {
        for (int b = bubbles_.Count - 1; b >= 0; b--)
        {
            PlayerBubble bubble     = bubbles_[b];
            Rect         bubbleRect = bubble.localRect.CloneAndScaleThenOffset(.2f, .2f, bubble.x, bubble.y);     //bubble.scale, bubble.scale, bubble.x, bubble.y);

            Rect enemyRect = enemy_.localRect.CloneAndScaleThenOffset(.25f, enemy_.scaleY, enemy_.x, enemy_.y);   //Mathf.Abs(enemy_.scaleX)*.25f, enemy_.scaleY, enemy_.x, enemy_.y);
            if (bubbleRect.CheckIntersect(enemyRect))
            {
                // if the enemy is currently being hit or its blocking then don't bother taking away more health
                if (enemy_.curr_behavior_ != EnemyCharacter.BehaviorType.BLOCK && enemy_.curr_behavior_ != EnemyCharacter.BehaviorType.HIT)
                {
                    HandleEnemyHit(0);
                }

                bubbles_.Remove(bubble);
                bubbleContainer_.RemoveChild(bubble);
            }
        }
    }
Example #7
0
 public void CreateBubble(Vector2 direction)
 {
     if(bubbles_.Count >= 3)
         return;
     PlayerBubble bubble = new PlayerBubble(direction);
     bubbleContainer_.AddChild(bubble);
     bubble.x = player_.x;
     bubble.y = player_.y;
     bubble.play("idle");
     bubbles_.Add(bubble);
 }