Example #1
0
    private void Update()
    {
        GameObject      dPhase          = GameObject.Find("DifficultyPhase");
        DifficultyPhase difficultyPhase = dPhase.GetComponent <DifficultyPhase>(); //refference to Difficulty Phase script

        Move(difficultyPhase);
    }
Example #2
0
 private void CountCentipedeParts() //counts centipede objects using method from D Phase script
 {
     dPhase = FindObjectOfType <DifficultyPhase>();
     if (tag == "Centipede")
     {
         dPhase.CountCentipede();
     }
 }
Example #3
0
 private void Move(DifficultyPhase difficultyPhase)
 {
     transform.Translate(Vector2.right * difficultyPhase.cenMoveSpeed * Time.deltaTime); //takes value for speed from Difficulty Phase script and
     if (moveDirection == "right")                                                       //checks in which direction centipede goes and changes its rotation in case centipede will have sprite in future
     {
         transform.rotation = Quaternion.Euler(0, 0, 0);
     }
     else if (moveDirection == "left")
     {
         transform.rotation = Quaternion.Euler(0, 0, 180);
     }
 }
Example #4
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Projectile") //if collides with projectile, instantiates a mushroom and raises difficulty from D Phase. Also rounds the current position for mushroom to be grid-like
     {
         float   cPartPosX = Mathf.Round(transform.position.x) - 0.5f;
         float   cPartPosY = Mathf.Round(transform.position.y) - 0.5f;
         Vector2 cPartPos  = new Vector2(cPartPosX, cPartPosY);
         Instantiate(mushroomPrefab, cPartPos, Quaternion.identity);
         Destroy(gameObject);
         GameObject      dPhase          = GameObject.Find("DifficultyPhase");
         DifficultyPhase difficultyPhase = dPhase.GetComponent <DifficultyPhase>();
         difficultyPhase.KillCentipedePart();
     }
     if (collision.gameObject.tag == "Lose Trigger") //when reaches Lose Trigger on the bottom of the screen, loads end scene
     {
         FindObjectOfType <SceneLoader>().LoadEndScene();
     }
 }