Пример #1
0
 private FloatTextController()
 {
     if (_instance == null)
     {
         _pool     = new List <GameObject>();
         _instance = this;
     }
 }
Пример #2
0
 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);
 }
Пример #3
0
    // ========== Private methods ==========
    private IEnumerator CountdownStartGame()
    {
        while (_countdownTime > 0)
        {
            yield return(new WaitForSeconds(0.1f));

            FloatTextController.DoFloatStaticText(_countdownTime.ToString(), Vector3.zero, Vector3.one * 2, 0.8f, Colors.TURQUOISE);
            yield return(new WaitForSeconds(0.9f));

            _countdownTime -= 1;
        }
        _isPlaying = true;
    }
 // ========== MonoBehaviour methods ==========
 // ========== Public methods ==========
 public override void OnGetHitByBullet(GameObject bullet)
 {
     base.OnGetHitByBullet(bullet);
     if (config.POINT > 0)
     {
         FloatTextController.DoFloatUpText("+" + config.POINT.ToString(), transform.position, Colors.TURQUOISE);
         Manager.instance.AddPoint(config.POINT);
     }
     else
     {
         FloatTextController.DoFloatUpText(config.POINT.ToString(), transform.position, Colors.ALIZARIN);
         Manager.instance.SubPoint(Mathf.Abs(config.POINT));
     }
     return;
 }
Пример #5
0
    private void OnDestroyedByLightningBall(GameObject sourceObject)
    {
        gameObject.GetComponent <Collider2D>().enabled = false;
        gameObject.GetComponent <IObjectMovement>().StopMoving();
        Invoke("DeactivateObject", _timeBeforeDeactivateObject);

        PointObjectConfig currentConfig = (PointObjectConfig)config;

        if (currentConfig.POINT > 0)
        {
            Manager.instance.AddPoint(currentConfig.POINT);
            FloatTextController.DoFloatUpText("+" + currentConfig.POINT.ToString(), transform.position, Colors.TURQUOISE);
        }
        gameObject.GetComponent <IObjectMovement>().StopMoving();
        gameObject.GetComponent <IShootableObjectAnimation>().DoEffectObjectAffectedByEffectObject(EffectObjectType.LIGHTNING_BALL, sourceObject);
    }
    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);
        }
    }
Пример #7
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);
        }
    }
Пример #8
0
 private void Awake()
 {
     m_mainController      = FindObjectOfType <MainController>();
     m_floatTextController = FindObjectOfType <FloatTextController>();
     m_audioSource         = FindObjectOfType <AudioSource>();
 }
Пример #9
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));
            }
        }
    }
Пример #10
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));
            }
        }
    }