예제 #1
0
    void OnTriggerEnter(Collider other)
    {
        if (!dead && other.CompareTag("Bullet"))
        {
            Bullet bullet = other.GetComponent <Bullet>();


            int damage = bullet.damage;


            if (networkView.isOwner && damageCooldownTimer <= 0)
            {
                networkView.RPC("SubtractHealth", uLink.RPCMode.All, damage, bullet.owner);
                UpdateHealth();
                damageCooldownTimer = damageCooldown;
            }

            StartCoroutine(Blink());

            TextPopup txtPop = PREFAB.SpawnPrefab(PREFAB.DAMAGE_TEXT, transform.position - new Vector3(0, 0, 5), "1").GetComponent <TextPopup>();
            txtPop.ChangeText(damage.ToString("f0"));

            AudioSource.PlayClipAtPoint(PREFAB.audio.hitSound, transform.position);

            HitCosmetics(damage, bullet.transform.position [0], bullet.transform.position [1]);
            PREFAB.DespawnPrefab(other.transform, "1");
        }
    }
예제 #2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            player = other.gameObject.GetComponent <Player>();

            if (player.networkView.isOwner)
            {
                TextPopup txtPop = PREFAB.SpawnPrefab(PREFAB.DAMAGE_TEXT, other.transform.position - new Vector3(0, 0, 5), "1").GetComponent <TextPopup>();

                // is this a healthpack?
                if (weaponId == 4)
                {
                    player.Healthpack();

                    txtPop.ChangeText("HEALTH", Color.red);
                }
                else
                {
                    player.ChangeWeapon(weaponId);

                    switch (weaponId)
                    {
                    case (1): txtPop.ChangeText("FAST MG", Color.yellow); break;

                    case (2): txtPop.ChangeText("SHOTGUN", Color.yellow); break;
                    }
                }

                StartCoroutine(DeferredDestroy());

                AudioSource.PlayClipAtPoint(PREFAB.audio.collectSound, transform.position);
            }
        }
    }
예제 #3
0
    void SpawnBullets(int _weaponId)
    {
        Transform instance = null;
        int       owner    = uLink.Network.player.id;

        switch (_weaponId)
        {
        case 0:
            instance = PREFAB.SpawnPrefab(PREFAB.BULLET, bulletSpawnPoint.position, transform.localEulerAngles - new Vector3(0, 0, 90), "1");
            instance.GetComponent <Bullet> ().owner = owner;
            break;

        case 1:
            instance = PREFAB.SpawnPrefab(PREFAB.BULLET, bulletSpawnPoint.position, transform.localEulerAngles - new Vector3(0, 0, 90), "1");
            instance.GetComponent <Bullet> ().owner = owner;
            break;

        case 2:
            for (int i = 0; i < 5; i++)
            {
                instance = PREFAB.SpawnPrefab(PREFAB.BULLET_SHOTGUN, bulletSpawnPoint.position, transform.localEulerAngles - new Vector3(0, 0, 76 + (i * 7)), "1");
                instance.GetComponent <Bullet> ().owner = owner;
            }
            break;
        }
    }
예제 #4
0
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Bullet"))
        {
            Bullet    bullet = other.GetComponent <Bullet>();
            TextPopup txtPop = PREFAB.SpawnPrefab(PREFAB.DAMAGE_TEXT, transform.position + new Vector3(Random.Range(-0.80f, 0.8f), Random.Range(-0.30f, 0.50f), -5), "1").GetComponent <TextPopup>();
            int       damage = bullet.damage;
            txtPop.ChangeText(damage.ToString("f0"));

            health -= damage;

            PREFAB.SpawnPrefab(PREFAB.HIT_IMPACT, other.transform.position - new Vector3(Random.Range(-0.1f, 0.1f), Random.Range(-0.1f, 0.1f), 5), "1");

            if (health > 0)
            {
                StartCoroutine(Blink());
                AudioSource.PlayClipAtPoint(PREFAB.audio.hitSound, transform.position);
            }
            else
            {
                PREFAB.SpawnPrefab(PREFAB.EXPLOSION, transform.position, "1");
                AudioSource.PlayClipAtPoint(PREFAB.audio.explosionSound, transform.position);
                if (bullet.mine)
                {
                    StartCoroutine(DeferredDestroy());
                }
            }

            PREFAB.DespawnPrefab(other.transform, "1");
        }
    }
예제 #5
0
 void OnTriggerStay(Collider other)
 {
     if (other.CompareTag("Bullet"))
     {
         PREFAB.SpawnPrefab(PREFAB.HIT_IMPACT, other.transform.position - new Vector3(0, 0, 5), "1");
         PREFAB.DespawnPrefab(other.transform, "1");
     }
 }
예제 #6
0
    void DeathCosmetics()
    {
        PREFAB.SpawnPrefab(PREFAB.EXPLOSION2, transform.position, "1");
        PREFAB.audio.PlayRandomKillSound();
        //StopCoroutine("Blink");
//        spriteTorso.color = Color.clear;
        flashlight.LightRadius = 0;
        torsoAnim.Play("Ghost");
        StartCoroutine(DeathCosmeticsCoroutine());
    }
예제 #7
0
 void Despawn()
 {
     PREFAB.DespawnPrefab(this.transform, "1");
 }
예제 #8
0
 void HitCosmetics(int damage, float positionX, float positionY)
 {
     PREFAB.SpawnPrefab(PREFAB.HIT_IMPACT, new Vector3(positionX, positionY, 0.0f) - new Vector3(Random.Range(-0.1f, 0.1f), Random.Range(-0.1f, 0.1f), 5), "1");
 }
예제 #9
0
 void TimedDespawn()
 {
     PREFAB.DespawnPrefab(this.transform, pool);
 }