Exemple #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (!Taken)
        {
            // "Hide" the mesh
            m_Renderer.material = m_HiddenMaterial;
            // Make sure nobody else can take the pickup
            Taken = true;
            // Show countdown text
            m_Text.enabled = true;

            // Give pickup to player
            Rigidbody targetRigidBody = other.GetComponent <Rigidbody>();

            if (other.GetComponent <CarMovement>() != null)
            {
                other.GetComponent <CarMovement>().CmdIncreasePoints(200);
            }
            if (targetRigidBody && targetRigidBody.GetComponent <CarShooting>() != null)
            {
                if (isEvil)
                {
                    CarHealth targetCarHealh = other.GetComponent <CarHealth>();
                    evilExplode.Play();
                    targetCarHealh.CmdTakeDamage(25);
                }
                else
                {
                    m_PickupVariable = DateTime.Now.Millisecond % 10.0f;

                    if (m_PickupVariable < 3)
                    {
                        CarShooting targetShooting = targetRigidBody.GetComponent <CarShooting>();
                        targetShooting.GetNewPickup(0);
                    }
                    else if (m_PickupVariable >= 3 && m_PickupVariable <= 7)
                    {
                        CarShooting targetShooting = targetRigidBody.GetComponent <CarShooting>();
                        targetShooting.GetNewPickup(1);
                    }
                    else
                    {
                        CarShooting targetShooting = targetRigidBody.GetComponent <CarShooting>();
                        targetShooting.GetNewPickup(2);
                    }
                }
            }
        }
    }
    private void OnTriggerStay(Collider other)
    {
        if (other.attachedRigidbody)
        {
            CarHealth   targetHealth   = other.GetComponent <CarHealth>();
            CarMovement targetMovement = other.GetComponent <CarMovement>();

            if (targetMovement != null)
            {
                if (targetMovement.IsMoving())
                {
                    targetHealth.CmdTakeDamage(0.5f);
                }
            }
        }
    }