Пример #1
0
    private void OnTriggerEnter(Collider collision)
    {
        GameObject obj = collision.gameObject;

        if (obj.tag == "EnemyBullet")
        {
            if (!isDodging)
            {
                if (!dead)
                {
                    BulletScript bulletScript = obj.GetComponent <BulletScript>();
                    //check if teammate its friendly bullet;
                    //if(bulletScript.GetBulletId().StartsWith(Network.instance.player.GetTeammateUsername()))
                    if (bulletScript.GetBulletTeam() == Network.instance.player.GetTeamNumber())
                    {
                    }
                    else
                    {
                        playerData.takeDamage(bulletScript.GetBulletDamage(), bulletScript.GetBulletId());

                        if (!offline)
                        {
                            Network.instance.SendPlayerDamage(bulletScript.GetBulletDamage(), bulletScript.GetBulletId());
                        }
                        ObjectHandler.instance.DestroyBullet(bulletScript.GetBulletId());
                        CameraFollow script = Camera.main.GetComponent <CameraFollow>();
                        script.ShakeCamera();
                    }
                }
            }
        }
        else if (obj.tag == "Revive")
        {
            Debug.Log(obj.tag);
            AbleToRevive = true;
            playerData.ReviveButton(true);
        }
        else if (obj.CompareTag("Coin"))
        {
            ObjectHandler.instance.DisableCoin(obj.name);
            if (!offline)
            {
                Network.instance.SendCollectiblesDestroy(obj.name, 0);         // 0 for coins 1 for pills
            }
            bool succcess = playerData.addCoinsIfAvailable(10);
        }
        else if (obj.CompareTag("Pill"))
        {
            if (playerData.RefreshHealth(20f))
            {
                ObjectHandler.instance.DisablePill(obj.name);
                if (!offline)
                {
                    Network.instance.SendCollectiblesDestroy(obj.name, 1);          // 0 for coins 1 for pills
                }
            }
        }
    }