Ejemplo n.º 1
0
 //? 发布 Damage event
 public virtual void OnCauseDamage(int damageVal)//? 具体的伤害就在这里设置
 {
     CauseDamage?.Invoke(this, new DamageEventArgs()
     {
         DamageValue = damageVal
     });
 }
Ejemplo n.º 2
0
 public DamageMove(Lidgren.Network.NetIncomingMessage p)
 {
     time_execute = p.ReadSingle();
     attacker     = (TargetType)p.ReadByte();
     attacker_id  = p.ReadUInt16();
     target       = (TargetType)p.ReadByte();
     target_id    = p.ReadUInt16();
     damage       = p.ReadInt16();
     damage_code  = (CauseDamage)p.ReadByte();
     range        = p.ReadUInt16();
 }
Ejemplo n.º 3
0
 public DamageMove(float ptime, ushort pattacker_id, TargetType pattacker, ushort ptarget_id, TargetType ptarget, short pdamage, CauseDamage p_cause, ushort prange)
 {
     time_execute = ptime;
     attacker     = pattacker;
     attacker_id  = pattacker_id;
     target       = ptarget;
     target_id    = ptarget_id;
     damage       = pdamage;
     damage_code  = p_cause;
     range        = prange;
 }
    private void OnCollisionEnter(Collision collision)
    {
        GameObject other = collision.gameObject;

        try
        {
            CauseDamage causeDamageScript = other.GetComponent <CauseDamage>();
            int         totalDamage       = causeDamageScript.GetDamage();
            Health      healthScript      = GetComponent <Health>();
            healthScript.TakeDamage(totalDamage);
        }
        catch
        {
            Debug.Log("Somthing hit us but didn't do any damage");
        }
    }
Ejemplo n.º 5
0
    void FixedUpdate()
    {
//		Debug.Log (fireRotation);
        if (shooting)
        {
            fireTime += Time.deltaTime;

            shooting = false;

            RaycastHit hit;

            Vector3 fireDirection = bulletSpawn.forward;

            fireRotation = Quaternion.LookRotation(fireDirection);

            Quaternion randomRotation = Random.rotation;

            float currentSpread = Mathf.Lerp(0.0f, maxBulletSpreadAngle, fireTime / timeToSpread);

            fireRotation = Quaternion.RotateTowards(fireRotation, randomRotation, Random.Range(0.0f, currentSpread));
            if (Physics.Raycast(bulletSpawn.position, fireRotation * Vector3.forward, out hit, distance, myLayMask))
            {
                if (hit.transform.tag == "Cover")
                {
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                }

                if (hit.transform.tag == "Environment")
                {
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                }

                if (hit.transform.tag == "Target Practice")
                {
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }

                    CauseDamage        causeD  = hit.transform.GetComponent <CauseDamage>();
                    CauseDamageDestroy causeDD = hit.transform.GetComponentInParent <CauseDamageDestroy>();

                    if (causeD.addPoints >= 125 && causeD.addPoints <= 400)
                    {
                        HUDScoreText.currentScore += 125;
                    }
                    if (causeD.addPoints >= 401 && causeD.addPoints <= 1001)
                    {
                        HUDScoreText.currentScore += 1000;
                    }
                    else if (causeD.addPoints >= 100 && causeD.addPoints <= 124)
                    {
                        HUDScoreText.currentScore += 100;
                    }
                    else if (causeD.addPoints >= 26 && causeD.addPoints <= 99)
                    {
                        HUDScoreText.currentScore += 50;
                    }
                    else if (causeD.addPoints >= 6 && causeD.addPoints <= 25)
                    {
                        HUDScoreText.currentScore += 25;
                    }
                    else if (causeD.addPoints >= 2 && causeD.addPoints <= 5)
                    {
                        HUDScoreText.currentScore += 5;
                    }
                    else if (causeD.addPoints >= 1 && causeD.addPoints <= 2)
                    {
                        HUDScoreText.currentScore += 1;
                    }
                    causeDD.shots++;
                }

                else if (hit.collider.tag == "TutorialDoors")
                {
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    CauseDamageDestroy causeDD = hit.transform.GetComponentInParent <CauseDamageDestroy>();
                    if (causeDD != null)
                    {
                        causeDD.shots++;
                    }
                }

                else if (hit.collider.tag == "Head")
                {
                    GameMasterObject.totalHeadShots++;
                    GameMasterObject.totalHitShots++;
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    BlockCharacterLife blockCharLife = hit.transform.GetComponentInParent <BlockCharacterLife>();
                    if (blockCharLife != null)
                    {
                        blockCharLife.shots  += 7;
                        blockCharLife.gotShot = true;
                    }

                    EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> ();
                    if (enemyHealth != null)
                    {
                        enemyHealth.TakeDamage(headDamage * attackBooster, hit.transform.position);
                        //hit.rigidbody.AddForceAtPosition(new Vector3(Random.Range(1,10), Random.Range(1, 10), Random.Range(1, 10)) * 10, hit.transform.position);
                    }
                }

                else if (hit.collider.tag == "Doors")
                {
                    //hit.rigidbody.AddForceAtPosition(new Vector3(Random.Range(1,10), Random.Range(1, 10), Random.Range(1, 10)) * 100, hit.transform.position);
                }

                else if (hit.collider.tag == "Body")
                {
                    GameMasterObject.totalBodyShots++;
                    GameMasterObject.totalHitShots++;
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    BlockCharacterLife blockCharLife = hit.transform.GetComponentInParent <BlockCharacterLife>();
                    if (blockCharLife != null)
                    {
                        blockCharLife.shots  += 4;
                        blockCharLife.gotShot = true;
                    }

                    EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> ();
                    if (enemyHealth != null)
                    {
                        enemyHealth.TakeDamage(bodyDamage * attackBooster, hit.transform.position);
                        //hit.rigidbody.AddForceAtPosition(new Vector3(Random.Range(1,10), Random.Range(1, 10), Random.Range(1, 10)) * 10, hit.transform.position);
                    }
                }
                else if (hit.collider.tag == "Weapon")
                {
                    GameMasterObject.totalHitShots++;
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    RocketDamage rocketDamage = hit.collider.GetComponent <RocketDamage> ();
                    if (rocketDamage != null)
                    {
                        rocketDamage.TakeDamage(3 * attackBooster);
                    }
                }

                else if (hit.collider.tag == "Poppy")
                {
                    GameMasterObject.totalHitShots++;
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    PoppyLife poppyLife = hit.collider.GetComponent <PoppyLife> ();
                    if (poppyLife != null)
                    {
                        poppyLife.TakeDamage(1);
                    }
                }

                else if (hit.collider.tag == "Bobby")
                {
                    GameMasterObject.totalHitShots++;
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    PoppyLife poppyLife = hit.collider.GetComponent <PoppyLife> ();
                    if (poppyLife != null)
                    {
                        poppyLife.TakeDamage(75);
                    }
                    PoppyLife poppyLife2 = hit.collider.GetComponentInParent <PoppyLife> ();
                    if (poppyLife2 != null)
                    {
                        poppyLife2.TakeDamage(75);
                    }
                }
                else if (hit.collider.tag == "Mask")
                {
                    GameMasterObject.totalHitShots++;
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    TalkingHeadLife headLift = hit.collider.GetComponent <TalkingHeadLife> ();
                    if (headLift != null)
                    {
                        headLift.TakeDamage(75);
                    }
                }
                else if (hit.collider.tag == "Legs")
                {
                    GameMasterObject.totalLegShots++;
                    GameMasterObject.totalHitShots++;
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    BlockCharacterLife blockCharlife = hit.transform.GetComponentInParent <BlockCharacterLife>();
                    if (blockCharlife != null)
                    {
                        blockCharlife.shots += 3;
                    }

                    EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> ();
                    if (enemyHealth != null)
                    {
                        enemyHealth.TakeDamage(legDamage * attackBooster, hit.transform.position);
                        //hit.rigidbody.AddForceAtPosition(new Vector3(Random.Range(1,10), Random.Range(1, 10), Random.Range(1, 10)) * 10, hit.transform.position);
                    }
                }

                else if (hit.collider.tag == "Arms")
                {
                    GameMasterObject.totalArmShots++;
                    GameMasterObject.totalHitShots++;
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    BlockCharacterLife blockCharlife = hit.transform.GetComponentInParent <BlockCharacterLife>();
                    if (blockCharlife != null)
                    {
                        blockCharlife.shots += 2;
                    }

                    EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> ();
                    if (enemyHealth != null)
                    {
                        enemyHealth.TakeDamage(armDamage * attackBooster, hit.transform.position);
                        //hit.rigidbody.AddForceAtPosition(new Vector3(Random.Range(1,10), Random.Range(1, 10), Random.Range(1, 10)) * 10, hit.transform.position);
                    }
                }
            }
        }
    }
Ejemplo n.º 6
0
    void OnCollisionEnter(Collision other)
    {
//		Debug.Log (other.collider.tag);
        if (other.gameObject.tag == "Enemy")
        {
            EnemyHealth1 enemyHealth = other.gameObject.GetComponent <EnemyHealth1>();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(attackDamage * attackBoost, other.transform.position);
                Instantiate(explosion, transform.position, transform.rotation);
                destroyThis = true;
            }
        }
        else if (other.gameObject.tag == "Player")
        {
            PlayerHealth1 playerHealth = other.gameObject.GetComponent <PlayerHealth1>();
            if (playerHealth != null)
            {
                playerHealth.TakeDamage(attackDamage * attackBoost);
                if (GameMasterObject.dannyActive)
                {
                    DannyCameraShake.InstanceD1.ShakeD1(amplitude, duration);
                }
                else if (GameMasterObject.strongmanActive)
                {
                    CameraShake.InstanceSM1.ShakeSM1(amplitude, duration);
                }
                HUDHealthScript.timer = 0;
                Instantiate(explosion, transform.position, transform.rotation);
                destroyThis = true;
            }
        }
        else if (other.gameObject.tag == "Body")
        {
            EnemyHealth1 enemyHealth = other.gameObject.GetComponentInParent <EnemyHealth1>();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(attackDamage * attackBoost, other.transform.position);
                Instantiate(explosion, transform.position, transform.rotation);
                destroyThis = true;
            }

            BlockCharacterLife blockLife = other.gameObject.GetComponent <BlockCharacterLife> ();
            if (blockLife != null)
            {
                blockLife.shots += 75;
            }
            BlockCharacterLife blockLife2 = other.gameObject.GetComponentInParent <BlockCharacterLife> ();
            if (blockLife2 != null)
            {
                blockLife2.shots += 75;
            }
            destroyThis = true;
        }
        else if (other.collider.tag == "Body")
        {
            Debug.Log(other.collider.tag);
            EnemyHealth1 enemyHealth = other.gameObject.GetComponentInParent <EnemyHealth1>();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(attackDamage * attackBoost, other.transform.position);
                Instantiate(explosion, transform.position, transform.rotation);
                destroyThis = true;
            }

            BlockCharacterLife blockLife = other.gameObject.GetComponent <BlockCharacterLife> ();
            if (blockLife != null)
            {
                blockLife.shots += 75;
            }
            BlockCharacterLife blockLife2 = other.gameObject.GetComponentInParent <BlockCharacterLife> ();
            if (blockLife2 != null)
            {
                blockLife2.shots += 75;
            }
            destroyThis = true;
        }
        else if (other.collider.tag == "Head")
        {
            EnemyHealth1 enemyHealth = other.gameObject.GetComponentInParent <EnemyHealth1>();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(attackDamage * attackBoost, other.transform.position);
                Instantiate(explosion, transform.position, transform.rotation);
                destroyThis = true;
            }
            BlockCharacterLife blockLife = other.gameObject.GetComponent <BlockCharacterLife> ();
            if (blockLife != null)
            {
                blockLife.shots += 150;
            }
            BlockCharacterLife blockLife2 = other.gameObject.GetComponentInParent <BlockCharacterLife> ();
            if (blockLife2 != null)
            {
                blockLife2.shots += 150;
            }
            destroyThis = true;
        }
        else if (other.collider.tag == "Arms")
        {
            EnemyHealth1 enemyHealth = other.gameObject.GetComponentInParent <EnemyHealth1>();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(attackDamage * attackBoost, other.transform.position);
                Instantiate(explosion, transform.position, transform.rotation);
                destroyThis = true;
            }
            BlockCharacterLife blockLife = other.gameObject.GetComponent <BlockCharacterLife> ();
            if (blockLife != null)
            {
                blockLife.shots += 10;
            }
            BlockCharacterLife blockLife2 = other.gameObject.GetComponentInParent <BlockCharacterLife> ();
            if (blockLife2 != null)
            {
                blockLife2.shots += 10;
            }
            destroyThis = true;
        }
        else if (other.collider.tag == "Target Practice")
        {
            CauseDamage        causeD  = other.collider.transform.GetComponent <CauseDamage>();
            CauseDamageDestroy causeDD = other.gameObject.GetComponentInParent <CauseDamageDestroy>();

            if (causeD.addPoints >= 125 && causeD.addPoints <= 400)
            {
                HUDScoreText.currentScore += 125;
            }
            if (causeD.addPoints >= 401 && causeD.addPoints <= 1001)
            {
                HUDScoreText.currentScore += 1000;
            }
            else if (causeD.addPoints >= 100 && causeD.addPoints <= 124)
            {
                HUDScoreText.currentScore += 100;
            }
            else if (causeD.addPoints >= 26 && causeD.addPoints <= 99)
            {
                HUDScoreText.currentScore += 50;
            }
            else if (causeD.addPoints >= 6 && causeD.addPoints <= 25)
            {
                HUDScoreText.currentScore += 25;
            }
            else if (causeD.addPoints >= 2 && causeD.addPoints <= 5)
            {
                HUDScoreText.currentScore += 5;
            }
            else if (causeD.addPoints >= 1 && causeD.addPoints <= 2)
            {
                HUDScoreText.currentScore += 1;
            }
            causeDD.shots++;
            destroyThis = true;
        }
        else if (other.collider.tag == "Poppy")
        {
            PoppyLife poppyLife = other.gameObject.GetComponent <PoppyLife> ();
            if (poppyLife != null)
            {
                poppyLife.TakeDamage(attackDamage);
            }
            destroyThis = true;
        }
        else if (other.collider.tag == "Bobby")
        {
            PoppyLife poppyLife = other.gameObject.GetComponent <PoppyLife> ();
            if (poppyLife != null)
            {
                poppyLife.TakeDamage(attackDamage * 2);
            }
            destroyThis = true;
        }
        else if (other.collider.tag == "Legs")
        {
            EnemyHealth1 enemyHealth = other.gameObject.GetComponentInParent <EnemyHealth1>();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(attackDamage * attackBoost, other.transform.position);
                Instantiate(explosion, transform.position, transform.rotation);
                destroyThis = true;
            }
            BlockCharacterLife blockLife = other.gameObject.GetComponent <BlockCharacterLife> ();
            if (blockLife != null)
            {
                blockLife.shots += 10;
            }
            BlockCharacterLife blockLife2 = other.gameObject.GetComponentInParent <BlockCharacterLife> ();
            if (blockLife2 != null)
            {
                blockLife2.shots += 10;
            }
            destroyThis = true;
        }
        else if (other.gameObject.tag == "Shield")
        {
            Destroy(this.gameObject);
            Instantiate(explosion, transform.position, transform.rotation);
        }
        else
        {
            Destroy(this.gameObject);
//			Instantiate (explosion, transform.position, transform.rotation);
        }
        //Destroy (this.gameObject);
    }
Ejemplo n.º 7
0
    void FixedUpdate()
    {
        if (shooting)
        {
            shooting = false;

            RaycastHit hit;

            if (Physics.Raycast(bulletSpawn.position, bulletSpawn.forward, out hit, distance, myLayerMask))
            {
//				Debug.Log (hit.collider.tag);
                if (hit.transform.tag == "Cover")
                {
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                }

                if (hit.transform.tag == "Environment")
                {
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                }

                if (hit.transform.tag == "Target Practice")
                {
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }

                    CauseDamage        causeD  = hit.transform.GetComponent <CauseDamage>();
                    CauseDamageDestroy causeDD = hit.transform.GetComponentInParent <CauseDamageDestroy>();

                    if (causeD.addPoints >= 125 && causeD.addPoints <= 400)
                    {
                        HUDScoreText.currentScore += 125;
                    }
                    if (causeD.addPoints >= 401 && causeD.addPoints <= 1001)
                    {
                        HUDScoreText.currentScore += 1000;
                    }
                    else if (causeD.addPoints >= 100 && causeD.addPoints <= 124)
                    {
                        HUDScoreText.currentScore += 100;
                    }
                    else if (causeD.addPoints >= 26 && causeD.addPoints <= 99)
                    {
                        HUDScoreText.currentScore += 50;
                    }
                    else if (causeD.addPoints >= 6 && causeD.addPoints <= 25)
                    {
                        HUDScoreText.currentScore += 25;
                    }
                    else if (causeD.addPoints >= 2 && causeD.addPoints <= 5)
                    {
                        HUDScoreText.currentScore += 5;
                    }
                    else if (causeD.addPoints >= 1 && causeD.addPoints <= 2)
                    {
                        HUDScoreText.currentScore += 1;
                    }
                    causeDD.shots += 1 * attackBooster;
                }

                else if (hit.collider.tag == "TutorialDoors")
                {
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    CauseDamageDestroy causeDD = hit.transform.GetComponentInParent <CauseDamageDestroy>();
                    if (causeDD != null)
                    {
                        causeDD.shots += 2 * attackBooster;
                    }
                }

                else if (hit.collider.tag == "Head")
                {
                    GameMasterObject.totalHeadShots++;
                    GameMasterObject.totalHitShots++;
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    BlockCharacterLife blockCharLife = hit.transform.GetComponentInParent <BlockCharacterLife>();
                    if (blockCharLife != null)
                    {
                        blockCharLife.shots  += 15 * attackBooster;
                        blockCharLife.gotShot = true;
                    }

                    EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> ();
                    if (enemyHealth != null)
                    {
                        enemyHealth.TakeDamage(headDamage * attackBooster, hit.transform.position);
                        //hit.rigidbody.AddForceAtPosition(new Vector3(Random.Range(1,10), Random.Range(1, 10), Random.Range(1, 10)) * 10, hit.transform.position);
                    }
                }
                else if (hit.collider.tag == "Weapon")
                {
                    GameMasterObject.totalHitShots++;
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    RocketDamage rocketDamage = hit.collider.GetComponent <RocketDamage> ();
                    if (rocketDamage != null)
                    {
                        rocketDamage.TakeDamage(6 * attackBooster);
                    }
                }

                else if (hit.collider.tag == "Poppy")
                {
                    GameMasterObject.totalHitShots++;
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    PoppyLife poppyLife = hit.collider.GetComponent <PoppyLife> ();
                    if (poppyLife != null)
                    {
                        poppyLife.TakeDamage(2 * attackBooster);
                    }
                }

                else if (hit.collider.tag == "Bobby")
                {
                    GameMasterObject.totalHitShots++;
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    PoppyLife poppyLife = hit.collider.GetComponent <PoppyLife> ();
                    if (poppyLife != null)
                    {
                        poppyLife.TakeDamage(125 * attackBooster);
                    }
                    PoppyLife poppyLife2 = hit.collider.GetComponentInParent <PoppyLife> ();
                    if (poppyLife2 != null)
                    {
                        poppyLife2.TakeDamage(125 * attackBooster);
                    }
                }
                else if (hit.collider.tag == "Mask")
                {
                    GameMasterObject.totalHitShots++;
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    TalkingHeadLife headLift = hit.collider.GetComponent <TalkingHeadLife> ();
                    if (headLift != null)
                    {
                        headLift.TakeDamage(75 * attackBooster);
                    }
                }

                else if (hit.collider.tag == "Body")
                {
                    GameMasterObject.totalBodyShots++;
                    GameMasterObject.totalHitShots++;
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    BlockCharacterLife blockCharLife = hit.collider.transform.GetComponentInParent <BlockCharacterLife>();
                    if (blockCharLife != null)
                    {
                        blockCharLife.shots  += 5 * attackBooster;
                        blockCharLife.gotShot = true;
                    }

                    EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> ();
                    if (enemyHealth != null)
                    {
                        enemyHealth.TakeDamage(bodyDamage * attackBooster, hit.transform.position);
                        //other.rigidbody.AddForceAtPosition(Vector3.forward * 10, other.transform.position);
                    }
                }

                else if (hit.collider.tag == "Legs")
                {
                    GameMasterObject.totalLegShots++;
                    GameMasterObject.totalHitShots++;
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    BlockCharacterLife blockCharLife = hit.transform.GetComponentInParent <BlockCharacterLife>();
                    if (blockCharLife != null)
                    {
                        blockCharLife.shots += 4 * attackBooster;
                    }

                    EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> ();
                    if (enemyHealth != null)
                    {
                        enemyHealth.TakeDamage(legDamage * attackBooster, hit.transform.position);
                        //other.rigidbody.AddForceAtPosition(Vector3.forward * 10, other.transform.position);
                    }
                }

                else if (hit.collider.tag == "Arms")
                {
                    GameMasterObject.totalArmShots++;
                    GameMasterObject.totalHitShots++;
                    impacts[currentImpact].transform.position = hit.point;
                    impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                    if (++currentImpact >= maxImpacts)
                    {
                        currentImpact = 0;
                    }
                    BlockCharacterLife blockCharLife = hit.transform.GetComponentInParent <BlockCharacterLife>();
                    if (blockCharLife != null)
                    {
                        blockCharLife.shots += 3 * attackBooster;
                    }

                    EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> ();
                    if (enemyHealth != null)
                    {
                        enemyHealth.TakeDamage(armDamage * attackBooster, hit.transform.position);
                        //other.rigidbody.AddForceAtPosition(Vector3.forward * 10, other.transform.position);
                    }
                }
            }
        }
    }
Ejemplo n.º 8
0
    void OnCollisionEnter(Collision other)
    {
//		Debug.Log (other.collider.tag);
        if (other.collider.tag == "Enemy")
        {
            EnemyHealth1 enemyHealth = other.gameObject.GetComponent <EnemyHealth1>();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(attackDamage * attackBoost, other.transform.position);
                Instantiate(explosion, transform.position, transform.rotation);
            }
        }
        if (other.collider.tag == "Body")
        {
//			Debug.Log ("body");
            EnemyHealth1 enemyHealth = other.collider.GetComponentInParent <EnemyHealth1>();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(attackDamage * attackBoost, other.transform.position);
                Instantiate(explosion, transform.position, transform.rotation);
            }

            BlockCharacterLife blockLife = other.gameObject.GetComponentInParent <BlockCharacterLife> ();
            if (blockLife != null)
            {
//				Debug.Log ("notnull2");
                blockLife.shots += 75;
            }
            BlockCharacterLife blockLife2 = other.gameObject.GetComponentInParent <BlockCharacterLife> ();
            if (blockLife2 != null)
            {
//				Debug.Log ("notnull2");
                blockLife2.shots += 75;
            }
        }
        else if (other.collider.tag == "Head")
        {
            EnemyHealth1 enemyHealth = other.collider.GetComponentInParent <EnemyHealth1>();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(attackDamage * attackBoost, other.transform.position);
                Instantiate(explosion, transform.position, transform.rotation);
            }
            BlockCharacterLife blockLife = other.gameObject.GetComponentInParent <BlockCharacterLife> ();
            if (blockLife != null)
            {
                blockLife.shots += 150;
            }
            BlockCharacterLife blockLife2 = other.gameObject.GetComponentInParent <BlockCharacterLife> ();
            if (blockLife2 != null)
            {
                blockLife2.shots += 150;
            }
        }
        else if (other.collider.tag == "Arms")
        {
            EnemyHealth1 enemyHealth = other.collider.GetComponentInParent <EnemyHealth1>();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(attackDamage * attackBoost, other.transform.position);
                Instantiate(explosion, transform.position, transform.rotation);
            }
            BlockCharacterLife blockLife = other.gameObject.GetComponentInParent <BlockCharacterLife> ();
            if (blockLife != null)
            {
                blockLife.shots += 10;
            }
            BlockCharacterLife blockLife2 = other.gameObject.GetComponentInParent <BlockCharacterLife> ();
            if (blockLife2 != null)
            {
                blockLife2.shots += 10;
            }
        }
        else if (other.collider.tag == "Target Practice")
        {
            CauseDamage        causeD  = other.collider.transform.GetComponent <CauseDamage>();
            CauseDamageDestroy causeDD = other.gameObject.GetComponentInParent <CauseDamageDestroy>();

            if (causeD.addPoints >= 125 && causeD.addPoints <= 400)
            {
                HUDScoreText.currentScore += 125;
            }
            if (causeD.addPoints >= 401 && causeD.addPoints <= 1001)
            {
                HUDScoreText.currentScore += 1000;
            }
            else if (causeD.addPoints >= 100 && causeD.addPoints <= 124)
            {
                HUDScoreText.currentScore += 100;
            }
            else if (causeD.addPoints >= 26 && causeD.addPoints <= 99)
            {
                HUDScoreText.currentScore += 50;
            }
            else if (causeD.addPoints >= 6 && causeD.addPoints <= 25)
            {
                HUDScoreText.currentScore += 25;
            }
            else if (causeD.addPoints >= 2 && causeD.addPoints <= 5)
            {
                HUDScoreText.currentScore += 5;
            }
            else if (causeD.addPoints >= 1 && causeD.addPoints <= 2)
            {
                HUDScoreText.currentScore += 1;
            }
            causeDD.shots++;
        }
        else if (other.collider.tag == "Poppy")
        {
            PoppyLife poppyLife = other.gameObject.GetComponent <PoppyLife> ();
            if (poppyLife != null)
            {
                poppyLife.TakeDamage(attackDamage);
            }
        }
        else if (other.collider.tag == "Bobby")
        {
            PoppyLife poppyLife = other.gameObject.GetComponent <PoppyLife> ();
            if (poppyLife != null)
            {
                poppyLife.TakeDamage(attackDamage * 2);
            }
        }
        else if (other.collider.tag == "Legs")
        {
            EnemyHealth1 enemyHealth = other.collider.GetComponentInParent <EnemyHealth1>();
            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(attackDamage * attackBoost, other.transform.position);
                Instantiate(explosion, transform.position, transform.rotation);
            }
            BlockCharacterLife blockLife = other.gameObject.GetComponentInParent <BlockCharacterLife> ();
            if (blockLife != null)
            {
                blockLife.shots += 10;
            }
            BlockCharacterLife blockLife2 = other.gameObject.GetComponentInParent <BlockCharacterLife> ();
            if (blockLife2 != null)
            {
                blockLife2.shots += 10;
            }
        }
        else if (other.gameObject.tag == "Cover")
        {
            Destroy(this.gameObject);
            Instantiate(explosion, transform.position, transform.rotation);
        }
        else
        {
            Destroy(this.gameObject);
        }
        Destroy(this.gameObject);
    }
Ejemplo n.º 9
0
 public void Attack(Position pos)
 {
     CauseDamage?.Invoke(pos, attackPower);
 }
Ejemplo n.º 10
0
    void FixedUpdate()
    {
        if (shooting)
        {
            shooting = false;

            for (int i = 0; i < shotFragments; i++)
            {
                RaycastHit hit;

                Vector3 fireDirection = bulletSpawn.forward;

                Quaternion fireRotation = Quaternion.LookRotation(fireDirection);

                Quaternion randomRotation = Random.rotation;

                //float currentSpread = Mathf.Lerp (0.0f, maxBulletSpreadAngle, fireTime / timeToSpread);

                fireRotation = Quaternion.RotateTowards(fireRotation, randomRotation, Random.Range(0.0f, spreadAngle));


                if (Physics.Raycast(bulletSpawn.position, fireRotation * Vector3.forward, out hit, distance, myLayerMask))
                {
                    if (hit.transform.tag == "Cover")
                    {
                        impacts[currentImpact].transform.position = hit.point;
                        impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                        if (++currentImpact >= maxImpacts)
                        {
                            currentImpact = 0;
                        }
                    }

                    if (hit.transform.tag == "Environment")
                    {
                        impacts[currentImpact].transform.position = hit.point;
                        impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                        if (++currentImpact >= maxImpacts)
                        {
                            currentImpact = 0;
                        }
                    }

                    if (hit.transform.tag == "Target Practice")
                    {
                        impacts[currentImpact].transform.position = hit.point;
                        impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                        if (++currentImpact >= maxImpacts)
                        {
                            currentImpact = 0;
                        }
                        CauseDamage        causeD  = hit.transform.GetComponent <CauseDamage>();
                        CauseDamageDestroy causeDD = hit.transform.GetComponentInParent <CauseDamageDestroy>();

                        if (causeD.addPoints >= 125 && causeD.addPoints <= 400)
                        {
                            HUDScoreText.currentScore += 125;
                        }
                        if (causeD.addPoints >= 401 && causeD.addPoints <= 1001)
                        {
                            HUDScoreText.currentScore += 1000;
                        }
                        else if (causeD.addPoints >= 100 && causeD.addPoints <= 124)
                        {
                            HUDScoreText.currentScore += 100;
                        }
                        else if (causeD.addPoints >= 26 && causeD.addPoints <= 99)
                        {
                            HUDScoreText.currentScore += 50;
                        }
                        else if (causeD.addPoints >= 6 && causeD.addPoints <= 25)
                        {
                            HUDScoreText.currentScore += 25;
                        }
                        else if (causeD.addPoints >= 2 && causeD.addPoints <= 5)
                        {
                            HUDScoreText.currentScore += 5;
                        }
                        else if (causeD.addPoints >= 1 && causeD.addPoints <= 2)
                        {
                            HUDScoreText.currentScore += 1;
                        }
                        causeDD.shots++;
                    }

                    else if (hit.collider.tag == "TutorialDoors")
                    {
                        impacts[currentImpact].transform.position = hit.point;
                        impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                        if (++currentImpact >= maxImpacts)
                        {
                            currentImpact = 0;
                        }
                        CauseDamageDestroy causeDD = hit.transform.GetComponentInParent <CauseDamageDestroy>();
                        if (causeDD != null)
                        {
                            causeDD.shots += 2;
                        }
                    }

                    else if (hit.collider.tag == "Head")
                    {
                        GameMasterObject.totalShotGunHits++;
                        impacts[currentImpact].transform.position = hit.point;
                        impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                        if (++currentImpact >= maxImpacts)
                        {
                            currentImpact = 0;
                        }
                        BlockCharacterLife blockCharLife = hit.transform.GetComponentInParent <BlockCharacterLife>();
                        if (blockCharLife != null)
                        {
                            blockCharLife.shots += 10;
                            if (!blockCharLife.reallyGotShot)
                            {
                                blockCharLife.reallyGotShot = true;
                            }
                        }


                        EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> ();
                        if (enemyHealth != null)
                        {
                            enemyHealth.TakeDamage(headDamage * attackBooster, hit.transform.position);
                            //hit.transform.GetComponentInParent<Rigidbody> ().AddForceAtPosition (hit.collider.transform.position - hit.point * pushForce, hit.point, ForceMode.Force);
                        }
                        //hit.collider.attachedRigidbody.AddForceAtPosition (hit.collider.transform.position - hit.point * pushForce, hit.point, ForceMode.Force);
                    }
                    else if (hit.collider.tag == "Weapon")
                    {
                        GameMasterObject.totalShotGunHits++;
                        impacts[currentImpact].transform.position = hit.point;
                        impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                        if (++currentImpact >= maxImpacts)
                        {
                            currentImpact = 0;
                        }
                        RocketDamage rocketDamage = hit.collider.GetComponent <RocketDamage> ();
                        if (rocketDamage != null)
                        {
                            rocketDamage.TakeDamage(11 * attackBooster);
                        }
                    }

                    else if (hit.collider.tag == "Poppy")
                    {
                        GameMasterObject.totalShotGunHits++;
                        impacts[currentImpact].transform.position = hit.point;
                        impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                        if (++currentImpact >= maxImpacts)
                        {
                            currentImpact = 0;
                        }
                        PoppyLife poppyLife = hit.collider.GetComponent <PoppyLife> ();
                        if (poppyLife != null)
                        {
                            poppyLife.TakeDamage(3);
                        }
                    }

                    else if (hit.collider.tag == "Bobby")
                    {
                        GameMasterObject.totalShotGunHits++;
                        impacts[currentImpact].transform.position = hit.point;
                        impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                        if (++currentImpact >= maxImpacts)
                        {
                            currentImpact = 0;
                        }
                        PoppyLife poppyLife = hit.collider.GetComponent <PoppyLife> ();
                        if (poppyLife != null)
                        {
                            poppyLife.TakeDamage(255);
                        }
                        PoppyLife poppyLife2 = hit.collider.GetComponentInParent <PoppyLife> ();
                        if (poppyLife2 != null)
                        {
                            poppyLife2.TakeDamage(255);
                        }
                    }
                    else if (hit.collider.tag == "Mask")
                    {
                        GameMasterObject.totalHitShots++;
                        impacts[currentImpact].transform.position = hit.point;
                        impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                        if (++currentImpact >= maxImpacts)
                        {
                            currentImpact = 0;
                        }
                        TalkingHeadLife headLift = hit.collider.GetComponent <TalkingHeadLife> ();
                        if (headLift != null)
                        {
                            headLift.TakeDamage(75);
                        }
                    }
                    else if (hit.collider.tag == "Body")
                    {
                        GameMasterObject.totalShotGunHits++;
                        impacts[currentImpact].transform.position = hit.point;
                        impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                        if (++currentImpact >= maxImpacts)
                        {
                            currentImpact = 0;
                        }
                        BlockCharacterLife blockCharLife = hit.collider.transform.GetComponentInParent <BlockCharacterLife>();
                        if (blockCharLife != null)
                        {
                            blockCharLife.shots += 6;
                            if (!blockCharLife.reallyGotShot)
                            {
                                blockCharLife.reallyGotShot = true;
                            }
                        }

                        EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> ();
                        if (enemyHealth != null)
                        {
                            enemyHealth.TakeDamage(bodyDamage * attackBooster, hit.transform.position);
                            //hit.transform.GetComponentInParent<Rigidbody>().AddForceAtPosition (hit.collider.transform.position - hit.point * pushForce, hit.point, ForceMode.Force);
                        }
                        //hit.collider.attachedRigidbody.AddForceAtPosition (hit.collider.transform.position - hit.point * pushForce, hit.point, ForceMode.Force);
                    }
                    else if (hit.collider.tag == "Legs")
                    {
                        GameMasterObject.totalShotGunHits++;
                        impacts[currentImpact].transform.position = hit.point;
                        impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                        if (++currentImpact >= maxImpacts)
                        {
                            currentImpact = 0;
                        }
                        BlockCharacterLife blockCharLife = hit.transform.GetComponentInParent <BlockCharacterLife>();
                        if (blockCharLife != null)
                        {
                            blockCharLife.shots += 3;
                        }

                        EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> ();
                        if (enemyHealth != null)
                        {
                            enemyHealth.TakeDamage(legDamage * attackBooster, hit.transform.position);
                            //hit.transform.GetComponentInParent<Rigidbody>().AddForceAtPosition (hit.collider.transform.position - hit.point * pushForce, hit.point, ForceMode.Force);
                        }
                        //hit.collider.attachedRigidbody.AddForceAtPosition (hit.collider.transform.position - hit.point * pushForce, hit.point, ForceMode.Force);
                    }
                    else if (hit.collider.tag == "Arms")
                    {
                        GameMasterObject.totalShotGunHits++;
                        impacts[currentImpact].transform.position = hit.point;
                        impacts[currentImpact].GetComponent <ParticleSystem>().Play();

                        if (++currentImpact >= maxImpacts)
                        {
                            currentImpact = 0;
                        }
                        BlockCharacterLife blockCharLife = hit.transform.GetComponentInParent <BlockCharacterLife>();
                        if (blockCharLife != null)
                        {
                            blockCharLife.shots += 2;
                            if (!blockCharLife.reallyGotShot)
                            {
                                blockCharLife.reallyGotShot = true;
                            }
                        }

                        EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> ();
                        if (enemyHealth != null)
                        {
                            enemyHealth.TakeDamage(armDamage * attackBooster, hit.transform.position);
                            //hit.transform.GetComponentInParent<Rigidbody>().AddForceAtPosition (hit.collider.transform.position - hit.point * pushForce, hit.point, ForceMode.Force);
                        }
                        //hit.collider.attachedRigidbody.AddForceAtPosition (hit.collider.transform.position - hit.point * pushForce, hit.point, ForceMode.Force);
                    }
                }
            }
        }
    }