コード例 #1
0
        //when the mouse is clicked
        void OnMouseDown()
        {
            //checks if the game over is false and game is started
            if (!GameManager.instance.gameOver && GameManager.instance.gameStarted)
            {//disable the trigger box collider

                if (playerObj == null)
                {
                    music.PlayOneShot(sfx[0]);
                    MoveUp(0.2f * speedRatio);        //move the tile up  
                }
                else if (playerObj != null)
                {
                    cubeDetector.SetActive(true);
                    playerObj.transform.parent = transform;
                    playerObj.MoveUp(0.2f * speedRatio);
                    MoveUp(0.2f * speedRatio);        //move the tile up  

                    if (playerObj.colorInd == colorInd)
                    {
                        music.PlayOneShot(sfx[2]);
                        CombatTextManager.instance.CreateText(playerObj.gameObject.transform.position,
                            "SCORE!!", Color.green, false);
                    }
                    else
                    {
                        music.PlayOneShot(sfx[1]);
                        CombatTextManager.instance.CreateText(playerObj.gameObject.transform.position,
                            "BANG!!", Color.red, false);
                    }

                }

            }
        }