コード例 #1
0
ファイル: Copy.cs プロジェクト: Canados1985/Bubbles-Numbers
    //////////////////////////////////////////////////////////////////////////////////////////////////////////


    void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.name == "player" && this.gameObject.activeSelf ||
            collision.gameObject.name == "player_idle" && this.gameObject.activeSelf
            )
        {
            Player tempPlayer = collision.GetComponent <Player>();
            FindObjectOfType <AudioManager>().Play("copy");

            //Here we call function
            foreach (var item in bubbleCopies)
            {
                PlayerCopy tempPlayerCopy = item.GetComponent <PlayerCopy>();
                tempPlayerCopy.gameObject.SetActive(true);
                tempPlayerCopy.transform.position   = tempPlayer.transform.position;
                tempPlayerCopy.playerCopyBubbleSize = tempPlayer.playerBubbleSize;
                tempPlayerCopy.ScaleControll(tempPlayerCopy.playerCopyBubbleSize);
                tempPlayerCopy.lifeTime = 10;
                tempPlayerCopy.timer    = 3;
                tempPlayerCopy.ApplySpeedRB(gameManagerRef.helperRef.TakeRandomPosition());
            }

            this.gameObject.SetActive(false);
            lifeTime = 0;
            gameObject.transform.position = lootContainer.transform.position;
            gameManagerRef.loot.Remove(this.gameObject);
            Destroy(this.gameObject);
        }
    }
コード例 #2
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //------------------------------- RECIVING POSITION OF ALL PLAYERS AND CREATING THEM-------------------------------//
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public void GetPlayersPosition()
    {
        ReciveFromServer();
        if (recivedClientMethod == 2)
        {
            //first bite from server is a number of the players
            int numberOfPlayers = recivedClientMethodData[0];

            short playerPositionX;
            short playerPositionY;
            short playerPositionZ;

            PlayerCopy[] playerCopy = new PlayerCopy[numberOfPlayers];

            // Comming data: NumberOfPlayers + ID + X+Y+Z + ID + X+Y+Z + ID+X+Y+Z but X, Y, Z have 2 bites so distance is 7 bites that is why:
            for (int i = 0; i < numberOfPlayers; i++)
            {
                ToShort(out playerPositionX, recivedClientMethodData[2 + (7 * i)], recivedClientMethodData[3 + (7 * i)]);
                ToShort(out playerPositionY, recivedClientMethodData[4 + (7 * i)], recivedClientMethodData[5 + (7 * i)]);
                ToShort(out playerPositionZ, recivedClientMethodData[6 + (7 * i)], recivedClientMethodData[7 + (7 * i)]);
                // Creating instantiate of players
                playerCopy[i].player             = Instantiate(player);
                playerCopy[i].ID                 = recivedClientMethodData[1 + (7 * i)];
                playerCopy[i].transform.position = new Vector3(playerPositionX, playerPositionY, playerPositionZ);
            }
        }
    }
コード例 #3
0
ファイル: Copy.cs プロジェクト: Canados1985/Bubbles-Numbers
 void DestroyObject()
 {
     for (int i = 0; i < bubbleCopies.Count; i++)
     {
         PlayerCopy tempCopy = bubbleCopies[i].GetComponent <PlayerCopy>();
         tempCopy.DestroyPlayerCopy();
     }
     Destroy(this.gameObject);
 }
コード例 #4
0
    ///////////////////////////////////////////////

    void OnCollisionEnter2D(Collision2D collision2D)
    {
        if (collision2D.gameObject.transform.name == "PlayerCopy_Effect_0" || collision2D.gameObject.transform.name == "PlayerCopy_Effect_1" || collision2D.gameObject.transform.name == "PlayerCopy_Effect_2")
        {
            PlayerCopy tempPlayerCopy = collision2D.gameObject.GetComponent <PlayerCopy>();

            int storeColliderCopyPlayerBubbleSize = tempPlayerCopy.playerCopyBubbleSize;

            this.playerCopyBubbleSize += storeColliderCopyPlayerBubbleSize;

            impact_UP.mute = false;
            impact_UP.Play();
            this.
            go_playerCopy_BubbleSize.SetActive(false);
            timeNotActive = 0;
            GetScore(storeColliderCopyPlayerBubbleSize, Color.green, " ", " +", name + "_ChangeArgument", this.transform.position, true);
            ScaleControll(playerCopyBubbleSize);
        }

        if (collision2D.gameObject.transform.name == "EdgeSpriteCollider")
        {
            EdgeBoard temp = collision2D.gameObject.transform.parent.GetComponent <EdgeBoard>();

            if (temp.negativePositiveChance < 2 && !temp.panelIsPortal && !temp.panelIsZero)
            {
                //Debug.Log("COLLISION WITH POSITIVE EDGE");

                impact_UP.mute = false;
                impact_UP.Play();
                tempNumber            = temp.edgeArgument;
                playerCopyBubbleSize += tempNumber;
                go_playerCopy_BubbleSize.SetActive(false);
                timeNotActive = 0;
                GetScore(tempNumber, Color.green, " ", " +", name + "_ChangeArgument", this.transform.position, true);
                ScaleControll(playerCopyBubbleSize);
            }
            if (temp.negativePositiveChance >= 2 && !temp.panelIsPortal && !temp.panelIsZero)
            {
                //Debug.Log("COLLISION WITH NEGATIVE EDGE")

                tempNumber            = temp.edgeArgument;
                playerCopyBubbleSize -= tempNumber;

                if (playerCopyBubbleSize <= 0)
                {
                    timer = 0;
                    this.gameObject.SetActive(false);
                    GetPlayerCopyBubbleEnd();
                    Invoke("DestroyPlayerCopy", 0.05f);
                }
                else
                {
                    impact_DOWN.mute = false;
                    impact_DOWN.Play();
                    this.go_playerCopy_BubbleSize.SetActive(false);
                    this.timeNotActive = 0;
                    GetScore(tempNumber, Color.red, " ", " -", name + "_ChangeArgument", this.transform.position, true);
                }

                ScaleControll(playerCopyBubbleSize);
            }
            if (temp.panelIsPortal && !temp.panelIsZero)
            {
                CopyPlayerTeleportOnImpactPortal(temp);
            }
            if (temp.panelIsZero && !temp.panelIsPortal)
            {
                timer = 0;
                this.gameObject.SetActive(false);
                GetPlayerCopyBubbleEnd();
                Invoke("DestroyPlayerCopy", 0.05f);
            }
        }
    }
コード例 #5
0
ファイル: Bubble.cs プロジェクト: Canados1985/Bubbles-Numbers
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    void OnCollisionEnter2D(Collision2D collision)
    {
        //////// HERE IS COLLISION WITH PLAYER IF IT"S ACTIVE  /////////
        if (playerRef != null && this.gameObject.activeSelf == true)
        {
            if (collision.gameObject.name == "player" && gameManagerRef.gameIsStarts || collision.gameObject.name == "player_idle" && gameManagerRef.gameIsStarts)
            {
                int tempPlayerSize = playerRef.playerBubbleSize; // store temp Player's bubble size
                int tempThisSize   = bubbleSize;                 // store temp Enemy bubble size
                bubbleSize              -= tempPlayerSize;       // here calculating enemy's bubble size
                storeBubbleSize          = bubbleSize;
                storeBubbleSizeExplosion = bubbleSize;
                if (playerRef.frozenDurability > 0)
                {
                    bubbleSize -= bubbleSize; FindObjectOfType <AudioManager>().Play("impact_W_ICE");
                }                                                                                                                      //If Player has frozen bubble

                //if player has NO ANY shield
                if (playerRef.shieldDurability <= 0 && playerRef.frozenDurability <= 0)
                {
                    playerRef.playerBubbleSize -= tempThisSize;    // here calculating player's bubble argument after collision
                    if (playerRef.playerBubbleSize <= 0)
                    {
                        playerRef.GetScore(1, Color.red, " Bubble", " -", "playerGetsScore", playerRef.transform.position, false);
                    }
                    if (playerRef.playerBubbleSize > 0)
                    {
                        //Debug.Log("PLAYER SHOULD SEE MINUS");
                        playerRef.go_player_BubbleSize.SetActive(false);
                        playerRef.timeNotActive = 0;
                        playerRef.GetScore(tempThisSize, Color.red, " ", " -", "PlayerChangeArgument", playerRef.transform.position, true);
                        playerRef.ScaleControll(playerRef.playerBubbleSize); // set new scale for player
                        ScaleControll(playerRef.playerBubbleSize);           // Set new scale for player bubble
                    }
                }

                /// CHECKING THIS BUBBLE STATUS AFTER COLLISION WITH PLAYER
                if (bubbleSize <= 0)
                {
                    GetScore(tempThisSize, bubbleSizeOnText.color, " pts", " +", this.transform.position, false, "playerGetsScore", false);
                    playerRef.playerScore             += tempThisSize;
                    playerRef.playerKills             += 1;
                    gameManagerRef.progressBar.f_fill -= (float)tempThisSize / 1000;
                    GetBubbleEnd();
                    Invoke("DestroyBubble", 0.005f);
                }
                else
                {
                    FindObjectOfType <AudioManager>().Play("impact_DOWN");
                    //GetScore(tempPlayerSize, Color.red," ", " -", this.transform.position, true, "changeArgument", true);
                    GetScore(tempPlayerSize, Color.red, " ", " -", this.transform.position, true, "BubbleChangeArgument_" + NUMBER_in_the_list.ToString(), false);
                    gameManagerRef.progressBar.f_fill -= (float)tempPlayerSize / 1000;
                    this.bubbleScoreRenderer.enabled   = false;
                    this.timeNotActive = 0;

                    ScaleControll(bubbleSize);
                }

                if (playerRef.shieldDurability > 0)
                {
                    playerRef.shieldDurability -= 1; // decrease durability for player's shield ability
                    //playerRef.GetScore(1, Color.red, " Shield", " -", "playerGetsScore", playerRef.transform.position, false);
                }
                if (playerRef.frozenDurability > 0)
                {
                    playerRef.frozenDurability -= 1; // decrease durability for player's shield ability
                    //playerRef.GetScore(1, Color.red, " Freeze", " -", "playerGetsScore", playerRef.transform.position, false);
                }
            }
        }


        //Checking collison with others bubbles
        if ((collision.gameObject.name == "blue" || collision.gameObject.name == "green" || collision.gameObject.name == "pink" || collision.gameObject.name == "red" ||
             collision.gameObject.name == "purple" || collision.gameObject.name == "white" || collision.gameObject.name == "yellow") &&
            !gameManagerRef.playerTurn && gameManagerRef.gameIsStarts

            || (collision.gameObject.name == "blue" || collision.gameObject.name == "green" || collision.gameObject.name == "pink" || collision.gameObject.name == "red" ||
                collision.gameObject.name == "purple" || collision.gameObject.name == "white" || collision.gameObject.name == "yellow") &&
            playerRef.gameObject.activeSelf == false && playerRef != null && !gameManagerRef.playerTurn && gameManagerRef.gameIsStarts

            || (collision.gameObject.name == "blue_idle" || collision.gameObject.name == "green_idle" || collision.gameObject.name == "pink_idle" || collision.gameObject.name == "red_idle" ||
                collision.gameObject.name == "purple_idle" || collision.gameObject.name == "white_idle" || collision.gameObject.name == "yellow_idle") &&
            !gameManagerRef.playerTurn && gameManagerRef.gameIsStarts

            || (collision.gameObject.name == "blue_idle" || collision.gameObject.name == "green_idle" || collision.gameObject.name == "pink_idle" || collision.gameObject.name == "red_idle" ||
                collision.gameObject.name == "purple_idle" || collision.gameObject.name == "white_idle" || collision.gameObject.name == "yellow_idle") &&
            playerRef.gameObject.activeSelf == false && playerRef != null && !gameManagerRef.playerTurn && gameManagerRef.gameIsStarts
            )
        {
            Bubble collisionBubble = collision.gameObject.GetComponent <Bubble>();
            this.bubbleScoreRenderer.enabled = false;
            this.timeNotActive = 0;
            gameManagerRef.helperRef.ControllOverBubbleCollideEachOther(collisionBubble, this);
        }


        if (collision.gameObject.name == "PlayerCopy_Effect_0" || collision.gameObject.name == "PlayerCopy_Effect_1" || collision.gameObject.name == "PlayerCopy_Effect_2")
        {
            PlayerCopy tempPlayerCopy = collision.gameObject.GetComponent <PlayerCopy>();

            int tempCopyPlayerSize = tempPlayerCopy.playerCopyBubbleSize;   // store temp player's Copy bubble size
            int tempThisSize       = bubbleSize;                            // store temp Enemy bubble size
            bubbleSize -= tempCopyPlayerSize;                               // here calculating enemy's bubble size
            tempPlayerCopy.playerCopyBubbleSize -= Mathf.Abs(tempThisSize); // here calculating player's bubble argument after collision

            if (bubbleSize <= 0)
            {
                bubbleSize = 0;
                GetScore(tempThisSize, bubbleSizeOnText.color, " pts", " +", this.transform.position, false, "playerGetsScore", false);
                tempPlayerCopy.GetScore(Mathf.Abs(tempThisSize), Color.red, " ", " -", "BubbleChangeArgument_" + NUMBER_in_the_list.ToString(), tempPlayerCopy.transform.position, true);
                playerRef.playerScore             += tempThisSize;
                playerRef.playerKills             += 1;
                gameManagerRef.progressBar.f_fill -= (float)tempThisSize / 1000;
                GetBubbleEnd();
                Invoke("DestroyBubble", 0.005f);
            }
            else
            {
                FindObjectOfType <AudioManager>().Play("impact_DOWN");
                GetScore(Mathf.Abs(tempCopyPlayerSize), Color.red, " ", " -", this.transform.position, true, "BubbleChangeArgument_" + NUMBER_in_the_list.ToString(), false);
                gameManagerRef.progressBar.f_fill -= (float)tempCopyPlayerSize / 1000;
                this.bubbleScoreRenderer.enabled   = false;
                this.timeNotActive       = 0;
                storeBubbleSize          = bubbleSize;
                storeBubbleSizeExplosion = bubbleSize;
                ScaleControll(bubbleSize);
            }
            if (tempPlayerCopy.playerCopyBubbleSize > 0)
            {
                tempPlayerCopy.go_playerCopy_BubbleSize.SetActive(false);
                tempPlayerCopy.timeNotActive = 0;
                tempPlayerCopy.GetScore(Mathf.Abs(tempThisSize), Color.red, " ", " -", tempPlayerCopy.name + "_ChangeArgument", tempPlayerCopy.transform.position, true);
                tempPlayerCopy.ScaleControll(tempPlayerCopy.playerCopyBubbleSize); // set new scale for player
            }
        }


        //Checking collision with platfomrs
        if (collision.gameObject.transform.name == "EdgeSpriteCollider" && bubbleIsMoving && playerRef.gameObject.activeSelf == true && playerRef != null && gameManagerRef.gameIsStarts ||
            collision.gameObject.transform.name == "EdgeSpriteCollider" && bubbleIsMoving && playerRef.gameObject.activeSelf == false && playerRef != null && gameManagerRef.gameIsStarts)
        {
            EdgeBoard temp           = collision.gameObject.transform.parent.GetComponent <EdgeBoard>();
            int       tempBubbleSize = bubbleSize; // here we store bubble size by using new variable
            storeBubbleSize          = bubbleSize;
            storeBubbleSizeExplosion = bubbleSize;
            if (temp.negativePositiveChance < 2 && !temp.panelIsPortal && !temp.panelIsZero)
            {
                FindObjectOfType <AudioManager>().Play("impact_UP");
                gameManagerRef.progressBar.f_fill += (float)temp.edgeArgument / 1000;
                //Here we need calculate number argument, make it bugger
                tempEdgeArgument                 = temp.edgeArgument;
                bubbleSize                      += tempEdgeArgument;
                storeBubbleSize                  = bubbleSize;
                storeBubbleSizeExplosion         = bubbleSize;
                this.bubbleScoreRenderer.enabled = false;
                this.timeNotActive               = 0;
                GetScore(tempEdgeArgument, Color.green, " ", " +", collision.transform.position, true, "BubbleChangeArgument_" + NUMBER_in_the_list.ToString(), false);
                ScaleControll(bubbleSize); // Set new scale for this bubble
                //Debug.Log("COLLISION WITH POSITIVE EDGE " + tempEdgeArgument);
                GetImpactEffect(true, this.transform.position, temp.gameObject.name);
            }
            if (temp.negativePositiveChance >= 2 && !temp.panelIsPortal && !temp.panelIsZero)
            {
                //Here we need calculate number, make it smaller

                tempEdgeArgument = temp.edgeArgument;
                bubbleSize      -= tempEdgeArgument;


                if (bubbleSize <= 0)
                {
                    bubbleSize = 0;
                    GetScore(storeBubbleSize, bubbleSizeOnText.color, " pts", " +", this.transform.position, false, "playerGetsScore", false);
                    playerRef.playerScore             += storeBubbleSize;
                    playerRef.playerKills             += 1;
                    gameManagerRef.progressBar.f_fill -= (float)storeBubbleSize / 1000;
                    GetBubbleEnd();
                    Invoke("DestroyBubble", 0.005f);
                }
                else
                {
                    FindObjectOfType <AudioManager>().Play("impact_DOWN");
                    GetScore(tempEdgeArgument, Color.red, " ", " -", collision.transform.position, true, "BubbleChangeArgument_" + NUMBER_in_the_list.ToString(), false);
                    this.bubbleScoreRenderer.enabled = false;
                    this.timeNotActive                 = 0;
                    storeBubbleSize                    = bubbleSize;
                    storeBubbleSizeExplosion           = bubbleSize;
                    gameManagerRef.progressBar.f_fill -= (float)tempEdgeArgument / 1000;
                    ScaleControll(bubbleSize); // Set new scale for this bubble
                }
                GetImpactEffect(false, this.transform.position, temp.gameObject.name);
            }
            if (temp.panelIsPortal && rb_bubble.velocity.magnitude > 0.25f)
            {
                FindObjectOfType <AudioManager>().Play("portal");
                BubbleTeleportOnImpactPortal(temp);
            }
            if (temp.panelIsZero)
            {
                bubbleSize = 0;
                GetScore(storeBubbleSize, bubbleSizeOnText.color, " pts", " +", this.transform.position, false, "playerGetsScore", false);
                playerRef.playerScore             += storeBubbleSize;
                playerRef.playerKills             += 1;
                gameManagerRef.progressBar.f_fill -= (float)storeBubbleSize / 1000;
                GetBubbleEnd();
                Invoke("DestroyBubble", 0.005f);
            }
        }
    }