private void CmdFire()
    {
        if (m_currentWeapon == 0)
        {
            SetShield();
            CarHealth carhealth = GetComponent <CarHealth>();
            carhealth.GetShield();

            m_currentWeapon = -1;
        }
        else if (m_currentWeapon == 1)
        {
            GameObject shellInstance = Instantiate(m_Shell, m_FireTransform.position, m_FireTransform.rotation) as GameObject;

            shellInstance.GetComponent <Rigidbody>().velocity = m_MaxLaunchForce * m_FireTransform.forward;
            NetworkServer.Spawn(shellInstance);

            m_currentWeapon = -1;
        }
        else if (m_currentWeapon == 2)
        {
            GameObject shellInstance = Instantiate(m_CatRigidyBody, m_FireTransform.position, m_FireTransform.rotation) as GameObject;

            shellInstance.GetComponent <Rigidbody>().velocity = m_MaxLaunchForce * m_FireTransform.forward * -1;
            NetworkServer.Spawn(shellInstance);

            m_currentWeapon = -1;
        }
    }
示例#2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.GetComponent <Rigidbody>() != null && other.gameObject != this && other.isTrigger)
        {
            Rigidbody targetRigidBody = other.GetComponent <Rigidbody>();
            if (targetRigidBody.GetComponent <CarHealth>() != null)
            {
                CarHealth targetCarHealth = targetRigidBody.GetComponent <CarHealth>();

                if (isShielded)
                {
                    if (!targetCarHealth.isShielded)
                    {
                        targetCarHealth.TakeCollisionDamage(2 * collisionDamage);
                    }
                    else
                    {
                        targetCarHealth.RemoveShield();
                    }
                }
                else
                {
                    if (!targetCarHealth.isShielded)
                    {
                        targetCarHealth.TakeCollisionDamage(collisionDamage);
                    }
                    else
                    {
                        targetCarHealth.RemoveShield();
                    }
                }
            }
        }
    }
示例#3
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.name == "CatchPoint")
     {
         GetComponentInParent <ZombieMovement>().enabled = false;
         transform.parent.transform.parent.GetComponent <CapsuleCollider>().isTrigger = true;
         gameObject.transform.parent.transform.parent.transform.SetParent(other.gameObject.transform);
         zombie_rigidbody.useGravity  = false;
         zombie_rigidbody.velocity    = Vector3.zero;
         zombie_rigidbody.isKinematic = true;
         anim.SetFloat("Speed", 0);
         anim.SetBool("Hang", true);
         if (carHealth == null)
         {
             carHealth = other.GetComponentInParent <CarHealth>();
         }
         carHealth.DamageTaken(zombieDamageToCar);
         return;
     }
     if (other.gameObject.tag == "Player")
     {
         if (carHealth == null)
         {
             carHealth = other.GetComponentInParent <CarHealth>();
         }
         carHealth.DamageTaken(zombieDamageToCar);
     }
 }
 void Start()
 {
     this.goal           = GameObject.Find("Goal");
     this.goalController = this.goal.GetComponent <GoalController>();
     this.player         = GameObject.Find("Player");
     this.carHealth      = player.GetComponent <CarHealth>();
     this.carDistance    = this.player.GetComponent <Distance>();
 }
示例#5
0
 private void Awake()
 {
     if (!carHealth)
     {
         carHealth = this;
     }
     else
     {
         Destroy(this);
     }
 }
示例#6
0
    private void Start()
    {
        Durability = 0.0f;
        Speed      = 0.0f;

        ControllerConnected = false;
        ControllsEnabled    = false;

        carController = GetComponent <CarController>();
        carHealth     = GetComponent <CarHealth>();
    }
示例#7
0
    public void Hit()
    {
        //Debug.LogFormat("Collidee: " + collidee.name);
        CarHealth hp = collidee.GetComponent <CarHealth>();

        if (hp != null && can_take_damage)
        {
            hp.Damage(damage);
            can_take_damage = false;
            StartCoroutine(DamageCooldown());
        }
    }
示例#8
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);
                }
            }
        }
    }
示例#10
0
    private void OnTriggerEnter(Collider other)
    {
        ObjectHealth targetHealth = other.GetComponent <ObjectHealth>();
        CarHealth    carHealth    = other.GetComponent <CarHealth>();

        if (targetHealth)
        {
            targetHealth.TakeDamage(m_Damage);
        }
        else if (carHealth)
        {
            carHealth.TakeDamage(m_Damage);
        }

        Destroy(gameObject);
    }
示例#11
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.GetComponent <CarMovement>() != null && other.isTrigger)
     {
         CarHealth targetCarHeath = other.GetComponent <CarHealth>();
         if (targetCarHeath.IsShielded())
         {
             targetCarHeath.RemoveShield();
             Destroy(gameObject);
         }
         else
         {
             CarMovement targetCarMovement = other.GetComponent <CarMovement>();
             targetCarMovement.SetCatOn();
         }
     }
 }
示例#12
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.GetComponent <Rigidbody>() != null && other.isTrigger)
     {
         CarHealth targetCarHeath = other.GetComponent <CarHealth>();
         if (targetCarHeath.IsShielded())
         {
             targetCarHeath.RemoveShield();
         }
         else
         {
             Rigidbody rigidbody     = other.GetComponent <Rigidbody>();
             Rigidbody thisRigidBody = GetComponent <Rigidbody>();
             rigidbody.AddForce(thisRigidBody.velocity * 10, ForceMode.Force);
             Destroy(gameObject);
         }
     }
 }