Ejemplo n.º 1
0
 //it detect the player
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player"))
     {   //assign the playerObj value
         playerObj = other.GetComponent<CubeController>();
     }
 }
Ejemplo n.º 2
0
 //it detect the player
 void OnTriggerExit2D(Collider2D other)
 {
     if (other.CompareTag("Player"))
     {//remove the playerObj value
         playerObj = null;
     }
 }
Ejemplo n.º 3
0
        // Update is called once per frame
        void Update()
        {
            //checks is player is not active and game over is false
            if (!cube.gameObject.activeInHierarchy && !GameManager.instance.gameOver)
            {
                cube = GameObject.FindGameObjectWithTag("Player").GetComponent<CubeController>();
            }

                if (cube.direction == Vector3.right)
            {
                direction = Vector3.left;
            }
            else
            {
                direction = Vector3.right;
            }
            //if game is not over and game is started
            if (!GameManager.instance.gameOver && GameManager.instance.gameStarted)
                transform.Translate(direction * speed * Time.deltaTime);//move

        }
Ejemplo n.º 4
0
        void OnTriggerEnter2D(Collider2D other)
        {//check if the triggering object is player
            if (other.CompareTag("Player"))
            {//get the ref to the object
                CubeController cube = other.GetComponent<CubeController>();
                //check the color ind of player and parent tile
                if (parentTile.colorInd == cube.colorInd)
                {//if same

                    //here we increase score , change cube color , move all tiles to equal level
                    GameManager.instance.currentScore += (GameManager.instance.level);
                    ChangeCubePlayerColor();
                    //make all the objects with lerpcolor script blink
                    for (int i = 0; i < lerpColorObjectList.Length; i++)
                    {
                        lerpColorObjectList[i].blink = true;
                    }
                    //move all the other tiles up
                    for (int i = 0; i < tileList.Length; i++)
                    {
                        if (tileList[i].name != parentName)
                        {
                            if (tileList[i].transform.position.y < parentTile.transform.position.y)
                            {
                                tileList[i].MoveUp(0.3f * speedRatio);
                            }
                        }
                    }
                }
                else //if not same then game is over
                {
                    //game over
                    GameManager.instance.gameOver = true;
                    GameManager.instance.gameStarted = false;
                }
            }

            gameObject.SetActive(false);
        }
Ejemplo n.º 5
0
        private bool hitLeft = false; //this is just to make hitbywall increase by one
        #endregion

        void Awake()
        {
            if (instance == null)
                instance = this;
        }
Ejemplo n.º 6
0
 // Use this for initialization
 void Start()
 {//ref to the playe in the scene
     cube = GameObject.FindGameObjectWithTag("Player").GetComponent<CubeController>();
 }
Ejemplo n.º 7
0
 // Use this for initialization
 void Start()
 {//get ref to the player
     cubePlayer = GameObject.FindGameObjectWithTag("Player").GetComponent<CubeController>();
 }