// Start is called before the first frame update
 void Start()
 {
     tweener           = GetComponent <Tweener>();
     LevelGeneratorObj = GameObject.FindWithTag("levelGen").GetComponent <LevelGenerator>();
     spawnPoint        = gameObject.transform.position;
     gridPos.y         = gameObject.transform.position.x / 1.25f;
     gridPos.x         = Mathf.Abs(gameObject.transform.position.y / 1.25f);
     lastMove          = 0;
     delayAnim         = 0.35f;
     playerObj         = GameObject.FindGameObjectWithTag("Player");
     playerController  = playerObj.GetComponent <PacStudentController>();
 }
Exemple #2
0
    // Get GameObject Character
    private void SetCharacter()
    {
        pacStudent  = GameObject.FindWithTag("Player").GetComponent <PacStudentController>();
        redGhost    = GameObject.FindWithTag("RedGhost").GetComponent <GhostController>();
        blueGhost   = GameObject.FindWithTag("BlueGhost").GetComponent <GhostController>();
        yellowGhost = GameObject.FindWithTag("YellowGhost").GetComponent <GhostController>();
        pinkGhost   = GameObject.FindWithTag("PinkGhost").GetComponent <GhostController>();

        pacStudent.enabled  = true;
        redGhost.enabled    = true;
        blueGhost.enabled   = true;
        yellowGhost.enabled = true;
        pinkGhost.enabled   = true;

        backgroundMusic.ChangeBackgroundMusic(1);
    }
Exemple #3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            PacStudentController pacStudent = collision.GetComponent <PacStudentController>();

            if (isNormal)
            {
                StartCoroutine(pacStudent.DeadTrigger());
                gameManager.LoseLife();
            }
            else if (isScared || isRecovering)
            {
                if (!isDeath)
                {
                    UiManager.Instance.UpdateScore(300);
                    SetDeath();
                }
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        //Only run sounds after the start countdown is finished and when game isnt finished
        if (HUDManager.StartCounter <= -1.0f && !HUDManager.GameOver)
        {
            //Sound Effects
            if (timeCounter >= 0.5)
            {
                timeCounter = 0;
                checkForPickups();
            }
            timeCounter += Time.deltaTime;

            if (pacman.GetComponent <Animator>().GetFloat("pacAniSpeed") == 0 && !collisionPlayed && !PacStudentController.tweening())
            {
                audioManager.PlayOneShot(collide);
                collisionPlayed = true;
            }

            else if (pacman.GetComponent <Animator>().GetFloat("pacAniSpeed") == 1)
            {
                collisionPlayed = false;
            }


            //Background Music
            if (audioManager.clip == intro)
            {
                changeBackgroundMusic(backgroundNormal);
            }

            else if (audioManager.clip == backgroundNormal)
            {
                if (PacStudentController.CurrentState == PacStudentController.PacState.Powered)
                {
                    changeBackgroundMusic(backgroundScared);
                }
            }

            else if (audioManager.clip == backgroundScared)
            {
                if (PacStudentController.CurrentState == PacStudentController.PacState.Normal && !anyDeadGhosts())
                {
                    changeBackgroundMusic(backgroundNormal);
                }

                else if (anyDeadGhosts())
                {
                    changeBackgroundMusic(backgroundDead);
                }
            }
            else if (audioManager.clip == backgroundDead)
            {
                if (!anyDeadGhosts())
                {
                    if (PacStudentController.CurrentState == PacStudentController.PacState.Normal)
                    {
                        changeBackgroundMusic(backgroundNormal);
                    }

                    else if (PacStudentController.CurrentState == PacStudentController.PacState.Powered)
                    {
                        changeBackgroundMusic(backgroundScared);
                    }
                }
            }
        }
    }
 public void GetPacStudentController(PacStudentController script)
 {
     pacStudent = script;
 }