protected override void OnTriggerEnter(Collider other)
    {
        BaseBall otherBall = other.GetComponentInParent <BaseBall>();

        if (otherBall.useHealth && !otherBall.infected)
        {
            otherBall.currentHealth = -1;
            otherBall.SetInfected();

            /*
             * if (otherBall.objectAffectingBall)
             * {
             *  otherBall.objectAffectingBall = null;
             * }*/
            return;
        }
    }
Пример #2
0
    protected virtual void OnTriggerEnter(Collider other)
    {
        if (isScaling)
        {
            return;
        }

        BaseBall otherBall = other.GetComponentInParent <BaseBall>();

        if (infected)
        {
            if (otherBall == null || otherBall.isMedic)
            {
                return;
            }

            if (otherBall.useHealth && !otherBall.infected)
            {
                //otherBall.objectAffectingBall = gameObject;
                return;
            }

            if (!otherBall.infected)
            {
                float infectChance = m_cachedVirusLevel / (m_cachedVirusLevel + otherBall.m_cachedVirusLevel);
                if (Random.value < infectChance)
                {
                    Debug.Log("set Infected");
                    otherBall.SetInfected();
                }
            }
        }
        else if (isMedic)
        {
            if (otherBall.useHealth && otherBall.infected && !otherBall.isSuperinfected)
            {
                otherBall.objectAffectingBall = gameObject;
            }
        }
    }
Пример #3
0
    protected virtual void OnTriggerStay(Collider other)
    {
        BaseBall otherBall = other.GetComponentInParent <BaseBall>();

        if (otherBall == null || !otherBall.useHealth)
        {
            return;
        }



        if (infected)
        {
            if (!otherBall.objectAffectingBall && !otherBall.infected)
            {
                otherBall.objectAffectingBall = gameObject;
            }

            float infectChance = m_cachedVirusLevel / (m_cachedVirusLevel + otherBall.m_cachedVirusLevel);
            float dmg          = infectChance;


            if (!otherBall.infected)
            {
                otherBall.ChangeHealth(-dmg, gameObject);
                //otherBall.currentHealth -= dmg;

                if (otherBall.currentHealth < 0)
                {
                    //Debug.Log("Current Health "+currentHealth);
                    otherBall.SetInfected();
                }
            }
            else
            {
                if (otherBall.currentHealth > -otherBall.startHealth * 0.5f)
                {
                    otherBall.ChangeHealth(-dmg, gameObject);
                    //otherBall.currentHealth -= dmg;
                }
            }
        }
        else if (isMedic)
        {
            if (otherBall.isSuperinfected)
            {
                return;
            }

            if (!otherBall.objectAffectingBall && otherBall.infected)
            {
                otherBall.objectAffectingBall = gameObject;
            }

            float infectChance = m_cachedVirusLevel / (m_cachedVirusLevel + otherBall.m_cachedVirusLevel);
            float heal         = 0.5f;

            if (otherBall.infected)
            {
                otherBall.ChangeHealth(heal, gameObject);
                currentHealth -= heal * 2f; //Damage medics when healing other balls
                //otherBall.currentHealth += heal;

                if (otherBall.currentHealth > otherBall.startHealth * 0.5f)
                {
                    otherBall.SetHealed();
                    //Debug.Log("Current Health Healed "+otherBall.currentHealth);
                }
            }
            else
            {
                if (otherBall.currentHealth < otherBall.startHealth)
                {
                    otherBall.ChangeHealth(heal, gameObject);
                    //Debug.Log("Healing OtherBall");
                    //otherBall.currentHealth += heal;
                }
            }

            if (currentHealth < 0)
            {
                OnDeath();
            }
        }

        if (objectAffectingBall && otherBall.gameObject == objectAffectingBall)
        {
            resetObjectTimer = 1;
        }
    }