public override void ObstacleEvent(GameObject playerObject)
 {
     GameObject.FindGameObjectWithTag("GameController").GetComponent <TimeManager>().AdjustTime(p_timeToAdd);
     FloatTextController.CreateFloatingText(p_timeToAdd.ToString() + "s", transform, true);
     base.ObstacleEvent(playerObject);
     soundManager = GameObject.FindWithTag("SoundManager").GetComponent <SoundScript>();
     soundManager.PlayAudio(ClockSound);
 }
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Bullet" && !canBeCollided)
        {
            FloatTextController.CreateFloatingText("-5s", transform, false);

            string color       = other.GetComponent <BulletScript>().p_color;
            Color  color_color = GameObject.FindGameObjectWithTag("GameController").GetComponent <ColorManager>().GetColor(color);
            particleScript.SpawnParticleSystem(particleSystem, transform.position, color_color);

            soundManager.PlayAudio(evilLaughter);
            Destroy(other.gameObject);
            Destroy(this.gameObject);
        }
        else if (other.tag == "Player" && canBeCollided)
        {
            FloatTextController.CreateFloatingText("5p", transform, true);
            Destroy(this.gameObject);
        }
    }
Example #3
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Bullet")
        {
            string color       = other.GetComponent <BulletScript>().p_color;
            Color  color_color = GameObject.FindGameObjectWithTag("GameController").GetComponent <ColorManager>().GetColor(color);
            if (color == "Rainbow")
            {
                color_color = Color.black;
            }
            particleScript.SpawnParticleSystem(particleSystem, transform.position, color_color);

            if (other.gameObject.GetComponent <BulletScript>().p_color == m_demandedColor ||
                other.gameObject.GetComponent <BulletScript>().p_color == "Rainbow")
            {
                soundManager.PlayAudio(satisfiedBleat);
                FloatTextController.CreateFloatingText("10p", transform, true);
                FloatTextController.CreateFloatingText("2s", transform, true);

                m_animator.speed = 1.0f;
                m_animator.SetBool("isSatisfied", true);
                m_collider.enabled = false;

                foreach (Transform child in transform)
                {
                    Destroy(child.gameObject);
                }
                Destroy(other.gameObject);
                Destroy(gameObject, 0.7f);
            }
            else
            {
                Destroy(other.gameObject);
            }
        }
        else if (other.tag == "Player" && canBeCollided)
        {
            Destroy(this.gameObject);
        }
    }
Example #4
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Bullet")
        {
            //Spawn Particle
            string bullet_color = other.gameObject.GetComponent <BulletScript>().p_color;
            Color  color_color  = gameManagerScript.gameObject.GetComponent <ColorManager>().GetColor(bullet_color);
            particleScript.SpawnParticleSystem(iceCreamParticles, transform.position, color_color);


            if (other.gameObject.GetComponent <BulletScript>().p_color != "Rainbow")
            {
                gameManagerScript.gameObject.GetComponent <TimeManager>().AdjustTime(-p_decreaseTime);
                FloatTextController.CreateFloatingText("-" + p_decreaseTime.ToString() + "s", transform, false);

                //Cool smoke bomb animation
                soundManager.PlayAudio(evilLaughter);
            }
            Destroy(other.gameObject);
            Destroy(this.gameObject);
        }
        else if (other.tag == "Player")
        {
            //They can die
            gameManagerScript.AddScore(p_increasePoints);

            int multiplier = 1;
            if (gameManagerScript.m_multiplier >= 2)
            {
                multiplier = (int)gameManagerScript.m_multiplier;
            }

            FloatTextController.CreateFloatingText((multiplier * p_increasePoints).ToString() + "p", transform, true);
            ss.ShakeScreen();
            Destroy(this.gameObject);
            soundManager = GameObject.FindWithTag("SoundManager").GetComponent <SoundScript>();
            soundManager.PlayAudio(HitByTruck);
        }
        else if (other.gameObject.tag == "Customer")
        {
            if (other.gameObject.transform.position.x < transform.position.x) // This sheep is taking over
            {
                p_speed = 0.5f;
            }
            else
            {
                if (p_speed < 1f)
                {
                    p_speed = 1f;
                }
            }
        }
        else if (other.gameObject.tag == "Obstacle")
        {
            if (other.transform.position.y > 2) // Top lane
            {
                StartCoroutine(MoveLane(false));
            }
            else if (other.transform.position.y > 0) // Middle lane
            {
                int i = Random.Range(0, 2);
                if (i == 0)
                {
                    StartCoroutine(MoveLane(true));
                }
                else
                {
                    StartCoroutine(MoveLane(false));
                }
            }
            else // Bottom lane
            {
                StartCoroutine(MoveLane(true));
            }
        }
    }
Example #5
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Bullet")
        {
            string bullet_color = other.gameObject.GetComponent <BulletScript>().p_color;
            Color  color_color  = Color.black;
            if (bullet_color != "Rainbow")
            {
                color_color = gameManagerScript.gameObject.GetComponent <ColorManager>().GetColor(bullet_color);
            }
            particleScript.SpawnParticleSystem(iceCreamParticles, transform.position, color_color);

            if (bullet_color == m_demandedColor || bullet_color == "Rainbow")
            {
                gameManagerScript.gameObject.GetComponent <TimeManager>().AdjustTime(p_timeValue);
                gameManagerScript.AddScore(p_scoreValue);
                soundManager.PlayAudio(RandomizeBleat());

                FloatTextController.CreateFloatingText((gameManagerScript.m_multiplier * p_scoreValue).ToString() + "p", transform, true);
                FloatTextController.CreateFloatingText(p_timeValue.ToString() + "s", transform, true);

                m_animator.SetBool("isSatisfied", true);
                m_collider.enabled = false;
                foreach (Transform child in transform)
                {
                    Destroy(child.gameObject);
                }
                Destroy(other.gameObject);
                Destroy(gameObject, 0.7f);
            }
            else
            {
                Destroy(other.gameObject);
                gameManagerScript.AddScore(-p_scoreFailure);
                FloatTextController.CreateFloatingText("-" + p_scoreFailure.ToString() + "p", transform, false);
                soundManager = GameObject.FindWithTag("SoundManager").GetComponent <SoundScript>();
                soundManager.PlayAudio(dissatisfiedBleat);
                //Something when wrong color hits sheeps
            }
        }
        else if (other.gameObject.tag == "Player")
        {
            gameManagerScript.gameObject.GetComponent <TimeManager>().AdjustTime(-p_timeWhenHit);
            FloatTextController.CreateFloatingText("-" + p_timeWhenHit.ToString() + "s", transform, false);
            ss.ShakeScreen();
            //Debug.Log("Sheep Hit");
            Destroy(this.gameObject);
            soundManager = GameObject.FindWithTag("SoundManager").GetComponent <SoundScript>();
            soundManager.PlayAudio(HitByTruck);
        }
        else if (other.gameObject.tag == "Customer")
        {
            if (other.gameObject.transform.position.x < transform.position.x) // This sheep is taking over
            {
                p_speed = 0.5f;
            }
            else
            {
                if (p_speed < 1f)
                {
                    p_speed = 1f;
                }
            }
        }
        else if (other.gameObject.tag == "Obstacle")
        {
            if (other.transform.position.y > 2) // Top lane
            {
                StartCoroutine(MoveLane(false));
            }
            else if (other.transform.position.y > 0) // Middle lane
            {
                int i = Random.Range(0, 2);
                if (i == 0)
                {
                    StartCoroutine(MoveLane(true));
                }
                else
                {
                    StartCoroutine(MoveLane(false));
                }
            }
            else // Bottom lane
            {
                StartCoroutine(MoveLane(true));
            }
        }
    }